CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/src/TEcnaNumbering.cc

Go to the documentation of this file.
00001 //----------Author's Name: B.Fabbro, F.X.Gentit + EB table from P.Jarry  DSM/IRFU/SPP CEA-Saclay
00002 //----------Copyright:Those valid for CEA software
00003 //----------Modified:31/03/2010
00004 
00005 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaNumbering.h"
00006 
00007 ClassImp(TEcnaNumbering)
00008 //-------------------------------------------------------------------------------------------------------
00009 //
00010 //  Building of the numbering for the Ecal channels (EB and EE)
00011 //
00012 //  Convention for the names used here and in the other "TEcna" and "TEcal" classes:
00013 //
00014 //  Name     Number                      Reference set   Range      Comment
00015 //
00016 //  SMTow  : Tower number                in SuperModule  [1,68]     (phi,eta) progression
00017 //  SMCrys : Crystal number              in SuperModule  [1,1700]   (phi,eta) progression
00018 //  SMEcha : Electronic channel number   in SuperModule  [0,1699]   S shape data reading order    
00019 //  TowEcha: Electronic channel number   in Tower        [0,24]     S shape data reading order  
00020 //
00021 //  DeeSC  : super-crystal(SC) number    in Dee          [1,200]    (IY,IX) progression
00022 //  DeeCrys: Crystal number              in Dee          [1,5000]   (IY,IX) progression
00023 //  DeeEcha: Electronic channel number   in Dee          [0,4999]   (IY,IX) progression (starting from 0)
00024 //  SCEcha : Electronic channel number   in SC           [1,25]     Crystal numbering for construction 
00025 //-------------------------------------------------------------------------------------------------------
00026 
00027 //====================================== constructors =========================================
00028 TEcnaNumbering::TEcnaNumbering() {
00029 // Constructor without argument: call to method Init()
00030 
00031 //  cout << "[Info Management] CLASS: TEcnaNumbering.    CREATE OBJECT: this = " << this << endl;
00032 
00033   Init();
00034 }
00035 
00036 TEcnaNumbering::TEcnaNumbering(const TString SubDet, const TEcnaParEcal* pEcal) {
00037 // Constructor with argument: call to methods Init() and SetEcalSubDetector(const TString)
00038 
00039  // cout << "[Info Management] CLASS: TEcnaNumbering.    CREATE OBJECT: this = " << this << endl;
00040 
00041   Init();
00042   SetEcalSubDetector(SubDet.Data(), pEcal);
00043 }
00044 
00045 //====================================== destructor =========================================
00046 TEcnaNumbering::~TEcnaNumbering() {
00047 //destructor
00048 
00049   //if (fEcal   != 0){delete fEcal;   fCdelete++;}
00050 
00051   //....................... Barrel
00052   if (fT2dSMCrys  != 0){delete [] fT2dSMCrys;  fCdelete++;}
00053   if (fT1dSMCrys  != 0){delete [] fT1dSMCrys;  fCdelete++;}
00054   if (fT1dSMTow   != 0){delete [] fT1dSMTow;   fCdelete++;}
00055   if (fT1dTowEcha != 0){delete [] fT1dTowEcha; fCdelete++;}
00056 
00057   //....................... Endcap
00058   if (fT3dDeeCrys     != 0){delete [] fT3dDeeCrys;     fCdelete++;}
00059   if (fT2dDeeCrys     != 0){delete [] fT2dDeeCrys;     fCdelete++;}
00060   if (fT1dDeeCrys     != 0){delete [] fT1dDeeCrys;     fCdelete++;}
00061   if (fT2dDeeSC       != 0){delete [] fT2dDeeSC;       fCdelete++;}
00062   if (fT1dDeeSC       != 0){delete [] fT1dDeeSC;       fCdelete++;}
00063   if (fT2dSCEcha      != 0){delete [] fT2dSCEcha;      fCdelete++;}
00064   if (fT1dSCEcha      != 0){delete [] fT1dSCEcha;      fCdelete++;}
00065   if (fT2d_jch_JY     != 0){delete [] fT2d_jch_JY;     fCdelete++;}
00066   if (fT1d_jch_JY     != 0){delete [] fT1d_jch_JY;     fCdelete++;}
00067   if (fT2d_ich_IX     != 0){delete [] fT2d_ich_IX;     fCdelete++;}
00068   if (fT1d_ich_IX     != 0){delete [] fT1d_ich_IX;     fCdelete++;}
00069   if (fT2d_DS         != 0){delete [] fT2d_DS;         fCdelete++;}
00070   if (fT1d_DS         != 0){delete [] fT1d_DS;         fCdelete++;}
00071   if (fT2d_DSSC       != 0){delete [] fT2d_DSSC;       fCdelete++;}
00072   if (fT1d_DSSC       != 0){delete [] fT1d_DSSC;       fCdelete++;}
00073   if (fT2d_DeeSCCons  != 0){delete [] fT2d_DeeSCCons;  fCdelete++;}
00074   if (fT1d_DeeSCCons  != 0){delete [] fT1d_DeeSCCons;  fCdelete++;}
00075   if (fT2d_RecovDeeSC != 0){delete [] fT2d_RecovDeeSC; fCdelete++;}
00076   if (fT1d_RecovDeeSC != 0){delete [] fT1d_RecovDeeSC; fCdelete++;}
00077 
00078  // cout << "[Info Management] CLASS: TEcnaNumbering.    DESTROY OBJECT: this = " << this << endl;
00079 
00080 }
00081 //------------------------------------------------------------- Init()
00082 void TEcnaNumbering::Init()
00083 {
00084 //Set default values and build crystal numbering table
00085 
00086   //.............................. Initialisations
00087   fTTBELL  = '\007';
00088   fgMaxCar = 512;
00089 
00090   //....................... Barrel
00091   fT2dSMCrys  = 0;
00092   fT1dSMCrys  = 0;
00093   fT1dSMTow   = 0;
00094   fT1dTowEcha = 0;
00095 
00096   fCodeChNumberingLvrbBot = "bottom";
00097   fCodeChNumberingLvrbTop = "top";
00098 
00099   //....................... Endcap
00100   fT3dDeeCrys     = 0;
00101   fT2dDeeCrys     = 0;
00102   fT1dDeeCrys     = 0;
00103   fT2dDeeSC       = 0;
00104   fT1dDeeSC       = 0;
00105   fT2dSCEcha      = 0;
00106   fT1dSCEcha      = 0;
00107   fT2d_jch_JY     = 0;
00108   fT1d_jch_JY     = 0;
00109   fT2d_ich_IX     = 0;
00110   fT1d_ich_IX     = 0;
00111   fT2d_DS         = 0;
00112   fT1d_DS         = 0;
00113   fT2d_DSSC       = 0;
00114   fT1d_DSSC       = 0;
00115   fT2d_DeeSCCons  = 0;
00116   fT1d_DeeSCCons  = 0;
00117   fT2d_RecovDeeSC = 0;
00118   fT1d_RecovDeeSC = 0;
00119 
00120   fCodeChNumberingITP1Bot = "bottom";   // ==> Type 1 Interface plate  IPT1 (a faire)
00121   fCodeChNumberingITP2Top = "top";      // ==> Type 2 Interface plate  IPT2 (a faire)
00122 
00123   //------------------ Init pointers on the CNA objects
00124   fEcal = 0;
00125 }
00126 // end of Init()
00127 //------------------------------------------------------------- SetEcalSubDetector(...)
00128 void TEcnaNumbering::SetEcalSubDetector(const TString SubDet, const TEcnaParEcal* pEcal){
00129 //Set the current subdetector flag and the current subdetector parameters
00130 
00131   fEcal = 0;
00132   if( pEcal == 0 )
00133     {fEcal = new TEcnaParEcal(SubDet.Data());  /*fCnew++*/ ;}
00134   else
00135     {fEcal = (TEcnaParEcal*)pEcal;}
00136 
00137   Int_t MaxCar = fgMaxCar;
00138   fFlagSubDet.Resize(MaxCar);
00139   fFlagSubDet = fEcal->GetEcalSubDetector();      // fFlagSubDet = "EB" or "EE"
00140 
00141   if( fFlagSubDet == "EB" ){BuildBarrelCrysTable();}
00142   if( fFlagSubDet == "EE" ){BuildEndcapCrysTable(); BuildEndcapSCTable();}
00143 }
00144 
00145 //====================================================================================================
00146 //
00147 //
00148 //                                  B   A   R   R   E   L 
00149 //
00150 //
00151 //====================================================================================================
00152 //
00153 //               SMCrys <-> (SMTow, TowEcha) correspondance table (from Patrick Jarry)
00154 //
00155 //====================================================================================================
00156 void TEcnaNumbering::BuildBarrelCrysTable()
00157 {
00158 // Build the correspondance table: SMCrys <-> (SMTow, TowEcha) for the ECAL BARREL
00159 //
00160 //  From CMS Internal Note  "CMS ECAL Barrel channel numbering"
00161 //
00162 //       Name      Number                     Reference set   Range        Comment
00163 //
00164 //       SMTow  : Tower number               in SuperModule  [1,68]      (phi,eta) progression
00165 //       SMCrys : Crystal number             in SuperModule  [1,1700]    (phi,eta) progression
00166 //       SMEcha : Electronic channel number  in SuperModule  [0,1699]    S shape data reading order 
00167 //   
00168 //       TowEcha: Electronic channel number  in Tower        [0,24]      S shape data reading order  
00169 //
00170 //
00171 //   fill the 2D array:  fT2dSMCrys[n_SMTow][n_TowEcha]
00172 //
00173 //   and the 1d arrays:  fT1dSMTow[i_SMCrys] and fT1dTowEcha[i_SMCrys]
00174 //
00175 //-----------------------------------------------------------------------------------------------------
00176 
00177   if ( fT2dSMCrys == 0 )
00178     {
00179       Int_t MaxSMTow   = fEcal->MaxTowInSM();
00180       Int_t MaxTowEcha = fEcal->MaxCrysInTow();
00181       Int_t MaxSMCrys  = fEcal->MaxCrysInSM();
00182       
00183       //................... Allocation and Init CrysNumbersTable
00184       
00185       fT2dSMCrys = new Int_t*[MaxSMTow];                         fCnew++;  
00186       fT1dSMCrys = new  Int_t[MaxSMTow*MaxTowEcha];              fCnew++;   
00187       for(Int_t i_SMTow = 0 ; i_SMTow < MaxSMTow ; i_SMTow++){
00188         fT2dSMCrys[i_SMTow] = &fT1dSMCrys[0] + i_SMTow*MaxTowEcha;}
00189       for(Int_t i=0; i<MaxSMTow; i++)
00190         {for(Int_t j=0; j<MaxTowEcha; j++){fT2dSMCrys[i][j]=0;}}      
00191 
00192       fT1dSMTow   = new Int_t[MaxSMCrys];                        fCnew++;
00193       for(Int_t i=0; i<MaxSMCrys; i++){fT1dSMTow[i]=0;}
00194 
00195       fT1dTowEcha = new Int_t[MaxSMCrys];                        fCnew++;
00196       for(Int_t i=0; i<MaxSMCrys; i++){fT1dTowEcha[i]=0;}
00197 
00198       //........................ Build table      
00199       Int_t m2  = (Int_t)2;
00200       Int_t m26 = (Int_t)26;
00201 
00202       //      Int_t jch_type[2][26];
00203       Int_t** jch_type    = new Int_t*[m2];                      fCnew++;  
00204       Int_t*  jch_type_d1 = new Int_t[m2*m26];                   fCnew++;
00205       for(Int_t i_m2 = 0 ; i_m2 < m2 ; i_m2++){
00206         jch_type[i_m2] = &jch_type_d1[0] + i_m2*m26;}
00207 
00208       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
00209       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
00210       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
00211       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
00212       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
00213       
00214       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
00215       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
00216       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
00217       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
00218       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
00219 
00220       //      Int_t ich_type[2][26]; 
00221       Int_t** ich_type    = new Int_t*[m2];                      fCnew++;  
00222       Int_t*  ich_type_d1 = new Int_t[m2*m26];                   fCnew++;
00223       for(Int_t i_m2 = 0 ; i_m2 < m2 ; i_m2++){
00224         ich_type[i_m2] = &ich_type_d1[0] + i_m2*m26;}
00225      
00226       for(Int_t k=25;k>=21;k--){ich_type[0][k] = 0;}     //  k = 25,24,23,22,21 -> ich_type[0][k] = 0
00227       for(Int_t k=16;k<=20;k++){ich_type[0][k] = 1;}     //  k = 16,17,18,19,20 -> ich_type[0][k] = 1
00228       for(Int_t k=15;k>=11;k--){ich_type[0][k] = 2;}     //  k = 15,14,12,13,11 -> ich_type[0][k] = 2
00229       for(Int_t k=6; k<=10;k++){ich_type[0][k] = 3;}     //  k =  6, 7, 8, 9,10 -> ich_type[0][k] = 3
00230       for(Int_t k=5; k>=1; k--){ich_type[0][k] = 4;}     //  k =  5, 4, 3, 2, 1 -> ich_type[0][k] = 4
00231       
00232       for(Int_t k=1; k<=5; k++){ich_type[1][k] = 0;}     //  k =  1, 2, 3, 4, 5 -> ich_type[1][k] = 0
00233       for(Int_t k=10;k>=6; k--){ich_type[1][k] = 1;}     //  k = 10, 9, 8, 7, 6 -> ich_type[1][k] = 1
00234       for(Int_t k=11;k<=15;k++){ich_type[1][k] = 2;}     //  k = 11,12,13,14,15 -> ich_type[1][k] = 2
00235       for(Int_t k=20;k>=16;k--){ich_type[1][k] = 3;}     //  k = 20,19,18,17,16 -> ich_type[1][k] = 3
00236       for(Int_t k=21;k<=25;k++){ich_type[1][k] = 4;}     //  k = 21,22,23,24,25 -> ich_type[1][k] = 4
00237       
00238       //     Int_t type[17]={0,0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1};
00239       Int_t m17 =17;
00240       Int_t* type = new Int_t[m17];                             fCnew++; 
00241 
00242       //  0 -> LVRB at the bottom, 1 -> LVRB at the top
00243       type[0] = 0;                   // M1
00244       type[1] = 0;
00245       type[2] = 0;
00246       type[3] = 1;
00247       type[4] = 1;
00248 
00249       type[5] = 0;                   // M2
00250       type[6] = 0;
00251       type[7] = 1;
00252       type[8] = 1;
00253 
00254       type[9]  = 0;                  // M3
00255       type[10] = 0;
00256       type[11] = 1;
00257       type[12] = 1;
00258 
00259       type[13] = 0;                  // M4
00260       type[14] = 0;
00261       type[15] = 1;
00262       type[16] = 1;
00263 
00264       for(Int_t tow=0; tow<MaxSMTow; tow++)                    //  tow  = 0 to 67   (MaxSMTow = 68)
00265         {
00266           for(Int_t ic=1; ic<=MaxTowEcha; ic++)                //  ic   = 1 to 25   (MaxTowEcha = 25) 
00267             {
00268               Int_t jtow = tow % 4;                            //  jtow = 0,1,2,3 
00269               Int_t itow = tow / 4;                            //  itow = 0 to 16
00270 
00271               Int_t icrys = itow*5 + ich_type[type[itow]][ic]; //  type[0->16] = 0,1 ,
00272                                                                //  ich_type[0->1][1->25] = 0,1,2,3,4
00273                                                                //  icrys = 0 to 84  (=> eta)
00274 
00275               Int_t jcrys = jtow*5 + jch_type[type[itow]][ic]; //  type[0->16] = 0,1 ,
00276                                                                //  jch_type[0->1][1->25] = 0,1,2,3,4
00277                                                                //  jcrys = 0 to 19  (=> phi)
00278 
00279               Int_t n1SMCrys = icrys*20+jcrys+1;               //  n1SMCrys = 1 to 1700
00280 
00281               fT2dSMCrys[tow][ic-1]   = n1SMCrys;      // fT2dSMCrys[]  : range = [1,1700]
00282               fT1dSMTow[n1SMCrys-1]   = tow+1;         // fT1dSMTow[]   : range = [1,68]
00283               fT1dTowEcha[n1SMCrys-1] = ic-1;          // fT1dTowEcha[] : range = [0,24]
00284             }
00285         }
00286       // cout << "#TEcnaNumbering::TBuildBarrelCrysTable()> Crys Table Building done" << endl;
00287 
00288       delete [] jch_type;                       fCdelete++;
00289       delete [] jch_type_d1;                    fCdelete++;
00290       delete [] ich_type;                       fCdelete++;
00291       delete [] ich_type_d1;                    fCdelete++;
00292       delete [] type;                           fCdelete++;
00293     }
00294   else
00295     {
00296       // cout << "#TEcnaNumbering::TBuildBarrelCrysTable()> No Building of Crys Table since it is already done." << endl;
00297     }
00298 }
00299 
00300 //===============================================================================
00301 //
00302 //        GetSMCrysFrom1SMTowAnd0TowEcha
00303 //        GetSMCrysFromSMEcha
00304 //
00305 //===============================================================================
00306 Int_t TEcnaNumbering::Get1SMCrysFrom1SMTowAnd0TowEcha(const Int_t& n1SMTow,
00307                                                       const Int_t& i0TowEcha)
00308 {
00309 //get crystal number in SM from tower number in SM
00310 // and from Electronic Channel number in tower
00311 
00312   Int_t n1SMCrys = 0;
00313 
00314   if( fT2dSMCrys == 0 ){BuildBarrelCrysTable();}
00315   
00316   if (n1SMTow >= 1 && n1SMTow <= fEcal->MaxTowInSM())
00317     {
00318       if (i0TowEcha >=0 && i0TowEcha < fEcal->MaxCrysInTow())
00319         {
00320           n1SMCrys = fT2dSMCrys[n1SMTow-1][i0TowEcha];
00321         }
00322       else
00323         {
00324           n1SMCrys = -2;   // Electronic Cnannel in Tower out of range 
00325           cout << "!TEcnaNumbering::Get1SMCrysFrom1SMTowAnd0TowEcha(...)> Electronic Channel in Tower out of range."
00326                << " i0TowEcha = " << i0TowEcha << fTTBELL << endl;
00327         }
00328     }
00329   else
00330     {
00331       n1SMCrys = -3;   // Tower number in SM out of range
00332       cout << "!TEcnaNumbering::Get1SMCrysFrom1SMTowAnd0TowEcha(...)> Tower number in SM out of range."
00333            << " n1SMTow = " << n1SMTow << fTTBELL << endl;
00334     }
00335 
00336   return n1SMCrys;   // Range = [1,1700]
00337 }
00338 
00339 //===============================================================================
00340 //
00341 //                Get0TowEchaFrom1SMCrys, Get1SMTowFrom1SMCrys
00342 //
00343 //===============================================================================
00344 
00345 Int_t TEcnaNumbering::Get0TowEchaFrom1SMCrys(const Int_t& n1SMCrys)
00346 {
00347 // get Electronic Channel number in Tower from Crystal number in SuperModule
00348 
00349   Int_t i0TowEcha = -1;
00350 
00351   if( n1SMCrys >= 1 && n1SMCrys <= fEcal->MaxCrysInSM() )
00352     {
00353       i0TowEcha = fT1dTowEcha[n1SMCrys-1];
00354     }
00355   else
00356     {
00357       i0TowEcha = -2;
00358       cout << "!TEcnaNumbering::Get0TowEchaFrom1SMCrys(...)> Crystal number in SM out of range."
00359            << " n1SMCrys = " << n1SMCrys << fTTBELL << endl;
00360     }
00361   return i0TowEcha;   // range = [0,24]
00362 }
00363 
00364 Int_t TEcnaNumbering::Get1SMTowFrom1SMCrys(const Int_t& n1SMCrys)
00365 {
00366 // get Tower number in SM (range [1,68]) from Crystal number in SuperModule (range [1,1700])
00367 
00368   Int_t n1SMtox = 0;
00369   
00370   if( n1SMCrys >= 1 && n1SMCrys <= fEcal->MaxCrysInSM() )
00371     {
00372       n1SMtox = fT1dSMTow[n1SMCrys-1];
00373     }
00374   else
00375     {
00376       n1SMtox = -1;
00377       cout << "!TEcnaNumbering::Get1SMTowFrom1SMCrys(...)> Crystal number in SM out of range."
00378            << " n1SMCrys = " << n1SMCrys << fTTBELL << endl;
00379     }
00380   return n1SMtox;   // range = [1,68]
00381 }
00382 
00383 //===============================================================================
00384 //
00385 //          Get0TowEchaFrom0SMEcha
00386 //          Get1SMTowFrom0SMEcha
00387 //
00388 //===============================================================================
00389 
00390 Int_t TEcnaNumbering::Get0TowEchaFrom0SMEcha(const Int_t& i0SMEcha)
00391 {
00392 //get electronic channel number in tower from electronic channel number in SM
00393 
00394   Int_t n1SMTow = i0SMEcha/fEcal->MaxCrysInTow()+1;
00395   Int_t i0TowEcha = i0SMEcha - fEcal->MaxCrysInTow()*(n1SMTow-1);
00396 
00397   return i0TowEcha;   // range = [0,24]
00398 }
00399 
00400 Int_t TEcnaNumbering::Get1SMTowFrom0SMEcha(const Int_t& i0SMEcha)
00401 {
00402 //get tower number from electronic channel number in SM
00403 
00404   Int_t n1SMTow = i0SMEcha/fEcal->MaxCrysInTow()+1;
00405 
00406   return n1SMTow;  // range = [1,68]
00407 }
00408 
00409 Int_t TEcnaNumbering::Get0SMEchaFrom1SMTowAnd0TowEcha(const Int_t& n1SMTow, const Int_t& i0TowEcha)
00410 {
00411 //get tower number from electronic channel number in SM
00412 
00413   Int_t i0SMEcha = (n1SMTow-1)*fEcal->MaxCrysInTow()+i0TowEcha;
00414 
00415   return i0SMEcha;
00416 }
00417 //===========================================================================
00418 //
00419 //                        GetHashedNumberFromIEtaAndIPhi
00420 //
00421 //===========================================================================
00422 Int_t TEcnaNumbering::GetHashedNumberFromIEtaAndIPhi(const Int_t& IEta, const Int_t& IPhi)
00423 {
00424   Int_t Hashed = 0;
00425 
00426   if( IEta > 0 ){Hashed = (85 + IEta - 1)*360 + IPhi - 1;}
00427   if( IEta < 0 ){Hashed = (85 + IEta)*360     + IPhi - 1;}
00428 
00429   return Hashed;
00430 }
00431 
00432 Int_t TEcnaNumbering::GetIEtaFromHashed(const Int_t& Hashed,  const Int_t& SMNumber)
00433 {
00434   Int_t IEta = 0;
00435 
00436   if( GetSMHalfBarrel(SMNumber) == "EB+" ){IEta = Hashed/360 - 85 + 1;}
00437   if( GetSMHalfBarrel(SMNumber) == "EB-" ){IEta = 85 + Hashed/360;}
00438 
00439   return IEta;
00440 }
00441 
00442 Int_t TEcnaNumbering::GetIPhiFromHashed(const Int_t& Hashed)
00443 {
00444   Int_t IPhi = Hashed%360 + 1;
00445 
00446   return IPhi;
00447 }
00448 //===========================================================================
00449 //
00450 //                        GetTowerLvrbType
00451 //
00452 //===========================================================================
00453 TString  TEcnaNumbering::GetStinLvrbType(const Int_t& n1SMTow)
00454 {
00455   TString lvrb_type = GetTowerLvrbType(n1SMTow);
00456   return lvrb_type;
00457 }
00458 TString  TEcnaNumbering::GetTowerLvrbType(const Int_t& n1SMTow)
00459 {
00460 //gives the LVRB type of the crystal numbering of tower
00461 
00462   TString type = fCodeChNumberingLvrbTop;   // => default value
00463 
00464   if (n1SMTow >=  1 && n1SMTow <= 12){type = fCodeChNumberingLvrbBot;}
00465   if (n1SMTow >= 21 && n1SMTow <= 28){type = fCodeChNumberingLvrbBot;}
00466   if (n1SMTow >= 37 && n1SMTow <= 44){type = fCodeChNumberingLvrbBot;}
00467   if (n1SMTow >= 53 && n1SMTow <= 60){type = fCodeChNumberingLvrbBot;}
00468 
00469   return type;
00470 }
00471 
00472 //==============================================================================
00473 //
00474 //       GetEta, GetEtaMin, GetEtaMax,  GetIEtaMin, GetIEtaMax
00475 //
00476 //==============================================================================
00477 Double_t TEcnaNumbering::GetEta(const Int_t& n1EBSM, const Int_t& n1SMTow,
00478                                 const Int_t& i0TowEcha)
00479 {
00480 //Gives Eta for a given (n1EBSM, n1SMTow, i0TowEcha)
00481   
00482   Double_t eta = (Double_t)0.;
00483 
00484   Int_t max_crys_eta_in_tower = fEcal->MaxCrysEtaInTow();
00485   Int_t max_tow_eta_in_sm     = fEcal->MaxTowEtaInSM();
00486   Int_t max_sm_in_barrel      = fEcal->MaxSMInEB();
00487 
00488   if ( n1EBSM >= 1 && n1EBSM <= max_sm_in_barrel )
00489     {
00490       for (Int_t i_sm_tow_eta = 0; i_sm_tow_eta < max_tow_eta_in_sm; i_sm_tow_eta++)
00491         {
00492           Int_t i_crys_eta_min = (Int_t)(1 + i_sm_tow_eta*(max_crys_eta_in_tower-1));
00493           Int_t i_crys_eta_max = (Int_t)((i_sm_tow_eta+1)*(max_crys_eta_in_tower-1));
00494           Int_t i_crys_eta     = (Int_t)(i_sm_tow_eta*max_crys_eta_in_tower);
00495           // = 0,..,16 -> last xtal in eta for the previous tower
00496           Double_t d_echa_eta  = (Double_t)(i0TowEcha/max_crys_eta_in_tower);    // = 0,1,2,3,4
00497 
00498             if ( n1SMTow >= i_crys_eta_min && n1SMTow <= i_crys_eta_max )
00499               {
00500                 if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbTop)
00501                 {eta = (Double_t)(i_crys_eta) + d_echa_eta + 1;}
00502                 if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbBot)
00503                 {eta = (Double_t)(i_crys_eta+max_crys_eta_in_tower)-d_echa_eta;}
00504               }
00505         }      
00506       if ( GetSMHalfBarrel(n1EBSM) == "EB-" ){eta = - eta;}      
00507     }
00508   else
00509     {
00510       cout << "TEcnaNumbering::GetEta(...)> SM = " << n1EBSM
00511            << ". Out of range (range = [1," << fEcal->MaxSMInEB() << "])" 
00512            << fTTBELL << endl; 
00513     }
00514   return eta;
00515 }
00516 //-------------------------------------------------------------------------------------
00517 Double_t TEcnaNumbering::GetEtaMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
00518 {
00519 //Gives EtaMin for a given Tower
00520 
00521   Int_t max_tow_eta_in_sm     = fEcal->MaxTowEtaInSM();
00522   Int_t max_crys_eta_in_tower = fEcal->MaxCrysEtaInTow();
00523 
00524   Double_t eta_min = (Double_t)0.;
00525 
00526   for (Int_t i_sm_tow_eta = 0; i_sm_tow_eta < max_tow_eta_in_sm; i_sm_tow_eta++)
00527     {
00528       Int_t i_crys_eta_min =    (Int_t)(1 + i_sm_tow_eta*(max_crys_eta_in_tower-1));
00529       Int_t i_crys_eta_max =    (Int_t)((i_sm_tow_eta+1)*(max_crys_eta_in_tower-1));
00530       Int_t i_crys_eta     =    (Int_t)(i_sm_tow_eta*max_crys_eta_in_tower);
00531 
00532       if ( n1SMTow >= i_crys_eta_min && n1SMTow <= i_crys_eta_max )
00533         {
00534           if (GetSMHalfBarrel(n1EBSM) == "EB+")
00535             {eta_min = (Double_t)i_crys_eta;}
00536           if (GetSMHalfBarrel(n1EBSM) == "EB-")
00537             {eta_min = -(Double_t)(i_crys_eta + max_crys_eta_in_tower);}
00538         }
00539     }
00540   return eta_min;
00541 }
00542 //------------------------------------------------------------------------------------
00543 Double_t TEcnaNumbering::GetEtaMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
00544 {
00545 //Gives EtaMax for a given Tower
00546 
00547   Int_t max_tow_eta_in_sm     = fEcal->MaxTowEtaInSM();
00548   Int_t max_crys_eta_in_tower = fEcal->MaxCrysEtaInTow();
00549 
00550   Double_t eta_max = (max_crys_eta_in_tower-1);
00551 
00552   for (Int_t i_sm_tow_eta = 0; i_sm_tow_eta < max_tow_eta_in_sm; i_sm_tow_eta++)
00553     {
00554       Int_t i_crys_eta_min = (Int_t)(1 + i_sm_tow_eta*(max_crys_eta_in_tower-1));
00555       Int_t i_crys_eta_max = (Int_t)((i_sm_tow_eta+1)*(max_crys_eta_in_tower-1));
00556       Int_t i_crys_eta     = (Int_t)(i_sm_tow_eta*max_crys_eta_in_tower);
00557 
00558       if ( n1SMTow >= i_crys_eta_min && n1SMTow <= i_crys_eta_max )
00559         {
00560           if (GetSMHalfBarrel(n1EBSM) == "EB+")
00561             {eta_max = (Double_t)(i_crys_eta + max_crys_eta_in_tower);}
00562           if (GetSMHalfBarrel(n1EBSM) == "EB-")
00563             {eta_max = -(Double_t)i_crys_eta;}
00564         }
00565     }
00566 
00567   return eta_max;
00568 }
00569 
00570 Double_t TEcnaNumbering::GetIEtaMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
00571 {
00572 //Gives IEtaMin for a given (n1EBSM, n1SMTow)
00573 
00574   Double_t i_eta_min = (Int_t)0.; 
00575    
00576   if(GetSMHalfBarrel(n1EBSM) == "EB+")
00577     {i_eta_min = (Double_t)GetEtaMin(n1EBSM, n1SMTow)+(Double_t)0.5;}
00578   if(GetSMHalfBarrel(n1EBSM) == "EB-")
00579     {i_eta_min = (Double_t)GetEtaMin(n1EBSM, n1SMTow)-(Double_t)0.5;}
00580 
00581   return i_eta_min;
00582 }
00583 
00584 Double_t TEcnaNumbering::GetIEtaMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
00585 {
00586 //Gives IEtaMax for a given (n1EBSM, n1SMTow)
00587 
00588   Double_t i_eta_max = (Int_t)0.; 
00589    
00590   if(GetSMHalfBarrel(n1EBSM) == "EB+")
00591     {i_eta_max = (Double_t)GetEtaMax(n1EBSM, n1SMTow)+(Double_t)0.5;}
00592   if(GetSMHalfBarrel(n1EBSM) == "EB-")
00593     {i_eta_max = (Double_t)GetEtaMax(n1EBSM, n1SMTow)-(Double_t)0.5;}
00594 
00595   return i_eta_max;
00596 }
00597 
00598 Double_t TEcnaNumbering::GetIEtaMin(const Int_t& n1EBSM)
00599 {
00600 //Gives IEtaMin for a given (n1EBSM)
00601 
00602   Double_t i_eta_min = (Int_t)0.;
00603 
00604   Int_t n1SMTowPlus  = (Int_t)1;   
00605   Int_t n1SMTowMinus = (Int_t)fEcal->MaxTowInSM();
00606 
00607   if( GetSMHalfBarrel(n1EBSM) == "EB+" )
00608     {i_eta_min = (Double_t)GetIEtaMin(n1EBSM, n1SMTowPlus );}
00609   if( GetSMHalfBarrel(n1EBSM) == "EB-" )
00610     {i_eta_min = (Double_t)GetIEtaMin(n1EBSM, n1SMTowMinus);}
00611 
00612   return i_eta_min;
00613 }
00614 
00615 Double_t TEcnaNumbering::GetIEtaMax(const Int_t& n1EBSM)
00616 {
00617 //Gives IEtaMax for a given (n1EBSM)
00618 
00619   Double_t i_eta_max = (Int_t)0.; 
00620 
00621   Int_t n1SMTowPlus  = (Int_t)fEcal->MaxTowInSM();   
00622   Int_t n1SMTowMinus = (Int_t)1;   
00623    
00624   if( GetSMHalfBarrel(n1EBSM) == "EB+")
00625     {i_eta_max = (Double_t)GetIEtaMax(n1EBSM, n1SMTowPlus );}
00626   if( GetSMHalfBarrel(n1EBSM) == "EB-")
00627     {i_eta_max = (Double_t)GetIEtaMax(n1EBSM, n1SMTowMinus);}
00628 
00629   return i_eta_max;
00630 }
00631 
00632 //==============================================================================
00633 //
00634 //    GetSMCentralPhi, GetPhiInSM, GetPhi,
00635 //    GetPhiMin, GetPhiMax, GetIPhiMin, GetIPhiMax
00636 //
00637 //==============================================================================
00638 Double_t TEcnaNumbering::GetSMCentralPhi(const Int_t& n1EBSM)
00639 {
00640 //Gives the central phi value of the SuperModule
00641 
00642   Double_t central_phi = (Double_t)10.;    //  DEFAULT = SM1
00643   
00644   if (GetSMHalfBarrel(n1EBSM) == "EB+"){central_phi = 10. + (Double_t)20.*(n1EBSM-1);}
00645   if (GetSMHalfBarrel(n1EBSM) == "EB-"){central_phi = 10. + (Double_t)20.*(n1EBSM-19);}
00646 
00647   return central_phi;
00648 }
00649 //------------------------------------------------------------------------------------
00650 Double_t TEcnaNumbering::GetPhiInSM(const Int_t& n1EBSM,
00651                                     const Int_t& n1SMTow, const Int_t& i0TowEcha)
00652 {
00653 //Gives Phi for a given (n1EBSM, n1SMTow, i0TowEcha)
00654 
00655   Double_t phi_in_SM = (Double_t)0.;
00656 
00657   Int_t rest_temp =(Int_t)(n1SMTow%(fEcal->MaxCrysPhiInTow()-1));  // "Phi" of the tower = 1,2,3,0 
00658 
00659   if ( n1EBSM >= 1 && n1EBSM <= fEcal->MaxSMInEB() )
00660     {
00661       if( rest_temp == 1 ){phi_in_SM = (Double_t)15.;}
00662       if( rest_temp == 2 ){phi_in_SM = (Double_t)10.;}
00663       if( rest_temp == 3 ){phi_in_SM = (Double_t)5.;}
00664       if( rest_temp == 0 ){phi_in_SM = (Double_t)0.;}
00665       
00666       if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbTop)
00667         { 
00668           if( i0TowEcha ==  4 || i0TowEcha ==  5 || i0TowEcha == 14 || i0TowEcha == 15 || i0TowEcha == 24 )
00669             {phi_in_SM = phi_in_SM + 0;}
00670           
00671           if( i0TowEcha ==  3 || i0TowEcha ==  6 || i0TowEcha == 13 || i0TowEcha == 16 || i0TowEcha == 23 )
00672             {phi_in_SM = phi_in_SM + 1;} 
00673           
00674           if( i0TowEcha ==  2 || i0TowEcha ==  7 || i0TowEcha == 12 || i0TowEcha == 17 || i0TowEcha == 22 )
00675             {phi_in_SM = phi_in_SM + 2;}
00676           
00677           if( i0TowEcha ==  1 || i0TowEcha ==  8 || i0TowEcha == 11 || i0TowEcha == 18 || i0TowEcha == 21 )
00678             {phi_in_SM = phi_in_SM + 3;}
00679           
00680           if( i0TowEcha ==  0 || i0TowEcha ==  9 || i0TowEcha == 10 || i0TowEcha == 19 || i0TowEcha == 20 )
00681             {phi_in_SM = phi_in_SM + 4;} 
00682         }
00683       if (GetTowerLvrbType(n1SMTow) == fCodeChNumberingLvrbBot)
00684         {
00685           if( i0TowEcha == 20 || i0TowEcha == 19 || i0TowEcha == 10 || i0TowEcha ==  9 || i0TowEcha ==  0 )
00686             {phi_in_SM = phi_in_SM + 0;}
00687           
00688           if( i0TowEcha == 21 || i0TowEcha == 18 || i0TowEcha == 11 || i0TowEcha ==  8 || i0TowEcha ==  1 )
00689             {phi_in_SM = phi_in_SM + 1;}
00690  
00691           if( i0TowEcha == 22 || i0TowEcha == 17 || i0TowEcha == 12 || i0TowEcha ==  7 || i0TowEcha ==  2 )
00692             {phi_in_SM = phi_in_SM + 2;}
00693 
00694           if( i0TowEcha == 23 || i0TowEcha == 16 || i0TowEcha == 13 || i0TowEcha ==  6 || i0TowEcha ==  3 )
00695             {phi_in_SM = phi_in_SM + 3;}
00696 
00697           if( i0TowEcha == 24 || i0TowEcha == 15 || i0TowEcha == 14 || i0TowEcha ==  5 || i0TowEcha ==  4 )
00698             {phi_in_SM = phi_in_SM + 4;} 
00699           }
00700     }
00701   else
00702     {
00703       cout << "TEcnaNumbering::GetPhiInSM(...)> SM = " << n1EBSM
00704            << ". Out of range (range = [1," << fEcal->MaxSMInEB() << "])" 
00705            << fTTBELL << endl; 
00706     }
00707   phi_in_SM = 20 - phi_in_SM;
00708   return phi_in_SM;
00709 }
00710 //---------------------------------------------------------------------------------------
00711 Double_t TEcnaNumbering::GetPhi(const Int_t& n1EBSM,
00712                                 const Int_t& n1SMTow, const Int_t& i0TowEcha)
00713 {
00714 //Gives Phi for a given (n1EBSM, n1SMTow, i0TowEcha)
00715   
00716   Double_t phi = (Double_t)0.;
00717 
00718   if ( n1EBSM >= 1 && n1EBSM <= fEcal->MaxSMInEB() )
00719     {
00720       Double_t phiInSM   = GetPhiInSM(n1EBSM, n1SMTow, i0TowEcha);
00721       Double_t phi_start = GetSMCentralPhi(n1EBSM);
00722  
00723       phi = 20 - phiInSM + phi_start -(Double_t)10.;
00724     }
00725   else
00726     {
00727       cout << "TEcnaNumbering::GetPhi(...)> SM = " << n1EBSM
00728            << ". Out of range (range = [1," << fEcal->MaxSMInEB() << "])" 
00729            << fTTBELL << endl; 
00730     }
00731   return phi;
00732 }
00733 
00734 //-----------------------------------------------------------------------------------------
00735 Double_t TEcnaNumbering::GetPhiMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
00736 {
00737 //Gives PhiMin for a given Tower
00738 
00739   Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
00740 
00741   Double_t phi_min = (Double_t)0.;     // DEFAULT
00742   Double_t phi_start = GetSMCentralPhi(n1EBSM);
00743 
00744   Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
00745 
00746   if(GetSMHalfBarrel(n1EBSM) == "EB+")
00747     {
00748       if ( rest_temp == 1 ) {phi_min = phi_start + (Double_t)5.;}
00749       if ( rest_temp == 2 ) {phi_min = phi_start + (Double_t)0.;}
00750       if ( rest_temp == 3 ) {phi_min = phi_start - (Double_t)5.;}
00751       if ( rest_temp == 0 ) {phi_min = phi_start - (Double_t)10.;}
00752     }
00753   if(GetSMHalfBarrel(n1EBSM) == "EB-")
00754     {
00755       if ( rest_temp == 0 ) {phi_min = phi_start + (Double_t)5.;}
00756       if ( rest_temp == 3 ) {phi_min = phi_start + (Double_t)0.;}
00757       if ( rest_temp == 2 ) {phi_min = phi_start - (Double_t)5.;}
00758       if ( rest_temp == 1 ) {phi_min = phi_start - (Double_t)10.;}
00759     }
00760   return phi_min;
00761 }
00762 //-----------------------------------------------------------------------------------------
00763 Double_t TEcnaNumbering::GetPhiMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
00764 {
00765 //Gives PhiMax for a given Tower
00766 
00767   Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
00768 
00769   Double_t phi_max = (Double_t)20.;     // DEFAULT
00770   Double_t phi_start = GetSMCentralPhi(n1EBSM);
00771 
00772   Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
00773 
00774   if(GetSMHalfBarrel(n1EBSM) == "EB+")
00775     {
00776       if ( rest_temp == 1 ) {phi_max = phi_start + (Double_t)10.;}
00777       if ( rest_temp == 2 ) {phi_max = phi_start + (Double_t)5.;}
00778       if ( rest_temp == 3 ) {phi_max = phi_start - (Double_t)0.;}
00779       if ( rest_temp == 0 ) {phi_max = phi_start - (Double_t)5.;}
00780     }
00781 
00782   if(GetSMHalfBarrel(n1EBSM) == "EB-")
00783     {
00784       if ( rest_temp == 0 ) {phi_max = phi_start + (Double_t)10.;}
00785       if ( rest_temp == 3 ) {phi_max = phi_start + (Double_t)5.;}
00786       if ( rest_temp == 2 ) {phi_max = phi_start - (Double_t)0.;}
00787       if ( rest_temp == 1 ) {phi_max = phi_start - (Double_t)5.;}
00788     }
00789 
00790   return phi_max;
00791 }
00792 //-----------------------------------------------------------------------------------------
00793 Double_t TEcnaNumbering::GetPhiMin(const Int_t& n1EBSM)
00794 {
00795 //Gives PhiMin for a given SuperModule
00796 
00797   Double_t phi_min = GetSMCentralPhi(n1EBSM) - (Double_t)10.;
00798 
00799   return phi_min;
00800 }
00801 //-----------------------------------------------------------------------------------------
00802 Double_t TEcnaNumbering::GetPhiMax(const Int_t& n1EBSM)
00803 {
00804 //Gives PhiMax for a given SuperModule
00805 
00806   Double_t phi_max = GetSMCentralPhi(n1EBSM) + (Double_t)10.;
00807 
00808   return phi_max;
00809 }
00810 //-----------------------------------------------------------------------------------------
00811 Double_t TEcnaNumbering::GetJPhiMin(const Int_t& n1EBSM, const Int_t& n1SMTow)
00812 {
00813 //Gives JPhiMin for a given Tower
00814 
00815   Double_t j_phi_min = (Double_t)1.;
00816   Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
00817   Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
00818   
00819   if ( rest_temp == 1 ){j_phi_min = (Double_t) 1. - (Double_t)0.5;}
00820   if ( rest_temp == 2 ){j_phi_min = (Double_t) 6. - (Double_t)0.5;}
00821   if ( rest_temp == 3 ){j_phi_min = (Double_t)11. - (Double_t)0.5;}
00822   if ( rest_temp == 0 ){j_phi_min = (Double_t)16. - (Double_t)0.5;}
00823 
00824   return j_phi_min;
00825 }
00826 //-----------------------------------------------------------------------------------------
00827 Double_t TEcnaNumbering::GetJPhiMax(const Int_t& n1EBSM, const Int_t& n1SMTow)
00828 {
00829 //Gives JPhiMax for a given Tower
00830 
00831   Double_t j_phi_max = (Double_t)20.;
00832   Int_t max_crys_phi_in_tower = fEcal->MaxCrysPhiInTow();
00833   Int_t rest_temp =(Int_t)(n1SMTow%(max_crys_phi_in_tower-1));
00834   
00835   if ( rest_temp == 1 ){j_phi_max = (Double_t) 5. + (Double_t)0.5;}
00836   if ( rest_temp == 2 ){j_phi_max = (Double_t)10. + (Double_t)0.5;}
00837   if ( rest_temp == 3 ){j_phi_max = (Double_t)15. + (Double_t)0.5;}
00838   if ( rest_temp == 0 ){j_phi_max = (Double_t)20. + (Double_t)0.5;}
00839 
00840   return j_phi_max;
00841 }
00842 
00843 //-----------------------------------------------------------------------------------------
00844 Double_t TEcnaNumbering::GetJPhiMin(const Int_t& n1EBSM)
00845 {
00846 //Gives JPhiMin for a given SuperModule
00847 
00848   Double_t j_phi_min = (Double_t)1. - (Double_t)0.5;
00849 
00850   return j_phi_min;
00851 }
00852 //-----------------------------------------------------------------------------------------
00853 Double_t TEcnaNumbering::GetJPhiMax(const Int_t& n1EBSM)
00854 {
00855 //Gives JPhiMax for a given SuperModule
00856 
00857   Double_t j_phi_max = (Double_t)20. + (Double_t)0.5;
00858 
00859   return j_phi_max;
00860 }
00861 
00862 //==============================================================================
00863 //
00864 //   GetXDirectionEB, GetYDirectionEB, GetJYDirectionEB
00865 //
00866 //==============================================================================
00867 
00868 //------------------------------------------------------------------
00869 TString TEcnaNumbering::GetXDirectionEB(const Int_t& SMNumber)
00870 {
00871   TString xdirection = "x";      // DEFAULT
00872 
00873   if( GetSMHalfBarrel(SMNumber) == "EB+" ){xdirection = "x";}
00874   if( GetSMHalfBarrel(SMNumber) == "EB-" ){xdirection = "x";}
00875 
00876   return xdirection;
00877 }
00878 //---------------------------------------------------------
00879 TString TEcnaNumbering::GetYDirectionEB(const Int_t& SMNumber)
00880 {
00881   TString ydirection = "-x";      // DEFAULT
00882 
00883   if( GetSMHalfBarrel(SMNumber) == "EB+" ){ydirection = "-x";}
00884   if( GetSMHalfBarrel(SMNumber) == "EB-" ){ydirection = "-x";}
00885 
00886   return ydirection;
00887 }
00888 
00889 //---------------------------------------------------------
00890 TString TEcnaNumbering::GetJYDirectionEB(const Int_t& SMNumber)
00891 {
00892   TString jydirection = "-x";      // DEFAULT
00893 
00894   if( GetSMHalfBarrel(SMNumber) == "EB+" ){jydirection = "x";}
00895   if( GetSMHalfBarrel(SMNumber) == "EB-" ){jydirection = "-x";}
00896 
00897   return jydirection;
00898 }
00899 
00900 //============================================================================
00901 TString  TEcnaNumbering::GetSMHalfBarrel(const Int_t& SMNumber)
00902 {
00903 //gives the half-barrel of the SM ("EB+" or "EB-")
00904 
00905   TString type = "EB-";   // => default value
00906 
00907   if ( SMNumber >=  1                      && SMNumber <= fEcal->MaxSMInEBPlus() ){type = "EB+";}
00908   if ( SMNumber >   fEcal->MaxSMInEBPlus() && SMNumber <= fEcal->MaxSMInEB()     ){type = "EB-";}
00909 
00910   return type;
00911 }
00912 
00913 //====================================================================================================
00914 //
00915 //
00916 //                                  E   N   D   C   A   P 
00917 //
00918 //
00919 //====================================================================================================
00920 //
00921 //               DeeCrys <-> (DeeSC, SCEcha) correspondance table
00922 //               (from the barrel table given by Patrick Jarry)
00923 //
00924 //====================================================================================================
00925 void TEcnaNumbering::BuildEndcapCrysTable()
00926 {
00927 // Build the correspondance table: DeeCrys <-> (DeeSC, SCEcha) for the ECAL ENDCAP
00928 //
00929 //  From CMS Internal Note  "CMS ECAL Endcap channel numbering"
00930 //
00931 //       Name      Number                     Reference set  Range          Comment
00932 //
00933 //       DeeSC   : Super-Crystal (SC) number    in Dee      [1,200]   (IY,IX) progression
00934 //       DeeCrys : Crystal number               in Dee      [1,5000]  (IY,IX) progression
00935 //       DeeEcha : Electronic channel number    in Dee      [0,4999]  Crystal numbering for construction 
00936 //   
00937 //       SCEcha  : Electronic channel number    in SC       [1,25]    Crystal numbering for construction  
00938 //
00939 //
00940 //   fill the 3D array:  fT3dDeeCrys[n_DeeSC][n_SCEcha][2]
00941 //
00942 //   and the 2d arrays:  fT2dDeeSC[n_DeeCrys][2] and fT2dSCEcha[n_DeeCrys][2]
00943 //
00944 //------------------------------------------------------------------------------------------------------
00945 
00946   if ( fT3dDeeCrys == 0 )
00947     {
00948       Int_t MaxDeeSC   = fEcal->MaxSCEcnaInDee();    // fEcal->MaxSCEcnaInDee() = 200
00949       Int_t MaxSCEcha  = fEcal->MaxCrysInSC();
00950       Int_t MaxDeeCrys = fEcal->MaxCrysEcnaInDee();
00951 
00952       Int_t MaxDirections = 2;    //  (2 directions: left and right)
00953 
00954       //................... Allocation and Init CrysNumbersTable
00955       fT3dDeeCrys = new Int_t**[MaxDeeSC];                         fCnew++;       
00956       fT2dDeeCrys = new  Int_t*[MaxDeeSC*MaxSCEcha];               fCnew++;  
00957       fT1dDeeCrys = new   Int_t[MaxDeeSC*MaxSCEcha*MaxDirections]; fCnew++;
00958       
00959       for(Int_t i_DeeSC = 0; i_DeeSC < MaxDeeSC; i_DeeSC++){
00960         fT3dDeeCrys[i_DeeSC] = &fT2dDeeCrys[0] + i_DeeSC*MaxSCEcha;
00961         for(Int_t i_SCEcha = 0; i_SCEcha < MaxSCEcha; i_SCEcha++){
00962           fT2dDeeCrys[i_DeeSC*MaxSCEcha + i_SCEcha] = &fT1dDeeCrys[0]
00963             + (i_DeeSC*MaxSCEcha + i_SCEcha)*MaxDirections;}}
00964       for(Int_t i=0; i<MaxDeeSC; i++)
00965         {for(Int_t j=0; j<MaxSCEcha; j++)
00966           {for(Int_t k=0; k<MaxDirections; k++){fT3dDeeCrys[i][j][k]=0;}}}      
00967 
00968       fT2dDeeSC  = new Int_t*[MaxDeeCrys];                         fCnew++;
00969       fT1dDeeSC  = new  Int_t[MaxDeeCrys*MaxDirections];           fCnew++;
00970       for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxDeeCrys ; i_DeeCrys++){
00971         fT2dDeeSC[i_DeeCrys] = &fT1dDeeSC[0] + i_DeeCrys*MaxDirections;}
00972       for(Int_t i=0; i<MaxDeeCrys; i++)
00973         {for(Int_t j=0; j<MaxDirections; j++){fT2dDeeSC[i][j]=0;}}
00974 
00975       fT2dSCEcha = new Int_t*[MaxDeeCrys];                       fCnew++;
00976       fT1dSCEcha = new  Int_t[MaxDeeCrys*MaxDirections];                    fCnew++;   
00977       for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxDeeCrys ; i_DeeCrys++){
00978         fT2dSCEcha[i_DeeCrys] = &fT1dSCEcha[0] + i_DeeCrys*MaxDirections;}
00979       for(Int_t i=0; i<MaxDeeCrys; i++)
00980         {for(Int_t j=0; j<MaxDirections; j++){fT2dSCEcha[i][j]=0;}}      
00981 
00982       //................................ Build table
00983       Int_t MaxTyp    = (Int_t)4;
00984       Int_t MaxCrysP1 = (Int_t)(fEcal->MaxCrysInSC()+1);
00985 
00986       //      Int_t fT2d_jch_JY[type][Echa+1]:  JY in the SC as a function of type and Echa+1
00987       fT2d_jch_JY    = new Int_t*[MaxTyp];                      fCnew++;  
00988       fT1d_jch_JY = new Int_t[MaxTyp*MaxCrysP1];             fCnew++;
00989       for(Int_t i_MaxTyp = 0 ; i_MaxTyp < MaxTyp ; i_MaxTyp++){
00990         fT2d_jch_JY[i_MaxTyp] = &fT1d_jch_JY[0] + i_MaxTyp*MaxCrysP1;}
00991 
00992       // type: 0=(top/right), 1=(top/left), 2=(bottom/left), 3=(bottom/right),  
00993  
00994       //................. top/right
00995       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
00996       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
00997       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
00998       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
00999       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
01000       //................. top/left
01001       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
01002       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
01003       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
01004       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
01005       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
01006       //................. bottom/left
01007       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
01008       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
01009       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
01010       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
01011       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
01012       //................. bottom/right
01013       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
01014       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
01015       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
01016       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
01017       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
01018 
01019       //      Int_t fT2d_ich_IX[type][Echa+1]:  IX in the SC as a function of type and Echa+1
01020       fT2d_ich_IX = new Int_t*[MaxTyp];                      fCnew++;  
01021       fT1d_ich_IX = new Int_t[MaxTyp*MaxCrysP1];             fCnew++;
01022       for(Int_t i_MaxTyp = 0 ; i_MaxTyp < MaxTyp ; i_MaxTyp++){
01023         fT2d_ich_IX[i_MaxTyp] = &fT1d_ich_IX[0] + i_MaxTyp*MaxCrysP1;}
01024 
01025       //................. top/right
01026       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
01027       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
01028       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
01029       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
01030       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
01031       //................. top/left      
01032       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
01033       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
01034       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
01035       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
01036       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
01037       //................. bottom/left
01038       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
01039       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
01040       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
01041       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
01042       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
01043       //................. bottom/right      
01044       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
01045       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
01046       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
01047       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
01048       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
01049 
01050       //............................................ type
01051       Int_t  Nb_DeeSC_JY  = fEcal->MaxSCIYInDee();      
01052       Int_t** type    = new Int_t*[Nb_DeeSC_JY];                   fCnew++; 
01053       Int_t*  type_d1 = new Int_t[Nb_DeeSC_JY*MaxDirections];      fCnew++;  
01054       for(Int_t i_DeeSC_JY = 0 ; i_DeeSC_JY < Nb_DeeSC_JY ; i_DeeSC_JY++){
01055         type[i_DeeSC_JY] = &type_d1[0] + i_DeeSC_JY*MaxDirections;}
01056 
01057       //  bottom = (0,9), top  = (10,19)
01058       //  right  = 0    , left = 1
01059       //  type = Quadrant number - 1
01060 
01061       type[10][0] = 0;                   // Q1 top right
01062       type[11][0] = 0;
01063       type[12][0] = 0;
01064       type[13][0] = 0;
01065       type[14][0] = 0;
01066       type[15][0] = 0;
01067       type[16][0] = 0;
01068       type[17][0] = 0;
01069       type[18][0] = 0;
01070       type[19][0] = 0;
01071  
01072       type[10][1] = 1;                   // Q2 top left    
01073       type[11][1] = 1;
01074       type[12][1] = 1;
01075       type[13][1] = 1;
01076       type[14][1] = 1;
01077       type[15][1] = 1;
01078       type[16][1] = 1;
01079       type[17][1] = 1;
01080       type[18][1] = 1;
01081       type[19][1] = 1;
01082 
01083       type[ 0][1] = 2;                   // Q3 : bottom left 
01084       type[ 1][1] = 2;
01085       type[ 2][1] = 2;
01086       type[ 3][1] = 2;
01087       type[ 4][1] = 2;
01088       type[ 5][1] = 2;
01089       type[ 6][1] = 2;
01090       type[ 7][1] = 2;
01091       type[ 8][1] = 2;
01092       type[ 9][1] = 2;
01093  
01094       type[ 0][0] = 3;                   // Q4 : bottom right 
01095       type[ 1][0] = 3;
01096       type[ 2][0] = 3;
01097       type[ 3][0] = 3;
01098       type[ 4][0] = 3;
01099       type[ 5][0] = 3;
01100       type[ 6][0] = 3;
01101       type[ 7][0] = 3;
01102       type[ 8][0] = 3;
01103       type[ 9][0] = 3;
01104 
01105       Int_t Nb_SCCrys_IX = fEcal->MaxCrysIXInSC();
01106       Int_t Nb_SCCrys_JY = fEcal->MaxCrysIYInSC();
01107 
01108       for(Int_t kSC=0; kSC<MaxDeeSC; kSC++)                   //  kSC  = 0 to 199   (MaxDeeSC = 200)
01109         {
01110           for(Int_t n_Echa=1; n_Echa<=MaxSCEcha; n_Echa++)       //  n_Echa   = 1 to 25    (MaxSCEcha = 25) 
01111             {
01112               for(Int_t idir=0; idir<2; idir++)
01113                 {
01114                   Int_t ikSC = kSC / Nb_DeeSC_JY;                 //  ikSC = 0 to 9
01115                   Int_t jkSC = kSC % Nb_DeeSC_JY;                 //  jkSC = 0,1,2,..,19 
01116                   
01117                   Int_t icrys = ikSC*Nb_SCCrys_IX + fT2d_ich_IX[type[jkSC][idir]][n_Echa];
01118                   //  type[0->9][1->2] = 0,1,2,3
01119                   //  fT2d_ich_IX[0->3][1->25] = 0,1,2,3,4
01120                   //  icrys = 0 to 49  (=> IX)
01121                   
01122                   Int_t jcrys = jkSC*Nb_SCCrys_JY + fT2d_jch_JY[type[jkSC][idir]][n_Echa];
01123                   //  type[0->9][1->2] = 0,1,2,3
01124                   //  fT2d_jch_JY[0->3][1->25] = 0,1,2,3,4
01125                   //  jcrys = 0 to 99  (=> IY)
01126                   
01127                   Int_t n_DeeCrys = icrys*Nb_DeeSC_JY*Nb_SCCrys_JY+jcrys+1;    //  n_DeeCrys = 1 to 5000
01128                   
01129                   fT3dDeeCrys[kSC][n_Echa-1][idir] = n_DeeCrys;   // fT3dDeeCrys[][][] : range = [1,5000]
01130                   fT2dDeeSC[n_DeeCrys-1][idir]     = kSC+1;       // fT2dDeeSC[][]     : range = [1,200]
01131                   fT2dSCEcha[n_DeeCrys-1][idir]    = n_Echa;      // fT2dSCEcha[][]    : range = [1,25]
01132                 }
01133             }
01134         }
01135       // cout << "#TEcnaNumbering::TBuildEndcapCrysTable()> Crys Table Building done" << endl;
01136 
01137       delete [] type;                           fCdelete++;
01138       delete [] type_d1;                        fCdelete++;
01139     }
01140   else
01141     {
01142       // cout << "#TEcnaNumbering::TBuildEndcapCrysTable()> No Building of Crys Table since it is already done " << endl;
01143     }
01144 }
01145 
01146 void TEcnaNumbering::BuildEndcapSCTable()
01147 {
01148 // Build the correspondance table: (Dee, DeeSC) <-> (DS , DSSC) for the ECAL ENDCAP
01149 //
01150 //  From CMS Internal Note  "CMS ECAL Endcap channel numbering"
01151 //
01152 //       Name       Number                     Reference set    Range     Comment
01153 //
01154 //       Dee      : Dee number                                  [1,4]
01155 //       DeeSC    : Super-Crystal (SC) number  in Dee           [1,200]   (IY,IX) progression
01156 //       DS       : Data Sector number         in EE + or -     [1,9]     (IY,IX) progression
01157 //       DSSC     : Super-Crystal (SC) number  in Data Sector   [1,32]    Crystal numbering in data sector
01158 //       DeeSCCons: Super-Crystal (SC) number  for construction [1,297]                      
01159 // 
01160 //   fill the 2d arrays:  fT2d_DS[4][200], fT2d_DSSC[4][200] and fT2d_DeeSCCons[4][200]
01161 //
01162 //------------------------------------------------------------------------------------------------------
01163 
01164 //.................. Allocations and Init
01165   Int_t MaxEEDee       = fEcal->MaxDeeInEE();
01166   Int_t MaxDeeSC       = fEcal->MaxSCEcnaInDee();
01167   Int_t MaxEESCForCons = 2*fEcal->MaxSCForConsInDee();
01168 
01169   fT2d_DS = new Int_t*[MaxEEDee];                       fCnew++;    // = DS[Dee - 1, CNA_SCInDee - 1]
01170   fT1d_DS = new  Int_t[MaxEEDee*MaxDeeSC];              fCnew++;
01171   for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
01172     fT2d_DS[i_DeeCrys] = &fT1d_DS[0] + i_DeeCrys*MaxDeeSC;}
01173   for(Int_t i=0; i<MaxEEDee; i++)
01174     {for(Int_t j=0; j<MaxDeeSC; j++){fT2d_DS[i][j]=0;}}
01175 
01176   fT2d_DSSC = new Int_t*[MaxEEDee];                     fCnew++;    // = SCInDS[Dee - 1, CNA_SCInDee - 1]  
01177   fT1d_DSSC = new  Int_t[MaxEEDee*MaxDeeSC];            fCnew++;
01178   for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
01179     fT2d_DSSC[i_DeeCrys] = &fT1d_DSSC[0] + i_DeeCrys*MaxDeeSC;}
01180   for(Int_t i=0; i<MaxEEDee; i++)
01181     {for(Int_t j=0; j<MaxDeeSC; j++){fT2d_DSSC[i][j]=0;}}
01182 
01183   fT2d_DeeSCCons = new Int_t*[MaxEEDee];                fCnew++;    // = SCConsInDee[Dee - 1, CNA_SCInDee - 1]
01184   fT1d_DeeSCCons = new  Int_t[MaxEEDee*MaxDeeSC];       fCnew++;
01185   for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
01186     fT2d_DeeSCCons[i_DeeCrys] = &fT1d_DeeSCCons[0] + i_DeeCrys*MaxDeeSC;}
01187   for(Int_t i=0; i<MaxEEDee; i++)
01188     {for(Int_t j=0; j<MaxDeeSC; j++){fT2d_DeeSCCons[i][j]=0;}}
01189 
01190   fT2d_RecovDeeSC = new Int_t*[MaxEEDee];               fCnew++;    // = CNA_SCInDee[Dee - 1, SCConsInDee - 1]
01191   fT1d_RecovDeeSC = new  Int_t[MaxEEDee*MaxEESCForCons];  fCnew++;
01192   for(Int_t i_DeeCrys = 0 ; i_DeeCrys < MaxEEDee ; i_DeeCrys++){
01193     fT2d_RecovDeeSC[i_DeeCrys] = &fT1d_RecovDeeSC[0] + i_DeeCrys*MaxEESCForCons;}
01194   for(Int_t i=0; i<MaxEEDee; i++)
01195     {for(Int_t j=0; j<MaxEESCForCons; j++){fT2d_RecovDeeSC[i][j]=0;}}
01196 
01197   //.............................. Data sector (DS) numbers: fT2d_DS[][]
01198   //                               isc = ECNA numbers
01199 
01200   Int_t ids = 0;
01201 
01202   //........... (D1,S1)=(D2,S9)=(D3,S9)=(D4,S1)
01203   for(Int_t dee = 1; dee<=4; dee++)
01204     {
01205       if( dee == 1 || dee == 4 ){ids = 1;}
01206       if( dee == 2 || dee == 3 ){ids = 9;}
01207       for(Int_t isc= 13; isc<= 20; isc++)fT2d_DS[dee-1][isc-1] = ids;
01208       for(Int_t isc= 33; isc<= 40; isc++)fT2d_DS[dee-1][isc-1] = ids;
01209       for(Int_t isc= 54; isc<= 60; isc++)fT2d_DS[dee-1][isc-1] = ids;
01210       for(Int_t isc= 75; isc<= 79; isc++)fT2d_DS[dee-1][isc-1] = ids;
01211       for(Int_t isc= 96; isc<= 99; isc++)fT2d_DS[dee-1][isc-1] = ids;
01212       for(Int_t isc=118; isc<=119; isc++)fT2d_DS[dee-1][isc-1] = ids;
01213     }
01214   //........... (D1,S2)=(D2,S8)=(D3,S8)=(D4,S2)
01215   for(Int_t dee = 1; dee<=4; dee++)
01216     {
01217       if( dee == 1 || dee == 4 ){ids = 2;}
01218       if( dee == 2 || dee == 3 ){ids = 8;}
01219       for(Int_t isc= 32; isc<= 32; isc++)fT2d_DS[dee-1][isc-1] = ids;
01220       for(Int_t isc= 51; isc<= 53; isc++)fT2d_DS[dee-1][isc-1] = ids;
01221       for(Int_t isc= 72; isc<= 74; isc++)fT2d_DS[dee-1][isc-1] = ids;
01222       for(Int_t isc= 92; isc<= 95; isc++)fT2d_DS[dee-1][isc-1] = ids;
01223       for(Int_t isc=112; isc<=117; isc++)fT2d_DS[dee-1][isc-1] = ids;
01224       for(Int_t isc=132; isc<=138; isc++)fT2d_DS[dee-1][isc-1] = ids;
01225       for(Int_t isc=152; isc<=157; isc++)fT2d_DS[dee-1][isc-1] = ids;
01226       for(Int_t isc=173; isc<=176; isc++)fT2d_DS[dee-1][isc-1] = ids;
01227       for(Int_t isc=193; isc<=193; isc++)fT2d_DS[dee-1][isc-1] = ids;
01228     }
01229   //........... (D1,S3)=(D2,S7)=(D3,S7)=(D4,S3)
01230   for(Int_t dee = 1; dee<=4; dee++)
01231     {
01232       if( dee == 1 || dee == 4 ){ids = 3;}
01233       if( dee == 2 || dee == 3 ){ids = 7;}
01234       for(Int_t isc= 50; isc<= 50; isc++)fT2d_DS[dee-1][isc-1] = ids;
01235       for(Int_t isc= 69; isc<= 71; isc++)fT2d_DS[dee-1][isc-1] = ids;
01236       for(Int_t isc= 88; isc<= 91; isc++)fT2d_DS[dee-1][isc-1] = ids;
01237       for(Int_t isc=108; isc<=111; isc++)fT2d_DS[dee-1][isc-1] = ids;
01238       for(Int_t isc=127; isc<=131; isc++)fT2d_DS[dee-1][isc-1] = ids;
01239       for(Int_t isc=147; isc<=151; isc++)fT2d_DS[dee-1][isc-1] = ids;
01240       for(Int_t isc=166; isc<=172; isc++)fT2d_DS[dee-1][isc-1] = ids;
01241       for(Int_t isc=188; isc<=192; isc++)fT2d_DS[dee-1][isc-1] = ids;
01242     }
01243   //........... (D1,S4)=(D2,S6)=(D3,S6)=(D4,S4)
01244   for(Int_t dee = 1; dee<=4; dee++)
01245     {
01246       if( dee == 1 || dee == 4 ){ids = 4;}
01247       if( dee == 2 || dee == 3 ){ids = 6;}
01248       for(Int_t isc= 27; isc<= 29; isc++)fT2d_DS[dee-1][isc-1] = ids;
01249       for(Int_t isc= 44; isc<= 49; isc++)fT2d_DS[dee-1][isc-1] = ids;
01250       for(Int_t isc= 62; isc<= 68; isc++)fT2d_DS[dee-1][isc-1] = ids;
01251       for(Int_t isc= 82; isc<= 87; isc++)fT2d_DS[dee-1][isc-1] = ids;
01252       for(Int_t isc=102; isc<=107; isc++)fT2d_DS[dee-1][isc-1] = ids;
01253       for(Int_t isc=123; isc<=126; isc++)fT2d_DS[dee-1][isc-1] = ids;
01254       for(Int_t isc=144; isc<=146; isc++)fT2d_DS[dee-1][isc-1] = ids;
01255       for(Int_t isc=165; isc<=165; isc++)fT2d_DS[dee-1][isc-1] = ids;
01256     }
01257   //........... (D1,S5)=(D2,S5)=(D3,S5)=(D4,S5)
01258   for(Int_t dee = 1; dee<=4; dee++)
01259     {
01260       for(Int_t isc=  1; isc<=  8; isc++)fT2d_DS[dee-1][isc-1] = 5;
01261       for(Int_t isc= 21; isc<= 26; isc++)fT2d_DS[dee-1][isc-1] = 5;
01262       for(Int_t isc= 41; isc<= 43; isc++)fT2d_DS[dee-1][isc-1] = 5;
01263     }
01264   
01265   //............................................ SC numbers in Data Sectors: fT2d_DSSC[][]
01266   //                                             fT2d_DSSC[dee-1][SC ECNA number - 1] = SC number in DS;
01267   for(Int_t dee=1; dee<=4; dee++)
01268     {
01269       for(Int_t isc=1; isc<=MaxDeeSC; isc++)
01270         {fT2d_DSSC[dee-1][isc-1] = -1;}
01271       //.......................................... S1 (D1,D4), S9 (D2,D3) ; 33 SC's
01272       fT2d_DSSC[dee-1][13-1] = 12;
01273       fT2d_DSSC[dee-1][14-1] = 11;
01274       fT2d_DSSC[dee-1][15-1] = 10;
01275       fT2d_DSSC[dee-1][16-1] =  9;
01276       fT2d_DSSC[dee-1][17-1] =  4;
01277       fT2d_DSSC[dee-1][18-1] =  3;
01278       fT2d_DSSC[dee-1][19-1] =  2;
01279       fT2d_DSSC[dee-1][20-1] =  1;
01280 
01281       fT2d_DSSC[dee-1][33-1] = 16;
01282       fT2d_DSSC[dee-1][34-1] = 15;
01283       fT2d_DSSC[dee-1][35-1] = 14;
01284       fT2d_DSSC[dee-1][36-1] = 13;
01285       fT2d_DSSC[dee-1][37-1] =  8;
01286       fT2d_DSSC[dee-1][38-1] =  7;
01287       fT2d_DSSC[dee-1][39-1] =  6;
01288       fT2d_DSSC[dee-1][40-1] =  5;
01289 
01290       fT2d_DSSC[dee-1][54-1] = 33;
01291       fT2d_DSSC[dee-1][55-1] = 31;
01292       fT2d_DSSC[dee-1][56-1] = 27;
01293       fT2d_DSSC[dee-1][57-1] = 24;
01294       fT2d_DSSC[dee-1][58-1] = 20;
01295       fT2d_DSSC[dee-1][59-1] = 17;
01296       fT2d_DSSC[dee-1][60-1] = 30;  //  (182a, 33a for construction)
01297       
01298       fT2d_DSSC[dee-1][75-1] = 32;
01299       fT2d_DSSC[dee-1][76-1] = 28;
01300       fT2d_DSSC[dee-1][77-1] = 25;
01301       fT2d_DSSC[dee-1][78-1] = 21;
01302       fT2d_DSSC[dee-1][79-1] = 18;
01303       
01304       fT2d_DSSC[dee-1][96-1] = 29;
01305       fT2d_DSSC[dee-1][97-1] = 26;
01306       fT2d_DSSC[dee-1][98-1] = 22;
01307       fT2d_DSSC[dee-1][99-1] = 19;
01308 
01309       fT2d_DSSC[dee-1][118-1] = 23;
01310       fT2d_DSSC[dee-1][119-1] = 30;  //  (182b, 33b for construction)
01311 
01312       //.......................................... S2 (D1,D4), S8(D2,D3) ; 32 SC's
01313       fT2d_DSSC[dee-1][32-1] = 25;  // also 3;  // ( (207c, 58c) also (178c, 29c) for construction)
01314 
01315       fT2d_DSSC[dee-1][51-1] = 32;
01316       fT2d_DSSC[dee-1][52-1] = 26;
01317       fT2d_DSSC[dee-1][53-1] = 18;
01318 
01319       fT2d_DSSC[dee-1][72-1] = 27;
01320       fT2d_DSSC[dee-1][73-1] = 19;
01321       fT2d_DSSC[dee-1][74-1] = 12;
01322       
01323       fT2d_DSSC[dee-1][92-1] = 28;
01324       fT2d_DSSC[dee-1][93-1] = 20;
01325       fT2d_DSSC[dee-1][94-1] = 13;
01326       fT2d_DSSC[dee-1][95-1] =  7;
01327 
01328       fT2d_DSSC[dee-1][112-1] = 29;
01329       fT2d_DSSC[dee-1][113-1] = 21;
01330       fT2d_DSSC[dee-1][114-1] = 14;
01331       fT2d_DSSC[dee-1][115-1] =  8;
01332       fT2d_DSSC[dee-1][116-1] =  4;
01333       fT2d_DSSC[dee-1][117-1] =  1;
01334 
01335       fT2d_DSSC[dee-1][132-1] = 30;
01336       fT2d_DSSC[dee-1][133-1] = 22;
01337       fT2d_DSSC[dee-1][134-1] = 15;
01338       fT2d_DSSC[dee-1][135-1] =  9;
01339       fT2d_DSSC[dee-1][136-1] =  5;
01340       fT2d_DSSC[dee-1][137-1] =  2;
01341       fT2d_DSSC[dee-1][138-1] =  3;  // (178a, 29a for construction)
01342 
01343       fT2d_DSSC[dee-1][152-1] = 31;
01344       fT2d_DSSC[dee-1][153-1] = 23;
01345       fT2d_DSSC[dee-1][154-1] = 16;
01346       fT2d_DSSC[dee-1][155-1] = 10;
01347       fT2d_DSSC[dee-1][156-1] =  6;
01348       fT2d_DSSC[dee-1][157-1] =  3;  // (178b, 29b for construction)
01349 
01350       fT2d_DSSC[dee-1][173-1] = 24;
01351       fT2d_DSSC[dee-1][174-1] = 17;
01352       fT2d_DSSC[dee-1][175-1] = 11;
01353       fT2d_DSSC[dee-1][176-1] = 25;  // (207a, 58a for construction)
01354 
01355       fT2d_DSSC[dee-1][193-1] = 25;  // (207b, 58b for construction)
01356 
01357       //.......................................... S3 (D1,D4), S7 (D2,D3)  ; 34 SC's
01358       fT2d_DSSC[dee-1][50-1] = 10;
01359 
01360       fT2d_DSSC[dee-1][69-1] = 18;
01361       fT2d_DSSC[dee-1][70-1] = 11;
01362       fT2d_DSSC[dee-1][71-1] =  3;
01363 
01364       fT2d_DSSC[dee-1][88-1] = 25;
01365       fT2d_DSSC[dee-1][89-1] = 19;
01366       fT2d_DSSC[dee-1][90-1] = 12;
01367       fT2d_DSSC[dee-1][91-1] =  4;
01368 
01369       fT2d_DSSC[dee-1][108-1] = 26;
01370       fT2d_DSSC[dee-1][109-1] = 20;
01371       fT2d_DSSC[dee-1][110-1] = 13;
01372       fT2d_DSSC[dee-1][111-1] =  5;
01373 
01374       fT2d_DSSC[dee-1][127-1] = 31;
01375       fT2d_DSSC[dee-1][128-1] = 27;
01376       fT2d_DSSC[dee-1][129-1] = 21;
01377       fT2d_DSSC[dee-1][130-1] = 14;
01378       fT2d_DSSC[dee-1][131-1] =  6;
01379 
01380       fT2d_DSSC[dee-1][147-1] = 32;
01381       fT2d_DSSC[dee-1][148-1] = 28;
01382       fT2d_DSSC[dee-1][149-1] = 22;
01383       fT2d_DSSC[dee-1][150-1] = 15;
01384       fT2d_DSSC[dee-1][151-1] =  7;
01385 
01386       fT2d_DSSC[dee-1][166-1] = 33;
01387       fT2d_DSSC[dee-1][167-1] = 30;
01388       fT2d_DSSC[dee-1][168-1] = 29;
01389       fT2d_DSSC[dee-1][169-1] = 23;
01390       fT2d_DSSC[dee-1][170-1] = 16;
01391       fT2d_DSSC[dee-1][171-1] =  8;
01392       fT2d_DSSC[dee-1][172-1] =  1;
01393 
01394       fT2d_DSSC[dee-1][188-1] = 34; // (298a, 149a for construction)
01395       fT2d_DSSC[dee-1][189-1] = 24;
01396       fT2d_DSSC[dee-1][190-1] = 17;
01397       fT2d_DSSC[dee-1][191-1] =  9;
01398       fT2d_DSSC[dee-1][192-1] =  2;
01399 
01400       //.......................................... S4 (D1,D4), S6 (D2,D3) ; 33 SC's
01401       fT2d_DSSC[dee-1][27-1] = 33;
01402       fT2d_DSSC[dee-1][28-1] = 32;
01403       fT2d_DSSC[dee-1][29-1] = 14; // also 21;  //  ( (261a, 112a) also (268a, 119a) for construction)
01404 
01405       fT2d_DSSC[dee-1][44-1] = 22;
01406       fT2d_DSSC[dee-1][45-1] = 15;
01407       fT2d_DSSC[dee-1][46-1] =  8;
01408       fT2d_DSSC[dee-1][47-1] =  4;
01409       fT2d_DSSC[dee-1][48-1] =  2;
01410       fT2d_DSSC[dee-1][49-1] =  1;
01411 
01412       fT2d_DSSC[dee-1][62-1] = 29;
01413       fT2d_DSSC[dee-1][63-1] = 28;
01414       fT2d_DSSC[dee-1][64-1] = 23;
01415       fT2d_DSSC[dee-1][65-1] = 16;
01416       fT2d_DSSC[dee-1][66-1] =  9;
01417       fT2d_DSSC[dee-1][67-1] =  5;
01418       fT2d_DSSC[dee-1][68-1] =  3;
01419 
01420       fT2d_DSSC[dee-1][82-1] = 31;
01421       fT2d_DSSC[dee-1][83-1] = 30;
01422       fT2d_DSSC[dee-1][84-1] = 24;
01423       fT2d_DSSC[dee-1][85-1] = 17;
01424       fT2d_DSSC[dee-1][86-1] = 10;
01425       fT2d_DSSC[dee-1][87-1] =  6;
01426 
01427       fT2d_DSSC[dee-1][102-1] = 21;  //   (268c, 119c for construction)
01428       fT2d_DSSC[dee-1][103-1] = 27;
01429       fT2d_DSSC[dee-1][104-1] = 25;
01430       fT2d_DSSC[dee-1][105-1] = 18;
01431       fT2d_DSSC[dee-1][106-1] = 11;
01432       fT2d_DSSC[dee-1][107-1] =  7;
01433 
01434       fT2d_DSSC[dee-1][123-1] = 21;  //   (268b, 119b for construction)
01435       fT2d_DSSC[dee-1][124-1] = 26;
01436       fT2d_DSSC[dee-1][125-1] = 19;
01437       fT2d_DSSC[dee-1][126-1] = 12;
01438 
01439       fT2d_DSSC[dee-1][144-1] = 14;  //   (261c, 112c for construction)
01440       fT2d_DSSC[dee-1][145-1] = 20;
01441       fT2d_DSSC[dee-1][146-1] = 13;
01442 
01443       fT2d_DSSC[dee-1][165-1] = 14;  //   (261b, 112b for construction)
01444 
01445       //.......................................... S5   (2*17 = 34 SC's)
01446       if(dee == 1 || dee == 3)
01447         {
01448           fT2d_DSSC[dee-1][1-1] = 34;
01449           fT2d_DSSC[dee-1][2-1] = 33;
01450           fT2d_DSSC[dee-1][3-1] = 32;
01451           fT2d_DSSC[dee-1][4-1] = 31;
01452           fT2d_DSSC[dee-1][5-1] = 26;
01453           fT2d_DSSC[dee-1][6-1] = 25;
01454           fT2d_DSSC[dee-1][7-1] = 24;
01455           fT2d_DSSC[dee-1][8-1] = 23;
01456 
01457           fT2d_DSSC[dee-1][21-1] = 30;
01458           fT2d_DSSC[dee-1][22-1] = 29;
01459           fT2d_DSSC[dee-1][23-1] = 28;
01460           fT2d_DSSC[dee-1][24-1] = 27;
01461           fT2d_DSSC[dee-1][25-1] = 22;
01462           fT2d_DSSC[dee-1][26-1] = 21;
01463 
01464           fT2d_DSSC[dee-1][41-1] = 20;  //   (281a for construction)
01465           fT2d_DSSC[dee-1][42-1] = 19;
01466           fT2d_DSSC[dee-1][43-1] = 18;
01467         }
01468 
01469       if(dee == 2 || dee == 4)
01470         {
01471           fT2d_DSSC[dee-1][1-1] = 17;
01472           fT2d_DSSC[dee-1][2-1] = 16;
01473           fT2d_DSSC[dee-1][3-1] = 15;
01474           fT2d_DSSC[dee-1][4-1] = 14;
01475           fT2d_DSSC[dee-1][5-1] =  9;
01476           fT2d_DSSC[dee-1][6-1] =  8;
01477           fT2d_DSSC[dee-1][7-1] =  7;
01478           fT2d_DSSC[dee-1][8-1] =  6;
01479 
01480           fT2d_DSSC[dee-1][21-1] = 13;
01481           fT2d_DSSC[dee-1][22-1] = 12;
01482           fT2d_DSSC[dee-1][23-1] = 11;
01483           fT2d_DSSC[dee-1][24-1] = 10;
01484           fT2d_DSSC[dee-1][25-1] =  5;
01485           fT2d_DSSC[dee-1][26-1] =  4;
01486 
01487           fT2d_DSSC[dee-1][41-1] = 3;  //   (132a for construction)
01488           fT2d_DSSC[dee-1][42-1] = 2;
01489           fT2d_DSSC[dee-1][43-1] = 1;
01490         }
01491     }
01492   //............................... Numbers for construction: fT2d_DeeSCCons[][]
01493   //                                fT2d_DeeSCCons[dee-1][SC ECNA number - 1] = SC number for construction;
01494 
01495   //............................... init to -1
01496   for(Int_t dee=1; dee<=4; dee++)
01497     {for(Int_t isc=1; isc<=MaxDeeSC; isc++)
01498         {fT2d_DeeSCCons[dee-1][isc-1] = -1;}}
01499 
01500   for(Int_t i_dee_type=1; i_dee_type<=2; i_dee_type++)
01501     {
01502       Int_t dee = -1;
01503       if( i_dee_type == 1 ){dee = 1;}
01504       if( i_dee_type == 2 ){dee = 3;}
01505       
01506       //.......................................... (D1,S1 or D3,S9) AND (D2,S9 or D4,S1)
01507       //  number in comment = fT2d_DSSC[dee-1][SC ECNA nb - 1] (= SC number in DS)
01508       fT2d_DeeSCCons[dee-1][13-1] = 161; fT2d_DeeSCCons[dee][13-1] = 12; // 12;
01509       fT2d_DeeSCCons[dee-1][14-1] = 160; fT2d_DeeSCCons[dee][14-1] = 11; // 11;
01510       fT2d_DeeSCCons[dee-1][15-1] = 159; fT2d_DeeSCCons[dee][15-1] = 10; // 10;
01511       fT2d_DeeSCCons[dee-1][16-1] = 158; fT2d_DeeSCCons[dee][16-1] =  9; //  9;
01512       fT2d_DeeSCCons[dee-1][17-1] = 153; fT2d_DeeSCCons[dee][17-1] =  4; //  4;
01513       fT2d_DeeSCCons[dee-1][18-1] = 152; fT2d_DeeSCCons[dee][18-1] =  3; //  3;
01514       fT2d_DeeSCCons[dee-1][19-1] = 151; fT2d_DeeSCCons[dee][19-1] =  2; //  2;
01515       fT2d_DeeSCCons[dee-1][20-1] = 150; fT2d_DeeSCCons[dee][20-1] =  1; //  1;
01516       
01517       fT2d_DeeSCCons[dee-1][33-1] = 165; fT2d_DeeSCCons[dee][33-1] = 16; // 16;
01518       fT2d_DeeSCCons[dee-1][34-1] = 164; fT2d_DeeSCCons[dee][34-1] = 15; // 15;
01519       fT2d_DeeSCCons[dee-1][35-1] = 163; fT2d_DeeSCCons[dee][35-1] = 14; // 14;
01520       fT2d_DeeSCCons[dee-1][36-1] = 162; fT2d_DeeSCCons[dee][36-1] = 13; // 13;
01521       fT2d_DeeSCCons[dee-1][37-1] = 157; fT2d_DeeSCCons[dee][37-1] =  8; //  8;
01522       fT2d_DeeSCCons[dee-1][38-1] = 156; fT2d_DeeSCCons[dee][38-1] =  7; //  7;
01523       fT2d_DeeSCCons[dee-1][39-1] = 155; fT2d_DeeSCCons[dee][39-1] =  6; //  6;
01524       fT2d_DeeSCCons[dee-1][40-1] = 154; fT2d_DeeSCCons[dee][40-1] =  5; //  5;
01525       
01526       fT2d_DeeSCCons[dee-1][54-1] = 193; fT2d_DeeSCCons[dee][54-1] = 44; // 33; 
01527       fT2d_DeeSCCons[dee-1][55-1] = 186; fT2d_DeeSCCons[dee][55-1] = 37; // 31;
01528       fT2d_DeeSCCons[dee-1][56-1] = 179; fT2d_DeeSCCons[dee][56-1] = 30; // 27;
01529       fT2d_DeeSCCons[dee-1][57-1] = 173; fT2d_DeeSCCons[dee][57-1] = 24; // 24;
01530       fT2d_DeeSCCons[dee-1][58-1] = 169; fT2d_DeeSCCons[dee][58-1] = 20; // 20;
01531       fT2d_DeeSCCons[dee-1][59-1] = 166; fT2d_DeeSCCons[dee][59-1] = 17; // 17;
01532       fT2d_DeeSCCons[dee-1][60-1] = 182; fT2d_DeeSCCons[dee][60-1] = 33; // 30;    // 182a ;  33a;
01533 
01534       fT2d_DeeSCCons[dee-1][75-1] = 187; fT2d_DeeSCCons[dee][75-1] = 38; // 32;
01535       fT2d_DeeSCCons[dee-1][76-1] = 180; fT2d_DeeSCCons[dee][76-1] = 31; // 28;
01536       fT2d_DeeSCCons[dee-1][77-1] = 174; fT2d_DeeSCCons[dee][77-1] = 25; // 25;
01537       fT2d_DeeSCCons[dee-1][78-1] = 170; fT2d_DeeSCCons[dee][78-1] = 21; // 21;
01538       fT2d_DeeSCCons[dee-1][79-1] = 167; fT2d_DeeSCCons[dee][79-1] = 18; // 18;
01539       
01540       fT2d_DeeSCCons[dee-1][96-1] = 181; fT2d_DeeSCCons[dee][96-1] = 32; // 29;
01541       fT2d_DeeSCCons[dee-1][97-1] = 175; fT2d_DeeSCCons[dee][97-1] = 26; // 26;
01542       fT2d_DeeSCCons[dee-1][98-1] = 171; fT2d_DeeSCCons[dee][98-1] = 22; // 22;
01543       fT2d_DeeSCCons[dee-1][99-1] = 168; fT2d_DeeSCCons[dee][99-1] = 19; // 19;
01544       
01545       fT2d_DeeSCCons[dee-1][118-1] = 172; fT2d_DeeSCCons[dee][118-1] = 23; // 23;
01546       fT2d_DeeSCCons[dee-1][119-1] = 182; fT2d_DeeSCCons[dee][119-1] = 33; // 30;    // 182b ;  33b;
01547      
01548       //.......................................... (D1,S2 or D3,S8) AND (D2,S8 or D4,S2)
01549       fT2d_DeeSCCons[dee-1][32-1] = 178; fT2d_DeeSCCons[dee][32-1] = 29; // 25-3;   // 178c-207c ; 29c-58c;
01550 
01551       fT2d_DeeSCCons[dee-1][51-1] = 216; fT2d_DeeSCCons[dee][51-1] = 67; // 32;
01552       fT2d_DeeSCCons[dee-1][52-1] = 208; fT2d_DeeSCCons[dee][52-1] = 59; // 26;
01553       fT2d_DeeSCCons[dee-1][53-1] = 200; fT2d_DeeSCCons[dee][53-1] = 51; // 18;
01554       
01555       fT2d_DeeSCCons[dee-1][72-1] = 209; fT2d_DeeSCCons[dee][72-1] = 60; // 27;
01556       fT2d_DeeSCCons[dee-1][73-1] = 201; fT2d_DeeSCCons[dee][73-1] = 52; // 19;
01557       fT2d_DeeSCCons[dee-1][74-1] = 194; fT2d_DeeSCCons[dee][74-1] = 45; // 12;
01558       
01559       fT2d_DeeSCCons[dee-1][92-1] = 210; fT2d_DeeSCCons[dee][92-1] = 61; // 28;
01560       fT2d_DeeSCCons[dee-1][93-1] = 202; fT2d_DeeSCCons[dee][93-1] = 53; // 20;
01561       fT2d_DeeSCCons[dee-1][94-1] = 195; fT2d_DeeSCCons[dee][94-1] = 46; // 13;
01562       fT2d_DeeSCCons[dee-1][95-1] = 188; fT2d_DeeSCCons[dee][95-1] = 39; //  7;
01563       
01564       fT2d_DeeSCCons[dee-1][112-1] = 211; fT2d_DeeSCCons[dee][112-1] = 62; // 29;
01565       fT2d_DeeSCCons[dee-1][113-1] = 203; fT2d_DeeSCCons[dee][113-1] = 54; // 21;
01566       fT2d_DeeSCCons[dee-1][114-1] = 196; fT2d_DeeSCCons[dee][114-1] = 47; // 14;
01567       fT2d_DeeSCCons[dee-1][115-1] = 189; fT2d_DeeSCCons[dee][115-1] = 40; //  8;
01568       fT2d_DeeSCCons[dee-1][116-1] = 183; fT2d_DeeSCCons[dee][116-1] = 34; //  4;
01569       fT2d_DeeSCCons[dee-1][117-1] = 176; fT2d_DeeSCCons[dee][117-1] = 27; //  1;
01570       
01571       fT2d_DeeSCCons[dee-1][132-1] = 212; fT2d_DeeSCCons[dee][132-1] = 63; // 30;
01572       fT2d_DeeSCCons[dee-1][133-1] = 204; fT2d_DeeSCCons[dee][133-1] = 55; // 22;
01573       fT2d_DeeSCCons[dee-1][134-1] = 197; fT2d_DeeSCCons[dee][134-1] = 48; // 15;
01574       fT2d_DeeSCCons[dee-1][135-1] = 190; fT2d_DeeSCCons[dee][135-1] = 41; //  9;
01575       fT2d_DeeSCCons[dee-1][136-1] = 184; fT2d_DeeSCCons[dee][136-1] = 35; //  5;
01576       fT2d_DeeSCCons[dee-1][137-1] = 177; fT2d_DeeSCCons[dee][137-1] = 28; //  2;
01577       fT2d_DeeSCCons[dee-1][138-1] = 178; fT2d_DeeSCCons[dee][138-1] = 29; //  3; //  178a ;  29a;
01578       
01579       fT2d_DeeSCCons[dee-1][152-1] = 213; fT2d_DeeSCCons[dee][152-1] = 64; // 31;
01580       fT2d_DeeSCCons[dee-1][153-1] = 205; fT2d_DeeSCCons[dee][153-1] = 56; // 23;
01581       fT2d_DeeSCCons[dee-1][154-1] = 198; fT2d_DeeSCCons[dee][154-1] = 49; // 16;
01582       fT2d_DeeSCCons[dee-1][155-1] = 191; fT2d_DeeSCCons[dee][155-1] = 42; // 10;
01583       fT2d_DeeSCCons[dee-1][156-1] = 185; fT2d_DeeSCCons[dee][156-1] = 36; //  6;
01584       fT2d_DeeSCCons[dee-1][157-1] = 178; fT2d_DeeSCCons[dee][157-1] = 29; //  3; //  178b ;  29b;
01585       
01586       fT2d_DeeSCCons[dee-1][173-1] = 206; fT2d_DeeSCCons[dee][173-1] = 57; // 24;
01587       fT2d_DeeSCCons[dee-1][174-1] = 199; fT2d_DeeSCCons[dee][174-1] = 50; // 17;
01588       fT2d_DeeSCCons[dee-1][175-1] = 192; fT2d_DeeSCCons[dee][175-1] = 43; // 11;
01589       fT2d_DeeSCCons[dee-1][176-1] = 207; fT2d_DeeSCCons[dee][176-1] = 58; // 25; //  58a ;  207a;
01590  
01591       fT2d_DeeSCCons[dee-1][193-1] = 207; fT2d_DeeSCCons[dee][193-1] = 58; // 25; //  58b ;  207b;
01592     
01593       //.......................................... (D1,S3 or D3,S7) AND  (D2,S7 or D4,S3) 
01594       fT2d_DeeSCCons[dee-1][50-1] = 224; fT2d_DeeSCCons[dee][50-1] = 75; // 10;
01595       
01596       fT2d_DeeSCCons[dee-1][69-1] = 233; fT2d_DeeSCCons[dee][69-1] = 84; // 18;
01597       fT2d_DeeSCCons[dee-1][70-1] = 225; fT2d_DeeSCCons[dee][70-1] = 76; // 11;
01598       fT2d_DeeSCCons[dee-1][71-1] = 217; fT2d_DeeSCCons[dee][71-1] = 68; //  3;
01599       
01600       fT2d_DeeSCCons[dee-1][88-1] = 242; fT2d_DeeSCCons[dee][88-1] = 93; // 25;
01601       fT2d_DeeSCCons[dee-1][89-1] = 234; fT2d_DeeSCCons[dee][89-1] = 85; // 19;
01602       fT2d_DeeSCCons[dee-1][90-1] = 226; fT2d_DeeSCCons[dee][90-1] = 77; // 12;
01603       fT2d_DeeSCCons[dee-1][91-1] = 218; fT2d_DeeSCCons[dee][91-1] = 69; //  4;
01604       
01605       fT2d_DeeSCCons[dee-1][108-1] = 243; fT2d_DeeSCCons[dee][108-1] = 94; // 26;
01606       fT2d_DeeSCCons[dee-1][109-1] = 235; fT2d_DeeSCCons[dee][109-1] = 86; // 20;
01607       fT2d_DeeSCCons[dee-1][110-1] = 227; fT2d_DeeSCCons[dee][110-1] = 78; // 13;
01608       fT2d_DeeSCCons[dee-1][111-1] = 219; fT2d_DeeSCCons[dee][111-1] = 70; //  5;
01609       
01610       fT2d_DeeSCCons[dee-1][127-1] = 252; fT2d_DeeSCCons[dee][127-1] = 103; // 31;
01611       fT2d_DeeSCCons[dee-1][128-1] = 244; fT2d_DeeSCCons[dee][128-1] =  95; // 27;
01612       fT2d_DeeSCCons[dee-1][129-1] = 236; fT2d_DeeSCCons[dee][129-1] =  87; // 21;
01613       fT2d_DeeSCCons[dee-1][130-1] = 228; fT2d_DeeSCCons[dee][130-1] =  79; // 14;
01614       fT2d_DeeSCCons[dee-1][131-1] = 220; fT2d_DeeSCCons[dee][131-1] =  71; //  6;
01615       
01616       fT2d_DeeSCCons[dee-1][147-1] = 253; fT2d_DeeSCCons[dee][147-1] = 104; // 32;
01617       fT2d_DeeSCCons[dee-1][148-1] = 245; fT2d_DeeSCCons[dee][148-1] =  96; // 28;
01618       fT2d_DeeSCCons[dee-1][149-1] = 237; fT2d_DeeSCCons[dee][149-1] =  88; // 22;
01619       fT2d_DeeSCCons[dee-1][150-1] = 229; fT2d_DeeSCCons[dee][150-1] =  80; // 15;
01620       fT2d_DeeSCCons[dee-1][151-1] = 221; fT2d_DeeSCCons[dee][151-1] =  72; //  7;
01621       
01622       fT2d_DeeSCCons[dee-1][166-1] = 254; fT2d_DeeSCCons[dee][166-1] = 105; // 33;
01623       fT2d_DeeSCCons[dee-1][167-1] = 247; fT2d_DeeSCCons[dee][167-1] =  98; // 30;
01624       fT2d_DeeSCCons[dee-1][168-1] = 246; fT2d_DeeSCCons[dee][168-1] =  97; // 29;
01625       fT2d_DeeSCCons[dee-1][169-1] = 238; fT2d_DeeSCCons[dee][169-1] =  89; // 23;
01626       fT2d_DeeSCCons[dee-1][170-1] = 230; fT2d_DeeSCCons[dee][170-1] =  81; // 16;
01627       fT2d_DeeSCCons[dee-1][171-1] = 222; fT2d_DeeSCCons[dee][171-1] =  73; //  8;
01628       fT2d_DeeSCCons[dee-1][172-1] = 214; fT2d_DeeSCCons[dee][172-1] =  65; //  1;
01629       
01630       fT2d_DeeSCCons[dee-1][188-1] = 298; fT2d_DeeSCCons[dee][188-1] = 149; // 24; //  298a ;  149a;
01631       fT2d_DeeSCCons[dee-1][189-1] = 239; fT2d_DeeSCCons[dee][189-1] =  90; // 24;
01632       fT2d_DeeSCCons[dee-1][190-1] = 231; fT2d_DeeSCCons[dee][190-1] =  82; // 17;
01633       fT2d_DeeSCCons[dee-1][191-1] = 223; fT2d_DeeSCCons[dee][191-1] =  74; //  9;
01634       fT2d_DeeSCCons[dee-1][192-1] = 215; fT2d_DeeSCCons[dee][192-1] =  66; //  2;
01635   
01636       //.......................................... (D1,S4 or D3,S6) AND  (D2,S6 or D4,S4)
01637       fT2d_DeeSCCons[dee-1][29-1] = 261; fT2d_DeeSCCons[dee][29-1] = 112; // 14-21;   // 261a-268a ; 112a-119a;
01638       fT2d_DeeSCCons[dee-1][27-1] = 283; fT2d_DeeSCCons[dee][27-1] = 134; // 33;
01639       fT2d_DeeSCCons[dee-1][28-1] = 282; fT2d_DeeSCCons[dee][28-1] = 133; // 32;
01640       
01641       fT2d_DeeSCCons[dee-1][44-1] = 269; fT2d_DeeSCCons[dee][44-1] = 120; // 22;
01642       fT2d_DeeSCCons[dee-1][45-1] = 262; fT2d_DeeSCCons[dee][45-1] = 113; // 15;
01643       fT2d_DeeSCCons[dee-1][46-1] = 255; fT2d_DeeSCCons[dee][46-1] = 106; //  8;
01644       fT2d_DeeSCCons[dee-1][47-1] = 248; fT2d_DeeSCCons[dee][47-1] =  99; //  4;
01645       fT2d_DeeSCCons[dee-1][48-1] = 240; fT2d_DeeSCCons[dee][48-1] =  91; //  2;
01646       fT2d_DeeSCCons[dee-1][49-1] = 232; fT2d_DeeSCCons[dee][49-1] =  83; //  1;
01647       
01648       fT2d_DeeSCCons[dee-1][62-1] = 276; fT2d_DeeSCCons[dee][62-1] = 127; // 29;
01649       fT2d_DeeSCCons[dee-1][63-1] = 275; fT2d_DeeSCCons[dee][63-1] = 126; // 28;
01650       fT2d_DeeSCCons[dee-1][64-1] = 270; fT2d_DeeSCCons[dee][64-1] = 121; // 23;
01651       fT2d_DeeSCCons[dee-1][65-1] = 263; fT2d_DeeSCCons[dee][65-1] = 114; // 16;
01652       fT2d_DeeSCCons[dee-1][66-1] = 256; fT2d_DeeSCCons[dee][66-1] = 107; //  9;
01653       fT2d_DeeSCCons[dee-1][67-1] = 249; fT2d_DeeSCCons[dee][67-1] = 100; //  5;
01654       fT2d_DeeSCCons[dee-1][68-1] = 241; fT2d_DeeSCCons[dee][68-1] =  92; //  3;
01655       
01656       fT2d_DeeSCCons[dee-1][82-1] = 278; fT2d_DeeSCCons[dee][82-1] = 129; // 31;
01657       fT2d_DeeSCCons[dee-1][83-1] = 277; fT2d_DeeSCCons[dee][83-1] = 128; // 30;
01658       fT2d_DeeSCCons[dee-1][84-1] = 271; fT2d_DeeSCCons[dee][84-1] = 122; // 24;
01659       fT2d_DeeSCCons[dee-1][85-1] = 264; fT2d_DeeSCCons[dee][85-1] = 115; // 17;
01660       fT2d_DeeSCCons[dee-1][86-1] = 257; fT2d_DeeSCCons[dee][86-1] = 108; // 10;
01661       fT2d_DeeSCCons[dee-1][87-1] = 250; fT2d_DeeSCCons[dee][87-1] = 101; //  6;
01662       
01663       fT2d_DeeSCCons[dee-1][102-1] = 268; fT2d_DeeSCCons[dee][102-1] = 119; // 21; //  268c ;  119c;
01664       fT2d_DeeSCCons[dee-1][103-1] = 274; fT2d_DeeSCCons[dee][103-1] = 125; // 27;
01665       fT2d_DeeSCCons[dee-1][104-1] = 272; fT2d_DeeSCCons[dee][104-1] = 123; // 25;
01666       fT2d_DeeSCCons[dee-1][105-1] = 265; fT2d_DeeSCCons[dee][105-1] = 116; // 18;
01667       fT2d_DeeSCCons[dee-1][106-1] = 258; fT2d_DeeSCCons[dee][106-1] = 109; // 11;
01668       fT2d_DeeSCCons[dee-1][107-1] = 251; fT2d_DeeSCCons[dee][107-1] = 102; //  7;
01669       
01670       fT2d_DeeSCCons[dee-1][123-1] = 268; fT2d_DeeSCCons[dee][123-1] = 119; // 27; //  268b ;  119b;
01671       fT2d_DeeSCCons[dee-1][124-1] = 273; fT2d_DeeSCCons[dee][124-1] = 124; // 26;
01672       fT2d_DeeSCCons[dee-1][125-1] = 266; fT2d_DeeSCCons[dee][125-1] = 117; // 19;
01673       fT2d_DeeSCCons[dee-1][126-1] = 259; fT2d_DeeSCCons[dee][126-1] = 110; // 12;
01674 
01675       fT2d_DeeSCCons[dee-1][144-1] = 261; fT2d_DeeSCCons[dee][144-1] = 112; // 27; //  261c ;  112c;      
01676       fT2d_DeeSCCons[dee-1][145-1] = 267; fT2d_DeeSCCons[dee][145-1] = 118; // 20;
01677       fT2d_DeeSCCons[dee-1][146-1] = 260; fT2d_DeeSCCons[dee][146-1] = 111; // 13;
01678 
01679       fT2d_DeeSCCons[dee-1][165-1] = 261; fT2d_DeeSCCons[dee][165-1] = 112; // 27; //  261b ;  112b;
01680       
01681       //.......................................... D1 or D3, right half of S5 
01682       fT2d_DeeSCCons[dee-1][1-1] = 297; // 34;
01683       fT2d_DeeSCCons[dee-1][2-1] = 296; // 33;
01684       fT2d_DeeSCCons[dee-1][3-1] = 295; // 32;
01685       fT2d_DeeSCCons[dee-1][4-1] = 294; // 31;
01686       fT2d_DeeSCCons[dee-1][5-1] = 289; // 26;
01687       fT2d_DeeSCCons[dee-1][6-1] = 288; // 25;
01688       fT2d_DeeSCCons[dee-1][7-1] = 287; // 24;
01689       fT2d_DeeSCCons[dee-1][8-1] = 286; // 23;
01690       
01691       fT2d_DeeSCCons[dee-1][21-1] = 293; // 30;
01692       fT2d_DeeSCCons[dee-1][22-1] = 292; // 29;
01693       fT2d_DeeSCCons[dee-1][23-1] = 291; // 28;
01694       fT2d_DeeSCCons[dee-1][24-1] = 290; // 27;
01695       fT2d_DeeSCCons[dee-1][25-1] = 285; // 22;
01696       fT2d_DeeSCCons[dee-1][26-1] = 284; // 21;
01697       
01698       fT2d_DeeSCCons[dee-1][41-1] = 281; // 20; //  281a
01699       fT2d_DeeSCCons[dee-1][42-1] = 280; // 19;
01700       fT2d_DeeSCCons[dee-1][43-1] = 279; // 18;
01701       
01702       //.......................................... D2 or D4, left half of S5
01703       fT2d_DeeSCCons[dee][1-1] = 148; // 17;
01704       fT2d_DeeSCCons[dee][2-1] = 147; // 16;
01705       fT2d_DeeSCCons[dee][3-1] = 146; // 15;
01706       fT2d_DeeSCCons[dee][4-1] = 145; // 14;
01707       fT2d_DeeSCCons[dee][5-1] = 140; //  9;
01708       fT2d_DeeSCCons[dee][6-1] = 139; //  8;
01709       fT2d_DeeSCCons[dee][7-1] = 138; //  7;
01710       fT2d_DeeSCCons[dee][8-1] = 137; //  6;
01711       
01712       fT2d_DeeSCCons[dee][21-1] = 144; // 13;
01713       fT2d_DeeSCCons[dee][22-1] = 143; // 12;
01714       fT2d_DeeSCCons[dee][23-1] = 142; // 11;
01715       fT2d_DeeSCCons[dee][24-1] = 141; // 10;
01716       fT2d_DeeSCCons[dee][25-1] = 136; //  5;
01717       fT2d_DeeSCCons[dee][26-1] = 135; //  4;
01718      
01719       fT2d_DeeSCCons[dee][41-1] = 132; // 3; //  132a
01720       fT2d_DeeSCCons[dee][42-1] = 131; // 2;
01721       fT2d_DeeSCCons[dee][43-1] = 130; // 1;
01722     }
01723 
01724   //........................ ECNA numbers from numbers for constructions: fT2d_RecovDeeSC[][]
01725 
01726   for(Int_t i0EEDee=0; i0EEDee<MaxEEDee; i0EEDee++)
01727     {
01728       for(Int_t i_ecna=0; i_ecna<MaxDeeSC; i_ecna++)
01729         {
01730           //....... test to avoid the -1 init value in 2nd index of array fT2d_RecovDeeSC[][]
01731           //        (part of the matrix without real SC counterpart)
01732           if( fT2d_DeeSCCons[i0EEDee][i_ecna] >= 0 && fT2d_DeeSCCons[i0EEDee][i_ecna] <= MaxEESCForCons )
01733             {
01734               fT2d_RecovDeeSC[i0EEDee][fT2d_DeeSCCons[i0EEDee][i_ecna]-1] = i_ecna+1;
01735             }
01736         }
01737     }
01738 }
01739 //------------ (end of BuildEndcapSCTable) -------------------------
01740 
01741 //===============================================================================
01742 //
01743 //        Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha
01744 //        GetDeeCrysFromDeeEcha
01745 //
01746 //===============================================================================
01747 Int_t TEcnaNumbering::Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(const Int_t&  n1DeeSCEcna,
01748                                                           const Int_t&  i0SCEcha,
01749                                                           const TString sDeeDir)
01750 {
01751 //get crystal number in Dee from SC number in Dee
01752 // and from Electronic Channel number in super-crystal
01753 
01754   Int_t n1DeeCrys = 0;
01755   Int_t i0DeeDir = GetDeeDirIndex(sDeeDir);
01756 
01757   if( fT3dDeeCrys == 0 ){BuildEndcapCrysTable();}
01758 
01759   if( (n1DeeSCEcna >= 1) && (n1DeeSCEcna <= fEcal->MaxSCEcnaInDee()) )
01760     {
01761       if (i0SCEcha >=0 && i0SCEcha < fEcal->MaxCrysInSC())
01762         {
01763           n1DeeCrys = fT3dDeeCrys[n1DeeSCEcna-1][i0SCEcha][i0DeeDir];
01764         }
01765       else
01766         {
01767           n1DeeCrys = -2;   // Electronic Cnannel in Super-Crystal out of range
01768           cout << "!TEcnaNumbering::Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(...)> Electronic Channel in SuperCrystal = "
01769                << i0SCEcha+1 << ". Out of range (range = [1," << fEcal->MaxCrysInSC() << "])" << fTTBELL << endl;
01770         }
01771     }
01772   else
01773     {
01774       n1DeeCrys = -3;   // Super-Crystal number in Dee out of range
01775       cout << "!TEcnaNumbering::Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(...)> Super-Crystal number in Dee out of range."
01776            << " n1DeeSCEcna = " << n1DeeSCEcna << fTTBELL << endl;
01777     }
01778 
01779   return n1DeeCrys;  // Range = [1,5000]
01780 }
01781 
01782 //===============================================================================
01783 //
01784 //                Get1SCEchaFrom1DeeCrys, Get1DeeSCEcnaFrom1DeeCrys
01785 //
01786 //===============================================================================
01787 
01788 Int_t TEcnaNumbering::Get1SCEchaFrom1DeeCrys(const Int_t& n1DeeCrys, const TString sDeeDir)
01789 {
01790 // get Electronic Channel number in Super-Crystal from Crystal ECNA number in Dee
01791 
01792   Int_t n1SCEcha = -1;
01793   Int_t iDeeDir  = GetDeeDirIndex(sDeeDir);
01794 
01795   if( n1DeeCrys >= 1 && n1DeeCrys <= fEcal->MaxCrysEcnaInDee() )
01796     {
01797       n1SCEcha = fT2dSCEcha[n1DeeCrys-1][iDeeDir];
01798     }
01799   else
01800     {
01801       n1SCEcha = -2;
01802       cout << "!TEcnaNumbering::Get1SCEchaFrom1DeeCrys(...)> Crystal number in Dee out of range."
01803            << " n1DeeCrys = " << n1DeeCrys << "(max = " << fEcal->MaxCrysEcnaInDee() << ")" << fTTBELL << endl;
01804     }
01805   return n1SCEcha;   // range = [1,25]
01806 }
01807 
01808 Int_t TEcnaNumbering::Get1DeeSCEcnaFrom1DeeCrys(const Int_t& n1DeeCrys, const TString sDeeDir)
01809 {
01810 // get Super-Crystal number in Dee from Crystal number in Dee
01811 
01812   Int_t n1DeeSCEcna = 0;
01813   Int_t iDeeDir    = GetDeeDirIndex(sDeeDir);
01814   
01815   if( n1DeeCrys >= 1 && n1DeeCrys <= fEcal->MaxCrysEcnaInDee() )
01816     {
01817       n1DeeSCEcna = fT2dDeeSC[n1DeeCrys-1][iDeeDir];
01818     }
01819   else
01820     {
01821       n1DeeSCEcna = -1;
01822       cout << "!TEcnaNumbering::Get1DeeSCEcnaFrom1DeeCrys(...)> Crystal number in Dee out of range."
01823            << " n1DeeCrys = " << n1DeeCrys << "(max = " << fEcal->MaxCrysEcnaInDee() << ")" << fTTBELL << endl;
01824     }
01825   return n1DeeSCEcna;  // range = [1,200]
01826 }
01827 
01828 //===============================================================================
01829 //
01830 //          GetSCEchaFromDeeEcha
01831 //          Get1DeeSCEcnaFromDeeEcha
01832 //
01833 //===============================================================================
01834 
01835 Int_t TEcnaNumbering::Get1SCEchaFrom0DeeEcha(const Int_t& i0DeeEcha)
01836 {
01837 //get electronic channel number in super-crystal from electronic channel number in Dee
01838 
01839   Int_t i0DeeSC = i0DeeEcha/fEcal->MaxCrysInSC();
01840   Int_t n1SCEcha = i0DeeEcha - fEcal->MaxCrysInSC()*i0DeeSC + 1;
01841 
01842   return n1SCEcha;  //  range = [1,25]
01843 }
01844 
01845 Int_t TEcnaNumbering::Get1DeeSCEcnaFrom0DeeEcha(const Int_t& i0DeeEcha)
01846 {
01847 //get super-crystal number from electronic channel number in Dee
01848 
01849   Int_t n1DeeSC = i0DeeEcha/fEcal->MaxCrysInSC()+1;
01850 
01851   return n1DeeSC;  //  range = [1,200]
01852 }
01853 
01854 //--------------------------------------------------------------------------------
01855 //
01856 //       Correspondance (n1DeeNumber, DeeSC)  <->  (DS, DSSC, DeeSCCons)
01857 //
01858 //       GetDSFrom1DeeSCEcna,        GetDSSCFrom1DeeSCEcna,
01859 //       GetDeeSCConsFrom1DeeSCEcna, Get1DeeSCEcnaFromDeeSCCons
01860 //      
01861 //       Get the values from the relevant arrays
01862 //       with cross-check of the index values in argument
01863 //--------------------------------------------------------------------------------
01864 
01865 Int_t TEcnaNumbering::GetDSFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna)
01866 {
01867 // Get Data Sector number from SC ECNA number in Dee 
01868 
01869   Int_t data_sector = -1;
01870 
01871   if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
01872     {
01873       if( n1DeeSCEcna > 0  &&  n1DeeSCEcna <= fEcal->MaxSCEcnaInDee() )
01874         {
01875           data_sector = fT2d_DS[n1DeeNumber-1][n1DeeSCEcna-1];
01876         }
01877       else
01878         {
01879           cout << "!TEcnaNumbering::GetDSFrom1DeeSCEcna(...)> n1DeeSCEcna = " << n1DeeSCEcna
01880                << ". Out of range ( range = [1," << fEcal->MaxSCEcnaInDee() << "] )"
01881                << fTTBELL << endl;
01882         }
01883     }
01884   else
01885     {
01886       if( n1DeeNumber != 0 )
01887         {
01888           cout << "!TEcnaNumbering::GetDSFrom1DeeSCEcna(...)> n1DeeNumber = " << n1DeeNumber 
01889                << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
01890                << fTTBELL << endl;
01891         }
01892       else
01893         {
01894           cout << "TEcnaNumbering::GetDSFrom1DeeSCEcna(...)> Dee = " << n1DeeNumber
01895                << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])" 
01896                << fTTBELL << endl; 
01897         }
01898     }
01899   return data_sector;
01900 }
01901 //..........................................................................................
01902 Int_t TEcnaNumbering::GetDSSCFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna,
01903                                             const Int_t& n1SCEcha)
01904 {
01905   //.......... Get the correct SC number for the unconnected SC's (inner border)
01906   Int_t ds_sc = GetDSSCFrom1DeeSCEcna(n1DeeNumber, n1DeeSCEcna);
01907 
01908   if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 )
01909     {
01910       if( n1SCEcha == 11 )
01911         {
01912           if( ds_sc == 14 ){ds_sc= 21;}  // 14 <=> 261/BR OR 112/BL
01913         }
01914       if( n1SCEcha == 1 || n1SCEcha == 2 || n1SCEcha == 3 ||
01915           n1SCEcha == 6 || n1SCEcha == 7 )
01916         {
01917           if( ds_sc ==  3 ){ds_sc = 25;}  // 3 <=> 178/TR OR 29/TL
01918         }
01919     }
01920   return ds_sc;
01921 }
01922 //..........................................................................................
01923 Int_t TEcnaNumbering::GetDSSCFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna)
01924 {
01925 // Get SC number in Data Sector from SC Ecna number in Dee 
01926 
01927   Int_t ds_sc = -1;
01928 
01929   if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
01930     {
01931       if( n1DeeSCEcna > 0  &&  n1DeeSCEcna <= fEcal->MaxSCEcnaInDee() )
01932         {
01933           ds_sc = fT2d_DSSC[n1DeeNumber-1][n1DeeSCEcna-1]; // 25 (not 3) or 14 (not 21) if n1DeeSCEcna = 32 or 29
01934                                                            // 25 and 14 => 5 Xtals,  3 and 21 => 1 Xtal
01935         }
01936       else
01937         {
01938           cout << "!TEcnaNumbering::GetDSSCFrom1DeeSCEcna(...)> n1DeeSCEcna = " << n1DeeSCEcna
01939                << ". Out of range ( range = [1," << fEcal->MaxSCEcnaInDee() << "] )"
01940                << fTTBELL << endl;
01941         }
01942     }
01943   else
01944     {
01945       if( n1DeeNumber != 0 )
01946         {
01947           cout << "!TEcnaNumbering::GetDSSCFrom1DeeSCEcna(...)> n1DeeNumber = " << n1DeeNumber 
01948                << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
01949                << fTTBELL << endl;
01950         }
01951       else
01952         {
01953           cout << "TEcnaNumbering::GetDSSCFrom1DeeSCEcna(...)> Dee = " << n1DeeNumber
01954                << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])" 
01955                << fTTBELL << endl;
01956         }
01957     }
01958   return ds_sc;
01959 }
01960 //..........................................................................................
01961 Int_t TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna)
01962 {
01963 // Get SC number for Construction in Dee from SC ECNA number in Dee
01964 
01965   Int_t dee_sc_cons = -1;
01966 
01967   if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
01968     {
01969       if( n1DeeSCEcna > 0  &&  n1DeeSCEcna <= fEcal->MaxSCEcnaInDee() )
01970         {
01971           dee_sc_cons = fT2d_DeeSCCons[n1DeeNumber-1][n1DeeSCEcna-1];
01972         }
01973       else
01974         {
01975           cout << "!TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(...)> *** WARNING *** n1DeeSCEcna = " << n1DeeSCEcna
01976                << ". Out of range ( range = [1," << fEcal->MaxSCEcnaInDee()
01977                << "] ). Nb for const. forced to " << fT2d_DeeSCCons[n1DeeNumber-1][19] << "." << endl;
01978           dee_sc_cons = fT2d_DeeSCCons[n1DeeNumber-1][19];
01979         }
01980     }
01981   else
01982     {
01983       if( n1DeeNumber != 0 )
01984         {
01985           cout << "!TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(...)> n1DeeNumber = " << n1DeeNumber 
01986                << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
01987                << fTTBELL << endl;
01988         }
01989       else
01990         {
01991           cout << "TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(...)> Dee = " << n1DeeNumber
01992                << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])" 
01993                << fTTBELL << endl;
01994         }
01995     }
01996   return dee_sc_cons;
01997 }
01998 //..........................................................................................
01999 Int_t TEcnaNumbering::GetDeeSCConsFrom1DeeSCEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna,
02000                                                  const Int_t& n1SCEcha)
02001 {
02002   //.......... Get the correct SC number (for cons) for the unconnected SC's (inner border)
02003   Int_t dee_sc_cons = GetDeeSCConsFrom1DeeSCEcna(n1DeeNumber, n1DeeSCEcna);
02004 
02005   if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 )
02006     {
02007       if( n1SCEcha == 11 )
02008         {
02009           if( dee_sc_cons == 261 ){dee_sc_cons = 268;}  // 261<=>14/BR
02010           if( dee_sc_cons == 112 ){dee_sc_cons = 119;}  // 112<=>14/BL
02011         }
02012       if( n1SCEcha == 1 ||  n1SCEcha == 2 || n1SCEcha == 3 ||
02013           n1SCEcha == 6 ||  n1SCEcha == 7 )
02014         {
02015           if( dee_sc_cons == 178 ){dee_sc_cons = 207;}  // 178<=>3/TR
02016           if( dee_sc_cons ==  29 ){dee_sc_cons =  58;}  //  29<=>3/TL
02017         }
02018     }
02019   return dee_sc_cons;
02020 }
02021 //..........................................................................................
02022 Int_t TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(const Int_t& n1DeeNumber, const Int_t& DeeSCCons)
02023 {
02024 // Get SC Ecna number in Dee from SC number for Construction in Dee
02025  
02026   Int_t dee_sc_ecna = -1;
02027 
02028   if( n1DeeNumber > 0 && n1DeeNumber <= fEcal->MaxDeeInEE() )
02029     {
02030       Int_t off_set_cons = 0;
02031       if( n1DeeNumber == 1 || n1DeeNumber == 3 ){off_set_cons = fEcal->MaxSCForConsInDee();}
02032       
02033       if( DeeSCCons > off_set_cons  &&  DeeSCCons <= fEcal->MaxSCForConsInDee()+off_set_cons )
02034         {
02035           dee_sc_ecna = fT2d_RecovDeeSC[n1DeeNumber-1][DeeSCCons-1];
02036         }
02037       else
02038         {
02039           cout << "!TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(...)> DeeSCCons = " << DeeSCCons
02040                << ". Out of range ( range = [ " << off_set_cons+1
02041                << "," << fEcal->MaxSCForConsInDee()+off_set_cons << "] )"
02042                << fTTBELL << endl;
02043         }
02044     }
02045   else
02046     {
02047       if( n1DeeNumber != 0 )
02048         {
02049           cout << "!TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(...)> n1DeeNumber = " << n1DeeNumber 
02050                << ". Out of range ( range = [1," << fEcal->MaxDeeInEE() << "] )"
02051                << fTTBELL << endl;
02052         }
02053       else
02054         {
02055           cout << "TEcnaNumbering::Get1DeeSCEcnaFromDeeSCCons(...)> Dee = " << n1DeeNumber
02056                << ". Out of range (range = [1," << fEcal->MaxDeeInEE() << "])" 
02057                << fTTBELL << endl;
02058         }
02059     }
02060   return dee_sc_ecna;
02061 }
02062 
02063 TString TEcnaNumbering::GetSCType(const Int_t& nb_for_cons)
02064 {
02065 // gives the special not connected SC's
02066 
02067   TString SCType = "Connected";   // => default type
02068 
02069   if( nb_for_cons == 182 || nb_for_cons ==  33 ){SCType = "NotConnected";}  // (D1,S1) (D3,S9) || (D2,S9) (D4,S1)
02070 
02071   if( nb_for_cons == 178 || nb_for_cons ==  29 ){SCType = "NotConnected";}  // (D1,S2) (D3,S8) || (D2,S8) (D4,S2)
02072   if( nb_for_cons == 207 || nb_for_cons ==  58 ){SCType = "NotConnected";}
02073 
02074   if( nb_for_cons == 298 || nb_for_cons == 149 ){SCType = "NotConnected";}  // (D1,S3) (D3,S7) || (D2,S7) (D4,S3)
02075 
02076   if( nb_for_cons == 261 || nb_for_cons == 112 ){SCType = "NotConnected";}  // (D1,S4) (D3,S6) || (D2,S6) (D4,S4)
02077   if( nb_for_cons == 268 || nb_for_cons == 119 ){SCType = "NotConnected";}
02078 
02079   if( nb_for_cons == 281 || nb_for_cons == 132 ){SCType = "NotConnected";}  // (D1,S5) (D3,S5) || (D2,S5) (D4,S5)
02080 
02081   if( nb_for_cons == 161 || nb_for_cons ==  12 ){SCType = "NotComplete";}   // (D1,S1) (D3,S9) || (D2,S9) (D4,S1)
02082   if( nb_for_cons == 216 || nb_for_cons ==  67 ){SCType = "NotComplete";}   // (D1,S2) (D3,S8) || (D2,S8) (D4,S2)
02083   if( nb_for_cons == 224 || nb_for_cons ==  75 ){SCType = "NotComplete";}   // (D1,S3) (D3,S7) || (D2,S7) (D4,S3)
02084   if( nb_for_cons == 286 || nb_for_cons == 137 ){SCType = "NotComplete";}   // (D1,S5) (D3,S5) || (D2,S5) (D4,S5)
02085 
02086   return SCType;
02087 }
02088 
02089 Int_t TEcnaNumbering::StexEchaForCons(const Int_t& n1DeeNumber, const Int_t& i0StexEcha)
02090 {
02091   Int_t n1StexStin = Get1StexStinFrom0StexEcha(i0StexEcha);
02092   return fT2d_DeeSCCons[n1DeeNumber-1][n1StexStin-1];
02093 }
02094   // return -1 if the SC does not correspond to a real SC; return the number for construction otherwise
02095 
02096 //===========================================================================
02097 //
02098 //                        GetSCQuadFrom1DeeSCEcna
02099 //
02100 //===========================================================================  
02101 
02102 TString  TEcnaNumbering::GetSCQuadFrom1DeeSCEcna(const Int_t& n1DeeSCEcna)
02103 {
02104 //gives the quadrant type ("top" or "bottom") from the SC number in Dee
02105 
02106   TString SCQuad = "top";   // => default value
02107 
02108   if (n1DeeSCEcna >=   1 && n1DeeSCEcna <=  10){SCQuad = "bottom";}
02109   if (n1DeeSCEcna >=  21 && n1DeeSCEcna <=  30){SCQuad = "bottom";}
02110   if (n1DeeSCEcna >=  41 && n1DeeSCEcna <=  50){SCQuad = "bottom";}
02111   if (n1DeeSCEcna >=  61 && n1DeeSCEcna <=  70){SCQuad = "bottom";}
02112   if (n1DeeSCEcna >=  81 && n1DeeSCEcna <=  90){SCQuad = "bottom";}
02113   if (n1DeeSCEcna >= 101 && n1DeeSCEcna <= 110){SCQuad = "bottom";}
02114   if (n1DeeSCEcna >= 121 && n1DeeSCEcna <= 130){SCQuad = "bottom";}
02115   if (n1DeeSCEcna >= 141 && n1DeeSCEcna <= 150){SCQuad = "bottom";}
02116   if (n1DeeSCEcna >= 161 && n1DeeSCEcna <= 170){SCQuad = "bottom";}
02117   if (n1DeeSCEcna >= 181 && n1DeeSCEcna <= 190){SCQuad = "bottom";}
02118 
02119   return SCQuad;
02120 }
02121 Int_t TEcnaNumbering::GetSCQuadTypeIndex(const TString SCQuadType, const TString sDeeDir)
02122 {
02123 //gives the index of the SC quadrant type (top/right, top/left, bottom/left, bottom/right)
02124 // = quadrant number - 1
02125 
02126   Int_t itype = 0;   // => default
02127   if ( SCQuadType == "top"    && sDeeDir == "right" ){itype = 0;}
02128   if ( SCQuadType == "top"    && sDeeDir == "left"  ){itype = 1;}
02129   if ( SCQuadType == "bottom" && sDeeDir == "left"  ){itype = 2;}
02130   if ( SCQuadType == "bottom" && sDeeDir == "right" ){itype = 3;}
02131   return itype;
02132 }
02133 //===========================================================================
02134 //
02135 //                    GetEEDeeType, GetDeeDirViewedFromIP
02136 //
02137 //===========================================================================  
02138 TString TEcnaNumbering::GetEEDeeEndcap(const Int_t& n1DeeNumber)
02139 {
02140 //gives the Endcap (EE+ or EE-) of the Dee (H. Heath, CMS NOTE 2006/027)
02141 
02142   TString eetype = "EE+";   // => default
02143   if ( n1DeeNumber == 1 || n1DeeNumber == 2 ){eetype = "EE+";}
02144   if ( n1DeeNumber == 3 || n1DeeNumber == 4 ){eetype = "EE-";}
02145   return eetype;
02146 }
02147 TString TEcnaNumbering::GetEEDeeType(const Int_t& n1DeeNumber)
02148 {
02149 //gives the EE +/- and Forward/Near of the Dee (H. Heath, CMS NOTE 2006/027)
02150 
02151   TString type = "EE+F";   // => default
02152   if ( n1DeeNumber == 1 ){type = "EE+F";}
02153   if ( n1DeeNumber == 2 ){type = "EE+N";}
02154   if ( n1DeeNumber == 3 ){type = "EE-N";}
02155   if ( n1DeeNumber == 4 ){type = "EE-F";}
02156   return type;
02157 }
02158 
02159 TString TEcnaNumbering::GetDeeDirViewedFromIP(const Int_t& n1DeeNumber)
02160 {
02161 //gives the direction (left/right) of the IX axis of the Dee
02162 // looking from the interaction point
02163 
02164   TString sDeeDir = "right";   // => default
02165   if ( (n1DeeNumber == 1) || (n1DeeNumber == 3) ){sDeeDir = "right";}
02166   if ( (n1DeeNumber == 2) || (n1DeeNumber == 4) ){sDeeDir = "left" ;}
02167   return sDeeDir;
02168 }
02169 Int_t TEcnaNumbering::GetDeeDirIndex(const TString sDeeDir)
02170 {
02171 //gives the index of the direction (left,right) of the IX axis of the Dee
02172 // looking from the interaction point (right = 0, left = 1)
02173 
02174   Int_t iDeeDir = 0;   // => default
02175   if ( sDeeDir == "right" ){iDeeDir = 0;}
02176   if ( sDeeDir == "left"  ){iDeeDir = 1;}
02177   return iDeeDir;
02178 }
02179 
02180 //==============================================================================
02181 //
02182 //    GetIXCrysInSC,  GetJYCrysInSC
02183 //    GetIXSCInDee,   GetJYSCInDee
02184 //    GetIXCrysInDee, GetJYCrysInDConsFrom1DeeSCEcna(fStexNumber, StexStinEcna);
02185 //
02186 //==============================================================================
02187 Int_t TEcnaNumbering::GetIXCrysInSC(const Int_t& n1DeeNumber, const Int_t& DeeSC,
02188                                     const Int_t& i0SCEcha)
02189 {
02190 //Gives Crys IX in SC for a given (n1DeeNumber, DeeSC, i0SCEcha)
02191   
02192   TString SCQuadType = GetSCQuadFrom1DeeSCEcna(DeeSC);
02193   TString sDeeDir    = GetDeeDirViewedFromIP(n1DeeNumber);
02194   Int_t type_index   = GetSCQuadTypeIndex(SCQuadType, sDeeDir);
02195   Int_t IXCrysInSC   = fT2d_ich_IX[type_index][i0SCEcha+1] + 1;
02196   return IXCrysInSC;   // possible values: 1,2,3,4,5
02197 }
02198 
02199 Int_t TEcnaNumbering::GetIXSCInDee(const Int_t& DeeSC)
02200 {
02201 //Gives SC IX in Dee for a given (DeeSC)
02202   
02203   Int_t IXSCInDee = (DeeSC-1)/fEcal->MaxSCIYInDee() + 1;
02204   return IXSCInDee;  //  possible values: 1,2,...,9,10
02205 }
02206 
02207 Int_t TEcnaNumbering::GetIXCrysInDee(const Int_t& n1DeeNumber, const Int_t& DeeSC,
02208                                      const Int_t& i0SCEcha)
02209 {
02210 //Gives Crys IX in Dee for a given (n1DeeNumber, DeeSC, i0SCEcha)
02211 
02212   Int_t IXCrysInDee =
02213     (GetIXSCInDee(DeeSC)-1)*fEcal->MaxCrysIXInSC() +
02214     GetIXCrysInSC(n1DeeNumber, DeeSC, i0SCEcha);
02215   return IXCrysInDee;  // possible values: 1,2,...,49,50
02216 }
02217 //---------------------------------------------------------------------------------
02218 Int_t TEcnaNumbering::GetJYCrysInSC(const Int_t& n1DeeNumber, const Int_t& DeeSC,
02219                                     const Int_t& i0SCEcha)
02220 {
02221 //Gives Crys JY in SC  for a given (n1DeeNumber, DeeSC, i0SCEcha)
02222 
02223   TString SCQuadType = GetSCQuadFrom1DeeSCEcna(DeeSC);
02224   TString sDeeDir    = GetDeeDirViewedFromIP(n1DeeNumber);
02225   Int_t type_index   = GetSCQuadTypeIndex(SCQuadType, sDeeDir);
02226   Int_t JYCrysInSC   = fT2d_jch_JY[type_index][i0SCEcha+1] + 1;
02227   return JYCrysInSC;   // possible values: 1,2,3,4,5
02228 }
02229 
02230 Int_t TEcnaNumbering::GetJYSCInDee(const Int_t& DeeSC)
02231 {
02232 //Gives SC JY in Dee for a given (n1DeeNumber, DeeSC, i0SCEcha)
02233   
02234   Int_t JYSCInDee = (DeeSC-1)%fEcal->MaxSCIYInDee() + 1;
02235   return JYSCInDee;  //  possible values: 1,2,...,19,20
02236 }
02237 
02238 Int_t TEcnaNumbering::GetJYCrysInDee(const Int_t& n1DeeNumber, const Int_t& DeeSC,
02239                                      const Int_t& i0SCEcha)
02240 {
02241 //Gives Crys JY in Dee for a given (n1DeeNumber, DeeSC, i0SCEcha)
02242 
02243   Int_t JYCrysInDee =
02244     (GetJYSCInDee(DeeSC)-1)*fEcal->MaxCrysIYInSC() +
02245     GetJYCrysInSC(n1DeeNumber, DeeSC, i0SCEcha);
02246   return JYCrysInDee;  // possible values: 1,2,...,99,100 
02247 }
02248 //---------------------------------------------------------------------------------
02249 Int_t TEcnaNumbering::GetMaxSCInDS(const Int_t& DeeDS)
02250 {
02251 // Gives the number of SC's in Data Sector DeeDS
02252 
02253   Int_t nb_of_sc = -1;
02254   if( DeeDS == 1 || DeeDS == 9 ){nb_of_sc = 33;}
02255   if( DeeDS == 2 || DeeDS == 8 ){nb_of_sc = 32;}
02256   if( DeeDS == 3 || DeeDS == 7 ){nb_of_sc = 34;}
02257   if( DeeDS == 4 || DeeDS == 6 ){nb_of_sc = 33;}
02258   if( DeeDS == 5){nb_of_sc = 34;}
02259   return nb_of_sc;
02260 }
02261 
02262 
02263 //==============================================================================
02264 //
02265 //       GetIXMin, GetIXMax,  GetIIXMin, GetIIXMax
02266 //
02267 //==============================================================================
02268 Double_t TEcnaNumbering::GetIIXMin(const Int_t& DeeSC)
02269 {
02270 //Gives IIXMin for a given DeeSC , unit = crystal
02271 
02272   Double_t IX_min   = (Double_t)((DeeSC-1)/fEcal->MaxSCIYInDee())*fEcal->MaxCrysIXInSC() + 1.;
02273   return IX_min;
02274 }
02275 
02276 Double_t TEcnaNumbering::GetIIXMax(const Int_t& DeeSC)
02277 {
02278 //Gives IIXMax for a given DeeSC , unit = crystal
02279 
02280   Double_t IX_max  = ((Double_t)((DeeSC-1)/fEcal->MaxSCIYInDee())+1.)*fEcal->MaxCrysIXInSC();
02281   return IX_max;
02282 }
02283 
02284 Double_t TEcnaNumbering::GetIIXMin()
02285 {
02286 //Gives IIXMin for Dee , unit = Super-crystal
02287 
02288   Double_t i_IX_min = (Int_t)1.;
02289   return i_IX_min;
02290 }
02291 
02292 Double_t TEcnaNumbering::GetIIXMax()
02293 {
02294 //Gives IIXMax for Dee , unit = Super-crystal
02295 
02296   Double_t i_IX_max = (Int_t)fEcal->MaxSCIXInDee(); 
02297   return i_IX_max;
02298 }
02299 
02300 //==============================================================================
02301 //
02302 //     GetIIYMin, GetIIYMax
02303 //
02304 //==============================================================================
02305 Double_t TEcnaNumbering::GetJIYMin(const Int_t& n1DeeNumber, const Int_t& DeeSC)
02306 {
02307 //Gives JIYMin for a given Super-Crystal
02308 
02309   Double_t IY_DeeSC = DeeSC%fEcal->MaxSCIYInDee();
02310   if( IY_DeeSC == 0. ){IY_DeeSC = fEcal->MaxSCIYInDee();}
02311 
02312   Double_t j_IY_min = (IY_DeeSC-1)*fEcal->MaxCrysIYInSC() + 1.;
02313  
02314   return j_IY_min;
02315 }
02316 //-----------------------------------------------------------------------------------------
02317 Double_t TEcnaNumbering::GetJIYMax(const Int_t& n1DeeNumber, const Int_t& DeeSC)
02318 {
02319 //Gives JIYMax for a given Super-Crystal
02320 
02321   Double_t IY_DeeSC = DeeSC%fEcal->MaxSCIYInDee();
02322   if( IY_DeeSC == 0  ){IY_DeeSC = fEcal->MaxSCIYInDee();}
02323 
02324   Double_t j_IY_max = IY_DeeSC*fEcal->MaxCrysIYInSC();
02325 
02326   return j_IY_max;
02327 }
02328 
02329 //-----------------------------------------------------------------------------------------
02330 Double_t TEcnaNumbering::GetJIYMin(const Int_t& n1DeeNumber)
02331 {
02332 //Gives JIYMin for a given Dee
02333 
02334   Double_t j_IY_min = (Double_t)1.;
02335 
02336   return j_IY_min;
02337 }
02338 //-----------------------------------------------------------------------------------------
02339 Double_t TEcnaNumbering::GetJIYMax(const Int_t& n1DeeNumber)
02340 {
02341 //Gives JIYMax for a given Dee
02342 
02343   Double_t j_IY_max = (Double_t)fEcal->MaxSCIYInDee();
02344 
02345   return j_IY_max;
02346 }
02347 //=====================================================================
02348 TString  TEcnaNumbering::GetDeeHalfEndcap(const Int_t& n1DeeNumber)
02349 {
02350 //gives the half-endcap of the Dee ("EE+" or "EE-")
02351 
02352   TString type = "EE-";   // => default value
02353 
02354   if ( n1DeeNumber == 1 || n1DeeNumber == 2 ){type = "EE+";}
02355   if ( n1DeeNumber == 3 || n1DeeNumber == 4 ){type = "EE-";}
02356 
02357   return type;
02358 }
02359 //==============================================================================
02360 //
02361 //   GetXDirectionEE, GetYDirectionEE, GetJYDirectionEE
02362 //
02363 //==============================================================================
02364 TString TEcnaNumbering::GetXDirectionEE(const Int_t& n1DeeNumber)
02365 {
02366   TString xdirection = "x";      // DEFAULT
02367 
02368   if( GetEEDeeType(n1DeeNumber) == "EE+F" ){xdirection = "-x";}   //  Dee 1
02369   if( GetEEDeeType(n1DeeNumber) == "EE+N" ){xdirection = "-x";}   //  Dee 2
02370   if( GetEEDeeType(n1DeeNumber) == "EE-N" ){xdirection = "x";}    //  Dee 3
02371   if( GetEEDeeType(n1DeeNumber) == "EE-F" ){xdirection = "x";}    //  Dee 4
02372 
02373   return xdirection;
02374 }
02375 //---------------------------------------------------------
02376 TString TEcnaNumbering::GetYDirectionEE(const Int_t& n1DeeNumber)
02377 {
02378   TString ydirection = "-x";      // DEFAULT
02379 
02380   if( GetEEDeeType(n1DeeNumber) == "endcap+" ){ydirection = "-x";}
02381   if( GetEEDeeType(n1DeeNumber) == "endcap-" ){ydirection = "-x";}
02382 
02383   return ydirection;
02384 }
02385 
02386 //---------------------------------------------------------
02387 TString TEcnaNumbering::GetJYDirectionEE(const Int_t& n1DeeNumber)
02388 {
02389   TString jydirection = "x";      // ALWAYS IN THIS CASE
02390   return jydirection;
02391 }
02392 
02393 //==========================================================================================================
02394 //
02395 //
02396 //                               B A R R E L    A N D    E N D C A P 
02397 //
02398 //
02399 //
02400 //==========================================================================================================
02401 //===============================================================================
02402 //
02403 //        Get1StexStinFrom0StexEcha
02404 //     // GetStinEchaFromStexEcha
02405 //        Get0StexEchaFrom1StexStinAnd0StinEcha
02406 //        Get1StexCrysFrom1StexStinAnd0StinEcha
02407 //
02408 //===============================================================================
02409 Int_t TEcnaNumbering::Get1StexStinFrom0StexEcha(const Int_t& i0StexEcha)
02410 {
02411   Int_t n1StexStin = 0;
02412 
02413   if( fFlagSubDet == "EB" ){n1StexStin = Get1SMTowFrom0SMEcha(i0StexEcha);}
02414   if( fFlagSubDet == "EE" ){n1StexStin = Get1DeeSCEcnaFrom0DeeEcha(i0StexEcha);}
02415 
02416   return n1StexStin;
02417 }
02418 
02419 Int_t TEcnaNumbering::Get0StexEchaFrom1StexStinAnd0StinEcha(const Int_t& n1StexStin,
02420                                                             const Int_t& i0StinEcha)
02421 {
02422 // Electronic Channel number in Stex from Stin number in Stex
02423 // and from Electronic Channel number in Stin
02424 
02425   Int_t StexEcha = (Int_t)(-1.);
02426                     
02427   if ( n1StexStin >  0 && n1StexStin <= fEcal->MaxStinEcnaInStex() &&
02428        i0StinEcha >= 0 && i0StinEcha < fEcal->MaxCrysInStin()  )
02429     {StexEcha = (n1StexStin-1)*fEcal->MaxCrysInStin() + i0StinEcha;}
02430   else
02431     {
02432       cout << "!TEcnaNumbering::Get0StexEchaFrom1StexStinAnd0StinEcha *** ERROR ***> VALUE"
02433            << " OUT OF RANGE. Forced to -1. Argument values: n1StexStin = " << n1StexStin
02434            << ", channel = " << i0StinEcha
02435            << fTTBELL << endl;
02436     }
02437   return StexEcha;
02438 }
02439 Int_t TEcnaNumbering::Get1StexCrysFrom1StexStinAnd0StinEcha(const Int_t& n1StexStin,
02440                                                             const Int_t& i0StinEcha, const Int_t& StexNumber)
02441 {
02442 // Crystal number in Stex from Stin number in Stex
02443 // and from Electronic Channel number in Stin (for the StexNumber_th Stex)
02444 // argument StexNumber used only in "EE" case
02445 
02446   Int_t n1StexCrys = (Int_t)0;
02447   if( fFlagSubDet ==  "EB" ){n1StexCrys = Get1SMCrysFrom1SMTowAnd0TowEcha(n1StexStin, i0StinEcha);}
02448   if( fFlagSubDet ==  "EE" ){TString sDeeDir = GetDeeDirViewedFromIP(StexNumber);
02449   n1StexCrys = Get1DeeCrysFrom1DeeSCEcnaAnd0SCEcha(n1StexStin, i0StinEcha, sDeeDir);}
02450   
02451   return n1StexCrys;
02452 }
02453 //===============================================================================
02454 //
02455 //        GetIHocoMin, GetIHocoMax, GetVecoMin, GetVecoMax
02456 //        GetJVecoMin, GetJVecoMax
02457 //
02458 //===============================================================================
02459 Double_t TEcnaNumbering::GetIHocoMin(const Int_t& Stex, const Int_t& StexStin)
02460 {
02461   Double_t IHocoMin = (Double_t)0.;
02462   if(fFlagSubDet == "EB" ){IHocoMin = GetIEtaMin(Stex, StexStin);}
02463   if(fFlagSubDet == "EE" ){IHocoMin = GetIIXMin(StexStin);}
02464   return IHocoMin;
02465 }
02466 
02467 Double_t TEcnaNumbering::GetIHocoMax(const Int_t& Stex, const Int_t& StexStin)
02468 {
02469   Double_t IHocoMax = (Double_t)0.;
02470   if(fFlagSubDet == "EB" ){IHocoMax = GetIEtaMax(Stex, StexStin);}
02471   if(fFlagSubDet == "EE" ){IHocoMax = GetIIXMax(StexStin);}
02472   return IHocoMax;
02473 }
02474 
02475 Double_t TEcnaNumbering::GetVecoMin(const Int_t& Stex, const Int_t& StexStin)
02476 {
02477   Double_t IVecoMin = (Double_t)0.;
02478   if(fFlagSubDet == "EB" ){IVecoMin = GetPhiMin(Stex, StexStin);}
02479   if(fFlagSubDet == "EE" ){IVecoMin = GetJIYMin(Stex, StexStin);}
02480   return IVecoMin;
02481 }
02482 
02483 Double_t TEcnaNumbering::GetVecoMax(const Int_t& Stex, const Int_t& StexStin)
02484 {
02485   Double_t IVecoMax = (Double_t)0.;
02486   if(fFlagSubDet == "EB" ){IVecoMax = GetPhiMax(Stex, StexStin);}
02487   if(fFlagSubDet == "EE" ){IVecoMax = GetJIYMax(Stex, StexStin);}
02488   return IVecoMax;
02489 }
02490 
02491 Double_t TEcnaNumbering::GetJVecoMin(const Int_t& Stex, const Int_t& StexStin)
02492 {
02493   Double_t JVecoMin = (Double_t)0.;
02494   if(fFlagSubDet == "EB" ){JVecoMin = GetJPhiMin(Stex, StexStin);}
02495   if(fFlagSubDet == "EE" ){JVecoMin = GetJIYMin(Stex, StexStin);}   // not used
02496   return JVecoMin;
02497 }
02498 Double_t TEcnaNumbering::GetJVecoMax(const Int_t& Stex, const Int_t& StexStin)
02499 {
02500   Double_t JVecoMax = (Double_t)0.;
02501   if(fFlagSubDet == "EB" ){JVecoMax = GetJPhiMax(Stex, StexStin);}
02502   if(fFlagSubDet == "EE" ){JVecoMax = GetJIYMax(Stex, StexStin);}   // not used
02503   return JVecoMax;
02504 }
02505 //===========================================================================
02506 //
02507 //                        GetStexHalfBarrel   
02508 //
02509 //===========================================================================  
02510 TString  TEcnaNumbering::GetStexHalfStas(const Int_t& SMNumber)
02511 {
02512   TString half_stas = "EB? EE?";
02513 
02514   if( fFlagSubDet == "EB" ){half_stas = GetSMHalfBarrel(SMNumber);}
02515   if( fFlagSubDet == "EE" ){half_stas = GetDeeHalfEndcap(SMNumber);}
02516 
02517   return half_stas;
02518 }
02519 //===========================================================================
02520 //
02521 //                  GetSMFromFED, GetDSFromFED
02522 //
02523 //=========================================================================== 
02524 Int_t TEcnaNumbering::GetSMFromFED(const Int_t& FEDNumber)
02525 {
02526   Int_t EBSMNumber = 0;    // SM = Super Module
02527   if( FEDNumber >= 610 && FEDNumber <= 645 ){EBSMNumber = FEDNumber - 609;}
02528   return EBSMNumber;
02529 }
02530 
02531 Int_t TEcnaNumbering::GetDSFromFED(const Int_t& FEDNumber)
02532 {
02533   Int_t EEDSNumber = 0;    // DS = Data Sector
02534 
02535   if( FEDNumber >= 600 && FEDNumber <= 609 ){EEDSNumber = FEDNumber - 599;} 
02536   if( FEDNumber >= 646 && FEDNumber <= 655 ){EEDSNumber = FEDNumber - 645;} 
02537 
02538   return EEDSNumber;
02539 }
02540 
02541 //--------------------------------------------
02542 Int_t TEcnaNumbering::MaxCrysInStinEcna(const Int_t& n1DeeNumber, const Int_t& n1DeeSCEcna, const TString s_option)
02543 {
02544 // Number of Xtals in "Ecna SC" for not complete and not connected SC's.
02545 // Also valid for all connected and complete SC's and for towers of EB
02546 
02547   Int_t max_crys = fEcal->MaxCrysInStin();   // valid for EB and for connected and complete SC's of EE
02548 
02549   // Number of Xtals in SC for not complete and not connected SC's
02550 
02551   if(fFlagSubDet == "EE")
02552     {
02553       Int_t n_for_cons = GetDeeSCConsFrom1DeeSCEcna(n1DeeNumber, n1DeeSCEcna);
02554 
02555       //............ not complete SC's (inner border)
02556       if( n_for_cons ==  12 || n_for_cons ==  67 || n_for_cons ==  75 || n_for_cons == 137 ||
02557           n_for_cons == 161 || n_for_cons == 216 || n_for_cons == 224 || n_for_cons == 286 ){max_crys = 20;}
02558 
02559       //............ not connected SC's
02560       if( (n_for_cons == 182 || n_for_cons ==  33) && (n1DeeSCEcna ==  60 || n1DeeSCEcna == 119) ){max_crys = 10;}
02561 
02562       if( (n_for_cons == 178 || n_for_cons ==  29) && (n1DeeSCEcna == 138 || n1DeeSCEcna == 157) ){max_crys = 10;}
02563       if( (n_for_cons == 207 || n_for_cons ==  58) && (n1DeeSCEcna == 176 || n1DeeSCEcna == 193) ){max_crys = 10;}
02564 
02565       if( (n_for_cons == 298 || n_for_cons == 149) && (n1DeeSCEcna == 188) ){max_crys = 10;}
02566 
02567       if( (n_for_cons == 261 || n_for_cons == 112) && (n1DeeSCEcna == 144 || n1DeeSCEcna == 165) ){max_crys = 10;}
02568       if( (n_for_cons == 268 || n_for_cons == 119) && (n1DeeSCEcna == 102 || n1DeeSCEcna == 123) ){max_crys = 10;}
02569 
02570       if( (n_for_cons == 281 || n_for_cons == 132) && (n1DeeSCEcna ==  41) ){max_crys = 10;}
02571 
02572       //............. not connected and mixed Ecna SC's
02573       if( s_option == "TEcnaRun" || s_option == "TEcnaRead" )
02574         {
02575           if( s_option == "TEcnaRun" )
02576             {
02577               // special translation of Xtal 11 of SCEcna 29 and 32 to respectively Xtal 11 of SCEcna 10 and 11
02578               if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 ){max_crys = 5;} 
02579               if( n1DeeSCEcna == 10 || n1DeeSCEcna == 11 ){max_crys = 1;}
02580             }
02581           if( s_option == "TEcnaRead" )
02582             {
02583               //if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 ){max_crys = 6;}
02584               if( n1DeeSCEcna == 29 || n1DeeSCEcna == 32 ){max_crys = 5;}
02585               if( n1DeeSCEcna == 10 || n1DeeSCEcna == 11 ){max_crys = 1;}
02586             }
02587         }
02588       else
02589         {
02590           cout << "!TEcnaNumbering::MaxCrysInStinEcna(...)> " << s_option
02591                << ": unknown option." << fTTBELL << endl;
02592         }
02593     }
02594   return max_crys;
02595 }