]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALEMCGeometry.cxx
from Francesco Blanco (based on code from Grenoble): QA update - adding L1 checks...
[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() && !fGeoName.Contains("12SMV1")) fNCells -= fNCellsInSupMod; // SM 10 and 11 are 1/2 size on phi
374   if(GetKey110DEG() && fGeoName.Contains("12SMV1") ) fNCells -=2*(2 * fNCellsInSupMod / 3); // SM 10 and 11 are 1/3 size on phi
375
376   fNPhiSuperModule = fNumberOfSuperModules/2;
377   if(fNPhiSuperModule < 1) fNPhiSuperModule = 1;
378     
379   fPhiTileSize = fPhiModuleSize/double(fNPHIdiv) - fLateralSteelStrip; // 13-may-05 
380   fEtaTileSize = fEtaModuleSize/double(fNETAdiv) - fLateralSteelStrip; // 13-may-05 
381
382   fLongModuleSize = fNECLayers*(fECScintThick + fECPbRadThickness);  
383   if(fGeoName.Contains("V1")){
384     Double_t ws = fECScintThick + fECPbRadThickness + 2.*fTrd1BondPaperThick; // sampling width
385     // Number of Pb tiles = Number of Sc tiles - 1
386     fLongModuleSize = fTrd1AlFrontThick + (ws*fNECLayers - fECPbRadThickness);
387   }
388   f2Trd1Dx2 = fEtaModuleSize + 2.*fLongModuleSize*TMath::Tan(fTrd1Angle*TMath::DegToRad()/2.);
389
390   if(!fGeoName.Contains("WSUC")) fShellThickness  = TMath::Sqrt(fLongModuleSize*fLongModuleSize + f2Trd1Dx2*f2Trd1Dx2);
391
392   //These parameters are used to create the mother volume to hold the supermodules
393   //2cm padding added to allow for misalignments - JLK 30-May-2008
394   fEnvelop[0]     = fIPDistance - 1.; // mother volume inner radius
395   fEnvelop[1]     = fIPDistance + fShellThickness + 1.; // mother volume outer r.
396   fEnvelop[2]     = fZLength + 2.; //mother volume length 
397
398   // Local coordinates
399   fParSM[0] = GetShellThickness()/2.;        
400   fParSM[1] = GetPhiModuleSize() * GetNPhi()/2.;
401   fParSM[2] = fZLength/4.;  //divide by 4 to get half-length of SM
402
403   // SM phi boundaries - (0,1),(2,3) .. (10,11) - has the same boundaries; Nov 7, 2006 
404   fPhiBoundariesOfSM.Set(fNumberOfSuperModules);
405   fPhiCentersOfSM.Set(fNumberOfSuperModules/2);
406   fPhiBoundariesOfSM[0] = TMath::PiOver2() - TMath::ATan2(fParSM[1] , fIPDistance); // 1th and 2th modules)
407   fPhiCentersOfSM[0]     = TMath::PiOver2();
408   if(fNumberOfSuperModules > 1) 
409     fPhiBoundariesOfSM[1] = TMath::PiOver2() + TMath::ATan2(fParSM[1] , fIPDistance);
410   if(fNumberOfSuperModules > 2) {
411         Int_t maxPhiBlock =fNumberOfSuperModules/2-1;
412         if(fNumberOfSuperModules > 10) maxPhiBlock = 4;
413     for(int i=1; i<=maxPhiBlock; i++) { // from 2th ro 9th
414       fPhiBoundariesOfSM[2*i]   = fPhiBoundariesOfSM[0] + 20.*TMath::DegToRad()*i;
415       fPhiBoundariesOfSM[2*i+1] = fPhiBoundariesOfSM[1] + 20.*TMath::DegToRad()*i;
416       fPhiCentersOfSM[i]        = fPhiCentersOfSM[0]     + 20.*TMath::DegToRad()*i;
417     }
418   }
419   if(fNumberOfSuperModules > 10) {
420     fPhiBoundariesOfSM[10] =  fPhiBoundariesOfSM[0] + 20.*TMath::DegToRad()*5; // in the ideal case the phi-gap is constant
421     fPhiBoundariesOfSM[11] =  fPhiBoundariesOfSM[10] + 2.*TMath::ATan2((fParSM[1])/3., fIPDistance); // one_third SMs
422     fPhiCentersOfSM[5]     = (fPhiBoundariesOfSM[10]+fPhiBoundariesOfSM[11])/2.; 
423   }
424
425   //called after setting of scintillator and lead layer parameters
426   DefineSamplingFraction(mcname,mctitle);
427
428   
429   // TRU parameters - Apr 29,08 by PAI. 
430   // These parameters values was updated at Nov 05, 2007
431   // As is on Olivier  BOURRION (LPSC) ppt preasentation 
432   // at ALICE trigger meeting at 13th-14th March
433   fNTRUEta = 1;           // was 3
434   fNTRUPhi = 3;           // was 1
435   fNModulesInTRUEta = 24; // was 8
436   fNModulesInTRUPhi = 4;  // was 12
437   // Jet trigger 
438   // 3*6*10 + 2*6*2 = 204 -> matrix (nphi(17), neta(12))
439   fNEtaSubOfTRU     = 6;  
440
441   fgInit = kTRUE; 
442 }
443
444 //___________________________________________________________________
445 void AliEMCALEMCGeometry::PrintGeometry()
446 {
447   // Separate routine is callable from broswer; Nov 7,2006
448   printf("\nInit: geometry of EMCAL named %s :\n", fGeoName.Data());
449   if(fArrayOpts) {
450     for(Int_t i=0; i<fArrayOpts->GetEntries(); i++){
451       TObjString *o = (TObjString*)fArrayOpts->At(i);
452       printf(" %i : %s \n", i, o->String().Data());
453     }
454   }
455   printf("Granularity: %d in eta and %d in phi\n", GetNZ(), GetNPhi()) ;
456   printf("Layout: phi = (%7.1f, %7.1f), eta = (%5.2f, %5.2f), IP = %7.2f -> for EMCAL envelope only\n",  
457            GetArm1PhiMin(), GetArm1PhiMax(),GetArm1EtaMin(), GetArm1EtaMax(), GetIPDistance() );
458
459   printf( "               ECAL      : %d x (%f cm Pb, %f cm Sc) \n", 
460   GetNECLayers(), GetECPbRadThick(), GetECScintThick() ) ; 
461   printf("                fSampling %5.2f \n",  fSampling );
462   printf(" fIPDistance       %6.3f cm \n", fIPDistance);
463   printf(" fNPhi %i   |  fNZ %i \n", fNPhi, fNZ);
464   printf(" fNCellsInModule %i : fNCellsInSupMod %i : fNCells %i\n",fNCellsInModule, fNCellsInSupMod, fNCells);
465   printf(" X:Y module size     %6.3f , %6.3f cm \n", fPhiModuleSize, fEtaModuleSize);
466   printf(" X:Y   tile size     %6.3f , %6.3f cm \n", fPhiTileSize, fEtaTileSize);
467   printf(" #of sampling layers %i(fNECLayers) \n", fNECLayers);
468   printf(" fLongModuleSize     %6.3f cm \n", fLongModuleSize);
469   printf(" #supermodule in phi direction %i \n", fNPhiSuperModule );
470   printf(" fILOSS %i : fIHADR %i \n", fILOSS, fIHADR);
471   printf(" fTrd1Angle %7.4f\n", fTrd1Angle);
472   printf(" f2Trd1Dx2  %7.4f\n",  f2Trd1Dx2);
473   printf(" fTrd1AlFrontThick   %7.4f \n", fTrd1AlFrontThick);
474   printf(" fTrd1BondPaperThick %5.4f \n", fTrd1BondPaperThick);
475   printf("SM dimensions(TRD1) : dx %7.2f dy %7.2f dz %7.2f (SMOD, BOX)\n", 
476          fParSM[0],fParSM[1],fParSM[2]);
477   printf(" fPhiGapForSM  %7.4f cm (%7.4f <- phi size in degree)\n",  
478          fPhiGapForSM, TMath::ATan2(fPhiGapForSM,fIPDistance)*TMath::RadToDeg());
479   if(GetKey110DEG() && !fGeoName.Contains("12SMV1") ) printf(" Last two modules have size 10 degree in  phi (180<phi<190)\n");
480   if(GetKey110DEG() && fGeoName.Contains("12SMV1")) printf(" Last two modules have size 6.6 degree in  phi (180<phi<186.6)\n");
481   printf(" phi SM boundaries \n"); 
482   for(int i=0; i<fPhiBoundariesOfSM.GetSize()/2.; i++) {
483     printf(" %i : %7.5f(%7.2f) -> %7.5f(%7.2f) : center %7.5f(%7.2f) \n", i, 
484            fPhiBoundariesOfSM[2*i], fPhiBoundariesOfSM[2*i]*TMath::RadToDeg(),
485            fPhiBoundariesOfSM[2*i+1], fPhiBoundariesOfSM[2*i+1]*TMath::RadToDeg(),
486            fPhiCentersOfSM[i], fPhiCentersOfSM[i]*TMath::RadToDeg());
487   }
488
489 }
490
491 //______________________________________________________________________
492 void AliEMCALEMCGeometry::CheckAdditionalOptions()
493 {
494   // Feb 06,2006
495   // Additional options that
496   // can be used to select
497   // the specific geometry of 
498   // EMCAL to run
499   // Dec 27,2006
500   // adeed allILOSS= and allIHADR= for MIP investigation
501   fArrayOpts = new TObjArray;
502   Int_t nopt = ParseString(fGeoName, *fArrayOpts);
503   if(nopt==1) { // no aditional option(s)
504     fArrayOpts->Delete();
505     delete fArrayOpts;
506     fArrayOpts = 0; 
507     return;
508   }              
509   for(Int_t i=1; i<nopt; i++){
510     TObjString *o = (TObjString*)fArrayOpts->At(i); 
511
512     TString addOpt = o->String();
513     Int_t indj=-1;
514     for(Int_t j=0; j<fNAdditionalOpts; j++) {
515       TString opt = fkAdditionalOpts[j];
516       if(addOpt.Contains(opt,TString::kIgnoreCase)) {
517           indj = j;
518         break;
519       }
520     }
521     if(indj<0) {
522       AliDebug(2,Form("<E> option |%s| unavailable : ** look to the file AliEMCALGeometry.h **\n", 
523                       addOpt.Data()));
524       assert(0);
525     } else {
526       AliDebug(2,Form("<I> option |%s| is valid : number %i : |%s|\n", 
527                       addOpt.Data(), indj, fkAdditionalOpts[indj]));
528       if       (addOpt.Contains("NL=",TString::kIgnoreCase))   {// number of sampling layers
529         sscanf(addOpt.Data(),"NL=%i", &fNECLayers);
530         AliDebug(2,Form(" fNECLayers %i (new) \n", fNECLayers));
531       } else if(addOpt.Contains("PBTH=",TString::kIgnoreCase)) {//Thickness of the Pb(fECPbRadThicknes)
532         sscanf(addOpt.Data(),"PBTH=%f", &fECPbRadThickness);
533       } else if(addOpt.Contains("SCTH=",TString::kIgnoreCase)) {//Thickness of the Sc(fECScintThick)
534         sscanf(addOpt.Data(),"SCTH=%f", &fECScintThick);
535       } else if(addOpt.Contains("LATSS=",TString::kIgnoreCase)) {// Thickness of lateral steel strip (fLateralSteelStrip)
536         sscanf(addOpt.Data(),"LATSS=%f", &fLateralSteelStrip);
537         AliDebug(2,Form(" fLateralSteelStrip %f (new) \n", fLateralSteelStrip));
538       } else if(addOpt.Contains("ILOSS=",TString::kIgnoreCase)) {// As in Geant
539         sscanf(addOpt.Data(),"ALLILOSS=%i", &fILOSS);
540         AliDebug(2,Form(" fILOSS %i \n", fILOSS));
541       } else if(addOpt.Contains("IHADR=",TString::kIgnoreCase)) {// As in Geant
542         sscanf(addOpt.Data(),"ALLIHADR=%i", &fIHADR);
543         AliDebug(2,Form(" fIHADR %i \n", fIHADR));
544       }
545     }
546   }
547 }
548
549 //__________________________________________________________________
550 void AliEMCALEMCGeometry::DefineSamplingFraction(const Text_t* mcname, const Text_t* mctitle)
551 {
552   // Jun 05,2006
553   // Look http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
554   // Keep for compatibilty
555   //
556   
557   // Sampling factor for G3
558   fSampling = 10.87; // Default value - Nov 25,2010
559   if(fNECLayers == 69) {        // 10% layer reduction
560     fSampling = 12.55;
561   } else if(fNECLayers == 61) { // 20% layer reduction
562     fSampling = 12.80;
563   } else if(fNECLayers == 77) {
564     if(fGeoName.Contains("V1")){
565       fSampling = 10.87; //Adding paper sheets and cover plate; Nov 25,2010
566     } else if   (fECScintThick>0.159 && fECScintThick<0.161) { // original sampling fraction, equal layers
567       fSampling = 12.327; // fECScintThick = fECPbRadThickness = 0.160;
568     } else if (fECScintThick>0.175 && fECScintThick<0.177) { // 10% Pb thicknes reduction
569       fSampling = 10.5; // fECScintThick = 0.176, fECPbRadThickness=0.144;
570     } else if(fECScintThick>0.191 && fECScintThick<0.193) { // 20% Pb thicknes reduction
571       fSampling = 8.93; // fECScintThick = 0.192, fECPbRadThickness=0.128;
572     }
573   }
574
575   // Default sampling factor for G3, modify it for other transport model
576   TString mcName  = mcname;
577   TString mcTitle = mctitle;
578
579   Float_t samplingFactorTranportModel = 1. ;
580   if     (mcName.Contains("Geant3")) samplingFactorTranportModel = 1.;//0.988 // Do nothing
581   else if(mcName.Contains("Fluka") ) samplingFactorTranportModel = 1.; // To be set
582   else if(mcName.Contains("Geant4")){
583     if(mcTitle.Contains("EMV"))      samplingFactorTranportModel = 1.096; // 0.906, 0.896 (OPT)
584     else                             samplingFactorTranportModel = 0.86; // 1.15 (CHIPS), 1.149 (BERT), 1.147 (BERT_CHIPS) 
585   }      
586   
587   AliDebug(2,Form("MC modeler <%s>, Title <%s>: Sampling %f, model fraction with respect to G3 %f, final sampling %f \n",
588                mcName.Data(),mcTitle.Data(),fSampling,samplingFactorTranportModel,fSampling*samplingFactorTranportModel));
589
590   
591   fSampling*=samplingFactorTranportModel;
592   
593 }
594
595 //________________________________________________________________________________________________
596 Double_t AliEMCALEMCGeometry::GetPhiCenterOfSM(Int_t nsupmod) const
597 {
598   //returns center of supermodule in phi
599   int i = nsupmod/2;
600   return fPhiCentersOfSM[i];
601
602 }
603
604 //________________________________________________________________________________________________
605 Bool_t AliEMCALEMCGeometry::GetPhiBoundariesOfSM(Int_t nSupMod, Double_t &phiMin, Double_t &phiMax) const
606 {
607   // 0<= nSupMod <=11; phi in rad
608     static int i;
609   if(nSupMod<0 || nSupMod >11) return kFALSE;
610   i = nSupMod/2;
611   phiMin = (Double_t)fPhiBoundariesOfSM[2*i];
612   phiMax = (Double_t)fPhiBoundariesOfSM[2*i+1];
613   return kTRUE;
614 }
615
616 //________________________________________________________________________________________________
617 Bool_t AliEMCALEMCGeometry::GetPhiBoundariesOfSMGap(Int_t nPhiSec, Double_t &phiMin, Double_t &phiMax) const
618 {
619   // 0<= nPhiSec <=4; phi in rad
620   // 0;  gap boundaries between  0th&2th  | 1th&3th SM
621   // 1;  gap boundaries between  2th&4th  | 3th&5th SM
622   // 2;  gap boundaries between  4th&6th  | 5th&7th SM
623   // 3;  gap boundaries between  6th&8th  | 7th&9th SM
624   // 4;  gap boundaries between  8th&10th | 9th&11th SM
625   if(nPhiSec<0 || nPhiSec >4) return kFALSE;
626   phiMin = fPhiBoundariesOfSM[2*nPhiSec+1];
627   phiMax = fPhiBoundariesOfSM[2*nPhiSec+2];
628   return kTRUE;
629 }
630
631 //________________________________________________________________________________________________
632 int AliEMCALEMCGeometry::ParseString(const TString &topt, TObjArray &Opt)
633
634         //Parse string, does what? GCB 08/09
635         Ssiz_t begin, index, end, end2;
636         begin = index = end = end2 = 0;
637         TRegexp separator("[^ ;,\\t\\s/]+");
638         while ( (begin < topt.Length()) && (index != kNPOS) ) {
639                 // loop over given options
640                 index = topt.Index(separator,&end,begin);
641                 if (index >= 0 && end >= 1) {
642                         TString substring(topt(index,end));
643                         Opt.Add(new TObjString(substring.Data()));
644                 }
645                 begin += end+1;
646         }
647         return Opt.GetEntries();
648 }
649