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