CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TEcnaNumbering.cc
Go to the documentation of this file.
1 //----------Author's Name: B.Fabbro, F.X.Gentit + EB table from P.Jarry DSM/IRFU/SPP CEA-Saclay
2 //----------Copyright:Those valid for CEA software
3 //----------Modified:30/06/2011
4 
6 using namespace std;
7 
8 //--------------------------------------
9 // TEcnaNumbering.cc
10 // Class creation: 30 September 2005
11 // Documentation: see TEcnaNumbering.h
12 //--------------------------------------
13 
14 ClassImp(TEcnaNumbering)
15 //-------------------------------------------------------------------------------------------------------
16 //
17 // Building of the numbering for the Ecal channels (EB and EE)
18 //
19 // Convention for the names used here and in the other "TEcna" classes:
20 //
21 // Name Number Reference set Range Comment
22 //
23 // SMTow : Tower number in SuperModule [1,68] (phi,eta) progression
24 // SMCrys : Crystal number in SuperModule [1,1700] (phi,eta) progression
25 // SMEcha : Electronic channel number in SuperModule [0,1699] S shape data reading order
26 // TowEcha: Electronic channel number in Tower [0,24] S shape data reading order
27 //
28 // DeeSC : super-crystal(SC) number in Dee [1,200] (IY,IX) progression
29 // DeeCrys: Crystal number in Dee matrix [1,5000] (IY,IX) progression
30 // DeeEcha: Electronic channel number in Dee matrix [0,4999] (IY,IX) progression (starting from 0)
31 // SCEcha : Electronic channel number in SC [1,25] Crystal numbering for construction
32 //-------------------------------------------------------------------------------------------------------
33 
34 //====================================== constructors =========================================
36 // Constructor without argument: call to method Init()
37 
38 // cout << "[Info Management] CLASS: TEcnaNumbering. CREATE OBJECT: this = " << this << endl;
39 
40  Init();
41 }
42 
43 TEcnaNumbering::TEcnaNumbering(TEcnaObject* pObjectManager, const TString& SubDet) {
44 // Constructor with argument: call to methods Init() and SetEcalSubDetector(const TString&)
45 
46  // cout << "[Info Management] CLASS: TEcnaNumbering. CREATE OBJECT: this = " << this << endl;
47 
48  Init();
49  Long_t i_this = (Long_t)this;
50  pObjectManager->RegisterPointer("TEcnaNumbering", i_this);
51 
52  //............................ fEcal => to be changed in fParEcal
53  fEcal = 0;
54  Long_t iParEcal = pObjectManager->GetPointerValue("TEcnaParEcal");
55  if( iParEcal == 0 )
56  {fEcal = new TEcnaParEcal(pObjectManager, SubDet.Data()); /*fCnew++*/}
57  else
58  {fEcal = (TEcnaParEcal*)iParEcal;}
59 
60  SetEcalSubDetector(SubDet.Data());
61 }
62 
63 
64 TEcnaNumbering::TEcnaNumbering(const TString& SubDet, const TEcnaParEcal* pEcal) {
65 // Constructor with argument: call to methods Init() and SetEcalSubDetector(const TString&)
66 
67  // cout << "[Info Management] CLASS: TEcnaNumbering. CREATE OBJECT: this = " << this << endl;
68 
69  Init();
70  SetEcalSubDetector(SubDet.Data(), pEcal);
71 }
72 
73 //====================================== destructor =========================================
75 //destructor
76 
77  //if (fEcal != 0){delete fEcal; fCdelete++;}
78 
79  //....................... Barrel
80  if (fT2dSMCrys != 0){delete [] fT2dSMCrys; fCdelete++;}
81  if (fT1dSMCrys != 0){delete [] fT1dSMCrys; fCdelete++;}
82  if (fT1dSMTow != 0){delete [] fT1dSMTow; fCdelete++;}
83  if (fT1dTowEcha != 0){delete [] fT1dTowEcha; fCdelete++;}
84 
85  //....................... Endcap
86  if (fT3dDeeCrys != 0){delete [] fT3dDeeCrys; fCdelete++;}
87  if (fT2dDeeCrys != 0){delete [] fT2dDeeCrys; fCdelete++;}
88  if (fT1dDeeCrys != 0){delete [] fT1dDeeCrys; fCdelete++;}
89  if (fT2dDeeSC != 0){delete [] fT2dDeeSC; fCdelete++;}
90  if (fT1dDeeSC != 0){delete [] fT1dDeeSC; fCdelete++;}
91  if (fT2dSCEcha != 0){delete [] fT2dSCEcha; fCdelete++;}
92  if (fT1dSCEcha != 0){delete [] fT1dSCEcha; fCdelete++;}
93  if (fT2d_jch_JY != 0){delete [] fT2d_jch_JY; fCdelete++;}
94  if (fT1d_jch_JY != 0){delete [] fT1d_jch_JY; fCdelete++;}
95  if (fT2d_ich_IX != 0){delete [] fT2d_ich_IX; fCdelete++;}
96  if (fT1d_ich_IX != 0){delete [] fT1d_ich_IX; fCdelete++;}
97  if (fT2d_DS != 0){delete [] fT2d_DS; fCdelete++;}
98  if (fT1d_DS != 0){delete [] fT1d_DS; fCdelete++;}
99  if (fT2d_DSSC != 0){delete [] fT2d_DSSC; fCdelete++;}
100  if (fT1d_DSSC != 0){delete [] fT1d_DSSC; fCdelete++;}
101  if (fT2d_DeeSCCons != 0){delete [] fT2d_DeeSCCons; fCdelete++;}
102  if (fT1d_DeeSCCons != 0){delete [] fT1d_DeeSCCons; fCdelete++;}
103  if (fT2d_RecovDeeSC != 0){delete [] fT2d_RecovDeeSC; fCdelete++;}
104  if (fT1d_RecovDeeSC != 0){delete [] fT1d_RecovDeeSC; fCdelete++;}
105 
106  // cout << "[Info Management] CLASS: TEcnaNumbering. DESTROY OBJECT: this = " << this << endl;
107 
108 }
109 //------------------------------------------------------------- Init()
111 {
112 //Set default values and build crystal numbering table
113 
114  //.............................. Initialisations
115  fTTBELL = '\007';
116  fgMaxCar = 512;
117 
118  //....................... Barrel
119  fT2dSMCrys = 0;
120  fT1dSMCrys = 0;
121  fT1dSMTow = 0;
122  fT1dTowEcha = 0;
123 
124  fCodeChNumberingLvrbBot = "bottom";
125  fCodeChNumberingLvrbTop = "top";
126 
127  //....................... Endcap
128  fT3dDeeCrys = 0;
129  fT2dDeeCrys = 0;
130  fT1dDeeCrys = 0;
131  fT2dDeeSC = 0;
132  fT1dDeeSC = 0;
133  fT2dSCEcha = 0;
134  fT1dSCEcha = 0;
135  fT2d_jch_JY = 0;
136  fT1d_jch_JY = 0;
137  fT2d_ich_IX = 0;
138  fT1d_ich_IX = 0;
139  fT2d_DS = 0;
140  fT1d_DS = 0;
141  fT2d_DSSC = 0;
142  fT1d_DSSC = 0;
143  fT2d_DeeSCCons = 0;
144  fT1d_DeeSCCons = 0;
145  fT2d_RecovDeeSC = 0;
146  fT1d_RecovDeeSC = 0;
147 
148  fCodeChNumberingITP1Bot = "bottom"; // ==> Type 1 Interface plate IPT1 (a faire)
149  fCodeChNumberingITP2Top = "top"; // ==> Type 2 Interface plate IPT2 (a faire)
150 
151  //------------------ Init pointers on the CNA objects
152  fEcal = 0;
153 }
154 // end of Init()
155 //------------------------------------------------------------- SetEcalSubDetector(...)
156 void TEcnaNumbering::SetEcalSubDetector(const TString& SubDet, const TEcnaParEcal* pEcal){
157 //Set the current subdetector flag and the current subdetector parameters
158 
159  fEcal = 0;
160  if( pEcal == 0 )
161  {fEcal = new TEcnaParEcal(SubDet.Data()); /*fCnew++*/ ;}
162  else
163  {fEcal = (TEcnaParEcal*)pEcal;}
164 
165  Int_t MaxCar = fgMaxCar;
166  fFlagSubDet.Resize(MaxCar);
167  fFlagSubDet = fEcal->GetEcalSubDetector(); // fFlagSubDet = "EB" or "EE"
168 
169  if( fFlagSubDet == "EB" ){BuildBarrelCrysTable();}
170  if( fFlagSubDet == "EE" ){BuildEndcapCrysTable(); BuildEndcapSCTable();}
171 }
172 
173 void TEcnaNumbering::SetEcalSubDetector(const TString& SubDet){
174 //Set the current subdetector flag and the current subdetector parameters
175 
176  Int_t MaxCar = fgMaxCar;
177  fFlagSubDet.Resize(MaxCar);
178  fFlagSubDet = fEcal->GetEcalSubDetector(); // fFlagSubDet = "EB" or "EE"
179 
180  if( fFlagSubDet == "EB" ){BuildBarrelCrysTable();}
181  if( fFlagSubDet == "EE" ){BuildEndcapCrysTable(); BuildEndcapSCTable();}
182 }
183 
184 //====================================================================================================
185 //
186 //
187 // B A R R E L
188 //
189 //
190 //====================================================================================================
191 //
192 // SMCrys <-> (SMTow, TowEcha) correspondance table (from Patrick Jarry)
193 //
194 //====================================================================================================
196 {
197 // Build the correspondance table: SMCrys <-> (SMTow, TowEcha) for the ECAL BARREL
198 //
199 // From CMS Internal Note "CMS ECAL Barrel channel numbering"
200 //
201 // Name Number Reference set Range Comment
202 //
203 // SMTow : Tower number in SuperModule [1,68] (phi,eta) progression
204 // SMCrys : Crystal number in SuperModule [1,1700] (phi,eta) progression
205 // SMEcha : Electronic channel number in SuperModule [0,1699] S shape data reading order
206 //
207 // TowEcha: Electronic channel number in Tower [0,24] S shape data reading order
208 //
209 //
210 // fill the 2D array: fT2dSMCrys[n_SMTow][n_TowEcha]
211 //
212 // and the 1d arrays: fT1dSMTow[i_SMCrys] and fT1dTowEcha[i_SMCrys]
213 //
214 //-----------------------------------------------------------------------------------------------------
215 
216  if ( fT2dSMCrys == 0 )
217  {
218  Int_t MaxSMTow = fEcal->MaxTowInSM();
219  Int_t MaxTowEcha = fEcal->MaxCrysInTow();
220  Int_t MaxSMCrys = fEcal->MaxCrysInSM();
221 
222  //................... Allocation and Init CrysNumbersTable
223 
224  fT2dSMCrys = new Int_t*[MaxSMTow]; fCnew++;
225  fT1dSMCrys = new Int_t[MaxSMTow*MaxTowEcha]; fCnew++;
226  for(Int_t i_SMTow = 0 ; i_SMTow < MaxSMTow ; i_SMTow++){
227  fT2dSMCrys[i_SMTow] = &fT1dSMCrys[0] + i_SMTow*MaxTowEcha;}
228  for(Int_t i=0; i<MaxSMTow; i++)
229  {for(Int_t j=0; j<MaxTowEcha; j++){fT2dSMCrys[i][j]=0;}}
230 
231  fT1dSMTow = new Int_t[MaxSMCrys]; fCnew++;
232  for(Int_t i=0; i<MaxSMCrys; i++){fT1dSMTow[i]=0;}
233 
234  fT1dTowEcha = new Int_t[MaxSMCrys]; fCnew++;
235  for(Int_t i=0; i<MaxSMCrys; i++){fT1dTowEcha[i]=0;}
236 
237  //........................ Build table
238  Int_t m2 = (Int_t)2;
239  Int_t m26 = (Int_t)26;
240 
241  // Int_t jch_type[2][26];
242  Int_t** jch_type = new Int_t*[m2]; fCnew++;
243  Int_t* jch_type_d1 = new Int_t[m2*m26]; fCnew++;
244  for(Int_t i_m2 = 0 ; i_m2 < m2 ; i_m2++){
245  jch_type[i_m2] = &jch_type_d1[0] + i_m2*m26;}
246 
247  for(Int_t k=25;k>=21;k--){jch_type[0][k] = 25-k;} // k = 25,24,23,22,21 -> jch_type[0][k] = 0,1,2,3,4
248  for(Int_t k=16;k<=20;k++){jch_type[0][k] = k-16;} // k = 16,17,18,19,20 -> jch_type[0][k] = 0,1,2,3,4
249  for(Int_t k=15;k>=11;k--){jch_type[0][k] = 15-k;} // k = 15,14,12,13,11 -> jch_type[0][k] = 0,1,2,3,4
250  for(Int_t k=6; k<=10;k++){jch_type[0][k] = k-6;} // k = 6, 7, 8, 9,10 -> jch_type[0][k] = 0,1,2,3,4
251  for(Int_t k=5; k>=1; k--){jch_type[0][k] = 5-k;} // k = 5, 4, 3, 2, 1 -> jch_type[0][k] = 0,1,2,3,4
252 
253  for(Int_t k=1; k<=5; k++){jch_type[1][k] = k-1;} // k = 1, 2, 3, 4, 5 -> jch_type[1][k] = 0,1,2,3,4
254  for(Int_t k=10;k>=6; k--){jch_type[1][k] = 10-k;} // k = 10, 9, 8, 7, 6 -> jch_type[1][k] = 0,1,2,3,4
255  for(Int_t k=11;k<=15;k++){jch_type[1][k] = k-11;} // k = 11,12,13,14,15 -> jch_type[1][k] = 0,1,2,3,4
256  for(Int_t k=20;k>=16;k--){jch_type[1][k] = 20-k;} // k = 20,19,18,17,16 -> jch_type[1][k] = 0,1,2,3,4
257  for(Int_t k=21;k<=25;k++){jch_type[1][k] = k-21;} // k = 21,22,23,24,25 -> jch_type[1][k] = 0,1,2,3,4
258 
259  // Int_t ich_type[2][26];
260  Int_t** ich_type = new Int_t*[m2]; fCnew++;
261  Int_t* ich_type_d1 = new Int_t[m2*m26]; fCnew++;
262  for(Int_t i_m2 = 0 ; i_m2 < m2 ; i_m2++){
263  ich_type[i_m2] = &ich_type_d1[0] + i_m2*m26;}
264 
265  for(Int_t k=25;k>=21;k--){ich_type[0][k] = 0;} // k = 25,24,23,22,21 -> ich_type[0][k] = 0
266  for(Int_t k=16;k<=20;k++){ich_type[0][k] = 1;} // k = 16,17,18,19,20 -> ich_type[0][k] = 1
267  for(Int_t k=15;k>=11;k--){ich_type[0][k] = 2;} // k = 15,14,12,13,11 -> ich_type[0][k] = 2
268  for(Int_t k=6; k<=10;k++){ich_type[0][k] = 3;} // k = 6, 7, 8, 9,10 -> ich_type[0][k] = 3
269  for(Int_t k=5; k>=1; k--){ich_type[0][k] = 4;} // k = 5, 4, 3, 2, 1 -> ich_type[0][k] = 4
270 
271  for(Int_t k=1; k<=5; k++){ich_type[1][k] = 0;} // k = 1, 2, 3, 4, 5 -> ich_type[1][k] = 0
272  for(Int_t k=10;k>=6; k--){ich_type[1][k] = 1;} // k = 10, 9, 8, 7, 6 -> ich_type[1][k] = 1
273  for(Int_t k=11;k<=15;k++){ich_type[1][k] = 2;} // k = 11,12,13,14,15 -> ich_type[1][k] = 2
274  for(Int_t k=20;k>=16;k--){ich_type[1][k] = 3;} // k = 20,19,18,17,16 -> ich_type[1][k] = 3
275  for(Int_t k=21;k<=25;k++){ich_type[1][k] = 4;} // k = 21,22,23,24,25 -> ich_type[1][k] = 4
276 
277  // Int_t type[17]={0,0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1};
278  Int_t m17 =17;
279  Int_t* type = new Int_t[m17]; fCnew++;
280 
281  // 0 -> LVRB at the bottom, 1 -> LVRB at the top
282  type[0] = 0; // M1
283  type[1] = 0;
284  type[2] = 0;
285  type[3] = 1;
286  type[4] = 1;
287 
288  type[5] = 0; // M2
289  type[6] = 0;
290  type[7] = 1;
291  type[8] = 1;
292 
293  type[9] = 0; // M3
294  type[10] = 0;
295  type[11] = 1;
296  type[12] = 1;
297 
298  type[13] = 0; // M4
299  type[14] = 0;
300  type[15] = 1;
301  type[16] = 1;
302 
303  for(Int_t tow=0; tow<MaxSMTow; tow++) // tow = 0 to 67 (MaxSMTow = 68)
304  {
305  for(Int_t ic=1; ic<=MaxTowEcha; ic++) // ic = 1 to 25 (MaxTowEcha = 25)
306  {
307  Int_t jtow = tow % 4; // jtow = 0,1,2,3
308  Int_t itow = tow / 4; // itow = 0 to 16
309 
310  Int_t icrys = itow*5 + ich_type[type[itow]][ic]; // type[0->16] = 0,1 ,
311  // ich_type[0->1][1->25] = 0,1,2,3,4
312  // icrys = 0 to 84 (=> eta)
313 
314  Int_t jcrys = jtow*5 + jch_type[type[itow]][ic]; // type[0->16] = 0,1 ,
315  // jch_type[0->1][1->25] = 0,1,2,3,4
316  // jcrys = 0 to 19 (=> phi)
317 
318  Int_t n1SMCrys = icrys*20+jcrys+1; // n1SMCrys = 1 to 1700
319 
320  fT2dSMCrys[tow][ic-1] = n1SMCrys; // fT2dSMCrys[] : range = [1,1700]
321  fT1dSMTow[n1SMCrys-1] = tow+1; // fT1dSMTow[] : range = [1,68]
322  fT1dTowEcha[n1SMCrys-1] = ic-1; // fT1dTowEcha[] : range = [0,24]
323  }
324  }
325  // cout << "#TEcnaNumbering::TBuildBarrelCrysTable()> Crys Table Building done" << endl;
326 
327  delete [] jch_type; fCdelete++;
328  delete [] jch_type_d1; fCdelete++;
329  delete [] ich_type; fCdelete++;
330  delete [] ich_type_d1; fCdelete++;
331  delete [] type; fCdelete++;
332  }
333  else
334  {
335  // cout << "#TEcnaNumbering::TBuildBarrelCrysTable()> No Building of Crys Table since it is already done." << endl;
336  }
337 }
338 
339 //===============================================================================
340 //
341 // GetSMCrysFrom1SMTowAnd0TowEcha
342 // GetSMCrysFromSMEcha
343 //
344 //===============================================================================
346  const Int_t& i0TowEcha)
347 {
348 //get crystal number in SM from tower number in SM
349 // and from Electronic Channel number in tower
350 
351  Int_t n1SMCrys = 0;
352 
353  if( fT2dSMCrys == 0 ){BuildBarrelCrysTable();}
354 
355  if (n1SMTow >= 1 && n1SMTow <= fEcal->MaxTowInSM())
356  {
357  if (i0TowEcha >=0 && i0TowEcha < fEcal->MaxCrysInTow())
358  {
359  n1SMCrys = fT2dSMCrys[n1SMTow-1][i0TowEcha];
360  }
361  else
362  {
363  n1SMCrys = -2; // Electronic Cnannel in Tower out of range
364  cout << "!TEcnaNumbering::Get1SMCrysFrom1SMTowAnd0TowEcha(...)> Electronic Channel in Tower out of range."
365  << " i0TowEcha = " << i0TowEcha << "(n1SMTow = " << n1SMTow << ")" << fTTBELL << endl;
366  }
367  }
368  else
369  {
370  n1SMCrys = -3; // Tower number in SM out of range
371  cout << "!TEcnaNumbering::Get1SMCrysFrom1SMTowAnd0TowEcha(...)> Tower number in SM out of range."
372  << " n1SMTow = " << n1SMTow << "(i0TowEcha = " << i0TowEcha << ")" << fTTBELL << endl;
373  }
374 
375  return n1SMCrys; // Range = [1,1700]
376 }
377 
378 //===============================================================================
379 //
380 // Get0TowEchaFrom1SMCrys, Get1SMTowFrom1SMCrys
381 //
382 //===============================================================================
383 
384 Int_t TEcnaNumbering::Get0TowEchaFrom1SMCrys(const Int_t& n1SMCrys)
385 {
386 // get Electronic Channel number in Tower from Crystal number in SuperModule
387 
388  Int_t i0TowEcha = -1;
389 
390  if( n1SMCrys >= 1 && n1SMCrys <= fEcal->MaxCrysInSM() )
391  {
392  i0TowEcha = fT1dTowEcha[n1SMCrys-1];
393  }
394  else
395  {
396  i0TowEcha = -2;
397  cout << "!TEcnaNumbering::Get0TowEchaFrom1SMCrys(...)> Crystal number in SM out of range."
398  << " n1SMCrys = " << n1SMCrys << fTTBELL << endl;
399  }
400  return i0TowEcha; // range = [0,24]
401 }
402 
403 Int_t TEcnaNumbering::Get1SMTowFrom1SMCrys(const Int_t& n1SMCrys)
404 {
405 // get Tower number in SM (range [1,68]) from Crystal number in SuperModule (range [1,1700])
406 
407  Int_t n1SMtox = 0;
408 
409  if( n1SMCrys >= 1 && n1SMCrys <= fEcal->MaxCrysInSM() )
410  {
411  n1SMtox = fT1dSMTow[n1SMCrys-1];
412  }
413  else
414  {
415  n1SMtox = -1;
416  cout << "!TEcnaNumbering::Get1SMTowFrom1SMCrys(...)> Crystal number in SM out of range."
417  << " n1SMCrys = " << n1SMCrys << fTTBELL << endl;
418  }
419  return n1SMtox; // range = [1,68]
420 }
421 
422 //===============================================================================
423 //
424 // Get0TowEchaFrom0SMEcha
425 // Get1SMTowFrom0SMEcha
426 //
427 //===============================================================================
428 
429 Int_t TEcnaNumbering::Get0TowEchaFrom0SMEcha(const Int_t& i0SMEcha)
430 {
431 //get electronic channel number in tower from electronic channel number in SM
432 
433  Int_t n1SMTow = i0SMEcha/fEcal->MaxCrysInTow()+1;
434  Int_t i0TowEcha = i0SMEcha - fEcal->MaxCrysInTow()*(n1SMTow-1);
435 
436  return i0TowEcha; // range = [0,24]
437 }
438 
439 Int_t TEcnaNumbering::Get1SMTowFrom0SMEcha(const Int_t& i0SMEcha)
440 {
441 //get tower number from electronic channel number in SM
442 
443  Int_t n1SMTow = i0SMEcha/fEcal->MaxCrysInTow()+1;
444 
445  return n1SMTow; // range = [1,68]
446 }
447 
448 Int_t TEcnaNumbering::Get0SMEchaFrom1SMTowAnd0TowEcha(const Int_t& n1SMTow, const Int_t& i0TowEcha)
449 {
450 //get tower number from electronic channel number in SM
451 
452  Int_t i0SMEcha = (n1SMTow-1)*fEcal->MaxCrysInTow()+i0TowEcha;
453 
454  return i0SMEcha;
455 }
456 //===========================================================================
457 //
458 // GetHashedNumberFromIEtaAndIPhi
459 //
460 //===========================================================================
461 Int_t TEcnaNumbering::GetHashedNumberFromIEtaAndIPhi(const Int_t& IEta, const Int_t& IPhi)
462 {
463  Int_t Hashed = 0;
464 
465  if( IEta > 0 ){Hashed = (85 + IEta - 1)*360 + IPhi - 1;}
466  if( IEta < 0 ){Hashed = (85 + IEta)*360 + IPhi - 1;}
467 
468  return Hashed;
469 }
470 
471 Int_t TEcnaNumbering::GetIEtaFromHashed(const Int_t& Hashed, const Int_t& SMNumber)
472 {
473  Int_t IEta = 0;
474 
475  if( GetSMHalfBarrel(SMNumber) == "EB+" ){IEta = Hashed/360 - 85 + 1;}
476  if( GetSMHalfBarrel(SMNumber) == "EB-" ){IEta = 85 + Hashed/360;}
477 
478  return IEta;
479 }
480 
481 Int_t TEcnaNumbering::GetIPhiFromHashed(const Int_t& Hashed)
482 {
483  Int_t IPhi = Hashed%360 + 1;
484 
485  return IPhi;
486 }
487 //===========================================================================
488 //
489 // GetTowerLvrbType
490 //
491 //===========================================================================
492 TString TEcnaNumbering::GetStinLvrbType(const Int_t& n1SMTow)
493 {
494  TString lvrb_type = GetTowerLvrbType(n1SMTow);
495  return lvrb_type;
496 }
497 TString TEcnaNumbering::GetTowerLvrbType(const Int_t& n1SMTow)
498 {
499 //gives the LVRB type of the crystal numbering of tower
500 
501  TString type = fCodeChNumberingLvrbTop; // => default value
502 
503  if (n1SMTow >= 1 && n1SMTow <= 12){type = fCodeChNumberingLvrbBot;}
504  if (n1SMTow >= 21 && n1SMTow <= 28){type = fCodeChNumberingLvrbBot;}
505  if (n1SMTow >= 37 && n1SMTow <= 44){type = fCodeChNumberingLvrbBot;}
506  if (n1SMTow >= 53 && n1SMTow <= 60){type = fCodeChNumberingLvrbBot;}
507 
508  return type;
509 }
510 
511 //==============================================================================
512 //
513 // GetEta, GetEtaMin, GetEtaMax, GetIEtaMin, GetIEtaMax
514 //
515 //==============================================================================
516 Double_t TEcnaNumbering::GetEta(const Int_t& n1EBSM, const Int_t& n1SMTow,
517  const Int_t& i0TowEcha)
518 {
519 //Gives Eta for a given (n1EBSM, n1SMTow, i0TowEcha)
520 
521  Double_t eta = (Double_t)0.;
522 
523  Int_t max_crys_eta_in_tower = fEcal->MaxCrysEtaInTow();
524  Int_t max_tow_eta_in_sm = fEcal->MaxTowEtaInSM();
525  Int_t max_sm_in_barrel = fEcal->MaxSMInEB();
526 
527  if ( n1EBSM >= 1 && n1EBSM <= max_sm_in_barrel )
528  {
529  for (Int_t i_sm_tow_eta = 0; i_sm_tow_eta < max_tow_eta_in_sm; i_sm_tow_eta++)
530  {
531  Int_t i_crys_eta_min = (Int_t)(1 + i_sm_tow_eta*(max_crys_eta_in_tower-1));
532  Int_t i_crys_eta_max = (Int_t)((i_sm_tow_eta+1)*(max_crys_eta_in_tower-1));
533  Int_t i_crys_eta = (Int_t)(i_sm_tow_eta*max_crys_eta_in_tower);
534  // = 0,..,16 -> last xtal in eta for the previous tower
535  Double_t d_echa_eta = (Double_t)(i0TowEcha/max_crys_eta_in_tower); // = 0,1,2,3,4
536 
537  if ( n1SMTow >= i_crys_eta_min && n1SMTow <= i_crys_eta_max )
538  {
539  if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbTop)
540  {eta = (Double_t)(i_crys_eta) + d_echa_eta + 1;}
541  if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbBot)
542  {eta = (Double_t)(i_crys_eta+max_crys_eta_in_tower)-d_echa_eta;}
543  }
544  }
545  if ( GetSMHalfBarrel(n1EBSM) == "EB-" ){eta = - eta;}
546  }
547  else
548  {
549  cout << "TEcnaNumbering::GetEta(...)> SM = " << n1EBSM
550  << ". Out of range (range = [1," << fEcal->MaxSMInEB() << "])"
551  << fTTBELL << endl;
552  }
553  return eta;
554 }
555 //-------------------------------------------------------------------------------------
556 Double_t TEcnaNumbering::GetEtaMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
557 {
558 //Gives EtaMin for a given Tower
559 
560  Int_t max_tow_eta_in_sm = fEcal->MaxTowEtaInSM();
561  Int_t max_crys_eta_in_tower = fEcal->MaxCrysEtaInTow();
562 
563  Double_t eta_min = (Double_t)0.;
564 
565  for (Int_t i_sm_tow_eta = 0; i_sm_tow_eta < max_tow_eta_in_sm; i_sm_tow_eta++)
566  {
567  Int_t i_crys_eta_min = (Int_t)(1 + i_sm_tow_eta*(max_crys_eta_in_tower-1));
568  Int_t i_crys_eta_max = (Int_t)((i_sm_tow_eta+1)*(max_crys_eta_in_tower-1));
569  Int_t i_crys_eta = (Int_t)(i_sm_tow_eta*max_crys_eta_in_tower);
570 
571  if ( n1SMTow >= i_crys_eta_min && n1SMTow <= i_crys_eta_max )
572  {
573  if (GetSMHalfBarrel(n1EBSM) == "EB+")
574  {eta_min = (Double_t)i_crys_eta;}
575  if (GetSMHalfBarrel(n1EBSM) == "EB-")
576  {eta_min = -(Double_t)(i_crys_eta + max_crys_eta_in_tower);}
577  }
578  }
579  return eta_min;
580 }
581 //------------------------------------------------------------------------------------
582 Double_t TEcnaNumbering::GetEtaMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
583 {
584 //Gives EtaMax for a given Tower
585 
586  Int_t max_tow_eta_in_sm = fEcal->MaxTowEtaInSM();
587  Int_t max_crys_eta_in_tower = fEcal->MaxCrysEtaInTow();
588 
589  Double_t eta_max = (max_crys_eta_in_tower-1);
590 
591  for (Int_t i_sm_tow_eta = 0; i_sm_tow_eta < max_tow_eta_in_sm; i_sm_tow_eta++)
592  {
593  Int_t i_crys_eta_min = (Int_t)(1 + i_sm_tow_eta*(max_crys_eta_in_tower-1));
594  Int_t i_crys_eta_max = (Int_t)((i_sm_tow_eta+1)*(max_crys_eta_in_tower-1));
595  Int_t i_crys_eta = (Int_t)(i_sm_tow_eta*max_crys_eta_in_tower);
596 
597  if ( n1SMTow >= i_crys_eta_min && n1SMTow <= i_crys_eta_max )
598  {
599  if (GetSMHalfBarrel(n1EBSM) == "EB+")
600  {eta_max = (Double_t)(i_crys_eta + max_crys_eta_in_tower);}
601  if (GetSMHalfBarrel(n1EBSM) == "EB-")
602  {eta_max = -(Double_t)i_crys_eta;}
603  }
604  }
605 
606  return eta_max;
607 }
608 
609 Double_t TEcnaNumbering::GetIEtaMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
610 {
611 //Gives IEtaMin for a given (n1EBSM, n1SMTow)
612 
613  Double_t i_eta_min = (Int_t)0.;
614 
615  if(GetSMHalfBarrel(n1EBSM) == "EB+")
616  {i_eta_min = (Double_t)GetEtaMin(n1EBSM, n1SMTow)+(Double_t)0.5;}
617  if(GetSMHalfBarrel(n1EBSM) == "EB-")
618  {i_eta_min = (Double_t)GetEtaMin(n1EBSM, n1SMTow)-(Double_t)0.5;}
619 
620  return i_eta_min;
621 }
622 
623 Double_t TEcnaNumbering::GetIEtaMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
624 {
625 //Gives IEtaMax for a given (n1EBSM, n1SMTow)
626 
627  Double_t i_eta_max = (Int_t)0.;
628 
629  if(GetSMHalfBarrel(n1EBSM) == "EB+")
630  {i_eta_max = (Double_t)GetEtaMax(n1EBSM, n1SMTow)+(Double_t)0.5;}
631  if(GetSMHalfBarrel(n1EBSM) == "EB-")
632  {i_eta_max = (Double_t)GetEtaMax(n1EBSM, n1SMTow)-(Double_t)0.5;}
633 
634  return i_eta_max;
635 }
636 
637 Double_t TEcnaNumbering::GetIEtaMin(const Int_t& n1EBSM)
638 {
639 //Gives IEtaMin for a given (n1EBSM)
640 
641  Double_t i_eta_min = (Int_t)0.;
642 
643  Int_t n1SMTowPlus = (Int_t)1;
644  Int_t n1SMTowMinus = (Int_t)fEcal->MaxTowInSM();
645 
646  if( GetSMHalfBarrel(n1EBSM) == "EB+" )
647  {i_eta_min = (Double_t)GetIEtaMin(n1EBSM, n1SMTowPlus );}
648  if( GetSMHalfBarrel(n1EBSM) == "EB-" )
649  {i_eta_min = (Double_t)GetIEtaMin(n1EBSM, n1SMTowMinus);}
650 
651  return i_eta_min;
652 }
653 
654 Double_t TEcnaNumbering::GetIEtaMax(const Int_t& n1EBSM)
655 {
656 //Gives IEtaMax for a given (n1EBSM)
657 
658  Double_t i_eta_max = (Int_t)0.;
659 
660  Int_t n1SMTowPlus = (Int_t)fEcal->MaxTowInSM();
661  Int_t n1SMTowMinus = (Int_t)1;
662 
663  if( GetSMHalfBarrel(n1EBSM) == "EB+")
664  {i_eta_max = (Double_t)GetIEtaMax(n1EBSM, n1SMTowPlus );}
665  if( GetSMHalfBarrel(n1EBSM) == "EB-")
666  {i_eta_max = (Double_t)GetIEtaMax(n1EBSM, n1SMTowMinus);}
667 
668  return i_eta_max;
669 }
670 
671 //==============================================================================
672 //
673 // GetSMCentralPhi, GetPhiInSM, GetPhi,
674 // GetPhiMin, GetPhiMax, GetIPhiMin, GetIPhiMax
675 //
676 //==============================================================================
677 Double_t TEcnaNumbering::GetSMCentralPhi(const Int_t& n1EBSM)
678 {
679 //Gives the central phi value of the SuperModule
680 
681  Double_t central_phi = (Double_t)10.; // DEFAULT = SM1
682 
683  if (GetSMHalfBarrel(n1EBSM) == "EB+"){central_phi = 10. + (Double_t)20.*(n1EBSM-1);}
684  if (GetSMHalfBarrel(n1EBSM) == "EB-"){central_phi = 10. + (Double_t)20.*(n1EBSM-19);}
685 
686  return central_phi;
687 }
688 //------------------------------------------------------------------------------------
689 Double_t TEcnaNumbering::GetPhiInSM(const Int_t& n1EBSM,
690  const Int_t& n1SMTow, const Int_t& i0TowEcha)
691 {
692 //Gives Phi for a given (n1EBSM, n1SMTow, i0TowEcha)
693 
694  Double_t phi_in_SM = (Double_t)0.;
695 
696  Int_t rest_temp =(Int_t)(n1SMTow%(fEcal->MaxCrysPhiInTow()-1)); // "Phi" of the tower = 1,2,3,0
697 
698  if ( n1EBSM >= 1 && n1EBSM <= fEcal->MaxSMInEB() )
699  {
700  if( rest_temp == 1 ){phi_in_SM = (Double_t)15.;}
701  if( rest_temp == 2 ){phi_in_SM = (Double_t)10.;}
702  if( rest_temp == 3 ){phi_in_SM = (Double_t)5.;}
703  if( rest_temp == 0 ){phi_in_SM = (Double_t)0.;}
704 
705  if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbTop)
706  {
707  if( i0TowEcha == 4 || i0TowEcha == 5 || i0TowEcha == 14 || i0TowEcha == 15 || i0TowEcha == 24 )
708  {phi_in_SM = phi_in_SM + 0;}
709 
710  if( i0TowEcha == 3 || i0TowEcha == 6 || i0TowEcha == 13 || i0TowEcha == 16 || i0TowEcha == 23 )
711  {phi_in_SM = phi_in_SM + 1;}
712 
713  if( i0TowEcha == 2 || i0TowEcha == 7 || i0TowEcha == 12 || i0TowEcha == 17 || i0TowEcha == 22 )
714  {phi_in_SM = phi_in_SM + 2;}
715 
716  if( i0TowEcha == 1 || i0TowEcha == 8 || i0TowEcha == 11 || i0TowEcha == 18 || i0TowEcha == 21 )
717  {phi_in_SM = phi_in_SM + 3;}
718 
719  if( i0TowEcha == 0 || i0TowEcha == 9 || i0TowEcha == 10 || i0TowEcha == 19 || i0TowEcha == 20 )
720  {phi_in_SM = phi_in_SM + 4;}
721  }
722  if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbBot)
723  {
724  if( i0TowEcha == 20 || i0TowEcha == 19 || i0TowEcha == 10 || i0TowEcha == 9 || i0TowEcha == 0 )
725  {phi_in_SM = phi_in_SM + 0;}
726 
727  if( i0TowEcha == 21 || i0TowEcha == 18 || i0TowEcha == 11 || i0TowEcha == 8 || i0TowEcha == 1 )
728  {phi_in_SM = phi_in_SM + 1;}
729 
730  if( i0TowEcha == 22 || i0TowEcha == 17 || i0TowEcha == 12 || i0TowEcha == 7 || i0TowEcha == 2 )
731  {phi_in_SM = phi_in_SM + 2;}
732 
733  if( i0TowEcha == 23 || i0TowEcha == 16 || i0TowEcha == 13 || i0TowEcha == 6 || i0TowEcha == 3 )
734  {phi_in_SM = phi_in_SM + 3;}
735 
736  if( i0TowEcha == 24 || i0TowEcha == 15 || i0TowEcha == 14 || i0TowEcha == 5 || i0TowEcha == 4 )
737  {phi_in_SM = phi_in_SM + 4;}
738  }
739  }
740  else
741  {
742  cout << "TEcnaNumbering::GetPhiInSM(...)> SM = " << n1EBSM
743  << ". Out of range (range = [1," << fEcal->MaxSMInEB() << "])"
744  << fTTBELL << endl;
745  }
746  phi_in_SM = 20 - phi_in_SM;
747  return phi_in_SM;
748 }
749 //---------------------------------------------------------------------------------------
750 Double_t TEcnaNumbering::GetPhi(const Int_t& n1EBSM,
751  const Int_t& n1SMTow, const Int_t& i0TowEcha)
752 {
753 //Gives Phi for a given (n1EBSM, n1SMTow, i0TowEcha)
754 
755  Double_t phi = (Double_t)0.;
756 
757  if ( n1EBSM >= 1 && n1EBSM <= fEcal->MaxSMInEB() )
758  {
759  Double_t phiInSM = GetPhiInSM(n1EBSM, n1SMTow, i0TowEcha);
760  Double_t phi_start = GetSMCentralPhi(n1EBSM);
761 
762  phi = 20 - phiInSM + phi_start -(Double_t)10.;
763  }
764  else
765  {
766  cout << "TEcnaNumbering::GetPhi(...)> SM = " << n1EBSM
767  << ". Out of range (range = [1," << fEcal->MaxSMInEB() << "])"
768  << fTTBELL << endl;
769  }
770  return phi;
771 }
772 
773 //-----------------------------------------------------------------------------------------
774 Double_t TEcnaNumbering::GetPhiMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
775 {
776 //Gives PhiMin for a given Tower
777 
778  Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
779 
780  Double_t phi_min = (Double_t)0.; // DEFAULT
781  Double_t phi_start = GetSMCentralPhi(n1EBSM);
782 
783  Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
784 
785  if(GetSMHalfBarrel(n1EBSM) == "EB+")
786  {
787  if ( rest_temp == 1 ) {phi_min = phi_start + (Double_t)5.;}
788  if ( rest_temp == 2 ) {phi_min = phi_start + (Double_t)0.;}
789  if ( rest_temp == 3 ) {phi_min = phi_start - (Double_t)5.;}
790  if ( rest_temp == 0 ) {phi_min = phi_start - (Double_t)10.;}
791  }
792  if(GetSMHalfBarrel(n1EBSM) == "EB-")
793  {
794  if ( rest_temp == 0 ) {phi_min = phi_start + (Double_t)5.;}
795  if ( rest_temp == 3 ) {phi_min = phi_start + (Double_t)0.;}
796  if ( rest_temp == 2 ) {phi_min = phi_start - (Double_t)5.;}
797  if ( rest_temp == 1 ) {phi_min = phi_start - (Double_t)10.;}
798  }
799  return phi_min;
800 }
801 //-----------------------------------------------------------------------------------------
802 Double_t TEcnaNumbering::GetPhiMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
803 {
804 //Gives PhiMax for a given Tower
805 
806  Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
807 
808  Double_t phi_max = (Double_t)20.; // DEFAULT
809  Double_t phi_start = GetSMCentralPhi(n1EBSM);
810 
811  Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
812 
813  if(GetSMHalfBarrel(n1EBSM) == "EB+")
814  {
815  if ( rest_temp == 1 ) {phi_max = phi_start + (Double_t)10.;}
816  if ( rest_temp == 2 ) {phi_max = phi_start + (Double_t)5.;}
817  if ( rest_temp == 3 ) {phi_max = phi_start - (Double_t)0.;}
818  if ( rest_temp == 0 ) {phi_max = phi_start - (Double_t)5.;}
819  }
820 
821  if(GetSMHalfBarrel(n1EBSM) == "EB-")
822  {
823  if ( rest_temp == 0 ) {phi_max = phi_start + (Double_t)10.;}
824  if ( rest_temp == 3 ) {phi_max = phi_start + (Double_t)5.;}
825  if ( rest_temp == 2 ) {phi_max = phi_start - (Double_t)0.;}
826  if ( rest_temp == 1 ) {phi_max = phi_start - (Double_t)5.;}
827  }
828 
829  return phi_max;
830 }
831 //-----------------------------------------------------------------------------------------
832 Double_t TEcnaNumbering::GetPhiMin(const Int_t& n1EBSM)
833 {
834 //Gives PhiMin for a given SuperModule
835 
836  Double_t phi_min = GetSMCentralPhi(n1EBSM) - (Double_t)10.;
837 
838  return phi_min;
839 }
840 //-----------------------------------------------------------------------------------------
841 Double_t TEcnaNumbering::GetPhiMax(const Int_t& n1EBSM)
842 {
843 //Gives PhiMax for a given SuperModule
844 
845  Double_t phi_max = GetSMCentralPhi(n1EBSM) + (Double_t)10.;
846 
847  return phi_max;
848 }
849 //-----------------------------------------------------------------------------------------
850 Double_t TEcnaNumbering::GetJPhiMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
851 {
852 //Gives JPhiMin for a given Tower
853 
854  Double_t j_phi_min = (Double_t)1.;
855  Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
856  Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
857 
858  if ( rest_temp == 1 ){j_phi_min = (Double_t) 1. - (Double_t)0.5;}
859  if ( rest_temp == 2 ){j_phi_min = (Double_t) 6. - (Double_t)0.5;}
860  if ( rest_temp == 3 ){j_phi_min = (Double_t)11. - (Double_t)0.5;}
861  if ( rest_temp == 0 ){j_phi_min = (Double_t)16. - (Double_t)0.5;}
862 
863  return j_phi_min;
864 }
865 //-----------------------------------------------------------------------------------------
866 Double_t TEcnaNumbering::GetJPhiMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
867 {
868 //Gives JPhiMax for a given Tower
869 
870  Double_t j_phi_max = (Double_t)20.;
871  Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
872  Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
873 
874  if ( rest_temp == 1 ){j_phi_max = (Double_t) 5. + (Double_t)0.5;}
875  if ( rest_temp == 2 ){j_phi_max = (Double_t)10. + (Double_t)0.5;}
876  if ( rest_temp == 3 ){j_phi_max = (Double_t)15. + (Double_t)0.5;}
877  if ( rest_temp == 0 ){j_phi_max = (Double_t)20. + (Double_t)0.5;}
878 
879  return j_phi_max;
880 }
881 
882 //-----------------------------------------------------------------------------------------
883 Double_t TEcnaNumbering::GetJPhiMin(const Int_t& n1EBSM)
884 {
885 //Gives JPhiMin for a given SuperModule
886 
887  Double_t j_phi_min = (Double_t)1. - (Double_t)0.5;
888 
889  return j_phi_min;
890 }
891 //-----------------------------------------------------------------------------------------
892 Double_t TEcnaNumbering::GetJPhiMax(const Int_t& n1EBSM)
893 {
894 //Gives JPhiMax for a given SuperModule
895 
896  Double_t j_phi_max = (Double_t)20. + (Double_t)0.5;
897 
898  return j_phi_max;
899 }
900 
901 //==============================================================================
902 //
903 // GetXDirectionEB, GetYDirectionEB, GetJYDirectionEB
904 //
905 //==============================================================================
906 
907 //------------------------------------------------------------------
908 TString TEcnaNumbering::GetXDirectionEB(const Int_t& SMNumber)
909 {
910  TString xdirection = "x"; // DEFAULT
911 
912  if( GetSMHalfBarrel(SMNumber) == "EB+" ){xdirection = "x";}
913  if( GetSMHalfBarrel(SMNumber) == "EB-" ){xdirection = "x";}
914 
915  return xdirection;
916 }
917 //---------------------------------------------------------
918 TString TEcnaNumbering::GetYDirectionEB(const Int_t& SMNumber)
919 {
920  TString ydirection = "-x"; // DEFAULT
921 
922  if( GetSMHalfBarrel(SMNumber) == "EB+" ){ydirection = "-x";}
923  if( GetSMHalfBarrel(SMNumber) == "EB-" ){ydirection = "-x";}
924 
925  return ydirection;
926 }
927 
928 //---------------------------------------------------------
929 TString TEcnaNumbering::GetJYDirectionEB(const Int_t& SMNumber)
930 {
931  TString jydirection = "-x"; // DEFAULT
932 
933  if( GetSMHalfBarrel(SMNumber) == "EB+" ){jydirection = "x";}
934  if( GetSMHalfBarrel(SMNumber) == "EB-" ){jydirection = "-x";}
935 
936  return jydirection;
937 }
938 
939 //============================================================================
940 TString TEcnaNumbering::GetSMHalfBarrel(const Int_t& SMNumber)
941 {
942 //gives the half-barrel of the SM ("EB+" or "EB-")
943 
944  TString type = "EB-"; // => default value
945 
946  if ( SMNumber >= 1 && SMNumber <= fEcal->MaxSMInEBPlus() ){type = "EB+";}
947  if ( SMNumber > fEcal->MaxSMInEBPlus() && SMNumber <= fEcal->MaxSMInEB() ){type = "EB-";}
948 
949  return type;
950 }
951 
952 Int_t TEcnaNumbering::PlusMinusSMNumber(const Int_t& PlusSMNumber)
953 {
954  Int_t PMSMNumber = PlusSMNumber;
955  if( PlusSMNumber > fEcal->MaxSMPhiInEB() ){PMSMNumber = - PlusSMNumber + fEcal->MaxSMPhiInEB();}
956  return PMSMNumber;
957 }
958 //====================================================================================================
959 //
960 //
961 // E N D C A P
962 //
963 //
964 //====================================================================================================
965 //
966 // DeeCrys <-> (DeeSC, SCEcha) correspondance table
967 // (from the barrel table given by Patrick Jarry)
968 //
969 //====================================================================================================
971 {
972 // Build the correspondance table: DeeCrys <-> (DeeSC, SCEcha) for the ECAL ENDCAP
973 //
974 // From CMS Internal Note "CMS ECAL Endcap channel numbering"
975 //
976 // Name Number Reference set Range Comment
977 //
978 // DeeSC : Super-Crystal (SC) number in Dee [1,200] (IY,IX) progression
979 // DeeCrys : Crystal number in Dee [1,5000] (IY,IX) progression
980 // DeeEcha : Electronic channel number in Dee [0,4999] Crystal numbering for construction
981 //
982 // SCEcha : Electronic channel number in SC [1,25] Crystal numbering for construction
983 //
984 //
985 // fill the 3D array: fT3dDeeCrys[n_DeeSC][n_SCEcha][2]
986 //
987 // and the 2d arrays: fT2dDeeSC[n_DeeCrys][2] and fT2dSCEcha[n_DeeCrys][2]
988 //
989 //------------------------------------------------------------------------------------------------------
990 
991  if ( fT3dDeeCrys == 0 )
992  {
993  Int_t MaxDeeSC = fEcal->MaxSCEcnaInDee(); // fEcal->MaxSCEcnaInDee() = 200
994  Int_t MaxSCEcha = fEcal->MaxCrysInSC();
995  Int_t MaxDeeCrys = fEcal->MaxCrysEcnaInDee();
996 
997  Int_t MaxDirections = 2; // (2 directions: left and right)
998 
999  //................... Allocation and Init CrysNumbersTable
1000  fT3dDeeCrys = new Int_t**[MaxDeeSC]; fCnew++;
1001  fT2dDeeCrys = new Int_t*[MaxDeeSC*MaxSCEcha]; fCnew++;
1002  fT1dDeeCrys = new Int_t[MaxDeeSC*MaxSCEcha*MaxDirections]; fCnew++;
1003 
1004  for(Int_t i_DeeSC = 0; i_DeeSC < MaxDeeSC; i_DeeSC++){
1005  fT3dDeeCrys[i_DeeSC] = &fT2dDeeCrys[0] + i_DeeSC*MaxSCEcha;
1006  for(Int_t i_SCEcha = 0; i_SCEcha < MaxSCEcha; i_SCEcha++){
1007  fT2dDeeCrys[i_DeeSC*MaxSCEcha + i_SCEcha] = &fT1dDeeCrys[0]
1008  + (i_DeeSC*MaxSCEcha + i_SCEcha)*MaxDirections;}}
1009  for(Int_t i=0; i<MaxDeeSC; i++)
1010  {for(Int_t j=0; j<MaxSCEcha; j++)
1011  {for(Int_t k=0; k<MaxDirections; k++){fT3dDeeCrys[i][j][k]=0;}}}
1012 
1013  fT2dDeeSC = new Int_t*[MaxDeeCrys]; fCnew++;
1014  fT1dDeeSC = new Int_t[MaxDeeCrys*MaxDirections]; fCnew++;
1015  for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxDeeCrys ; i_DeeCrys++){
1016  fT2dDeeSC[i_DeeCrys] = &fT1dDeeSC[0] + i_DeeCrys*MaxDirections;}
1017  for(Int_t i=0; i<MaxDeeCrys; i++)
1018  {for(Int_t j=0; j<MaxDirections; j++){fT2dDeeSC[i][j]=0;}}
1019 
1020  fT2dSCEcha = new Int_t*[MaxDeeCrys]; fCnew++;
1021  fT1dSCEcha = new Int_t[MaxDeeCrys*MaxDirections]; fCnew++;
1022  for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxDeeCrys ; i_DeeCrys++){
1023  fT2dSCEcha[i_DeeCrys] = &fT1dSCEcha[0] + i_DeeCrys*MaxDirections;}
1024  for(Int_t i=0; i<MaxDeeCrys; i++)
1025  {for(Int_t j=0; j<MaxDirections; j++){fT2dSCEcha[i][j]=0;}}
1026 
1027  //................................ Build table
1028  Int_t MaxTyp = (Int_t)4;
1029  Int_t MaxCrysP1 = (Int_t)(fEcal->MaxCrysInSC()+1);
1030 
1031  // Int_t fT2d_jch_JY[type][Echa+1]: JY in the SC as a function of type and Echa+1
1032  fT2d_jch_JY = new Int_t*[MaxTyp]; fCnew++;
1033  fT1d_jch_JY = new Int_t[MaxTyp*MaxCrysP1]; fCnew++;
1034  for(Int_t i_MaxTyp = 0 ; i_MaxTyp < MaxTyp ; i_MaxTyp++){
1035  fT2d_jch_JY[i_MaxTyp] = &fT1d_jch_JY[0] + i_MaxTyp*MaxCrysP1;}
1036 
1037  // type: 0=(top/right), 1=(top/left), 2=(bottom/left), 3=(bottom/right),
1038 
1039  //................. top/right
1040  for(Int_t k= 5;k>= 1;k--){fT2d_jch_JY[0][k] = 4;} // k = 5, 4, 3, 2, 1 -> fT2d_jch_JY[0][k] = 4
1041  for(Int_t k=10;k>= 6;k--){fT2d_jch_JY[0][k] = 3;} // k = 10, 9, 8, 7, 6 -> fT2d_jch_JY[0][k] = 3
1042  for(Int_t k=15;k>=11;k--){fT2d_jch_JY[0][k] = 2;} // k = 15,14,13,12,11 -> fT2d_jch_JY[0][k] = 2
1043  for(Int_t k=20;k>=16;k--){fT2d_jch_JY[0][k] = 1;} // k = 20,19,18,17,16 -> fT2d_jch_JY[0][k] = 1
1044  for(Int_t k=25;k>=21;k--){fT2d_jch_JY[0][k] = 0;} // k = 25,24,23,22,21 -> fT2d_jch_JY[0][k] = 0
1045  //................. top/left
1046  for(Int_t k= 5;k>= 1;k--){fT2d_jch_JY[1][k] = 5-k;} // k = 5, 4, 3, 2, 1 -> fT2d_jch_JY[1][k] = 0,1,2,3,4
1047  for(Int_t k=10;k>= 6;k--){fT2d_jch_JY[1][k] = 10-k;} // k = 10, 9, 8, 7, 6 -> fT2d_jch_JY[1][k] = 0,1,2,3,4
1048  for(Int_t k=15;k>=11;k--){fT2d_jch_JY[1][k] = 15-k;} // k = 15,14,13,12,11 -> fT2d_jch_JY[1][k] = 0,1,2,3,4
1049  for(Int_t k=20;k>=16;k--){fT2d_jch_JY[1][k] = 20-k;} // k = 20,19,18,17,16 -> fT2d_jch_JY[1][k] = 0,1,2,3,4
1050  for(Int_t k=25;k>=21;k--){fT2d_jch_JY[1][k] = 25-k;} // k = 25,24,23,22,21 -> fT2d_jch_JY[1][k] = 0,1,2,3,4
1051  //................. bottom/left
1052  for(Int_t k= 1;k<=5; k++){fT2d_jch_JY[2][k] = 0;} // k = 1, 2, 3, 4, 5 -> fT2d_jch_JY[2][k] = 0
1053  for(Int_t k= 6;k<=10;k++){fT2d_jch_JY[2][k] = 1;} // k = 6, 7, 8, 9,10 -> fT2d_jch_JY[2][k] = 1
1054  for(Int_t k=11;k<=15;k++){fT2d_jch_JY[2][k] = 2;} // k = 11,12,13,14,15 -> fT2d_jch_JY[2][k] = 2
1055  for(Int_t k=16;k<=20;k++){fT2d_jch_JY[2][k] = 3;} // k = 16,17,18,19,20 -> fT2d_jch_JY[2][k] = 3
1056  for(Int_t k=21;k<=25;k++){fT2d_jch_JY[2][k] = 4;} // k = 21,22,23,24,25 -> fT2d_jch_JY[2][k] = 4
1057  //................. bottom/right
1058  for(Int_t k= 1;k<=5; k++){fT2d_jch_JY[3][k] = k-1;} // k = 1, 2, 3, 4, 5 -> fT2d_jch_JY[3][k] = 0,1,2,3,4
1059  for(Int_t k= 6;k<=10;k++){fT2d_jch_JY[3][k] = k-6;} // k = 6, 7, 8, 9,10 -> fT2d_jch_JY[3][k] = 0,1,2,3,4
1060  for(Int_t k=11;k<=15;k++){fT2d_jch_JY[3][k] = k-11;} // k = 11,12,13,14,15 -> fT2d_jch_JY[3][k] = 0,1,2,3,4
1061  for(Int_t k=16;k<=20;k++){fT2d_jch_JY[3][k] = k-16;} // k = 16,17,18,19,20 -> fT2d_jch_JY[3][k] = 0,1,2,3,4
1062  for(Int_t k=21;k<=25;k++){fT2d_jch_JY[3][k] = k-21;} // k = 21,22,23,24,25 -> fT2d_jch_JY[3][k] = 0,1,2,3,4
1063 
1064  // Int_t fT2d_ich_IX[type][Echa+1]: IX in the SC as a function of type and Echa+1
1065  fT2d_ich_IX = new Int_t*[MaxTyp]; fCnew++;
1066  fT1d_ich_IX = new Int_t[MaxTyp*MaxCrysP1]; fCnew++;
1067  for(Int_t i_MaxTyp = 0 ; i_MaxTyp < MaxTyp ; i_MaxTyp++){
1068  fT2d_ich_IX[i_MaxTyp] = &fT1d_ich_IX[0] + i_MaxTyp*MaxCrysP1;}
1069 
1070  //................. top/right
1071  for(Int_t k= 5;k>= 1;k--){fT2d_ich_IX[0][k] = 5-k;} // k = 5, 4, 3, 2, 1 -> fT2d_ich_IX[0][k] = 0,1,2,3,4
1072  for(Int_t k=10;k>= 6;k--){fT2d_ich_IX[0][k] = 10-k;} // k = 10, 9, 8, 7, 6 -> fT2d_ich_IX[0][k] = 0,1,2,3,4
1073  for(Int_t k=15;k>=11;k--){fT2d_ich_IX[0][k] = 15-k;} // k = 15,14,13,12,11 -> fT2d_ich_IX[0][k] = 0,1,2,3,4
1074  for(Int_t k=20;k>=16;k--){fT2d_ich_IX[0][k] = 20-k;} // k = 20,19,18,17,16 -> fT2d_ich_IX[0][k] = 0,1,2,3,4
1075  for(Int_t k=25;k>=21;k--){fT2d_ich_IX[0][k] = 25-k;} // k = 25,24,23,22,21 -> fT2d_ich_IX[0][k] = 0,1,2,3,4
1076  //................. top/left
1077  for(Int_t k= 5;k>= 1;k--){fT2d_ich_IX[1][k] = 4;} // k = 5, 4, 3, 2, 1 -> fT2d_ich_IX[1][k] = 4
1078  for(Int_t k=10;k>= 6;k--){fT2d_ich_IX[1][k] = 3;} // k = 10, 9, 8, 7, 6 -> fT2d_ich_IX[1][k] = 3
1079  for(Int_t k=15;k>=11;k--){fT2d_ich_IX[1][k] = 2;} // k = 15,14,13,12,11 -> fT2d_ich_IX[1][k] = 2
1080  for(Int_t k=20;k>=16;k--){fT2d_ich_IX[1][k] = 1;} // k = 20,19,18,17,16 -> fT2d_ich_IX[1][k] = 1
1081  for(Int_t k=25;k>=21;k--){fT2d_ich_IX[1][k] = 0;} // k = 25,24,23,22,21 -> fT2d_ich_IX[1][k] = 0
1082  //................. bottom/left
1083  for(Int_t k=1; k<=5; k++){fT2d_ich_IX[2][k] = 5-k;} // k = 1, 2, 3, 4, 5 -> fT2d_ich_IX[2][k] = 0,1,2,3,4
1084  for(Int_t k=6; k<=10;k++){fT2d_ich_IX[2][k] = 10-k;} // k = 6, 7, 8, 9,10 -> fT2d_ich_IX[2][k] = 0,1,2,3,4
1085  for(Int_t k=11;k<=15;k++){fT2d_ich_IX[2][k] = 15-k;} // k = 11,12,13,14,15 -> fT2d_ich_IX[2][k] = 0,1,2,3,4
1086  for(Int_t k=16;k<=20;k++){fT2d_ich_IX[2][k] = 20-k;} // k = 16,17,18,19,20 -> fT2d_ich_IX[2][k] = 0,1,2,3,4
1087  for(Int_t k=21;k<=25;k++){fT2d_ich_IX[2][k] = 25-k;} // k = 21,22,23,24,25 -> fT2d_ich_IX[2][k] = 0,1,2,3,4
1088  //................. bottom/right
1089  for(Int_t k= 1;k<= 5;k++){fT2d_ich_IX[3][k] = 4;} // k = 1, 2, 3, 4, 5 -> fT2d_ich_IX[3][k] = 4
1090  for(Int_t k= 6;k<=10;k++){fT2d_ich_IX[3][k] = 3;} // k = 6, 7, 8, 9,10 -> fT2d_ich_IX[3][k] = 3
1091  for(Int_t k=11;k<=15;k++){fT2d_ich_IX[3][k] = 2;} // k = 11,12,13,14,15 -> fT2d_ich_IX[3][k] = 2
1092  for(Int_t k=16;k<=20;k++){fT2d_ich_IX[3][k] = 1;} // k = 16,17,18,19,20 -> fT2d_ich_IX[3][k] = 1
1093  for(Int_t k=21;k<=25;k++){fT2d_ich_IX[3][k] = 0;} // k = 21,22,23,24,25 -> fT2d_ich_IX[3][k] = 0
1094 
1095  //............................................ type
1096  Int_t Nb_DeeSC_JY = fEcal->MaxSCIYInDee();
1097  Int_t** type = new Int_t*[Nb_DeeSC_JY]; fCnew++;
1098  Int_t* type_d1 = new Int_t[Nb_DeeSC_JY*MaxDirections]; fCnew++;
1099  for(Int_t i_DeeSC_JY = 0 ; i_DeeSC_JY < Nb_DeeSC_JY ; i_DeeSC_JY++){
1100  type[i_DeeSC_JY] = &type_d1[0] + i_DeeSC_JY*MaxDirections;}
1101 
1102  // bottom = (0,9), top = (10,19)
1103  // right = 0 , left = 1
1104  // type = Quadrant number - 1
1105 
1106  type[10][0] = 0; // Q1 top right
1107  type[11][0] = 0;
1108  type[12][0] = 0;
1109  type[13][0] = 0;
1110  type[14][0] = 0;
1111  type[15][0] = 0;
1112  type[16][0] = 0;
1113  type[17][0] = 0;
1114  type[18][0] = 0;
1115  type[19][0] = 0;
1116 
1117  type[10][1] = 1; // Q2 top left
1118  type[11][1] = 1;
1119  type[12][1] = 1;
1120  type[13][1] = 1;
1121  type[14][1] = 1;
1122  type[15][1] = 1;
1123  type[16][1] = 1;
1124  type[17][1] = 1;
1125  type[18][1] = 1;
1126  type[19][1] = 1;
1127 
1128  type[ 0][1] = 2; // Q3 : bottom left
1129  type[ 1][1] = 2;
1130  type[ 2][1] = 2;
1131  type[ 3][1] = 2;
1132  type[ 4][1] = 2;
1133  type[ 5][1] = 2;
1134  type[ 6][1] = 2;
1135  type[ 7][1] = 2;
1136  type[ 8][1] = 2;
1137  type[ 9][1] = 2;
1138 
1139  type[ 0][0] = 3; // Q4 : bottom right
1140  type[ 1][0] = 3;
1141  type[ 2][0] = 3;
1142  type[ 3][0] = 3;
1143  type[ 4][0] = 3;
1144  type[ 5][0] = 3;
1145  type[ 6][0] = 3;
1146  type[ 7][0] = 3;
1147  type[ 8][0] = 3;
1148  type[ 9][0] = 3;
1149 
1150  Int_t Nb_SCCrys_IX = fEcal->MaxCrysIXInSC();
1151  Int_t Nb_SCCrys_JY = fEcal->MaxCrysIYInSC();
1152 
1153  for(Int_t kSC=0; kSC<MaxDeeSC; kSC++) // kSC = 0 to 199 (MaxDeeSC = 200)
1154  {
1155  for(Int_t n_Echa=1; n_Echa<=MaxSCEcha; n_Echa++) // n_Echa = 1 to 25 (MaxSCEcha = 25)
1156  {
1157  for(Int_t idir=0; idir<2; idir++)
1158  {
1159  Int_t ikSC = kSC / Nb_DeeSC_JY; // ikSC = 0 to 9
1160  Int_t jkSC = kSC % Nb_DeeSC_JY; // jkSC = 0,1,2,..,19
1161 
1162  Int_t icrys = ikSC*Nb_SCCrys_IX + fT2d_ich_IX[type[jkSC][idir]][n_Echa];
1163  // type[0->9][1->2] = 0,1,2,3
1164  // fT2d_ich_IX[0->3][1->25] = 0,1,2,3,4
1165  // icrys = 0 to 49 (=> IX)
1166 
1167  Int_t jcrys = jkSC*Nb_SCCrys_JY + fT2d_jch_JY[type[jkSC][idir]][n_Echa];
1168  // type[0->9][1->2] = 0,1,2,3
1169  // fT2d_jch_JY[0->3][1->25] = 0,1,2,3,4
1170  // jcrys = 0 to 99 (=> IY)
1171 
1172  Int_t n_DeeCrys = icrys*Nb_DeeSC_JY*Nb_SCCrys_JY+jcrys+1; // n_DeeCrys = 1 to 5000
1173 
1174  fT3dDeeCrys[kSC][n_Echa-1][idir] = n_DeeCrys; // fT3dDeeCrys[][][] : range = [1,5000]
1175  fT2dDeeSC[n_DeeCrys-1][idir] = kSC+1; // fT2dDeeSC[][] : range = [1,200]
1176  fT2dSCEcha[n_DeeCrys-1][idir] = n_Echa; // fT2dSCEcha[][] : range = [1,25]
1177  }
1178  }
1179  }
1180  // cout << "#TEcnaNumbering::TBuildEndcapCrysTable()> Crys Table Building done" << endl;
1181 
1182  delete [] type; fCdelete++;
1183  delete [] type_d1; fCdelete++;
1184  }
1185  else
1186  {
1187  // cout << "#TEcnaNumbering::TBuildEndcapCrysTable()> No Building of Crys Table since it is already done " << endl;
1188  }
1189 }
1190 
1192 {
1193 // Build the correspondance table: (Dee, DeeSC) <-> (DS , DSSC) for the ECAL ENDCAP
1194 //
1195 // From CMS Internal Note "CMS ECAL Endcap channel numbering"
1196 //
1197 // Name Number Reference set Range Comment
1198 //
1199 // Dee : Dee number [1,4]
1200 // DeeSC : Super-Crystal (SC) number in Dee [1,200] (IY,IX) progression
1201 // DS : Data Sector number in EE + or - [1,9] (IY,IX) progression
1202 // DSSC : Super-Crystal (SC) number in Data Sector [1,32] Crystal numbering in data sector
1203 // DeeSCCons: Super-Crystal (SC) number for construction [1,297]
1204 //
1205 // fill the 2d arrays: fT2d_DS[4][200], fT2d_DSSC[4][200] and fT2d_DeeSCCons[4][200]
1206 //
1207 //------------------------------------------------------------------------------------------------------
1208 
1209 //.................. Allocations and Init
1210  Int_t MaxEEDee = fEcal->MaxDeeInEE();
1211  Int_t MaxDeeSC = fEcal->MaxSCEcnaInDee();
1212  Int_t MaxEESCForCons = 2*fEcal->MaxSCForConsInDee();
1213 
1214  fT2d_DS = new Int_t*[MaxEEDee]; fCnew++; // = DS[Dee - 1, CNA_SCInDee - 1]
1215  fT1d_DS = new Int_t[MaxEEDee*MaxDeeSC]; fCnew++;
1216  for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
1217  fT2d_DS[i_DeeCrys] = &fT1d_DS[0] + i_DeeCrys*MaxDeeSC;}
1218  for(Int_t i=0; i<MaxEEDee; i++)
1219  {for(Int_t j=0; j<MaxDeeSC; j++){fT2d_DS[i][j]=0;}}
1220 
1221  fT2d_DSSC = new Int_t*[MaxEEDee]; fCnew++; // = SCInDS[Dee - 1, CNA_SCInDee - 1]
1222  fT1d_DSSC = new Int_t[MaxEEDee*MaxDeeSC]; fCnew++;
1223  for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
1224  fT2d_DSSC[i_DeeCrys] = &fT1d_DSSC[0] + i_DeeCrys*MaxDeeSC;}
1225  for(Int_t i=0; i<MaxEEDee; i++)
1226  {for(Int_t j=0; j<MaxDeeSC; j++){fT2d_DSSC[i][j]=0;}}
1227 
1228  fT2d_DeeSCCons = new Int_t*[MaxEEDee]; fCnew++; // = SCConsInDee[Dee - 1, CNA_SCInDee - 1]
1229  fT1d_DeeSCCons = new Int_t[MaxEEDee*MaxDeeSC]; fCnew++;
1230  for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
1231  fT2d_DeeSCCons[i_DeeCrys] = &fT1d_DeeSCCons[0] + i_DeeCrys*MaxDeeSC;}
1232  for(Int_t i=0; i<MaxEEDee; i++)
1233  {for(Int_t j=0; j<MaxDeeSC; j++){fT2d_DeeSCCons[i][j]=0;}}
1234 
1235  fT2d_RecovDeeSC = new Int_t*[MaxEEDee]; fCnew++; // = CNA_SCInDee[Dee - 1, SCConsInDee - 1]
1236  fT1d_RecovDeeSC = new Int_t[MaxEEDee*MaxEESCForCons]; fCnew++;
1237  for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
1238  fT2d_RecovDeeSC[i_DeeCrys] = &fT1d_RecovDeeSC[0] + i_DeeCrys*MaxEESCForCons;}
1239  for(Int_t i=0; i<MaxEEDee; i++)
1240  {for(Int_t j=0; j<MaxEESCForCons; j++){fT2d_RecovDeeSC[i][j]=0;}}
1241 
1242  //.............................. Data sector (DS) numbers: fT2d_DS[][]
1243  // isc = ECNA numbers
1244 
1245  Int_t ids = 0;
1246 
1247  //........... (D1,S1)=(D2,S9)=(D3,S9)=(D4,S1)
1248  for(Int_t dee = 1; dee<=4; dee++)
1249  {
1250  if( dee == 1 || dee == 4 ){ids = 1;}
1251  if( dee == 2 || dee == 3 ){ids = 9;}
1252  for(Int_t isc= 13; isc<= 20; isc++)fT2d_DS[dee-1][isc-1] = ids;
1253  for(Int_t isc= 33; isc<= 40; isc++)fT2d_DS[dee-1][isc-1] = ids;
1254  for(Int_t isc= 54; isc<= 60; isc++)fT2d_DS[dee-1][isc-1] = ids;
1255  for(Int_t isc= 75; isc<= 79; isc++)fT2d_DS[dee-1][isc-1] = ids;
1256  for(Int_t isc= 96; isc<= 99; isc++)fT2d_DS[dee-1][isc-1] = ids;
1257  for(Int_t isc=118; isc<=119; isc++)fT2d_DS[dee-1][isc-1] = ids;
1258  }
1259  //........... (D1,S2)=(D2,S8)=(D3,S8)=(D4,S2)
1260  for(Int_t dee = 1; dee<=4; dee++)
1261  {
1262  if( dee == 1 || dee == 4 ){ids = 2;}
1263  if( dee == 2 || dee == 3 ){ids = 8;}
1264  for(Int_t isc= 32; isc<= 32; isc++)fT2d_DS[dee-1][isc-1] = ids;
1265  for(Int_t isc= 51; isc<= 53; isc++)fT2d_DS[dee-1][isc-1] = ids;
1266  for(Int_t isc= 72; isc<= 74; isc++)fT2d_DS[dee-1][isc-1] = ids;
1267  for(Int_t isc= 92; isc<= 95; isc++)fT2d_DS[dee-1][isc-1] = ids;
1268  for(Int_t isc=112; isc<=117; isc++)fT2d_DS[dee-1][isc-1] = ids;
1269  for(Int_t isc=132; isc<=138; isc++)fT2d_DS[dee-1][isc-1] = ids;
1270  for(Int_t isc=152; isc<=157; isc++)fT2d_DS[dee-1][isc-1] = ids;
1271  for(Int_t isc=173; isc<=176; isc++)fT2d_DS[dee-1][isc-1] = ids;
1272  for(Int_t isc=193; isc<=193; isc++)fT2d_DS[dee-1][isc-1] = ids;
1273  }
1274  //........... (D1,S3)=(D2,S7)=(D3,S7)=(D4,S3)
1275  for(Int_t dee = 1; dee<=4; dee++)
1276  {
1277  if( dee == 1 || dee == 4 ){ids = 3;}
1278  if( dee == 2 || dee == 3 ){ids = 7;}
1279  for(Int_t isc= 50; isc<= 50; isc++)fT2d_DS[dee-1][isc-1] = ids;
1280  for(Int_t isc= 69; isc<= 71; isc++)fT2d_DS[dee-1][isc-1] = ids;
1281  for(Int_t isc= 88; isc<= 91; isc++)fT2d_DS[dee-1][isc-1] = ids;
1282  for(Int_t isc=108; isc<=111; isc++)fT2d_DS[dee-1][isc-1] = ids;
1283  for(Int_t isc=127; isc<=131; isc++)fT2d_DS[dee-1][isc-1] = ids;
1284  for(Int_t isc=147; isc<=151; isc++)fT2d_DS[dee-1][isc-1] = ids;
1285  for(Int_t isc=166; isc<=172; isc++)fT2d_DS[dee-1][isc-1] = ids;
1286  for(Int_t isc=188; isc<=192; isc++)fT2d_DS[dee-1][isc-1] = ids;
1287  }
1288  //........... (D1,S4)=(D2,S6)=(D3,S6)=(D4,S4)
1289  for(Int_t dee = 1; dee<=4; dee++)
1290  {
1291  if( dee == 1 || dee == 4 ){ids = 4;}
1292  if( dee == 2 || dee == 3 ){ids = 6;}
1293  for(Int_t isc= 27; isc<= 29; isc++)fT2d_DS[dee-1][isc-1] = ids;
1294  for(Int_t isc= 44; isc<= 49; isc++)fT2d_DS[dee-1][isc-1] = ids;
1295  for(Int_t isc= 62; isc<= 68; isc++)fT2d_DS[dee-1][isc-1] = ids;
1296  for(Int_t isc= 82; isc<= 87; isc++)fT2d_DS[dee-1][isc-1] = ids;
1297  for(Int_t isc=102; isc<=107; isc++)fT2d_DS[dee-1][isc-1] = ids;
1298  for(Int_t isc=123; isc<=126; isc++)fT2d_DS[dee-1][isc-1] = ids;
1299  for(Int_t isc=144; isc<=146; isc++)fT2d_DS[dee-1][isc-1] = ids;
1300  for(Int_t isc=165; isc<=165; isc++)fT2d_DS[dee-1][isc-1] = ids;
1301  }
1302  //........... (D1,S5)=(D2,S5)=(D3,S5)=(D4,S5)
1303  for(Int_t dee = 1; dee<=4; dee++)
1304  {
1305  for(Int_t isc= 1; isc<= 8; isc++)fT2d_DS[dee-1][isc-1] = 5;
1306  for(Int_t isc= 21; isc<= 26; isc++)fT2d_DS[dee-1][isc-1] = 5;
1307  for(Int_t isc= 41; isc<= 43; isc++)fT2d_DS[dee-1][isc-1] = 5;
1308  }
1309 
1310  //............................................ SC numbers in Data Sectors: fT2d_DSSC[][]
1311  // fT2d_DSSC[dee-1][SC ECNA number - 1] = SC number in DS;
1312  for(Int_t dee=1; dee<=4; dee++)
1313  {
1314  for(Int_t isc=1; isc<=MaxDeeSC; isc++)
1315  {fT2d_DSSC[dee-1][isc-1] = -1;}
1316  //.......................................... S1 (D1,D4), S9 (D2,D3) ; 33 SC's
1317  fT2d_DSSC[dee-1][13-1] = 12;
1318  fT2d_DSSC[dee-1][14-1] = 11;
1319  fT2d_DSSC[dee-1][15-1] = 10;
1320  fT2d_DSSC[dee-1][16-1] = 9;
1321  fT2d_DSSC[dee-1][17-1] = 4;
1322  fT2d_DSSC[dee-1][18-1] = 3;
1323  fT2d_DSSC[dee-1][19-1] = 2;
1324  fT2d_DSSC[dee-1][20-1] = 1;
1325 
1326  fT2d_DSSC[dee-1][33-1] = 16;
1327  fT2d_DSSC[dee-1][34-1] = 15;
1328  fT2d_DSSC[dee-1][35-1] = 14;
1329  fT2d_DSSC[dee-1][36-1] = 13;
1330  fT2d_DSSC[dee-1][37-1] = 8;
1331  fT2d_DSSC[dee-1][38-1] = 7;
1332  fT2d_DSSC[dee-1][39-1] = 6;
1333  fT2d_DSSC[dee-1][40-1] = 5;
1334 
1335  fT2d_DSSC[dee-1][54-1] = 33;
1336  fT2d_DSSC[dee-1][55-1] = 31;
1337  fT2d_DSSC[dee-1][56-1] = 27;
1338  fT2d_DSSC[dee-1][57-1] = 24;
1339  fT2d_DSSC[dee-1][58-1] = 20;
1340  fT2d_DSSC[dee-1][59-1] = 17;
1341  fT2d_DSSC[dee-1][60-1] = 30; // (182a, 33a for construction)
1342 
1343  fT2d_DSSC[dee-1][75-1] = 32;
1344  fT2d_DSSC[dee-1][76-1] = 28;
1345  fT2d_DSSC[dee-1][77-1] = 25;
1346  fT2d_DSSC[dee-1][78-1] = 21;
1347  fT2d_DSSC[dee-1][79-1] = 18;
1348 
1349  fT2d_DSSC[dee-1][96-1] = 29;
1350  fT2d_DSSC[dee-1][97-1] = 26;
1351  fT2d_DSSC[dee-1][98-1] = 22;
1352  fT2d_DSSC[dee-1][99-1] = 19;
1353 
1354  fT2d_DSSC[dee-1][118-1] = 23;
1355  fT2d_DSSC[dee-1][119-1] = 30; // (182b, 33b for construction)
1356 
1357  //.......................................... S2 (D1,D4), S8(D2,D3) ; 32 SC's
1358  fT2d_DSSC[dee-1][32-1] = 25; // also 3; // ( (207c, 58c) also (178c, 29c) for construction)
1359 
1360  fT2d_DSSC[dee-1][51-1] = 32;
1361  fT2d_DSSC[dee-1][52-1] = 26;
1362  fT2d_DSSC[dee-1][53-1] = 18;
1363 
1364  fT2d_DSSC[dee-1][72-1] = 27;
1365  fT2d_DSSC[dee-1][73-1] = 19;
1366  fT2d_DSSC[dee-1][74-1] = 12;
1367 
1368  fT2d_DSSC[dee-1][92-1] = 28;
1369  fT2d_DSSC[dee-1][93-1] = 20;
1370  fT2d_DSSC[dee-1][94-1] = 13;
1371  fT2d_DSSC[dee-1][95-1] = 7;
1372 
1373  fT2d_DSSC[dee-1][112-1] = 29;
1374  fT2d_DSSC[dee-1][113-1] = 21;
1375  fT2d_DSSC[dee-1][114-1] = 14;
1376  fT2d_DSSC[dee-1][115-1] = 8;
1377  fT2d_DSSC[dee-1][116-1] = 4;
1378  fT2d_DSSC[dee-1][117-1] = 1;
1379 
1380  fT2d_DSSC[dee-1][132-1] = 30;
1381  fT2d_DSSC[dee-1][133-1] = 22;
1382  fT2d_DSSC[dee-1][134-1] = 15;
1383  fT2d_DSSC[dee-1][135-1] = 9;
1384  fT2d_DSSC[dee-1][136-1] = 5;
1385  fT2d_DSSC[dee-1][137-1] = 2;
1386  fT2d_DSSC[dee-1][138-1] = 3; // (178a, 29a for construction)
1387 
1388  fT2d_DSSC[dee-1][152-1] = 31;
1389  fT2d_DSSC[dee-1][153-1] = 23;
1390  fT2d_DSSC[dee-1][154-1] = 16;
1391  fT2d_DSSC[dee-1][155-1] = 10;
1392  fT2d_DSSC[dee-1][156-1] = 6;
1393  fT2d_DSSC[dee-1][157-1] = 3; // (178b, 29b for construction)
1394 
1395  fT2d_DSSC[dee-1][173-1] = 24;
1396  fT2d_DSSC[dee-1][174-1] = 17;
1397  fT2d_DSSC[dee-1][175-1] = 11;
1398  fT2d_DSSC[dee-1][176-1] = 25; // (207a, 58a for construction)
1399 
1400  fT2d_DSSC[dee-1][193-1] = 25; // (207b, 58b for construction)
1401 
1402  //.......................................... S3 (D1,D4), S7 (D2,D3) ; 34 SC's
1403  fT2d_DSSC[dee-1][50-1] = 10;
1404 
1405  fT2d_DSSC[dee-1][69-1] = 18;
1406  fT2d_DSSC[dee-1][70-1] = 11;
1407  fT2d_DSSC[dee-1][71-1] = 3;
1408 
1409  fT2d_DSSC[dee-1][88-1] = 25;
1410  fT2d_DSSC[dee-1][89-1] = 19;
1411  fT2d_DSSC[dee-1][90-1] = 12;
1412  fT2d_DSSC[dee-1][91-1] = 4;
1413 
1414  fT2d_DSSC[dee-1][108-1] = 26;
1415  fT2d_DSSC[dee-1][109-1] = 20;
1416  fT2d_DSSC[dee-1][110-1] = 13;
1417  fT2d_DSSC[dee-1][111-1] = 5;
1418 
1419  fT2d_DSSC[dee-1][127-1] = 31;
1420  fT2d_DSSC[dee-1][128-1] = 27;
1421  fT2d_DSSC[dee-1][129-1] = 21;
1422  fT2d_DSSC[dee-1][130-1] = 14;
1423  fT2d_DSSC[dee-1][131-1] = 6;
1424 
1425  fT2d_DSSC[dee-1][147-1] = 32;
1426  fT2d_DSSC[dee-1][148-1] = 28;
1427  fT2d_DSSC[dee-1][149-1] = 22;
1428  fT2d_DSSC[dee-1][150-1] = 15;
1429  fT2d_DSSC[dee-1][151-1] = 7;
1430 
1431  fT2d_DSSC[dee-1][166-1] = 33;
1432  fT2d_DSSC[dee-1][167-1] = 30;
1433  fT2d_DSSC[dee-1][168-1] = 29;
1434  fT2d_DSSC[dee-1][169-1] = 23;
1435  fT2d_DSSC[dee-1][170-1] = 16;
1436  fT2d_DSSC[dee-1][171-1] = 8;
1437  fT2d_DSSC[dee-1][172-1] = 1;
1438 
1439  fT2d_DSSC[dee-1][188-1] = 34; // (298a, 149a for construction)
1440  fT2d_DSSC[dee-1][189-1] = 24;
1441  fT2d_DSSC[dee-1][190-1] = 17;
1442  fT2d_DSSC[dee-1][191-1] = 9;
1443  fT2d_DSSC[dee-1][192-1] = 2;
1444 
1445  //.......................................... S4 (D1,D4), S6 (D2,D3) ; 33 SC's
1446  fT2d_DSSC[dee-1][27-1] = 33;
1447  fT2d_DSSC[dee-1][28-1] = 32;
1448  fT2d_DSSC[dee-1][29-1] = 14; // also 21; // ( (261a, 112a) also (268a, 119a) for construction)
1449 
1450  fT2d_DSSC[dee-1][44-1] = 22;
1451  fT2d_DSSC[dee-1][45-1] = 15;
1452  fT2d_DSSC[dee-1][46-1] = 8;
1453  fT2d_DSSC[dee-1][47-1] = 4;
1454  fT2d_DSSC[dee-1][48-1] = 2;
1455  fT2d_DSSC[dee-1][49-1] = 1;
1456 
1457  fT2d_DSSC[dee-1][62-1] = 29;
1458  fT2d_DSSC[dee-1][63-1] = 28;
1459  fT2d_DSSC[dee-1][64-1] = 23;
1460  fT2d_DSSC[dee-1][65-1] = 16;
1461  fT2d_DSSC[dee-1][66-1] = 9;
1462  fT2d_DSSC[dee-1][67-1] = 5;
1463  fT2d_DSSC[dee-1][68-1] = 3;
1464 
1465  fT2d_DSSC[dee-1][82-1] = 31;
1466  fT2d_DSSC[dee-1][83-1] = 30;
1467  fT2d_DSSC[dee-1][84-1] = 24;
1468  fT2d_DSSC[dee-1][85-1] = 17;
1469  fT2d_DSSC[dee-1][86-1] = 10;
1470  fT2d_DSSC[dee-1][87-1] = 6;
1471 
1472  fT2d_DSSC[dee-1][102-1] = 21; // (268c, 119c for construction)
1473  fT2d_DSSC[dee-1][103-1] = 27;
1474  fT2d_DSSC[dee-1][104-1] = 25;
1475  fT2d_DSSC[dee-1][105-1] = 18;
1476  fT2d_DSSC[dee-1][106-1] = 11;
1477  fT2d_DSSC[dee-1][107-1] = 7;
1478 
1479  fT2d_DSSC[dee-1][123-1] = 21; // (268b, 119b for construction)
1480  fT2d_DSSC[dee-1][124-1] = 26;
1481  fT2d_DSSC[dee-1][125-1] = 19;
1482  fT2d_DSSC[dee-1][126-1] = 12;
1483 
1484  fT2d_DSSC[dee-1][144-1] = 14; // (261c, 112c for construction)
1485  fT2d_DSSC[dee-1][145-1] = 20;
1486  fT2d_DSSC[dee-1][146-1] = 13;
1487 
1488  fT2d_DSSC[dee-1][165-1] = 14; // (261b, 112b for construction)
1489 
1490  //.......................................... S5 (2*17 = 34 SC's)
1491  if(dee == 1 || dee == 3)
1492  {
1493  fT2d_DSSC[dee-1][1-1] = 34;
1494  fT2d_DSSC[dee-1][2-1] = 33;
1495  fT2d_DSSC[dee-1][3-1] = 32;
1496  fT2d_DSSC[dee-1][4-1] = 31;
1497  fT2d_DSSC[dee-1][5-1] = 26;
1498  fT2d_DSSC[dee-1][6-1] = 25;
1499  fT2d_DSSC[dee-1][7-1] = 24;
1500  fT2d_DSSC[dee-1][8-1] = 23;
1501 
1502  fT2d_DSSC[dee-1][21-1] = 30;
1503  fT2d_DSSC[dee-1][22-1] = 29;
1504  fT2d_DSSC[dee-1][23-1] = 28;
1505  fT2d_DSSC[dee-1][24-1] = 27;
1506  fT2d_DSSC[dee-1][25-1] = 22;
1507  fT2d_DSSC[dee-1][26-1] = 21;
1508 
1509  fT2d_DSSC[dee-1][41-1] = 20; // (281a for construction)
1510  fT2d_DSSC[dee-1][42-1] = 19;
1511  fT2d_DSSC[dee-1][43-1] = 18;
1512  }
1513 
1514  if(dee == 2 || dee == 4)
1515  {
1516  fT2d_DSSC[dee-1][1-1] = 17;
1517  fT2d_DSSC[dee-1][2-1] = 16;
1518  fT2d_DSSC[dee-1][3-1] = 15;
1519  fT2d_DSSC[dee-1][4-1] = 14;
1520  fT2d_DSSC[dee-1][5-1] = 9;
1521  fT2d_DSSC[dee-1][6-1] = 8;
1522  fT2d_DSSC[dee-1][7-1] = 7;
1523  fT2d_DSSC[dee-1][8-1] = 6;
1524 
1525  fT2d_DSSC[dee-1][21-1] = 13;
1526  fT2d_DSSC[dee-1][22-1] = 12;
1527  fT2d_DSSC[dee-1][23-1] = 11;
1528  fT2d_DSSC[dee-1][24-1] = 10;
1529  fT2d_DSSC[dee-1][25-1] = 5;
1530  fT2d_DSSC[dee-1][26-1] = 4;
1531 
1532  fT2d_DSSC[dee-1][41-1] = 3; // (132a for construction)
1533  fT2d_DSSC[dee-1][42-1] = 2;
1534  fT2d_DSSC[dee-1][43-1] = 1;
1535  }
1536  }
1537  //............................... Numbers for construction: fT2d_DeeSCCons[][]
1538  // fT2d_DeeSCCons[dee-1][SC ECNA number - 1] = SC number for construction;
1539 
1540  //............................... init to -1
1541  for(Int_t dee=1; dee<=4; dee++)
1542  {for(Int_t isc=1; isc<=MaxDeeSC; isc++)
1543  {fT2d_DeeSCCons[dee-1][isc-1] = -1;}}
1544 
1545  for(Int_t i_dee_type=1; i_dee_type<=2; i_dee_type++)
1546  {
1547  Int_t dee = -1;
1548  if( i_dee_type == 1 ){dee = 1;}
1549  if( i_dee_type == 2 ){dee = 3;}
1550 
1551  //.......................................... (D1,S1 or D3,S9) AND (D2,S9 or D4,S1)
1552  // number in comment = fT2d_DSSC[dee-1][SC ECNA nb - 1] (= SC number in DS)
1553  fT2d_DeeSCCons[dee-1][13-1] = 161; fT2d_DeeSCCons[dee][13-1] = 12; // 12;
1554  fT2d_DeeSCCons[dee-1][14-1] = 160; fT2d_DeeSCCons[dee][14-1] = 11; // 11;
1555  fT2d_DeeSCCons[dee-1][15-1] = 159; fT2d_DeeSCCons[dee][15-1] = 10; // 10;
1556  fT2d_DeeSCCons[dee-1][16-1] = 158; fT2d_DeeSCCons[dee][16-1] = 9; // 9;
1557  fT2d_DeeSCCons[dee-1][17-1] = 153; fT2d_DeeSCCons[dee][17-1] = 4; // 4;
1558  fT2d_DeeSCCons[dee-1][18-1] = 152; fT2d_DeeSCCons[dee][18-1] = 3; // 3;
1559  fT2d_DeeSCCons[dee-1][19-1] = 151; fT2d_DeeSCCons[dee][19-1] = 2; // 2;
1560  fT2d_DeeSCCons[dee-1][20-1] = 150; fT2d_DeeSCCons[dee][20-1] = 1; // 1;
1561 
1562  fT2d_DeeSCCons[dee-1][33-1] = 165; fT2d_DeeSCCons[dee][33-1] = 16; // 16;
1563  fT2d_DeeSCCons[dee-1][34-1] = 164; fT2d_DeeSCCons[dee][34-1] = 15; // 15;
1564  fT2d_DeeSCCons[dee-1][35-1] = 163; fT2d_DeeSCCons[dee][35-1] = 14; // 14;
1565  fT2d_DeeSCCons[dee-1][36-1] = 162; fT2d_DeeSCCons[dee][36-1] = 13; // 13;
1566  fT2d_DeeSCCons[dee-1][37-1] = 157; fT2d_DeeSCCons[dee][37-1] = 8; // 8;
1567  fT2d_DeeSCCons[dee-1][38-1] = 156; fT2d_DeeSCCons[dee][38-1] = 7; // 7;
1568  fT2d_DeeSCCons[dee-1][39-1] = 155; fT2d_DeeSCCons[dee][39-1] = 6; // 6;
1569  fT2d_DeeSCCons[dee-1][40-1] = 154; fT2d_DeeSCCons[dee][40-1] = 5; // 5;
1570 
1571  fT2d_DeeSCCons[dee-1][54-1] = 193; fT2d_DeeSCCons[dee][54-1] = 44; // 33;
1572  fT2d_DeeSCCons[dee-1][55-1] = 186; fT2d_DeeSCCons[dee][55-1] = 37; // 31;
1573  fT2d_DeeSCCons[dee-1][56-1] = 179; fT2d_DeeSCCons[dee][56-1] = 30; // 27;
1574  fT2d_DeeSCCons[dee-1][57-1] = 173; fT2d_DeeSCCons[dee][57-1] = 24; // 24;
1575  fT2d_DeeSCCons[dee-1][58-1] = 169; fT2d_DeeSCCons[dee][58-1] = 20; // 20;
1576  fT2d_DeeSCCons[dee-1][59-1] = 166; fT2d_DeeSCCons[dee][59-1] = 17; // 17;
1577  fT2d_DeeSCCons[dee-1][60-1] = 182; fT2d_DeeSCCons[dee][60-1] = 33; // 30; // 182a ; 33a;
1578 
1579  fT2d_DeeSCCons[dee-1][75-1] = 187; fT2d_DeeSCCons[dee][75-1] = 38; // 32;
1580  fT2d_DeeSCCons[dee-1][76-1] = 180; fT2d_DeeSCCons[dee][76-1] = 31; // 28;
1581  fT2d_DeeSCCons[dee-1][77-1] = 174; fT2d_DeeSCCons[dee][77-1] = 25; // 25;
1582  fT2d_DeeSCCons[dee-1][78-1] = 170; fT2d_DeeSCCons[dee][78-1] = 21; // 21;
1583  fT2d_DeeSCCons[dee-1][79-1] = 167; fT2d_DeeSCCons[dee][79-1] = 18; // 18;
1584 
1585  fT2d_DeeSCCons[dee-1][96-1] = 181; fT2d_DeeSCCons[dee][96-1] = 32; // 29;
1586  fT2d_DeeSCCons[dee-1][97-1] = 175; fT2d_DeeSCCons[dee][97-1] = 26; // 26;
1587  fT2d_DeeSCCons[dee-1][98-1] = 171; fT2d_DeeSCCons[dee][98-1] = 22; // 22;
1588  fT2d_DeeSCCons[dee-1][99-1] = 168; fT2d_DeeSCCons[dee][99-1] = 19; // 19;
1589 
1590  fT2d_DeeSCCons[dee-1][118-1] = 172; fT2d_DeeSCCons[dee][118-1] = 23; // 23;
1591  fT2d_DeeSCCons[dee-1][119-1] = 182; fT2d_DeeSCCons[dee][119-1] = 33; // 30; // 182b ; 33b;
1592 
1593  //.......................................... (D1,S2 or D3,S8) AND (D2,S8 or D4,S2)
1594  fT2d_DeeSCCons[dee-1][32-1] = 178; fT2d_DeeSCCons[dee][32-1] = 29; // 25-3; // 178c-207c ; 29c-58c;
1595 
1596  fT2d_DeeSCCons[dee-1][51-1] = 216; fT2d_DeeSCCons[dee][51-1] = 67; // 32;
1597  fT2d_DeeSCCons[dee-1][52-1] = 208; fT2d_DeeSCCons[dee][52-1] = 59; // 26;
1598  fT2d_DeeSCCons[dee-1][53-1] = 200; fT2d_DeeSCCons[dee][53-1] = 51; // 18;
1599 
1600  fT2d_DeeSCCons[dee-1][72-1] = 209; fT2d_DeeSCCons[dee][72-1] = 60; // 27;
1601  fT2d_DeeSCCons[dee-1][73-1] = 201; fT2d_DeeSCCons[dee][73-1] = 52; // 19;
1602  fT2d_DeeSCCons[dee-1][74-1] = 194; fT2d_DeeSCCons[dee][74-1] = 45; // 12;
1603 
1604  fT2d_DeeSCCons[dee-1][92-1] = 210; fT2d_DeeSCCons[dee][92-1] = 61; // 28;
1605  fT2d_DeeSCCons[dee-1][93-1] = 202; fT2d_DeeSCCons[dee][93-1] = 53; // 20;
1606  fT2d_DeeSCCons[dee-1][94-1] = 195; fT2d_DeeSCCons[dee][94-1] = 46; // 13;
1607  fT2d_DeeSCCons[dee-1][95-1] = 188; fT2d_DeeSCCons[dee][95-1] = 39; // 7;
1608 
1609  fT2d_DeeSCCons[dee-1][112-1] = 211; fT2d_DeeSCCons[dee][112-1] = 62; // 29;
1610  fT2d_DeeSCCons[dee-1][113-1] = 203; fT2d_DeeSCCons[dee][113-1] = 54; // 21;
1611  fT2d_DeeSCCons[dee-1][114-1] = 196; fT2d_DeeSCCons[dee][114-1] = 47; // 14;
1612  fT2d_DeeSCCons[dee-1][115-1] = 189; fT2d_DeeSCCons[dee][115-1] = 40; // 8;
1613  fT2d_DeeSCCons[dee-1][116-1] = 183; fT2d_DeeSCCons[dee][116-1] = 34; // 4;
1614  fT2d_DeeSCCons[dee-1][117-1] = 176; fT2d_DeeSCCons[dee][117-1] = 27; // 1;
1615 
1616  fT2d_DeeSCCons[dee-1][132-1] = 212; fT2d_DeeSCCons[dee][132-1] = 63; // 30;
1617  fT2d_DeeSCCons[dee-1][133-1] = 204; fT2d_DeeSCCons[dee][133-1] = 55; // 22;
1618  fT2d_DeeSCCons[dee-1][134-1] = 197; fT2d_DeeSCCons[dee][134-1] = 48; // 15;
1619  fT2d_DeeSCCons[dee-1][135-1] = 190; fT2d_DeeSCCons[dee][135-1] = 41; // 9;
1620  fT2d_DeeSCCons[dee-1][136-1] = 184; fT2d_DeeSCCons[dee][136-1] = 35; // 5;
1621  fT2d_DeeSCCons[dee-1][137-1] = 177; fT2d_DeeSCCons[dee][137-1] = 28; // 2;
1622  fT2d_DeeSCCons[dee-1][138-1] = 178; fT2d_DeeSCCons[dee][138-1] = 29; // 3; // 178a ; 29a;
1623 
1624  fT2d_DeeSCCons[dee-1][152-1] = 213; fT2d_DeeSCCons[dee][152-1] = 64; // 31;
1625  fT2d_DeeSCCons[dee-1][153-1] = 205; fT2d_DeeSCCons[dee][153-1] = 56; // 23;
1626  fT2d_DeeSCCons[dee-1][154-1] = 198; fT2d_DeeSCCons[dee][154-1] = 49; // 16;
1627  fT2d_DeeSCCons[dee-1][155-1] = 191; fT2d_DeeSCCons[dee][155-1] = 42; // 10;
1628  fT2d_DeeSCCons[dee-1][156-1] = 185; fT2d_DeeSCCons[dee][156-1] = 36; // 6;
1629  fT2d_DeeSCCons[dee-1][157-1] = 178; fT2d_DeeSCCons[dee][157-1] = 29; // 3; // 178b ; 29b;
1630 
1631  fT2d_DeeSCCons[dee-1][173-1] = 206; fT2d_DeeSCCons[dee][173-1] = 57; // 24;
1632  fT2d_DeeSCCons[dee-1][174-1] = 199; fT2d_DeeSCCons[dee][174-1] = 50; // 17;
1633  fT2d_DeeSCCons[dee-1][175-1] = 192; fT2d_DeeSCCons[dee][175-1] = 43; // 11;
1634  fT2d_DeeSCCons[dee-1][176-1] = 207; fT2d_DeeSCCons[dee][176-1] = 58; // 25; // 58a ; 207a;
1635 
1636  fT2d_DeeSCCons[dee-1][193-1] = 207; fT2d_DeeSCCons[dee][193-1] = 58; // 25; // 58b ; 207b;
1637 
1638  //.......................................... (D1,S3 or D3,S7) AND (D2,S7 or D4,S3)
1639  fT2d_DeeSCCons[dee-1][50-1] = 224; fT2d_DeeSCCons[dee][50-1] = 75; // 10;
1640 
1641  fT2d_DeeSCCons[dee-1][69-1] = 233; fT2d_DeeSCCons[dee][69-1] = 84; // 18;
1642  fT2d_DeeSCCons[dee-1][70-1] = 225; fT2d_DeeSCCons[dee][70-1] = 76; // 11;
1643  fT2d_DeeSCCons[dee-1][71-1] = 217; fT2d_DeeSCCons[dee][71-1] = 68; // 3;
1644 
1645  fT2d_DeeSCCons[dee-1][88-1] = 242; fT2d_DeeSCCons[dee][88-1] = 93; // 25;
1646  fT2d_DeeSCCons[dee-1][89-1] = 234; fT2d_DeeSCCons[dee][89-1] = 85; // 19;
1647  fT2d_DeeSCCons[dee-1][90-1] = 226; fT2d_DeeSCCons[dee][90-1] = 77; // 12;
1648  fT2d_DeeSCCons[dee-1][91-1] = 218; fT2d_DeeSCCons[dee][91-1] = 69; // 4;
1649 
1650  fT2d_DeeSCCons[dee-1][108-1] = 243; fT2d_DeeSCCons[dee][108-1] = 94; // 26;
1651  fT2d_DeeSCCons[dee-1][109-1] = 235; fT2d_DeeSCCons[dee][109-1] = 86; // 20;
1652  fT2d_DeeSCCons[dee-1][110-1] = 227; fT2d_DeeSCCons[dee][110-1] = 78; // 13;
1653  fT2d_DeeSCCons[dee-1][111-1] = 219; fT2d_DeeSCCons[dee][111-1] = 70; // 5;
1654 
1655  fT2d_DeeSCCons[dee-1][127-1] = 252; fT2d_DeeSCCons[dee][127-1] = 103; // 31;
1656  fT2d_DeeSCCons[dee-1][128-1] = 244; fT2d_DeeSCCons[dee][128-1] = 95; // 27;
1657  fT2d_DeeSCCons[dee-1][129-1] = 236; fT2d_DeeSCCons[dee][129-1] = 87; // 21;
1658  fT2d_DeeSCCons[dee-1][130-1] = 228; fT2d_DeeSCCons[dee][130-1] = 79; // 14;
1659  fT2d_DeeSCCons[dee-1][131-1] = 220; fT2d_DeeSCCons[dee][131-1] = 71; // 6;
1660 
1661  fT2d_DeeSCCons[dee-1][147-1] = 253; fT2d_DeeSCCons[dee][147-1] = 104; // 32;
1662  fT2d_DeeSCCons[dee-1][148-1] = 245; fT2d_DeeSCCons[dee][148-1] = 96; // 28;
1663  fT2d_DeeSCCons[dee-1][149-1] = 237; fT2d_DeeSCCons[dee][149-1] = 88; // 22;
1664  fT2d_DeeSCCons[dee-1][150-1] = 229; fT2d_DeeSCCons[dee][150-1] = 80; // 15;
1665  fT2d_DeeSCCons[dee-1][151-1] = 221; fT2d_DeeSCCons[dee][151-1] = 72; // 7;
1666 
1667  fT2d_DeeSCCons[dee-1][166-1] = 254; fT2d_DeeSCCons[dee][166-1] = 105; // 33;
1668  fT2d_DeeSCCons[dee-1][167-1] = 247; fT2d_DeeSCCons[dee][167-1] = 98; // 30;
1669  fT2d_DeeSCCons[dee-1][168-1] = 246; fT2d_DeeSCCons[dee][168-1] = 97; // 29;
1670  fT2d_DeeSCCons[dee-1][169-1] = 238; fT2d_DeeSCCons[dee][169-1] = 89; // 23;
1671  fT2d_DeeSCCons[dee-1][170-1] = 230; fT2d_DeeSCCons[dee][170-1] = 81; // 16;
1672  fT2d_DeeSCCons[dee-1][171-1] = 222; fT2d_DeeSCCons[dee][171-1] = 73; // 8;
1673  fT2d_DeeSCCons[dee-1][172-1] = 214; fT2d_DeeSCCons[dee][172-1] = 65; // 1;
1674 
1675  fT2d_DeeSCCons[dee-1][188-1] = 298; fT2d_DeeSCCons[dee][188-1] = 149; // 24; // 298a ; 149a;
1676  fT2d_DeeSCCons[dee-1][189-1] = 239; fT2d_DeeSCCons[dee][189-1] = 90; // 24;
1677  fT2d_DeeSCCons[dee-1][190-1] = 231; fT2d_DeeSCCons[dee][190-1] = 82; // 17;
1678  fT2d_DeeSCCons[dee-1][191-1] = 223; fT2d_DeeSCCons[dee][191-1] = 74; // 9;
1679  fT2d_DeeSCCons[dee-1][192-1] = 215; fT2d_DeeSCCons[dee][192-1] = 66; // 2;
1680 
1681  //.......................................... (D1,S4 or D3,S6) AND (D2,S6 or D4,S4)
1682  fT2d_DeeSCCons[dee-1][29-1] = 261; fT2d_DeeSCCons[dee][29-1] = 112; // 14-21; // 261a-268a ; 112a-119a;
1683  fT2d_DeeSCCons[dee-1][27-1] = 283; fT2d_DeeSCCons[dee][27-1] = 134; // 33;
1684  fT2d_DeeSCCons[dee-1][28-1] = 282; fT2d_DeeSCCons[dee][28-1] = 133; // 32;
1685 
1686  fT2d_DeeSCCons[dee-1][44-1] = 269; fT2d_DeeSCCons[dee][44-1] = 120; // 22;
1687  fT2d_DeeSCCons[dee-1][45-1] = 262; fT2d_DeeSCCons[dee][45-1] = 113; // 15;
1688  fT2d_DeeSCCons[dee-1][46-1] = 255; fT2d_DeeSCCons[dee][46-1] = 106; // 8;
1689  fT2d_DeeSCCons[dee-1][47-1] = 248; fT2d_DeeSCCons[dee][47-1] = 99; // 4;
1690  fT2d_DeeSCCons[dee-1][48-1] = 240; fT2d_DeeSCCons[dee][48-1] = 91; // 2;
1691  fT2d_DeeSCCons[dee-1][49-1] = 232; fT2d_DeeSCCons[dee][49-1] = 83; // 1;
1692 
1693  fT2d_DeeSCCons[dee-1][62-1] = 276; fT2d_DeeSCCons[dee][62-1] = 127; // 29;
1694  fT2d_DeeSCCons[dee-1][63-1] = 275; fT2d_DeeSCCons[dee][63-1] = 126; // 28;
1695  fT2d_DeeSCCons[dee-1][64-1] = 270; fT2d_DeeSCCons[dee][64-1] = 121; // 23;
1696  fT2d_DeeSCCons[dee-1][65-1] = 263; fT2d_DeeSCCons[dee][65-1] = 114; // 16;
1697  fT2d_DeeSCCons[dee-1][66-1] = 256; fT2d_DeeSCCons[dee][66-1] = 107; // 9;
1698  fT2d_DeeSCCons[dee-1][67-1] = 249; fT2d_DeeSCCons[dee][67-1] = 100; // 5;
1699  fT2d_DeeSCCons[dee-1][68-1] = 241; fT2d_DeeSCCons[dee][68-1] = 92; // 3;
1700 
1701  fT2d_DeeSCCons[dee-1][82-1] = 278; fT2d_DeeSCCons[dee][82-1] = 129; // 31;
1702  fT2d_DeeSCCons[dee-1][83-1] = 277; fT2d_DeeSCCons[dee][83-1] = 128; // 30;
1703  fT2d_DeeSCCons[dee-1][84-1] = 271; fT2d_DeeSCCons[dee][84-1] = 122; // 24;
1704  fT2d_DeeSCCons[dee-1][85-1] = 264; fT2d_DeeSCCons[dee][85-1] = 115; // 17;
1705  fT2d_DeeSCCons[dee-1][86-1] = 257; fT2d_DeeSCCons[dee][86-1] = 108; // 10;
1706  fT2d_DeeSCCons[dee-1][87-1] = 250; fT2d_DeeSCCons[dee][87-1] = 101; // 6;
1707 
1708  fT2d_DeeSCCons[dee-1][102-1] = 268; fT2d_DeeSCCons[dee][102-1] = 119; // 21; // 268c ; 119c;
1709  fT2d_DeeSCCons[dee-1][103-1] = 274; fT2d_DeeSCCons[dee][103-1] = 125; // 27;
1710  fT2d_DeeSCCons[dee-1][104-1] = 272; fT2d_DeeSCCons[dee][104-1] = 123; // 25;
1711  fT2d_DeeSCCons[dee-1][105-1] = 265; fT2d_DeeSCCons[dee][105-1] = 116; // 18;
1712  fT2d_DeeSCCons[dee-1][106-1] = 258; fT2d_DeeSCCons[dee][106-1] = 109; // 11;
1713  fT2d_DeeSCCons[dee-1][107-1] = 251; fT2d_DeeSCCons[dee][107-1] = 102; // 7;
1714 
1715  fT2d_DeeSCCons[dee-1][123-1] = 268; fT2d_DeeSCCons[dee][123-1] = 119; // 27; // 268b ; 119b;
1716  fT2d_DeeSCCons[dee-1][124-1] = 273; fT2d_DeeSCCons[dee][124-1] = 124; // 26;
1717  fT2d_DeeSCCons[dee-1][125-1] = 266; fT2d_DeeSCCons[dee][125-1] = 117; // 19;
1718  fT2d_DeeSCCons[dee-1][126-1] = 259; fT2d_DeeSCCons[dee][126-1] = 110; // 12;
1719 
1720  fT2d_DeeSCCons[dee-1][144-1] = 261; fT2d_DeeSCCons[dee][144-1] = 112; // 27; // 261c ; 112c;
1721  fT2d_DeeSCCons[dee-1][145-1] = 267; fT2d_DeeSCCons[dee][145-1] = 118; // 20;
1722  fT2d_DeeSCCons[dee-1][146-1] = 260; fT2d_DeeSCCons[dee][146-1] = 111; // 13;
1723 
1724  fT2d_DeeSCCons[dee-1][165-1] = 261; fT2d_DeeSCCons[dee][165-1] = 112; // 27; // 261b ; 112b;
1725 
1726  //.......................................... D1 or D3, right half of S5
1727  fT2d_DeeSCCons[dee-1][1-1] = 297; // 34;
1728  fT2d_DeeSCCons[dee-1][2-1] = 296; // 33;
1729  fT2d_DeeSCCons[dee-1][3-1] = 295; // 32;
1730  fT2d_DeeSCCons[dee-1][4-1] = 294; // 31;
1731  fT2d_DeeSCCons[dee-1][5-1] = 289; // 26;
1732  fT2d_DeeSCCons[dee-1][6-1] = 288; // 25;
1733  fT2d_DeeSCCons[dee-1][7-1] = 287; // 24;
1734  fT2d_DeeSCCons[dee-1][8-1] = 286; // 23;
1735 
1736  fT2d_DeeSCCons[dee-1][21-1] = 293; // 30;
1737  fT2d_DeeSCCons[dee-1][22-1] = 292; // 29;
1738  fT2d_DeeSCCons[dee-1][23-1] = 291; // 28;
1739  fT2d_DeeSCCons[dee-1][24-1] = 290; // 27;
1740  fT2d_DeeSCCons[dee-1][25-1] = 285; // 22;
1741  fT2d_DeeSCCons[dee-1][26-1] = 284; // 21;
1742 
1743  fT2d_DeeSCCons[dee-1][41-1] = 281; // 20; // 281a
1744  fT2d_DeeSCCons[dee-1][42-1] = 280; // 19;
1745  fT2d_DeeSCCons[dee-1][43-1] = 279; // 18;
1746 
1747  //.......................................... D2 or D4, left half of S5
1748  fT2d_DeeSCCons[dee][1-1] = 148; // 17;
1749  fT2d_DeeSCCons[dee][2-1] = 147; // 16;
1750  fT2d_DeeSCCons[dee][3-1] = 146; // 15;
1751  fT2d_DeeSCCons[dee][4-1] = 145; // 14;
1752  fT2d_DeeSCCons[dee][5-1] = 140; // 9;
1753  fT2d_DeeSCCons[dee][6-1] = 139; // 8;
1754  fT2d_DeeSCCons[dee][7-1] = 138; // 7;
1755  fT2d_DeeSCCons[dee][8-1] = 137; // 6;
1756 
1757  fT2d_DeeSCCons[dee][21-1] = 144; // 13;
1758  fT2d_DeeSCCons[dee][22-1] = 143; // 12;
1759  fT2d_DeeSCCons[dee][23-1] = 142; // 11;
1760  fT2d_DeeSCCons[dee][24-1] = 141; // 10;
1761  fT2d_DeeSCCons[dee][25-1] = 136; // 5;
1762  fT2d_DeeSCCons[dee][26-1] = 135; // 4;
1763 
1764  fT2d_DeeSCCons[dee][41-1] = 132; // 3; // 132a
1765  fT2d_DeeSCCons[dee][42-1] = 131; // 2;
1766  fT2d_DeeSCCons[dee][43-1] = 130; // 1;
1767  }
1768 
1769  //........................ ECNA numbers from numbers for constructions: fT2d_RecovDeeSC[][]
1770 
1771  for(Int_t i0EEDee=0; i0EEDee<MaxEEDee; i0EEDee++)
1772  {
1773  for(Int_t i_ecna=0; i_ecna<MaxDeeSC; i_ecna++)
1774  {
1775  //....... test to avoid the -1 init value in 2nd index of array fT2d_RecovDeeSC[][]
1776  // (part of the matrix without real SC counterpart)
1777  if( fT2d_DeeSCCons[i0EEDee][i_ecna] >= 0 && fT2d_DeeSCCons[i0EEDee][i_ecna] <= MaxEESCForCons )
1778  {
1779  fT2d_RecovDeeSC[i0EEDee][fT2d_DeeSCCons[i0EEDee][i_ecna]-1] = i_ecna+1;
1780  }
1781  }
1782  }
1783 }
1784 //------------ (end of BuildEndcapSCTable) -------------------------
1785 
1786 //===============================================================================
1787 //
1788 // Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha
1789 // GetDeeCrysFromDeeEcha
1790 //
1791 //===============================================================================
1793  const Int_t& i0SCEcha,
1794  const TString& sDeeDir)
1795 {
1796 //get crystal number in Dee from SC number in Dee
1797 // and from Electronic Channel number in super-crystal
1798 
1799  Int_t n1DeeCrys = 0;
1800  Int_t i0DeeDir = GetDeeDirIndex(sDeeDir);
1801 
1802  if( fT3dDeeCrys == 0 ){BuildEndcapCrysTable();}
1803 
1804  if( (n1DeeSCEcna >= 1) && (n1DeeSCEcna <= fEcal->MaxSCEcnaInDee()) )
1805  {
1806  if (i0SCEcha >=0 && i0SCEcha < fEcal->MaxCrysInSC())
1807  {
1808  n1DeeCrys = fT3dDeeCrys[n1DeeSCEcna-1][i0SCEcha][i0DeeDir];
1809  }
1810  else
1811  {
1812  n1DeeCrys = -2; // Electronic Cnannel in Super-Crystal out of range
1813  cout << "!TEcnaNumbering::Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(...)> Electronic Channel in SuperCrystal = "
1814  << i0SCEcha+1 << ". Out of range (range = [1," << fEcal->MaxCrysInSC() << "])" << fTTBELL << endl;
1815  }
1816  }
1817  else
1818  {
1819  n1DeeCrys = -3; // Super-Crystal number in Dee out of range
1820  cout << "!TEcnaNumbering::Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(...)> Super-Crystal number in Dee out of range."
1821  << " n1DeeSCEcna = " << n1DeeSCEcna << fTTBELL << endl;
1822  }
1823 
1824  return n1DeeCrys; // Range = [1,5000]
1825 }
1826 
1827 //===============================================================================
1828 //
1829 // Get1SCEchaFrom1DeeCrys, Get1DeeSCEcnaFrom1DeeCrys
1830 //
1831 //===============================================================================
1832 
1833 Int_t TEcnaNumbering::Get1SCEchaFrom1DeeCrys(const Int_t& n1DeeCrys, const TString& sDeeDir)
1834 {
1835 // get Electronic Channel number in Super-Crystal from Crystal ECNA number in Dee
1836 
1837  Int_t n1SCEcha = -1;
1838  Int_t iDeeDir = GetDeeDirIndex(sDeeDir);
1839 
1840  if( n1DeeCrys >= 1 && n1DeeCrys <= fEcal->MaxCrysEcnaInDee() )
1841  {
1842  n1SCEcha = fT2dSCEcha[n1DeeCrys-1][iDeeDir];
1843  }
1844  else
1845  {
1846  n1SCEcha = -2;
1847  cout << "!TEcnaNumbering::Get1SCEchaFrom1DeeCrys(...)> Crystal number in Dee out of range."
1848  << " n1DeeCrys = " << n1DeeCrys << "(max = " << fEcal->MaxCrysEcnaInDee() << ")" << fTTBELL << endl;
1849  }
1850  return n1SCEcha; // range = [1,25]
1851 }
1852 
1853 Int_t TEcnaNumbering::Get1DeeSCEcnaFrom1DeeCrys(const Int_t& n1DeeCrys, const TString& sDeeDir)
1854 {
1855 // get Super-Crystal number in Dee from Crystal number in Dee
1856 
1857  Int_t n1DeeSCEcna = 0;
1858  Int_t iDeeDir = GetDeeDirIndex(sDeeDir);
1859 
1860  if( n1DeeCrys >= 1 && n1DeeCrys <= fEcal->MaxCrysEcnaInDee() )
1861  {
1862  n1DeeSCEcna = fT2dDeeSC[n1DeeCrys-1][iDeeDir];
1863  }
1864  else
1865  {
1866  n1DeeSCEcna = -1;
1867  cout << "!TEcnaNumbering::Get1DeeSCEcnaFrom1DeeCrys(...)> Crystal number in Dee out of range."
1868  << " n1DeeCrys = " << n1DeeCrys << "(max = " << fEcal->MaxCrysEcnaInDee() << ")" << fTTBELL << endl;
1869  }
1870  return n1DeeSCEcna; // range = [1,200]
1871 }
1872 
1873 //===============================================================================
1874 //
1875 // GetSCEchaFromDeeEcha
1876 // Get1DeeSCEcnaFromDeeEcha
1877 //
1878 //===============================================================================
1879 
1880 Int_t TEcnaNumbering::Get1SCEchaFrom0DeeEcha(const Int_t& i0DeeEcha)
1881 {
1882 //get electronic channel number in super-crystal from electronic channel number in Dee
1883 
1884  Int_t i0DeeSC = i0DeeEcha/fEcal->MaxCrysInSC();
1885  Int_t n1SCEcha = i0DeeEcha - fEcal->MaxCrysInSC()*i0DeeSC + 1;
1886 
1887  return n1SCEcha; // range = [1,25]
1888 }
1889 
1890 Int_t TEcnaNumbering::Get1DeeSCEcnaFrom0DeeEcha(const Int_t& i0DeeEcha)
1891 {
1892 //get super-crystal number from electronic channel number in Dee
1893 
1894  Int_t n1DeeSC = i0DeeEcha/fEcal->MaxCrysInSC()+1;
1895 
1896  return n1DeeSC; // range = [1,200]
1897 }
1898 
1899 //--------------------------------------------------------------------------------
1900 //
1901 // Correspondance (n1DeeNumber, DeeSC) <-> (DS, DSSC, DeeSCCons)
1902 //
1903 // GetDSFrom1DeeSCEcna, GetDSSCFrom1DeeSCEcna,
1904 // GetDeeSCConsFrom1DeeSCEcna, Get1DeeSCEcnaFromDeeSCCons
1905 //
1906 // Get the values from the relevant arrays
1907 // with cross-check of the index values in argument
1908 //--------------------------------------------------------------------------------
1909 
1910 Int_t TEcnaNumbering::GetDSFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna)
1911 {
1912 // Get Data Sector number from SC ECNA number in Dee
1913 
1914  Int_t data_sector = -1;
1915 
1916  if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
1917  {
1918  if( n1DeeSCEcna > 0 && n1DeeSCEcna <= fEcal->MaxSCEcnaInDee() )
1919  {
1920  data_sector = fT2d_DS[n1DeeNumber-1][n1DeeSCEcna-1];
1921  }
1922  else
1923  {
1924  cout << "!TEcnaNumbering::GetDSFrom1DeeSCEcna(...)> n1DeeSCEcna = " << n1DeeSCEcna
1925  << ". Out of range ( range = [1," << fEcal->MaxSCEcnaInDee() << "] )"
1926  << fTTBELL << endl;
1927  }
1928  }
1929  else
1930  {
1931  if( n1DeeNumber != 0 )
1932  {
1933  cout << "!TEcnaNumbering::GetDSFrom1DeeSCEcna(...)> n1DeeNumber = " << n1DeeNumber
1934  << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
1935  << fTTBELL << endl;
1936  }
1937  else
1938  {
1939  cout << "TEcnaNumbering::GetDSFrom1DeeSCEcna(...)> Dee = " << n1DeeNumber
1940  << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])"
1941  << fTTBELL << endl;
1942  }
1943  }
1944  return data_sector;
1945 }
1946 //..........................................................................................
1947 Int_t TEcnaNumbering::GetDSSCFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna,
1948  const Int_t& n1SCEcha)
1949 {
1950  //.......... Get the correct SC number for the unconnected SC's (inner border)
1951  Int_t ds_sc = GetDSSCFrom1DeeSCEcna(n1DeeNumber, n1DeeSCEcna);
1952 
1953  if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 )
1954  {
1955  if( n1SCEcha == 11 )
1956  {
1957  if( ds_sc == 14 ){ds_sc= 21;} // 14 <=> 261/BR OR 112/BL
1958  }
1959  if( n1SCEcha == 1 || n1SCEcha == 2 || n1SCEcha == 3 ||
1960  n1SCEcha == 6 || n1SCEcha == 7 )
1961  {
1962  if( ds_sc == 3 ){ds_sc = 25;} // 3 <=> 178/TR OR 29/TL
1963  }
1964  }
1965  return ds_sc;
1966 }
1967 //..........................................................................................
1968 Int_t TEcnaNumbering::GetDSSCFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna)
1969 {
1970 // Get SC number in Data Sector from SC Ecna number in Dee
1971 
1972  Int_t ds_sc = -1;
1973 
1974  if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
1975  {
1976  if( n1DeeSCEcna > 0 && n1DeeSCEcna <= fEcal->MaxSCEcnaInDee() )
1977  {
1978  ds_sc = fT2d_DSSC[n1DeeNumber-1][n1DeeSCEcna-1]; // 25 (not 3) or 14 (not 21) if n1DeeSCEcna = 32 or 29
1979  // 25 and 14 => 5 Xtals, 3 and 21 => 1 Xtal
1980  }
1981  else
1982  {
1983  cout << "!TEcnaNumbering::GetDSSCFrom1DeeSCEcna(...)> n1DeeSCEcna = " << n1DeeSCEcna
1984  << ". Out of range ( range = [1," << fEcal->MaxSCEcnaInDee() << "] )"
1985  << fTTBELL << endl;
1986  }
1987  }
1988  else
1989  {
1990  if( n1DeeNumber != 0 )
1991  {
1992  cout << "!TEcnaNumbering::GetDSSCFrom1DeeSCEcna(...)> n1DeeNumber = " << n1DeeNumber
1993  << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
1994  << fTTBELL << endl;
1995  }
1996  else
1997  {
1998  cout << "TEcnaNumbering::GetDSSCFrom1DeeSCEcna(...)> Dee = " << n1DeeNumber
1999  << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])"
2000  << fTTBELL << endl;
2001  }
2002  }
2003  return ds_sc;
2004 }
2005 //..........................................................................................
2006 Int_t TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna)
2007 {
2008 // Get SC number for Construction in Dee from SC ECNA number in Dee
2009 
2010  Int_t dee_sc_cons = -1;
2011 
2012  if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
2013  {
2014  if( n1DeeSCEcna > 0 && n1DeeSCEcna <= fEcal->MaxSCEcnaInDee() )
2015  {
2016  dee_sc_cons = fT2d_DeeSCCons[n1DeeNumber-1][n1DeeSCEcna-1];
2017  }
2018  else
2019  {
2020  cout << "!TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(...)> *** WARNING *** n1DeeSCEcna = " << n1DeeSCEcna
2021  << ". Out of range ( range = [1," << fEcal->MaxSCEcnaInDee()
2022  << "] ). Nb for const. forced to " << fT2d_DeeSCCons[n1DeeNumber-1][19] << "." << endl;
2023  dee_sc_cons = fT2d_DeeSCCons[n1DeeNumber-1][19];
2024  }
2025  }
2026  else
2027  {
2028  if( n1DeeNumber != 0 )
2029  {
2030  cout << "!TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(...)> n1DeeNumber = " << n1DeeNumber
2031  << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
2032  << fTTBELL << endl;
2033  }
2034  else
2035  {
2036  cout << "TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(...)> Dee = " << n1DeeNumber
2037  << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])"
2038  << fTTBELL << endl;
2039  }
2040  }
2041  return dee_sc_cons;
2042 }
2043 //..........................................................................................
2044 Int_t TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna,
2045  const Int_t& n1SCEcha)
2046 {
2047  //.......... Get the correct SC number (for cons) for the unconnected SC's (inner border)
2048  Int_t dee_sc_cons = GetDeeSCConsFrom1DeeSCEcna(n1DeeNumber, n1DeeSCEcna);
2049 
2050  if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 )
2051  {
2052  if( n1SCEcha == 11 )
2053  {
2054  if( dee_sc_cons == 261 ){dee_sc_cons = 268;} // 261<=>14/BR
2055  if( dee_sc_cons == 112 ){dee_sc_cons = 119;} // 112<=>14/BL
2056  }
2057  if( n1SCEcha == 1 || n1SCEcha == 2 || n1SCEcha == 3 ||
2058  n1SCEcha == 6 || n1SCEcha == 7 )
2059  {
2060  if( dee_sc_cons == 178 ){dee_sc_cons = 207;} // 178<=>3/TR
2061  if( dee_sc_cons == 29 ){dee_sc_cons = 58;} // 29<=>3/TL
2062  }
2063  }
2064  return dee_sc_cons;
2065 }
2066 //..........................................................................................
2067 Int_t TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(const Int_t& n1DeeNumber, const Int_t& DeeSCCons)
2068 {
2069 // Get SC Ecna number in Dee from SC number for Construction in Dee
2070 
2071  Int_t dee_sc_ecna = -1;
2072 
2073  if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
2074  {
2075  Int_t off_set_cons = 0;
2076  if( n1DeeNumber == 1 || n1DeeNumber == 3 ){off_set_cons = fEcal->MaxSCForConsInDee();}
2077 
2078  if( DeeSCCons > off_set_cons && DeeSCCons <= fEcal->MaxSCForConsInDee()+off_set_cons )
2079  {
2080  dee_sc_ecna = fT2d_RecovDeeSC[n1DeeNumber-1][DeeSCCons-1];
2081  }
2082  else
2083  {
2084  cout << "!TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(...)> DeeSCCons = " << DeeSCCons
2085  << ". Out of range ( range = [ " << off_set_cons+1
2086  << "," << fEcal->MaxSCForConsInDee()+off_set_cons << "] )"
2087  << fTTBELL << endl;
2088  }
2089  }
2090  else
2091  {
2092  if( n1DeeNumber != 0 )
2093  {
2094  cout << "!TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(...)> n1DeeNumber = " << n1DeeNumber
2095  << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
2096  << fTTBELL << endl;
2097  }
2098  else
2099  {
2100  cout << "TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(...)> Dee = " << n1DeeNumber
2101  << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])"
2102  << fTTBELL << endl;
2103  }
2104  }
2105  return dee_sc_ecna;
2106 }
2107 
2108 TString TEcnaNumbering::GetSCType(const Int_t& nb_for_cons)
2109 {
2110 // gives the special not connected SC's
2111 
2112  TString SCType = "Connected"; // => default type
2113 
2114  if( nb_for_cons == 182 || nb_for_cons == 33 ){SCType = "NotConnected";} // (D1,S1) (D3,S9) || (D2,S9) (D4,S1)
2115 
2116  if( nb_for_cons == 178 || nb_for_cons == 29 ){SCType = "NotConnected";} // (D1,S2) (D3,S8) || (D2,S8) (D4,S2)
2117  if( nb_for_cons == 207 || nb_for_cons == 58 ){SCType = "NotConnected";}
2118 
2119  if( nb_for_cons == 298 || nb_for_cons == 149 ){SCType = "NotConnected";} // (D1,S3) (D3,S7) || (D2,S7) (D4,S3)
2120 
2121  if( nb_for_cons == 261 || nb_for_cons == 112 ){SCType = "NotConnected";} // (D1,S4) (D3,S6) || (D2,S6) (D4,S4)
2122  if( nb_for_cons == 268 || nb_for_cons == 119 ){SCType = "NotConnected";}
2123 
2124  if( nb_for_cons == 281 || nb_for_cons == 132 ){SCType = "NotConnected";} // (D1,S5) (D3,S5) || (D2,S5) (D4,S5)
2125 
2126  if( nb_for_cons == 161 || nb_for_cons == 12 ){SCType = "NotComplete";} // (D1,S1) (D3,S9) || (D2,S9) (D4,S1)
2127  if( nb_for_cons == 216 || nb_for_cons == 67 ){SCType = "NotComplete";} // (D1,S2) (D3,S8) || (D2,S8) (D4,S2)
2128  if( nb_for_cons == 224 || nb_for_cons == 75 ){SCType = "NotComplete";} // (D1,S3) (D3,S7) || (D2,S7) (D4,S3)
2129  if( nb_for_cons == 286 || nb_for_cons == 137 ){SCType = "NotComplete";} // (D1,S5) (D3,S5) || (D2,S5) (D4,S5)
2130 
2131  return SCType;
2132 }
2133 
2134 Int_t TEcnaNumbering::StexEchaForCons(const Int_t& n1DeeNumber, const Int_t& i0StexEcha)
2135 {
2136  Int_t n1StexStin = Get1StexStinFrom0StexEcha(i0StexEcha);
2137  return fT2d_DeeSCCons[n1DeeNumber-1][n1StexStin-1];
2138 }
2139  // return -1 if the SC does not correspond to a real SC; return the number for construction otherwise
2140 
2141 //===========================================================================
2142 //
2143 // GetSCQuadFrom1DeeSCEcna
2144 //
2145 //===========================================================================
2146 
2147 TString TEcnaNumbering::GetSCQuadFrom1DeeSCEcna(const Int_t& n1DeeSCEcna)
2148 {
2149 //gives the quadrant type ("top" or "bottom") from the SC number in Dee
2150 
2151  TString SCQuad = "top"; // => default value
2152 
2153  if (n1DeeSCEcna >= 1 && n1DeeSCEcna <= 10){SCQuad = "bottom";}
2154  if (n1DeeSCEcna >= 21 && n1DeeSCEcna <= 30){SCQuad = "bottom";}
2155  if (n1DeeSCEcna >= 41 && n1DeeSCEcna <= 50){SCQuad = "bottom";}
2156  if (n1DeeSCEcna >= 61 && n1DeeSCEcna <= 70){SCQuad = "bottom";}
2157  if (n1DeeSCEcna >= 81 && n1DeeSCEcna <= 90){SCQuad = "bottom";}
2158  if (n1DeeSCEcna >= 101 && n1DeeSCEcna <= 110){SCQuad = "bottom";}
2159  if (n1DeeSCEcna >= 121 && n1DeeSCEcna <= 130){SCQuad = "bottom";}
2160  if (n1DeeSCEcna >= 141 && n1DeeSCEcna <= 150){SCQuad = "bottom";}
2161  if (n1DeeSCEcna >= 161 && n1DeeSCEcna <= 170){SCQuad = "bottom";}
2162  if (n1DeeSCEcna >= 181 && n1DeeSCEcna <= 190){SCQuad = "bottom";}
2163 
2164  return SCQuad;
2165 }
2166 Int_t TEcnaNumbering::GetSCQuadTypeIndex(const TString& SCQuadType, const TString& sDeeDir)
2167 {
2168 //gives the index of the SC quadrant type (top/right, top/left, bottom/left, bottom/right)
2169 // = quadrant number - 1
2170 
2171  Int_t itype = 0; // => default
2172  if ( SCQuadType == "top" && sDeeDir == "right" ){itype = 0;}
2173  if ( SCQuadType == "top" && sDeeDir == "left" ){itype = 1;}
2174  if ( SCQuadType == "bottom" && sDeeDir == "left" ){itype = 2;}
2175  if ( SCQuadType == "bottom" && sDeeDir == "right" ){itype = 3;}
2176  return itype;
2177 }
2178 //===========================================================================
2179 //
2180 // GetEEDeeType, GetDeeDirViewedFromIP
2181 //
2182 //===========================================================================
2183 TString TEcnaNumbering::GetEEDeeEndcap(const Int_t& n1DeeNumber)
2184 {
2185 //gives the Endcap (EE+ or EE-) of the Dee (H. Heath, CMS NOTE 2006/027)
2186 
2187  TString eetype = "EE+"; // => default
2188  if ( n1DeeNumber == 1 || n1DeeNumber == 2 ){eetype = "EE+";}
2189  if ( n1DeeNumber == 3 || n1DeeNumber == 4 ){eetype = "EE-";}
2190  return eetype;
2191 }
2192 TString TEcnaNumbering::GetEEDeeType(const Int_t& n1DeeNumber)
2193 {
2194 //gives the EE +/- and Forward/Near of the Dee (H. Heath, CMS NOTE 2006/027)
2195 
2196  TString type = "EE+F"; // => default
2197  if ( n1DeeNumber == 1 ){type = "EE+F";}
2198  if ( n1DeeNumber == 2 ){type = "EE+N";}
2199  if ( n1DeeNumber == 3 ){type = "EE-N";}
2200  if ( n1DeeNumber == 4 ){type = "EE-F";}
2201  return type;
2202 }
2203 
2204 TString TEcnaNumbering::GetDeeDirViewedFromIP(const Int_t& n1DeeNumber)
2205 {
2206 //gives the direction (left/right) of the IX axis of the Dee
2207 // looking from the interaction point
2208 
2209  TString sDeeDir = "right"; // => default
2210  if ( (n1DeeNumber == 1) || (n1DeeNumber == 3) ){sDeeDir = "right";}
2211  if ( (n1DeeNumber == 2) || (n1DeeNumber == 4) ){sDeeDir = "left" ;}
2212  return sDeeDir;
2213 }
2214 Int_t TEcnaNumbering::GetDeeDirIndex(const TString& sDeeDir)
2215 {
2216 //gives the index of the direction (left,right) of the IX axis of the Dee
2217 // looking from the interaction point (right = 0, left = 1)
2218 
2219  Int_t iDeeDir = 0; // => default
2220  if ( sDeeDir == "right" ){iDeeDir = 0;}
2221  if ( sDeeDir == "left" ){iDeeDir = 1;}
2222  return iDeeDir;
2223 }
2224 
2225 //==============================================================================
2226 //
2227 // GetIXCrysInSC, GetJYCrysInSC
2228 // GetIXSCInDee, GetJYSCInDee
2229 // GetIXCrysInDee, GetJYCrysInDConsFrom1DeeSCEcna(fStexNumber, StexStinEcna);
2230 //
2231 //==============================================================================
2232 Int_t TEcnaNumbering::GetIXCrysInSC(const Int_t& n1DeeNumber, const Int_t& DeeSC,
2233  const Int_t& i0SCEcha)
2234 {
2235 //Gives Crys IX in SC for a given (n1DeeNumber, DeeSC, i0SCEcha)
2236 
2237  TString SCQuadType = GetSCQuadFrom1DeeSCEcna(DeeSC);
2238  TString sDeeDir = GetDeeDirViewedFromIP(n1DeeNumber);
2239  Int_t type_index = GetSCQuadTypeIndex(SCQuadType, sDeeDir);
2240  Int_t IXCrysInSC = fT2d_ich_IX[type_index][i0SCEcha+1] + 1;
2241  return IXCrysInSC; // possible values: 1,2,3,4,5
2242 }
2243 
2244 Int_t TEcnaNumbering::GetIXSCInDee(const Int_t& DeeSC)
2245 {
2246 //Gives SC IX in Dee for a given (DeeSC)
2247 
2248  Int_t IXSCInDee = (DeeSC-1)/fEcal->MaxSCIYInDee() + 1;
2249  return IXSCInDee; // possible values: 1,2,...,9,10
2250 }
2251 
2252 Int_t TEcnaNumbering::GetIXCrysInDee(const Int_t& n1DeeNumber, const Int_t& DeeSC,
2253  const Int_t& i0SCEcha)
2254 {
2255 //Gives Crys IX in Dee for a given (n1DeeNumber, DeeSC, i0SCEcha)
2256 
2257  Int_t IXCrysInDee =
2258  (GetIXSCInDee(DeeSC)-1)*fEcal->MaxCrysIXInSC() +
2259  GetIXCrysInSC(n1DeeNumber, DeeSC, i0SCEcha);
2260  return IXCrysInDee; // possible values: 1,2,...,49,50
2261 }
2262 //---------------------------------------------------------------------------------
2263 Int_t TEcnaNumbering::GetJYCrysInSC(const Int_t& n1DeeNumber, const Int_t& DeeSC,
2264  const Int_t& i0SCEcha)
2265 {
2266 //Gives Crys JY in SC for a given (n1DeeNumber, DeeSC, i0SCEcha)
2267 
2268  TString SCQuadType = GetSCQuadFrom1DeeSCEcna(DeeSC);
2269  TString sDeeDir = GetDeeDirViewedFromIP(n1DeeNumber);
2270  Int_t type_index = GetSCQuadTypeIndex(SCQuadType, sDeeDir);
2271  Int_t JYCrysInSC = fT2d_jch_JY[type_index][i0SCEcha+1] + 1;
2272  return JYCrysInSC; // possible values: 1,2,3,4,5
2273 }
2274 
2275 Int_t TEcnaNumbering::GetJYSCInDee(const Int_t& DeeSC)
2276 {
2277 //Gives SC JY in Dee for a given (n1DeeNumber, DeeSC, i0SCEcha)
2278 
2279  Int_t JYSCInDee = (DeeSC-1)%fEcal->MaxSCIYInDee() + 1;
2280  return JYSCInDee; // possible values: 1,2,...,19,20
2281 }
2282 
2283 Int_t TEcnaNumbering::GetJYCrysInDee(const Int_t& n1DeeNumber, const Int_t& DeeSC,
2284  const Int_t& i0SCEcha)
2285 {
2286 //Gives Crys JY in Dee for a given (n1DeeNumber, DeeSC, i0SCEcha)
2287 
2288  Int_t JYCrysInDee =
2289  (GetJYSCInDee(DeeSC)-1)*fEcal->MaxCrysIYInSC() +
2290  GetJYCrysInSC(n1DeeNumber, DeeSC, i0SCEcha);
2291  return JYCrysInDee; // possible values: 1,2,...,99,100
2292 }
2293 //---------------------------------------------------------------------------------
2294 Int_t TEcnaNumbering::GetMaxSCInDS(const Int_t& DeeDS)
2295 {
2296 // Gives the number of SC's in Data Sector DeeDS
2297 
2298  Int_t nb_of_sc = -1;
2299  if( DeeDS == 1 || DeeDS == 9 ){nb_of_sc = 33;}
2300  if( DeeDS == 2 || DeeDS == 8 ){nb_of_sc = 32;}
2301  if( DeeDS == 3 || DeeDS == 7 ){nb_of_sc = 34;}
2302  if( DeeDS == 4 || DeeDS == 6 ){nb_of_sc = 33;}
2303  if( DeeDS == 5){nb_of_sc = 34;}
2304  return nb_of_sc;
2305 }
2306 
2307 
2308 //==============================================================================
2309 //
2310 // GetIXMin, GetIXMax, GetIIXMin, GetIIXMax
2311 //
2312 //==============================================================================
2313 Double_t TEcnaNumbering::GetIIXMin(const Int_t& DeeSC)
2314 {
2315 //Gives IIXMin for a given DeeSC , unit = crystal
2316 
2317  Double_t IX_min = (Double_t)((DeeSC-1)/fEcal->MaxSCIYInDee())*fEcal->MaxCrysIXInSC() + 1.;
2318  return IX_min;
2319 }
2320 
2321 Double_t TEcnaNumbering::GetIIXMax(const Int_t& DeeSC)
2322 {
2323 //Gives IIXMax for a given DeeSC , unit = crystal
2324 
2325  Double_t IX_max = ((Double_t)((DeeSC-1)/fEcal->MaxSCIYInDee())+1.)*fEcal->MaxCrysIXInSC();
2326  return IX_max;
2327 }
2328 
2330 {
2331 //Gives IIXMin for Dee , unit = Super-crystal
2332 
2333  Double_t i_IX_min = (Int_t)1.;
2334  return i_IX_min;
2335 }
2336 
2338 {
2339 //Gives IIXMax for Dee , unit = Super-crystal
2340 
2341  Double_t i_IX_max = (Int_t)fEcal->MaxSCIXInDee();
2342  return i_IX_max;
2343 }
2344 
2345 //==============================================================================
2346 //
2347 // GetIIYMin, GetIIYMax
2348 //
2349 //==============================================================================
2350 Double_t TEcnaNumbering::GetJIYMin(const Int_t& n1DeeNumber, const Int_t& DeeSC)
2351 {
2352 //Gives JIYMin for a given Super-Crystal
2353 
2354  Double_t IY_DeeSC = DeeSC%fEcal->MaxSCIYInDee();
2355  if( IY_DeeSC == 0. ){IY_DeeSC = fEcal->MaxSCIYInDee();}
2356 
2357  Double_t j_IY_min = (IY_DeeSC-1)*fEcal->MaxCrysIYInSC() + 1.;
2358 
2359  return j_IY_min;
2360 }
2361 //-----------------------------------------------------------------------------------------
2362 Double_t TEcnaNumbering::GetJIYMax(const Int_t& n1DeeNumber, const Int_t& DeeSC)
2363 {
2364 //Gives JIYMax for a given Super-Crystal
2365 
2366  Double_t IY_DeeSC = DeeSC%fEcal->MaxSCIYInDee();
2367  if( IY_DeeSC == 0 ){IY_DeeSC = fEcal->MaxSCIYInDee();}
2368 
2369  Double_t j_IY_max = IY_DeeSC*fEcal->MaxCrysIYInSC();
2370 
2371  return j_IY_max;
2372 }
2373 
2374 //-----------------------------------------------------------------------------------------
2375 Double_t TEcnaNumbering::GetJIYMin(const Int_t& n1DeeNumber)
2376 {
2377 //Gives JIYMin for a given Dee
2378 
2379  Double_t j_IY_min = (Double_t)1.;
2380 
2381  return j_IY_min;
2382 }
2383 //-----------------------------------------------------------------------------------------
2384 Double_t TEcnaNumbering::GetJIYMax(const Int_t& n1DeeNumber)
2385 {
2386 //Gives JIYMax for a given Dee
2387 
2388  Double_t j_IY_max = (Double_t)fEcal->MaxSCIYInDee();
2389 
2390  return j_IY_max;
2391 }
2392 //=====================================================================
2393 TString TEcnaNumbering::GetDeeHalfEndcap(const Int_t& n1DeeNumber)
2394 {
2395 //gives the half-endcap of the Dee ("EE+" or "EE-")
2396 
2397  TString type = "EE-"; // => default value
2398 
2399  if ( n1DeeNumber == 1 || n1DeeNumber == 2 ){type = "EE+";}
2400  if ( n1DeeNumber == 3 || n1DeeNumber == 4 ){type = "EE-";}
2401 
2402  return type;
2403 }
2404 //==============================================================================
2405 //
2406 // GetXDirectionEE, GetYDirectionEE, GetJYDirectionEE
2407 //
2408 //==============================================================================
2409 TString TEcnaNumbering::GetXDirectionEE(const Int_t& n1DeeNumber)
2410 {
2411  TString xdirection = "x"; // DEFAULT
2412 
2413  if( GetEEDeeType(n1DeeNumber) == "EE+F" ){xdirection = "-x";} // Dee 1
2414  if( GetEEDeeType(n1DeeNumber) == "EE+N" ){xdirection = "-x";} // Dee 2
2415  if( GetEEDeeType(n1DeeNumber) == "EE-N" ){xdirection = "x";} // Dee 3
2416  if( GetEEDeeType(n1DeeNumber) == "EE-F" ){xdirection = "x";} // Dee 4
2417 
2418  return xdirection;
2419 }
2420 //---------------------------------------------------------
2421 TString TEcnaNumbering::GetYDirectionEE(const Int_t& n1DeeNumber)
2422 {
2423  TString ydirection = "-x"; // DEFAULT
2424 
2425  if( GetEEDeeType(n1DeeNumber) == "endcap+" ){ydirection = "-x";}
2426  if( GetEEDeeType(n1DeeNumber) == "endcap-" ){ydirection = "-x";}
2427 
2428  return ydirection;
2429 }
2430 
2431 //---------------------------------------------------------
2432 TString TEcnaNumbering::GetJYDirectionEE(const Int_t& n1DeeNumber)
2433 {
2434  TString jydirection = "x"; // ALWAYS IN THIS CASE
2435  return jydirection;
2436 }
2437 
2438 //==========================================================================================================
2439 //
2440 //
2441 // B A R R E L A N D E N D C A P
2442 //
2443 //
2444 //
2445 //==========================================================================================================
2446 //===============================================================================
2447 //
2448 // Get1StexStinFrom0StexEcha
2449 // // GetStinEchaFromStexEcha
2450 // Get0StexEchaFrom1StexStinAnd0StinEcha
2451 // Get1StexCrysFrom1StexStinAnd0StinEcha
2452 //
2453 //===============================================================================
2454 Int_t TEcnaNumbering::Get1StexStinFrom0StexEcha(const Int_t& i0StexEcha)
2455 {
2456  Int_t n1StexStin = 0;
2457 
2458  if( fFlagSubDet == "EB" ){n1StexStin = Get1SMTowFrom0SMEcha(i0StexEcha);}
2459  if( fFlagSubDet == "EE" ){n1StexStin = Get1DeeSCEcnaFrom0DeeEcha(i0StexEcha);}
2460 
2461  return n1StexStin;
2462 }
2463 
2465  const Int_t& i0StinEcha)
2466 {
2467 // Electronic Channel number in Stex from Stin number in Stex
2468 // and from Electronic Channel number in Stin
2469 
2470  Int_t StexEcha = (Int_t)(-1.);
2471 
2472  if ( n1StexStin > 0 && n1StexStin <= fEcal->MaxStinEcnaInStex() &&
2473  i0StinEcha >= 0 && i0StinEcha < fEcal->MaxCrysInStin() )
2474  {StexEcha = (n1StexStin-1)*fEcal->MaxCrysInStin() + i0StinEcha;}
2475  else
2476  {
2477  cout << "!TEcnaNumbering::Get0StexEchaFrom1StexStinAnd0StinEcha *** ERROR ***> VALUE"
2478  << " OUT OF RANGE. Forced to -1. Argument values: n1StexStin = " << n1StexStin
2479  << ", channel = " << i0StinEcha
2480  << fTTBELL << endl;
2481  }
2482  return StexEcha;
2483 }
2485  const Int_t& i0StinEcha, const Int_t& StexNumber)
2486 {
2487 // Crystal number in Stex from Stin number in Stex
2488 // and from Electronic Channel number in Stin (for the StexNumber_th Stex)
2489 // argument StexNumber used only in "EE" case
2490 
2491  Int_t n1StexCrys = (Int_t)0;
2492  if( fFlagSubDet == "EB" ){n1StexCrys = Get1SMCrysFrom1SMTowAnd0TowEcha(n1StexStin, i0StinEcha);}
2493  if( fFlagSubDet == "EE" ){TString sDeeDir = GetDeeDirViewedFromIP(StexNumber);
2494  n1StexCrys = Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(n1StexStin, i0StinEcha, sDeeDir);}
2495 
2496  return n1StexCrys;
2497 }
2498 //===============================================================================
2499 //
2500 // GetIHocoMin, GetIHocoMax, GetVecoMin, GetVecoMax
2501 // GetJVecoMin, GetJVecoMax
2502 //
2503 //===============================================================================
2504 Double_t TEcnaNumbering::GetIHocoMin(const Int_t& Stex, const Int_t& StexStin)
2505 {
2506  Double_t IHocoMin = (Double_t)0.;
2507  if(fFlagSubDet == "EB" ){IHocoMin = GetIEtaMin(Stex, StexStin);}
2508  if(fFlagSubDet == "EE" ){IHocoMin = GetIIXMin(StexStin);}
2509  return IHocoMin;
2510 }
2511 
2512 Double_t TEcnaNumbering::GetIHocoMax(const Int_t& Stex, const Int_t& StexStin)
2513 {
2514  Double_t IHocoMax = (Double_t)0.;
2515  if(fFlagSubDet == "EB" ){IHocoMax = GetIEtaMax(Stex, StexStin);}
2516  if(fFlagSubDet == "EE" ){IHocoMax = GetIIXMax(StexStin);}
2517  return IHocoMax;
2518 }
2519 
2520 Double_t TEcnaNumbering::GetVecoMin(const Int_t& Stex, const Int_t& StexStin)
2521 {
2522  Double_t IVecoMin = (Double_t)0.;
2523  if(fFlagSubDet == "EB" ){IVecoMin = GetPhiMin(Stex, StexStin);}
2524  if(fFlagSubDet == "EE" ){IVecoMin = GetJIYMin(Stex, StexStin);}
2525  return IVecoMin;
2526 }
2527 
2528 Double_t TEcnaNumbering::GetVecoMax(const Int_t& Stex, const Int_t& StexStin)
2529 {
2530  Double_t IVecoMax = (Double_t)0.;
2531  if(fFlagSubDet == "EB" ){IVecoMax = GetPhiMax(Stex, StexStin);}
2532  if(fFlagSubDet == "EE" ){IVecoMax = GetJIYMax(Stex, StexStin);}
2533  return IVecoMax;
2534 }
2535 
2536 Double_t TEcnaNumbering::GetJVecoMin(const Int_t& Stex, const Int_t& StexStin)
2537 {
2538  Double_t JVecoMin = (Double_t)0.;
2539  if(fFlagSubDet == "EB" ){JVecoMin = GetJPhiMin(Stex, StexStin);}
2540  if(fFlagSubDet == "EE" ){JVecoMin = GetJIYMin(Stex, StexStin);} // not used
2541  return JVecoMin;
2542 }
2543 Double_t TEcnaNumbering::GetJVecoMax(const Int_t& Stex, const Int_t& StexStin)
2544 {
2545  Double_t JVecoMax = (Double_t)0.;
2546  if(fFlagSubDet == "EB" ){JVecoMax = GetJPhiMax(Stex, StexStin);}
2547  if(fFlagSubDet == "EE" ){JVecoMax = GetJIYMax(Stex, StexStin);} // not used
2548  return JVecoMax;
2549 }
2550 //===========================================================================
2551 //
2552 // GetStexHalfBarrel
2553 //
2554 //===========================================================================
2555 TString TEcnaNumbering::GetStexHalfStas(const Int_t& SMNumber)
2556 {
2557  TString half_stas = "EB? EE?";
2558 
2559  if( fFlagSubDet == "EB" ){half_stas = GetSMHalfBarrel(SMNumber);}
2560  if( fFlagSubDet == "EE" ){half_stas = GetDeeHalfEndcap(SMNumber);}
2561 
2562  return half_stas;
2563 }
2564 //===========================================================================
2565 //
2566 // GetSMFromFED, GetDSFromFED
2567 //
2568 //===========================================================================
2569 Int_t TEcnaNumbering::GetSMFromFED(const Int_t& FEDNumber)
2570 {
2571  Int_t EBSMNumber = 0; // SM = Super Module
2572  if( FEDNumber >= 610 && FEDNumber <= 645 ){EBSMNumber = FEDNumber - 609;}
2573  return EBSMNumber;
2574 }
2575 
2576 Int_t TEcnaNumbering::GetDSFromFED(const Int_t& FEDNumber)
2577 {
2578  Int_t EEDSNumber = 0; // DS = Data Sector
2579 
2580  if( FEDNumber >= 600 && FEDNumber <= 609 ){EEDSNumber = FEDNumber - 599;}
2581  if( FEDNumber >= 646 && FEDNumber <= 655 ){EEDSNumber = FEDNumber - 645;}
2582 
2583  return EEDSNumber;
2584 }
2585 
2586 //--------------------------------------------
2587 Int_t TEcnaNumbering::MaxCrysInStinEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna, const TString& s_option)
2588 {
2589 // Number of Xtals in "Ecna SC" for not complete and not connected SC's.
2590 // Also valid for all connected and complete SC's and for towers of EB
2591 
2592  Int_t max_crys = fEcal->MaxCrysInStin(); // valid for EB and for connected and complete SC's of EE
2593 
2594  // Number of Xtals in SC for not complete and not connected SC's
2595 
2596  if(fFlagSubDet == "EE")
2597  {
2598  Int_t n_for_cons = GetDeeSCConsFrom1DeeSCEcna(n1DeeNumber, n1DeeSCEcna);
2599 
2600  //............ not complete SC's (inner border)
2601  if( n_for_cons == 12 || n_for_cons == 67 || n_for_cons == 75 || n_for_cons == 137 ||
2602  n_for_cons == 161 || n_for_cons == 216 || n_for_cons == 224 || n_for_cons == 286 ){max_crys = 20;}
2603 
2604  //............ not connected SC's
2605  if( (n_for_cons == 182 || n_for_cons == 33) && (n1DeeSCEcna == 60 || n1DeeSCEcna == 119) ){max_crys = 10;}
2606 
2607  if( (n_for_cons == 178 || n_for_cons == 29) && (n1DeeSCEcna == 138 || n1DeeSCEcna == 157) ){max_crys = 10;}
2608  if( (n_for_cons == 207 || n_for_cons == 58) && (n1DeeSCEcna == 176 || n1DeeSCEcna == 193) ){max_crys = 10;}
2609 
2610  if( (n_for_cons == 298 || n_for_cons == 149) && (n1DeeSCEcna == 188) ){max_crys = 10;}
2611 
2612  if( (n_for_cons == 261 || n_for_cons == 112) && (n1DeeSCEcna == 144 || n1DeeSCEcna == 165) ){max_crys = 10;}
2613  if( (n_for_cons == 268 || n_for_cons == 119) && (n1DeeSCEcna == 102 || n1DeeSCEcna == 123) ){max_crys = 10;}
2614 
2615  if( (n_for_cons == 281 || n_for_cons == 132) && (n1DeeSCEcna == 41) ){max_crys = 10;}
2616 
2617  //............. not connected and mixed Ecna SC's
2618  if( s_option == "TEcnaRun" || s_option == "TEcnaRead" )
2619  {
2620  if( s_option == "TEcnaRun" )
2621  {
2622  // special translation of Xtal 11 of SCEcna 29 and 32 to respectively Xtal 11 of SCEcna 10 and 11
2623  if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 ){max_crys = 5;}
2624  if( n1DeeSCEcna == 10 || n1DeeSCEcna == 11 ){max_crys = 1;}
2625  }
2626  if( s_option == "TEcnaRead" )
2627  {
2628  //if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 ){max_crys = 6;}
2629  if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 ){max_crys = 5;}
2630  if( n1DeeSCEcna == 10 || n1DeeSCEcna == 11 ){max_crys = 1;}
2631  }
2632  }
2633  else
2634  {
2635  cout << "!TEcnaNumbering::MaxCrysInStinEcna(...)> " << s_option
2636  << ": unknown option." << fTTBELL << endl;
2637  }
2638  }
2639  return max_crys;
2640 }
Double_t GetEtaMax(const Int_t &, const Int_t &)
Int_t Get1StexStinFrom0StexEcha(const Int_t &)
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
void BuildBarrelCrysTable()
TString GetSCQuadFrom1DeeSCEcna(const Int_t &)
Double_t GetVecoMin(const Int_t &, const Int_t &)
Int_t Get0SMEchaFrom1SMTowAnd0TowEcha(const Int_t &, const Int_t &)
Int_t Get1DeeSCEcnaFromDeeSCCons(const Int_t &, const Int_t &)
Double_t GetPhiMin(const Int_t &, const Int_t &)
Int_t GetSMFromFED(const Int_t &)
TString GetYDirectionEB(const Int_t &)
TString GetSMHalfBarrel(const Int_t &)
TString GetDeeDirViewedFromIP(const Int_t &)
TString GetJYDirectionEB(const Int_t &)
Double_t GetJPhiMax(const Int_t &, const Int_t &)
Int_t Get1DeeSCEcnaFrom0DeeEcha(const Int_t &)
TString GetEEDeeType(const Int_t &)
TString GetStinLvrbType(const Int_t &)
Double_t GetPhiMax(const Int_t &, const Int_t &)
Int_t Get1SCEchaFrom0DeeEcha(const Int_t &)
Double_t GetEtaMin(const Int_t &, const Int_t &)
Int_t Get0TowEchaFrom1SMCrys(const Int_t &)
Int_t GetIXSCInDee(const Int_t &)
T eta() const
Double_t GetIHocoMin(const Int_t &, const Int_t &)
Int_t Get1DeeSCEcnaFrom1DeeCrys(const Int_t &, const TString &)
Int_t GetHashedNumberFromIEtaAndIPhi(const Int_t &, const Int_t &)
Int_t Get1SMTowFrom1SMCrys(const Int_t &)
Bool_t RegisterPointer(const TString &, const Long_t &)
Definition: TEcnaObject.cc:103
Int_t GetJYSCInDee(const Int_t &)
TString GetXDirectionEE(const Int_t &)
void BuildEndcapCrysTable()
TString GetTowerLvrbType(const Int_t &)
Double_t GetJVecoMin(const Int_t &, const Int_t &)
Int_t Get0TowEchaFrom0SMEcha(const Int_t &)
Double_t GetJIYMax(const Int_t &, const Int_t &)
Int_t GetJYCrysInDee(const Int_t &, const Int_t &, const Int_t &)
Int_t Get1SCEchaFrom1DeeCrys(const Int_t &, const TString &)
TString GetDeeHalfEndcap(const Int_t &)
Double_t GetJPhiMin(const Int_t &, const Int_t &)
TString GetYDirectionEE(const Int_t &)
int j
Definition: DBlmapReader.cc:9
Int_t Get1SMTowFrom0SMEcha(const Int_t &)
Int_t GetDSSCFrom1DeeSCEcna(const Int_t &, const Int_t &, const Int_t &)
Int_t GetDSFromFED(const Int_t &)
Double_t GetVecoMax(const Int_t &, const Int_t &)
Int_t StexEchaForCons(const Int_t &, const Int_t &)
Double_t GetJIYMin(const Int_t &, const Int_t &)
Int_t GetDSFrom1DeeSCEcna(const Int_t &, const Int_t &)
int k[5][pyjets_maxn]
Int_t GetDeeSCConsFrom1DeeSCEcna(const Int_t &, const Int_t &)
Int_t Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(const Int_t &, const Int_t &, const TString &)
Double_t GetEta(const Int_t &, const Int_t &, const Int_t &)
Int_t Get1SMCrysFrom1SMTowAnd0TowEcha(const Int_t &, const Int_t &)
Int_t MaxCrysInStinEcna(const Int_t &, const Int_t &, const TString &)
Double_t GetIIXMax()
Int_t GetIXCrysInSC(const Int_t &, const Int_t &, const Int_t &)
Double_t GetIEtaMin(const Int_t &, const Int_t &)
Int_t GetIPhiFromHashed(const Int_t &)
Int_t GetMaxSCInDS(const Int_t &)
Double_t GetPhiInSM(const Int_t &, const Int_t &, const Int_t &)
Int_t GetSCQuadTypeIndex(const TString &, const TString &)
Int_t GetIEtaFromHashed(const Int_t &, const Int_t &)
Int_t GetJYCrysInSC(const Int_t &, const Int_t &, const Int_t &)
Double_t GetPhi(const Int_t &, const Int_t &, const Int_t &)
TString GetSCType(const Int_t &)
Double_t GetIHocoMax(const Int_t &, const Int_t &)
Int_t GetDeeDirIndex(const TString &)
Int_t GetIXCrysInDee(const Int_t &, const Int_t &, const Int_t &)
Int_t PlusMinusSMNumber(const Int_t &)
Int_t Get0StexEchaFrom1StexStinAnd0StinEcha(const Int_t &, const Int_t &)
Double_t GetIEtaMax(const Int_t &, const Int_t &)
TString GetStexHalfStas(const Int_t &)
tuple cout
Definition: gather_cfg.py:121
TString GetEEDeeEndcap(const Int_t &)
Double_t GetIIXMin()
TString GetEcalSubDetector()
Double_t GetSMCentralPhi(const Int_t &)
TString GetJYDirectionEE(const Int_t &)
Double_t GetJVecoMax(const Int_t &, const Int_t &)
void SetEcalSubDetector(const TString &)
Int_t Get1StexCrysFrom1StexStinAnd0StinEcha(const Int_t &, const Int_t &, const Int_t &)
TString GetXDirectionEB(const Int_t &)
Long_t GetPointerValue(const TString &)
Definition: TEcnaObject.cc:230
Definition: DDAxes.h:10