11/* *****************************************************************************
22 * Copyright (C) 2022 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3- * Copyright (C) 2022-2023 Members of R3B Collaboration *
3+ * Copyright (C) 2022-2026 Members of R3B Collaboration *
44 * *
55 * This software is distributed under the terms of the *
66 * GNU General Public Licence (GPL) version 3, *
1616// ----- Created 11/02/22 by J.L. Rodriguez-Sanchez -----
1717// --------------------------------------------------------------
1818
19- #include " FairLogger.h"
20- #include " FairParamList.h"
21-
2219#include " R3BAlpideMappingPar.h"
2320#include " R3BLogger.h"
2421
22+ #include < FairLogger.h>
23+ #include < FairParamList.h>
24+
25+ #include < TArrayD.h>
26+ #include < sstream>
27+ #include < string>
28+
2529// ---- Standard Constructor ---------------------------------------------------
2630R3BAlpideMappingPar::R3BAlpideMappingPar (const char * name, const char * title, const char * context)
2731 : FairParGenericSet(name, title, context)
28- , fNbSensors(363 )
29- , fGeoVersion(2024 )
30- , fAlpideCols(DAlpideCols)
31- , fAlpideRows(DAlpideRows)
3232{
33- for (Int_t c = 0 ; c < fAlpideCols ; c++)
34- for (Int_t r = 0 ; r < fAlpideRows ; r++)
35- {
36- fIn_use [c][r].resize (fNbSensors );
37- for (Int_t s = 0 ; s < fNbSensors ; s++)
38- {
39- fIn_use [c][r][s] = 1 ;
40- }
41- }
4233}
4334
4435// ---- Destructor ------------------------------------------------------------
4536R3BAlpideMappingPar::~R3BAlpideMappingPar () { clear (); }
4637
47- // ---- Method SetNbSensors ---------------------------------------------------
48- void R3BAlpideMappingPar::SetNbSensors (Int_t n)
49- {
50- fNbSensors = n;
51- for (Int_t c = 0 ; c < fAlpideCols ; c++)
52- for (Int_t r = 0 ; r < fAlpideRows ; r++)
53- {
54- fIn_use [c][r].resize (fNbSensors );
55- for (Int_t s = 0 ; s < fNbSensors ; s++)
56- fIn_use [c][r][s] = 1 ;
57- }
58- }
59-
6038// ---- Method clear ----------------------------------------------------------
6139void R3BAlpideMappingPar::clear ()
6240{
@@ -80,16 +58,15 @@ void R3BAlpideMappingPar::putParams(FairParamList* list)
8058 list->add (" NbSensorsPar" , fNbSensors );
8159 R3BLOG (info, " Nb of ALPIDE sensors: " << fNbSensors );
8260
83- Int_t defzero = 0 ;
84- char name[300 ];
85- for (int s = 1 ; s <= fNbSensors ; s++)
86- for (int c = 1 ; c <= fAlpideCols ; c++)
87- for (int r = 1 ; r <= fAlpideRows ; r++)
88- if (fIn_use [c - 1 ][r - 1 ][s - 1 ] == 0 )
89- {
90- sprintf (name, " Sensor%dCol%dRow%dPar" , s, c, r);
91- list->add (name, defzero);
92- }
61+ list->add (" NbMaskPixelsPar" , fNbMaskPixels );
62+ R3BLOG (info, " Nb of masking pixels: " << fNbMaskPixels );
63+
64+ TArrayD fMask_pixels (fNbMaskPixels );
65+ for (auto pixel = 0 ; pixel < fNbMaskPixels ; pixel++)
66+ {
67+ fMask_pixels [pixel] = fMask_sensors [pixel];
68+ }
69+ list->add (" MaskPixelPar" , fMask_pixels );
9370}
9471
9572// ---- Method getParams ------------------------------------------------------
@@ -122,49 +99,36 @@ Bool_t R3BAlpideMappingPar::getParams(FairParamList* list)
12299 R3BLOG (info, " Nb of ALPIDE sensors: " << fNbSensors );
123100 }
124101
125- char name[300 ];
126- for (int s = 1 ; s <= fNbSensors ; s++)
127- for (Int_t c = 1 ; c <= fAlpideCols ; c++)
128- for (Int_t r = 1 ; r <= fAlpideRows ; r++)
129- {
130- sprintf (name, " Sensor%dCol%dRow%dPar" , s, c, r);
131- Int_t value = 1 ;
132- auto check = fillParams (name, &value, list);
133- if (check)
134- {
135- fIn_use [c - 1 ][r - 1 ][s - 1 ] = 0 ;
136- }
137- }
138- return kTRUE ;
139- }
140-
141- Bool_t R3BAlpideMappingPar::fillParams (const Text_t* name, Int_t* values, FairParamList* paramList, const Int_t nValues)
142- {
143- // Copies the data from the list object into the parameter array of type Int_t.
144- // The function returns an error, if the array size of the list object is not equal
145- // to nValues.
146- if (values == 0 )
102+ if (!list->fill (" NbMaskPixelsPar" , &fNbMaskPixels ))
147103 {
104+ R3BLOG (error, " Could not initialize NbMaskPixelsPar" );
148105 return kFALSE ;
149106 }
150- auto o = paramList->find (name);
151- if (o && strcmp (o->getParamType (), " Int_t" ) == 0 )
107+ else
152108 {
153- Int_t l = o-> getLength ( );
154- Int_t n = o-> getNumParams ();
109+ R3BLOG (info, " Nb of masking pixels: " << fNbMaskPixels );
110+ }
155111
156- if (n == nValues)
112+ if (fNbMaskPixels > 0 )
113+ {
114+ TArrayD fMask_pixels (fNbMaskPixels );
115+ if (!(list->fill (" MaskPixelPar" , &fMask_pixels )))
157116 {
158- memcpy (values, o-> getParamValue (), l );
159- return kTRUE ;
117+ R3BLOG (error, " Could not initialize MaskPixelPar " );
118+ return kFALSE ;
160119 }
161- else
120+
121+ for (auto pixel = 0 ; pixel < fNbMaskPixels ; pixel++)
162122 {
163- R3BLOG (error, " Different array sizes for parameter " << name);
164- return kFALSE ;
123+ fMask_sensors .push_back (fMask_pixels [pixel]);
124+
125+ auto sen = this ->GetSensorId (fMask_sensors [pixel]);
126+ auto col = this ->GetCol (fMask_sensors [pixel]);
127+ auto row = this ->GetRow (fMask_sensors [pixel]);
128+ LOG (info) << " Skipping Sensor: " << sen << " Col: " << col << " Row: " << row;
165129 }
166130 }
167- return kFALSE ;
131+ return kTRUE ;
168132}
169133
170134// ---- Method print ----------------------------------------------------------
@@ -174,15 +138,15 @@ void R3BAlpideMappingPar::print() { printParams(); }
174138void R3BAlpideMappingPar::printParams ()
175139{
176140 R3BLOG (info, " Nb Sensors: " << fNbSensors );
177- for (Int_t s = 0 ; s < fNbSensors ; s++)
141+ R3BLOG (info, " Geo Version: " << fGeoVersion );
142+ R3BLOG (info, " Nb masked pixels: " << fNbMaskPixels );
143+
144+ for (auto pixel = 0 ; pixel < fNbMaskPixels ; pixel++)
178145 {
179- R3BLOG (info, " ALPIDE sensor: " << s + 1 );
180- for (Int_t c = 0 ; c < fAlpideCols ; c++)
181- for (Int_t r = 0 ; r < fAlpideRows ; r++)
182- {
183- if (fIn_use [c][r][s] == 0 )
184- LOG (info) << " Pixel column: " << c + 1 << " , row: " << r + 1 << " is skipped" ;
185- }
146+ auto sen = this ->GetSensorId (fMask_sensors [pixel]);
147+ auto col = this ->GetCol (fMask_sensors [pixel]);
148+ auto row = this ->GetRow (fMask_sensors [pixel]);
149+ LOG (info) << " Skipping Sensor: " << sen << " Col: " << col << " Row: " << row;
186150 }
187151}
188152
0 commit comments