]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALEMCGeometry.cxx
coverity
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALEMCGeometry.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id: AliEMCALEMCGeometry.cxx 29514 2008-10-26 10:24:38Z hristov $*/
17
18 //_________________________________________________________________________
19 // Geometry class  for EMCAL : singleton  
20 // EMCAL consists of layers of scintillator and lead
21 // with scintillator fiber arranged as "shish-kebab" skewers 
22 // Places the the Barrel Geometry of The EMCAL at Midrapidity
23 // between 80 and 180(or 190) degrees of Phi and
24 // -0.7 to 0.7 in eta 
25 //
26 //     EMCAL geometry tree:
27 //     EMCAL -> superModule -> module -> tower(cell)
28 //     Indexes
29 //     absId -> nSupMod     -> nModule -> (nIphi,nIeta)
30 //
31 //   Name choices: 
32 //   EMCAL_PDC06 (geometry used for PDC06 simulations, kept for backward compatibility)
33 //      = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG in old notation
34 //   EMCAL_COMPLETE (geometry for expected complete detector)
35 //      = equivalent to SHISH_77_TRD1_2X2_FINAL_110DEG scTh=0.176 pbTh=0.144
36 //          in old notation
37 //
38 //   EMCAL_FIRSTYEAR - geometry for December 2009 to December 2010 run period
39 //                     with four Super Modules
40 //  
41 //   Adding V1 (EMCAL_FIRSTYEARV1, EMCAL_COMPLETEV1) - geometry from December 2009 ; 
42 //                1. Fixed bug for positions of modules inside SM
43 //                   (first module has tilt 0.75 degree);
44 //                2. Added Al front plate (width 1 cm) and 2 paper sheets per sampling
45 //                   layer (additional 0.2 mm) 
46 //                   The sizes have updated with last information from production
47 //                   drawing (end of October 2010). 
48 //                3. COMPLETEV1 contains now only 10 SM for runs for year 2011
49 //                4. COMPLETE12SMV1 contains 12 SM for runs from year 2012 and on
50 //
51 //   EMCAL_WSUC (Wayne State test stand)
52 //      = no definite equivalent in old notation, was only used by
53 //          Aleksei, but kept for testing purposes
54 //
55 //   etc.
56 //
57 //
58 //
59 //*-- Author: Sahal Yacoob (LBL / UCT)
60 //     and  : Yves Schutz (SUBATECH)
61 //     and  : Jennifer Klay (LBL)
62 //     and  : Aleksei Pavlinov (WSU) 
63 //     and  : Magali Estienne (SUBATECH)
64
65 // --- Root header files ---
66 #include <TObjArray.h>
67 #include <TObjString.h>
68 #include <TRegexp.h>
69
70 // -- ALICE Headers.
71 #include "AliLog.h"
72
73 // --- EMCAL headers
74 #include "AliEMCALEMCGeometry.h"
75 #include <cassert>
76
77 ClassImp(AliEMCALEMCGeometry)
78
79 // these initialisations are needed for a singleton
80 Bool_t    AliEMCALEMCGeometry::fgInit      = kFALSE;
81 const Char_t*   AliEMCALEMCGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETE12SMV1";
82
83
84 AliEMCALEMCGeometry::AliEMCALEMCGeometry() 
85   : TNamed(),
86     fGeoName(0),fArrayOpts(0),fNAdditionalOpts(0),fECPbRadThickness(0.),fECScintThick(0.),
87     fNECLayers(0),fArm1PhiMin(0.),fArm1PhiMax(0.),fArm1EtaMin(0.),fArm1EtaMax(0.),fIPDistance(0.),
88     fShellThickness(0.),fZLength(0.),fNZ(0),fNPhi(0),fSampling(0.),fNumberOfSuperModules(0),
89     fFrontSteelStrip(0.),fLateralSteelStrip(0.),fPassiveScintThick(0.),fPhiModuleSize(0.),
90     fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fLongModuleSize(0.),fNPhiSuperModule(0),
91     fNPHIdiv(0),fNETAdiv(0), fNCells(0),fNCellsInSupMod(0),fNCellsInModule(0),
92     // Trigger staff
93     fNTRUEta(0), fNTRUPhi(0), fNModulesInTRUEta(0), fNModulesInTRUPhi(0), fNEtaSubOfTRU(0),
94     // 
95     fTrd1Angle(0.),f2Trd1Dx2(0.),
96     fPhiGapForSM(0.),fKey110DEG(0),fPhiBoundariesOfSM(0), fPhiCentersOfSM(0),fEtaMaxOfTRD1(0),
97     fTrd1AlFrontThick(0.0), fTrd1BondPaperThick(0.),
98     fCentersOfCellsEtaDir(0), fCentersOfCellsXDir(0),fCentersOfCellsPhiDir(0),
99     fEtaCentersOfCells(0),fPhiCentersOfCells(0),fShishKebabTrd1Modules(0),
100     fParSM(), fILOSS(-1), fIHADR(-1),
101     //obsolete member data
102      fGap2Active(0.), fSteelFrontThick(0.), fTrd2AngleY(0.),
103     f2Trd2Dy2(0.), fEmptySpace(0.), fTubsR(0.), fTubsTurnAngle(0.)
104
105   // default ctor only for internal usage (singleton)
106   // must be kept public for root persistency purposes, 
107   // but should never be called by the outside world    
108   fParSM[0]=0; fParSM[1]=0; fParSM[2]=0;
109   fEnvelop[0] = 0; fEnvelop[1] = 0; fEnvelop[2] = 0;
110   for(Int_t i = 0; i < 6; i++) fkAdditionalOpts[i] = "";
111   
112   AliDebug(2, "AliEMCALEMCGeometry : default ctor ");
113 }
114 //______________________________________________________________________
115 AliEMCALEMCGeometry::AliEMCALEMCGeometry(const Text_t* name, const Text_t* title,
116                                          const Text_t* mcname, const Text_t* mctitle ) :
117   TNamed(name,title),
118     fGeoName(0),fArrayOpts(0),fNAdditionalOpts(0),fECPbRadThickness(0.),fECScintThick(0.),
119     fNECLayers(0),fArm1PhiMin(0.),fArm1PhiMax(0.),fArm1EtaMin(0.),fArm1EtaMax(0.),fIPDistance(0.),
120     fShellThickness(0.),fZLength(0.),fNZ(0),fNPhi(0),fSampling(0.),fNumberOfSuperModules(0),
121     fFrontSteelStrip(0.),fLateralSteelStrip(0.),fPassiveScintThick(0.),fPhiModuleSize(0.),
122     fEtaModuleSize(0.),fPhiTileSize(0.),fEtaTileSize(0.),fLongModuleSize(0.),fNPhiSuperModule(0),
123     fNPHIdiv(0),fNETAdiv(0), fNCells(0),fNCellsInSupMod(0),fNCellsInModule(0),
124     // Trigger staff
125     fNTRUEta(0), fNTRUPhi(0), fNModulesInTRUEta(0), fNModulesInTRUPhi(0), fNEtaSubOfTRU(0),
126     // 
127     fTrd1Angle(0.),f2Trd1Dx2(0.),
128     fPhiGapForSM(0.),fKey110DEG(0),fPhiBoundariesOfSM(0), fPhiCentersOfSM(0), fEtaMaxOfTRD1(0),
129     fTrd1AlFrontThick(0.0), fTrd1BondPaperThick(0.),
130     fCentersOfCellsEtaDir(0),fCentersOfCellsXDir(0),fCentersOfCellsPhiDir(0),
131     fEtaCentersOfCells(0),fPhiCentersOfCells(0),fShishKebabTrd1Modules(0),
132     fParSM(),fILOSS(-1), fIHADR(-1), 
133     //obsolete member data
134     fGap2Active(0.), fSteelFrontThick(0.), fTrd2AngleY(0.),
135     f2Trd2Dy2(0.), fEmptySpace(0.), fTubsR(0.), fTubsTurnAngle(0.)
136 {
137   // ctor only for internal usage (singleton)
138   AliDebug(2, Form("AliEMCALEMCGeometry(%s,%s,%s,%s) ", name,title,mcname,mctitle));
139
140   Init(mcname,mctitle);
141
142   //  CreateListOfTrd1Modules();
143
144   if (AliDebugLevel()>=2) {
145     PrintGeometry();
146   }
147
148 }
149 //______________________________________________________________________
150 AliEMCALEMCGeometry::AliEMCALEMCGeometry(const AliEMCALEMCGeometry& geom)
151   : TNamed(geom),
152     fGeoName(geom.fGeoName),
153     fArrayOpts(geom.fArrayOpts),
154     fNAdditionalOpts(geom.fNAdditionalOpts),
155     fECPbRadThickness(geom.fECPbRadThickness),
156     fECScintThick(geom.fECScintThick),
157     fNECLayers(geom.fNECLayers),
158     fArm1PhiMin(geom.fArm1PhiMin),
159     fArm1PhiMax(geom.fArm1PhiMax),
160     fArm1EtaMin(geom.fArm1EtaMin),
161     fArm1EtaMax(geom.fArm1EtaMax),
162     fIPDistance(geom.fIPDistance),
163     fShellThickness(geom.fShellThickness),
164     fZLength(geom.fZLength),
165     fNZ(geom.fNZ),
166     fNPhi(geom.fNPhi),
167     fSampling(geom.fSampling),
168     fNumberOfSuperModules(geom.fNumberOfSuperModules),
169     fFrontSteelStrip(geom.fFrontSteelStrip),
170     fLateralSteelStrip(geom.fLateralSteelStrip),
171     fPassiveScintThick(geom.fPassiveScintThick),
172     fPhiModuleSize(geom.fPhiModuleSize),
173     fEtaModuleSize(geom.fEtaModuleSize),
174     fPhiTileSize(geom.fPhiTileSize),
175     fEtaTileSize(geom.fEtaTileSize),
176     fLongModuleSize(geom.fLongModuleSize),
177     fNPhiSuperModule(geom.fNPhiSuperModule),
178     fNPHIdiv(geom.fNPHIdiv),
179     fNETAdiv(geom.fNETAdiv),
180     fNCells(geom.fNCells),
181     fNCellsInSupMod(geom.fNCellsInSupMod),
182     fNCellsInModule(geom.fNCellsInModule),
183     // Trigger staff
184     fNTRUEta(geom.fNTRUEta),
185     fNTRUPhi(geom.fNTRUPhi),
186     fNModulesInTRUEta(geom.fNModulesInTRUEta),
187     fNModulesInTRUPhi(geom.fNModulesInTRUPhi),
188     fNEtaSubOfTRU(geom.fNEtaSubOfTRU),
189     //
190     fTrd1Angle(geom.fTrd1Angle),
191     f2Trd1Dx2(geom.f2Trd1Dx2),
192     fPhiGapForSM(geom.fPhiGapForSM),
193     fKey110DEG(geom.fKey110DEG),
194     fPhiBoundariesOfSM(geom.fPhiBoundariesOfSM),
195     fPhiCentersOfSM(geom.fPhiCentersOfSM),
196     fEtaMaxOfTRD1(geom.fEtaMaxOfTRD1),
197     fTrd1AlFrontThick(geom.fTrd1AlFrontThick),
198     fTrd1BondPaperThick(geom.fTrd1BondPaperThick),
199     fCentersOfCellsEtaDir(geom.fCentersOfCellsEtaDir),
200     fCentersOfCellsXDir(geom.fCentersOfCellsXDir),
201     fCentersOfCellsPhiDir(geom.fCentersOfCellsPhiDir),
202     fEtaCentersOfCells(geom.fEtaCentersOfCells),
203     fPhiCentersOfCells(geom.fPhiCentersOfCells),
204     fShishKebabTrd1Modules(geom.fShishKebabTrd1Modules),
205     fILOSS(geom.fILOSS), fIHADR(geom.fIHADR),
206     //obsolete member data
207     fGap2Active(geom.fGap2Active),
208     fSteelFrontThick(geom.fSteelFrontThick),
209     fTrd2AngleY(geom.fTrd2AngleY),
210     f2Trd2Dy2(geom.f2Trd2Dy2),
211     fEmptySpace(geom.fEmptySpace),
212     fTubsR(geom.fTubsR),
213     fTubsTurnAngle(geom.fTubsTurnAngle)
214 {
215   //copy ctor
216   fParSM[0]=geom.fParSM[0]; 
217   fParSM[1]=geom.fParSM[1]; 
218   fParSM[2]=geom.fParSM[2];
219   fEnvelop[0] = geom.fEnvelop[0]; 
220   fEnvelop[1] = geom.fEnvelop[1]; 
221   fEnvelop[2] = geom.fEnvelop[2];
222   for(Int_t i = 0; i < 6; i++) fkAdditionalOpts[i] = geom.fkAdditionalOpts[i];
223
224 }
225
226 //______________________________________________________________________
227 AliEMCALEMCGeometry::~AliEMCALEMCGeometry(void){
228     // dtor
229 }
230
231 //______________________________________________________________________
232 void AliEMCALEMCGeometry::Init(const Text_t* mcname, const Text_t* mctitle){
233   //
234   // Initializes the EMCAL parameters based on the name
235   // Only Shashlyk geometry is available, but various combinations of
236   // layers and number of supermodules can be selected with additional
237   // options or geometry name
238   //
239
240   fkAdditionalOpts[0] = "nl=";       // number of sampling layers (fNECLayers)
241   fkAdditionalOpts[1] = "pbTh=";     // cm, Thickness of the Pb   (fECPbRadThick)
242   fkAdditionalOpts[2] = "scTh=";     // cm, Thickness of the Sc    (fECScintThick)
243   fkAdditionalOpts[3] = "latSS=";    // cm, Thickness of lateral steel strip (fLateralSteelStrip)
244   fkAdditionalOpts[4] = "allILOSS="; // = 0,1,2,3,4 (4 - energy loss without fluctuation)
245   fkAdditionalOpts[5] = "allIHADR="; // = 0,1,2 (0 - no hadronic interaction)
246
247   fNAdditionalOpts = sizeof(fkAdditionalOpts) / sizeof(char*);
248
249   // geometry
250   fgInit = kFALSE; // Assume failed until proven otherwise.
251   fGeoName   = GetName();
252   fGeoName.ToUpper();
253
254   //Convert old geometry names to new ones
255   if(fGeoName.Contains("SHISH_77_TRD1_2X2_FINAL_110DEG")) {
256     if(fGeoName.Contains("PBTH=0.144") && fGeoName.Contains("SCTH=0.176")) {
257       fGeoName = "EMCAL_COMPLETE";
258     } else {
259       fGeoName = "EMCAL_PDC06";
260     }
261   }
262   
263   if(fGeoName.Contains("WSUC")) fGeoName = "EMCAL_WSUC";
264
265   //check that we have a valid geometry name
266   if(!(   fGeoName.Contains("EMCAL_PDC06")     || fGeoName.Contains("EMCAL_WSUC")  
267        || fGeoName.Contains("EMCAL_COMPLETE")  || fGeoName.Contains("EMCAL_COMPLETEV1")  || fGeoName.Contains("EMCAL_COMPLETE12SMV1") 
268        || fGeoName.Contains("EMCAL_FIRSTYEAR") || fGeoName.Contains("EMCAL_FIRSTYEARV1") )) {
269     Fatal("Init", "%s is an undefined geometry!", fGeoName.Data()) ; 
270   }
271
272   // Option to know whether we have the "half" supermodule(s) or not
273   fKey110DEG = 0;
274   if(fGeoName.Contains("COMPLETE") || fGeoName.Contains("PDC06") || fGeoName.Contains("12SM")) fKey110DEG = 1; // for GetAbsCellId
275   if(fGeoName.Contains("COMPLETEV1"))  fKey110DEG = 0; 
276   fShishKebabTrd1Modules = 0;
277
278   // JLK 13-Apr-2008
279   //default parameters are those of EMCAL_COMPLETE geometry
280   //all others render variations from these at the end of
281   //geometry-name specific options
282
283   fNumberOfSuperModules = 12;       // 12 = 6 * 2 (6 in phi, 2 in Z)
284   fNPhi                 = 12;         // module granularity in phi within smod (azimuth)
285   fNZ                   = 24;       // module granularity along Z within smod (eta)
286   fNPHIdiv = fNETAdiv   = 2;        // tower granularity within module
287   fArm1PhiMin           = 80.0;     // degrees, Starting EMCAL Phi position
288   fArm1PhiMax           = 200.0;    // degrees, Ending EMCAL Phi position
289   fArm1EtaMin           = -0.7;     // pseudorapidity, Starting EMCAL Eta position
290   fArm1EtaMax           = +0.7;     // pseudorapidity, Ending EMCAL Eta position
291   fIPDistance           = 428.0;    // cm, radial distance to front face from nominal vertex point
292   fPhiGapForSM          = 2.;       // cm, only for final TRD1 geometry
293   fFrontSteelStrip      = 0.025;    // 0.025cm = 0.25mm  (13-may-05 from V.Petrov)
294   fPassiveScintThick    = 0.8;      // 0.8cm   = 8mm     (13-may-05 from V.Petrov)
295   fLateralSteelStrip    = 0.01;     // 0.01cm  = 0.1mm   (13-may-05 from V.Petrov) - was 0.025
296   fTrd1Angle            = 1.5;      // in degrees       
297
298   fSampling             = 1.;       // should be calculated with call to DefineSamplingFraction()
299   fNECLayers            = 77;       // (13-may-05 from V.Petrov) - can be changed with additional options
300   fECScintThick         = 0.176;    // scintillator layer thickness
301   fECPbRadThickness     = 0.144;    // lead layer thickness
302
303   fPhiModuleSize = 12.26 - fPhiGapForSM / Float_t(fNPhi); // first assumption
304   fEtaModuleSize = fPhiModuleSize;
305
306   fZLength              = 700.;     // Z coverage (cm)
307
308
309   //needs to be called for each geometry and before setting geometry
310   //parameters which can depend on the outcome
311   CheckAdditionalOptions();
312
313   //modifications to the above for PDC06 geometry
314   if(fGeoName.Contains("PDC06")){ // 18-may-05 - about common structure
315     fECScintThick  = fECPbRadThickness = 0.16;// (13-may-05 from V.Petrov)    
316     CheckAdditionalOptions();
317   }
318
319   //modifications to the above for WSUC geometry
320   if(fGeoName.Contains("WSUC")){ // 18-may-05 - about common structure
321     fNumberOfSuperModules = 2;  // 27-may-05; Nov 24,2010 for TB
322     fNPhi = fNZ = 4; 
323     fTrd1AlFrontThick   = 1.0;  // one cm
324     // Bond paper - two sheets around Sc tile
325     fTrd1BondPaperThick = 0.01; // 0.01cm = 0.1 mm
326     
327     fPhiModuleSize = 12.0;
328     fEtaModuleSize = fPhiModuleSize;
329     fLateralSteelStrip = 0.015; // 0.015cm  = 0.15mm
330
331     CheckAdditionalOptions();
332   }
333
334   //In 2009-2010 data taking runs only 4 SM, in the upper position.
335   if(fGeoName.Contains("FIRSTYEAR")){   
336     fNumberOfSuperModules = 4;  
337     fArm1PhiMax           = 120.0; 
338     CheckAdditionalOptions();   
339   }     
340   
341   if(fGeoName.Contains("FIRSTYEARV1") || fGeoName.Contains("COMPLETEV1") || fGeoName.Contains("COMPLETE12SMV1") ){
342     // Oct 26,2010 : First module has tilt = 0.75 degree : 
343     // look to AliEMCALShishKebabTrd1Module::DefineFirstModule(key)
344     // New sizes from production drawing, added Al front plate.
345     // The thickness of sampling is change due to existing two sheets of paper.
346     
347     // Will replace fFrontSteelStrip
348     fTrd1AlFrontThick   = 1.0;  // one cm
349     // Bond paper - two sheets around Sc tile
350     fTrd1BondPaperThick = 0.01; // 0.01cm = 0.1 mm
351     
352     fPhiModuleSize = 12.0;
353     fEtaModuleSize = fPhiModuleSize;
354     fLateralSteelStrip = 0.015; // 0.015cm  = 0.15mm
355     
356     if(fGeoName.Contains("COMPLETEV1"))
357     {
358       fNumberOfSuperModules = 10;       
359       fArm1PhiMax           = 180.0; 
360     }
361     else if (fGeoName.Contains("COMPLETE12SMV1"))
362     {
363       fNumberOfSuperModules = 12;       
364       fArm1PhiMax           = 200.0; 
365     }
366     CheckAdditionalOptions();   
367   }
368
369   // constant for transition absid <--> indexes
370   fNCellsInModule = fNPHIdiv*fNETAdiv;
371   fNCellsInSupMod = fNCellsInModule*fNPhi*fNZ;
372   fNCells         = fNCellsInSupMod*fNumberOfSuperModules;
373   if(GetKey110DEG()) fNCells -= fNCellsInSupMod;
374
375   fNPhiSuperModule = fNumberOfSuperModules/2;
376   if(fNPhiSuperModule < 1) fNPhiSuperModule = 1;
377     
378   fPhiTileSize = fPhiModuleSize/double(fNPHIdiv) - fLateralSteelStrip; // 13-may-05 
379   fEtaTileSize = fEtaModuleSize/double(fNETAdiv) - fLateralSteelStrip; // 13-may-05 
380
381   fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);  
382   if(fGeoName.Contains("V1")){
383     Double_t ws = fECScintThick + fECPbRadThickness + 2.*fTrd1BondPaperThick; // sampling width
384     // Number of Pb tiles = Number of Sc tiles - 1
385     fLongModuleSize = fTrd1AlFrontThick + (ws*fNECLayers - fECPbRadThickness);
386   }
387   f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.);
388
389   if(!fGeoName.Contains("WSUC")) fShellThickness  = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2);
390
391   //These parameters are used to create the mother volume to hold the supermodules
392   //2cm padding added to allow for misalignments - JLK 30-May-2008
393   fEnvelop[0]     = fIPDistance - 1.; // mother volume inner radius
394   fEnvelop[1]     = fIPDistance + fShellThickness + 1.; // mother volume outer r.
395   fEnvelop[2]     = fZLength + 2.; //mother volume length 
396
397   // Local coordinates
398   fParSM[0] = GetShellThickness()/2.;        
399   fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
400   fParSM[2] = fZLength/4.;  //divide by 4 to get half-length of SM
401
402   // SM phi boundaries - (0,1),(2,3) .. (10,11) - has the same boundaries; Nov 7, 2006 
403   fPhiBoundariesOfSM.Set(fNumberOfSuperModules);
404   fPhiCentersOfSM.Set(fNumberOfSuperModules/2);
405   fPhiBoundariesOfSM[0] = TMath::PiOver2() - TMath::ATan2(fParSM[1] , fIPDistance); // 1th and 2th modules)
406   fPhiCentersOfSM[0]     = TMath::PiOver2();
407   if(fNumberOfSuperModules > 1) 
408     fPhiBoundariesOfSM[1] = TMath::PiOver2() + TMath::ATan2(fParSM[1] , fIPDistance);
409   if(fNumberOfSuperModules > 2) {
410         Int_t maxPhiBlock =fNumberOfSuperModules/2-1;
411         if(fNumberOfSuperModules > 10) maxPhiBlock = 4;
412     for(int i=1; i<=maxPhiBlock; i++) { // from 2th ro 9th
413       fPhiBoundariesOfSM[2*i]   = fPhiBoundariesOfSM[0] + 20.*TMath::DegToRad()*i;
414       fPhiBoundariesOfSM[2*i+1] = fPhiBoundariesOfSM[1] + 20.*TMath::DegToRad()*i;
415       fPhiCentersOfSM[i]        = fPhiCentersOfSM[0]     + 20.*TMath::DegToRad()*i;
416     }
417   }
418   if(fNumberOfSuperModules > 10) {
419     fPhiBoundariesOfSM[11] = 190.*TMath::DegToRad();
420     fPhiBoundariesOfSM[10] = fPhiBoundariesOfSM[11] - TMath::ATan2((fParSM[1]) , fIPDistance);
421     fPhiCentersOfSM[5]     = (fPhiBoundariesOfSM[10]+fPhiBoundariesOfSM[11])/2.; 
422   }
423
424   //called after setting of scintillator and lead layer parameters
425   DefineSamplingFraction(mcname,mctitle);
426
427   
428   // TRU parameters - Apr 29,08 by PAI. 
429   // These parameters values was updated at Nov 05, 2007
430   // As is on Olivier  BOURRION (LPSC) ppt preasentation 
431   // at ALICE trigger meeting at 13th-14th March
432   fNTRUEta = 1;           // was 3
433   fNTRUPhi = 3;           // was 1
434   fNModulesInTRUEta = 24; // was 8
435   fNModulesInTRUPhi = 4;  // was 12
436   // Jet trigger 
437   // 3*6*10 + 2*6*2 = 204 -> matrix (nphi(17), neta(12))
438   fNEtaSubOfTRU     = 6;  
439
440   fgInit = kTRUE; 
441 }
442
443 //___________________________________________________________________
444 void AliEMCALEMCGeometry::PrintGeometry()
445 {
446   // Separate routine is callable from broswer; Nov 7,2006
447   printf("\nInit: geometry of EMCAL named %s :\n", fGeoName.Data());
448   if(fArrayOpts) {
449     for(Int_t i=0; i<fArrayOpts->GetEntries(); i++){
450       TObjString *o = (TObjString*)fArrayOpts->At(i);
451       printf(" %i : %s \n", i, o->String().Data());
452     }
453   }
454   printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
455   printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f -> for EMCAL envelope only\n",  
456            GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
457
458   printf( "               ECAL      : %d x (%f cm Pb, %f cm Sc) \n", 
459   GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ; 
460   printf("                fSampling %5.2f \n",  fSampling );
461   printf(" fIPDistance       %6.3f cm \n", fIPDistance);
462   printf(" fNPhi %i   |  fNZ %i \n", fNPhi, fNZ);
463   printf(" fNCellsInModule %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInModule, fNCellsInSupMod, fNCells);
464   printf(" X:Y module size     %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize);
465   printf(" X:Y   tile size     %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize);
466   printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers);
467   printf(" fLongModuleSize     %6.3f cm \n", fLongModuleSize);
468   printf(" #supermodule in phi direction %i \n", fNPhiSuperModule );
469   printf(" fILOSS %i : fIHADR %i \n", fILOSS, fIHADR);
470   printf(" fTrd1Angle %7.4f\n", fTrd1Angle);
471   printf(" f2Trd1Dx2  %7.4f\n",  f2Trd1Dx2);
472   printf(" fTrd1AlFrontThick   %7.4f \n", fTrd1AlFrontThick);
473   printf(" fTrd1BondPaperThick %5.4f \n", fTrd1BondPaperThick);
474   printf("SM dimensions(TRD1) : dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n", 
475          fParSM[0],fParSM[1],fParSM[2]);
476   printf(" fPhiGapForSM  %7.4f cm (%7.4f <- phi size in degree)\n",  
477          fPhiGapForSM, TMath::ATan2(fPhiGapForSM,fIPDistance)*TMath::RadToDeg());
478   if(GetKey110DEG()) printf(" Last two modules have size 10 degree in  phi (180<phi<190)\n");
479   printf(" phi SM boundaries \n"); 
480   for(int i=0; i<fPhiBoundariesOfSM.GetSize()/2.; i++) {
481     printf(" %i : %7.5f(%7.2f) -> %7.5f(%7.2f) : center %7.5f(%7.2f) \n", i, 
482            fPhiBoundariesOfSM[2*i], fPhiBoundariesOfSM[2*i]*TMath::RadToDeg(),
483            fPhiBoundariesOfSM[2*i+1], fPhiBoundariesOfSM[2*i+1]*TMath::RadToDeg(),
484            fPhiCentersOfSM[i], fPhiCentersOfSM[i]*TMath::RadToDeg());
485   }
486
487 }
488
489 //______________________________________________________________________
490 void AliEMCALEMCGeometry::CheckAdditionalOptions()
491 {
492   // Feb 06,2006
493   // Additional options that
494   // can be used to select
495   // the specific geometry of 
496   // EMCAL to run
497   // Dec 27,2006
498   // adeed allILOSS= and allIHADR= for MIP investigation
499   fArrayOpts = new TObjArray;
500   Int_t nopt = ParseString(fGeoName, *fArrayOpts);
501   if(nopt==1) { // no aditional option(s)
502     fArrayOpts->Delete();
503     delete fArrayOpts;
504     fArrayOpts = 0; 
505     return;
506   }              
507   for(Int_t i=1; i<nopt; i++){
508     TObjString *o = (TObjString*)fArrayOpts->At(i); 
509
510     TString addOpt = o->String();
511     Int_t indj=-1;
512     for(Int_t j=0; j<fNAdditionalOpts; j++) {
513       TString opt = fkAdditionalOpts[j];
514       if(addOpt.Contains(opt,TString::kIgnoreCase)) {
515           indj = j;
516         break;
517       }
518     }
519     if(indj<0) {
520       AliDebug(2,Form("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n", 
521                       addOpt.Data()));
522       assert(0);
523     } else {
524       AliDebug(2,Form("<I> option |%s| is valid : number %i : |%s|\n", 
525                       addOpt.Data(), indj, fkAdditionalOpts[indj]));
526       if       (addOpt.Contains("NL=",TString::kIgnoreCase))   {// number of sampling layers
527         sscanf(addOpt.Data(),"NL=%i", &fNECLayers);
528         AliDebug(2,Form(" fNECLayers %i (new) \n", fNECLayers));
529       } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb(fECPbRadThicknes)
530         sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness);
531       } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc(fECScintThick)
532         sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick);
533       } else if(addOpt.Contains("LATSS=",TString::kIgnoreCase)) {// Thickness of lateral steel strip (fLateralSteelStrip)
534         sscanf(addOpt.Data(),"LATSS=%f", &fLateralSteelStrip);
535         AliDebug(2,Form(" fLateralSteelStrip %f (new) \n", fLateralSteelStrip));
536       } else if(addOpt.Contains("ILOSS=",TString::kIgnoreCase)) {// As in Geant
537         sscanf(addOpt.Data(),"ALLILOSS=%i", &fILOSS);
538         AliDebug(2,Form(" fILOSS %i \n", fILOSS));
539       } else if(addOpt.Contains("IHADR=",TString::kIgnoreCase)) {// As in Geant
540         sscanf(addOpt.Data(),"ALLIHADR=%i", &fIHADR);
541         AliDebug(2,Form(" fIHADR %i \n", fIHADR));
542       }
543     }
544   }
545 }
546
547 //__________________________________________________________________
548 void AliEMCALEMCGeometry::DefineSamplingFraction(const Text_t* mcname, const Text_t* mctitle)
549 {
550   // Jun 05,2006
551   // Look http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
552   // Keep for compatibilty
553   //
554   
555   // Sampling factor for G3
556   fSampling = 10.87; // Default value - Nov 25,2010
557   if(fNECLayers == 69) {        // 10% layer reduction
558     fSampling = 12.55;
559   } else if(fNECLayers == 61) { // 20% layer reduction
560     fSampling = 12.80;
561   } else if(fNECLayers == 77) {
562     if(fGeoName.Contains("V1")){
563       fSampling = 10.87; //Adding paper sheets and cover plate; Nov 25,2010
564     } else if   (fECScintThick>0.159 && fECScintThick<0.161) { // original sampling fraction, equal layers
565       fSampling = 12.327; // fECScintThick = fECPbRadThickness = 0.160;
566     } else if (fECScintThick>0.175 && fECScintThick<0.177) { // 10% Pb thicknes reduction
567       fSampling = 10.5; // fECScintThick = 0.176, fECPbRadThickness=0.144;
568     } else if(fECScintThick>0.191 && fECScintThick<0.193) { // 20% Pb thicknes reduction
569       fSampling = 8.93; // fECScintThick = 0.192, fECPbRadThickness=0.128;
570     }
571   }
572
573   // Default sampling factor for G3, modify it for other transport model
574   TString mcName  = mcname;
575   TString mcTitle = mctitle;
576
577   Float_t samplingFactorTranportModel = 1. ;
578   if     (mcName.Contains("Geant3")) samplingFactorTranportModel = 1.;//0.988 // Do nothing
579   else if(mcName.Contains("Fluka") ) samplingFactorTranportModel = 1.; // To be set
580   else if(mcName.Contains("Geant4")){
581     if(mcTitle.Contains("EMV"))      samplingFactorTranportModel = 1.096; // 0.906, 0.896 (OPT)
582     else                             samplingFactorTranportModel = 0.86; // 1.15 (CHIPS), 1.149 (BERT), 1.147 (BERT_CHIPS) 
583   }      
584   
585   AliDebug(2,Form("MC modeler <%s>, Title <%s>: Sampling %f, model fraction with respect to G3 %f, final sampling %f \n",
586                mcName.Data(),mcTitle.Data(),fSampling,samplingFactorTranportModel,fSampling*samplingFactorTranportModel));
587
588   
589   fSampling*=samplingFactorTranportModel;
590   
591 }
592
593 //________________________________________________________________________________________________
594 Double_t AliEMCALEMCGeometry::GetPhiCenterOfSM(Int_t nsupmod) const
595 {
596   //returns center of supermodule in phi
597   int i = nsupmod/2;
598   return fPhiCentersOfSM[i];
599
600 }
601
602 //________________________________________________________________________________________________
603 Bool_t AliEMCALEMCGeometry::GetPhiBoundariesOfSM(Int_t nSupMod, Double_t &phiMin, Double_t &phiMax) const
604 {
605   // 0<= nSupMod <=11; phi in rad
606     static int i;
607   if(nSupMod<0 || nSupMod >11) return kFALSE;
608   i = nSupMod/2;
609   phiMin = (Double_t)fPhiBoundariesOfSM[2*i];
610   phiMax = (Double_t)fPhiBoundariesOfSM[2*i+1];
611   return kTRUE;
612 }
613
614 //________________________________________________________________________________________________
615 Bool_t AliEMCALEMCGeometry::GetPhiBoundariesOfSMGap(Int_t nPhiSec, Double_t &phiMin, Double_t &phiMax) const
616 {
617   // 0<= nPhiSec <=4; phi in rad
618   // 0;  gap boundaries between  0th&2th  | 1th&3th SM
619   // 1;  gap boundaries between  2th&4th  | 3th&5th SM
620   // 2;  gap boundaries between  4th&6th  | 5th&7th SM
621   // 3;  gap boundaries between  6th&8th  | 7th&9th SM
622   // 4;  gap boundaries between  8th&10th | 9th&11th SM
623   if(nPhiSec<0 || nPhiSec >4) return kFALSE;
624   phiMin = fPhiBoundariesOfSM[2*nPhiSec+1];
625   phiMax = fPhiBoundariesOfSM[2*nPhiSec+2];
626   return kTRUE;
627 }
628
629 //________________________________________________________________________________________________
630 int AliEMCALEMCGeometry::ParseString(const TString &topt, TObjArray &Opt)
631
632         //Parse string, does what? GCB 08/09
633         Ssiz_t begin, index, end, end2;
634         begin = index = end = end2 = 0;
635         TRegexp separator("[^ ;,\\t\\s/]+");
636         while ( (begin < topt.Length()) && (index != kNPOS) ) {
637                 // loop over given options
638                 index = topt.Index(separator,&end,begin);
639                 if (index >= 0 && end >= 1) {
640                         TString substring(topt(index,end));
641                         Opt.Add(new TObjString(substring.Data()));
642                 }
643                 begin += end+1;
644         }
645         return Opt.GetEntries();
646 }
647