1 /**************************************************************************
2 * Copyright(c) 1998-2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
19 //*-- Implementation version v2 of EMCAL Manager class; SHASHLYK version
20 //*-- An object of this class does not produce digits
21 //*-- It is the one to use if you do want to produce outputs in TREEH
23 //*-- Author : Alexei Pavlinov (WSU)
25 // This Class not stores information on all particles prior to EMCAL entry - in order to facilitate analysis.
26 // This is done by setting fIShunt =2, and flagging all parents of particles entering the EMCAL.
29 // --- ROOT system ---
31 #include <TClonesArray.h>
33 #include <TParticle.h>
35 #include <TVirtualMC.h>
37 // --- Standard library ---
39 // --- AliRoot header files ---
40 #include "AliEMCALv2.h"
41 #include "AliEMCALHit.h"
42 #include "AliEMCALGeometry.h"
44 #include "AliHeader.h"
47 #include "AliTrackReference.h"
48 // for TRD1 case only; May 31,2006
52 //______________________________________________________________________
53 AliEMCALv2::AliEMCALv2()
59 //______________________________________________________________________
60 AliEMCALv2::AliEMCALv2(const char *name, const char *title)
61 : AliEMCALv1(name,title)
65 //fHits= new TClonesArray("AliEMCALHit",1000); //Already done in ctor of v1
66 gAlice->GetMCApp()->AddHitList(fHits);
69 fIshunt = 2; // All hits are associated with particles entering the calorimeter
72 fGeometry = GetGeometry();
75 //______________________________________________________________________
76 AliEMCALv2::~AliEMCALv2(){
79 //Already done in dtor of v1
87 //______________________________________________________________________
88 void AliEMCALv2::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
89 Int_t id, Float_t * hits,Float_t * p){
90 // Add a hit to the hit list.
91 // An EMCAL hit is the sum of all hits in a tower section
92 // originating from the same entering particle
93 static Int_t hitCounter;
94 static AliEMCALHit *newHit, *curHit;
99 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
100 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
101 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
102 // We add hits with the same tracknumber, while GEANT treats
103 // primaries succesively
104 if(curHit->GetPrimary() != primary)
106 if( *curHit == *newHit ) {
107 *curHit = *curHit + *newHit;
109 // break; // 30-aug-04 by PAI
111 } // end for hitCounter
114 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
117 // printf(" fNhits %i \n", fNhits);
121 //______________________________________________________________________
122 void AliEMCALv2::StepManager(void){
123 // Accumulates hits as long as the track stays in a tower
125 // position wrt MRS and energy deposited
126 static Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
127 static Float_t pmom[4]={0.,0.,0.,0.};
128 static TLorentzVector pos; // Lorentz vector of the track current position.
129 static TLorentzVector mom; // Lorentz vector of the track current momentum.
130 static Float_t ienergy = 0; // part->Energy();
131 static TString curVolName="";
132 static int supModuleNumber=-1, moduleNumber=-1, yNumber=-1, xNumber=-1, absid=-1;
133 static int keyGeom=1; //real TRD1 geometry
134 static const char *vn = "SCMX"; // Apr 13, 2006 - only TRD1 case now
135 static int nSMOP[7]={1,3,5,7,9,11}; // 30-mar-05
136 static int nSMON[7]={2,4,6,8,10,12};
137 static Float_t depositedEnergy=0.0;
141 if(gMC->VolId("PBMO")==0 || gMC->VolId("WSUC")==1) {
142 vn = "SCMX"; // old TRD2(TRD1) or WSUC
145 printf("AliEMCALv2::StepManager(): keyGeom %i : Sensetive volume %s \n",
147 if(gMC->VolId("WSUC")==1) printf(" WSUC - cosmic ray stand geometry \n");
149 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
153 curVolName = gMC->CurrentVolName();
154 if(curVolName.Contains(vn) || curVolName.Contains("SCX")) { // We are in a scintillator layer; SCX for 3X3
156 if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy
157 // Info("StepManager "," entry %i DE %f",++ientry, depositedEnergy); // for testing
159 fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber);
161 if (fCurParent==-1 || tracknumber != fCurTrack) {
165 if (fCurParent != -1) {
166 while (parent != fCurParent && parent != -1) {
167 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
168 part=gAlice->GetMCApp()->Particle(parent);
169 parent=part->GetFirstMother();
172 if (fCurParent==-1 || parent==-1) {
173 //Int_t parent=tracknumber;
174 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
176 part=gAlice->GetMCApp()->Particle(parent);
177 while (parent != -1 && fGeometry->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
178 parent=part->GetFirstMother();
180 part=gAlice->GetMCApp()->Particle(parent);
184 Error("StepManager","Cannot find parent");
186 //TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
187 part=gAlice->GetMCApp()->Particle(fCurParent);
188 ienergy = part->Energy();
190 //Add reference to parent in TR tree.
191 AddTrackReference(tracknumber, AliTrackReference::kEMCAL);
194 while (parent != -1) {
195 part=gAlice->GetMCApp()->Particle(parent);
196 part->SetBit(kKeepBit);
197 parent=part->GetFirstMother();
200 fCurTrack=tracknumber;
202 gMC->TrackPosition(pos);
206 xyzte[3] = gMC->TrackTime() ;
208 gMC->TrackMomentum(mom);
214 // if(ientry%200 > 0) return; // testing
215 supModuleNumber = moduleNumber = yNumber = xNumber = absid = 0;
216 if(keyGeom >= 1) { // TRD1 case now
217 gMC->CurrentVolOffID(4, supModuleNumber);
218 gMC->CurrentVolOffID(3, moduleNumber);
219 gMC->CurrentVolOffID(1, yNumber);
220 gMC->CurrentVolOffID(0, xNumber); // really x number now
221 if(strcmp(gMC->CurrentVolOffName(4),"SM10")==0) supModuleNumber += 10; // 13-oct-05
223 if(strcmp(gMC->CurrentVolOffName(0),vn) != 0) { // 3X3 case
224 if (strcmp(gMC->CurrentVolOffName(0),"SCX1")==0) xNumber=1;
225 else if(strcmp(gMC->CurrentVolOffName(0),"SCX2")==0) xNumber=2;
226 else if(strcmp(gMC->CurrentVolOffName(0),"SCX3")==0) xNumber=3;
227 else Fatal("StepManager()", "Wrong name of sensitive volume in 3X3 case : %s ", gMC->CurrentVolOffName(0));
230 gMC->CurrentVolOffID(5, supModuleNumber);
231 gMC->CurrentVolOffID(4, moduleNumber);
232 gMC->CurrentVolOffID(1, yNumber);
233 gMC->CurrentVolOffID(0, xNumber);
234 if (strcmp(gMC->CurrentVolOffName(5),"SMOP")==0) supModuleNumber = nSMOP[supModuleNumber-1];
235 else if(strcmp(gMC->CurrentVolOffName(5),"SMON")==0) supModuleNumber = nSMON[supModuleNumber-1];
236 else assert(0); // something wrong
239 // Due to problem with index ordering conventions the calcultation of absid is no more like this:
240 //absid = fGeometry->GetAbsCellId(smNumber, moduleNumber-1, yNumber-1, xNumber-1);
242 //Swap A side in Phi and C side in Eta due to wrong indexing.
245 Int_t smNumber = supModuleNumber-1;
247 fGeometry->GetCellPhiEtaIndexInSModule(smNumber,moduleNumber-1,yNumber-1,xNumber-1, iphi, ieta);
248 if (smNumber%2 == 0) {
249 ieta = ((fGeometry->GetCentersOfCellsEtaDir()).GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
252 if(smNumber >= 10) smType = 2 ; //half supermodule
253 iphi= ((fGeometry->GetCentersOfCellsPhiDir()).GetSize()/smType-1)-iphi;//23-iphi, revert the ordering on C side in order to keep convention.
256 //Once we know the indexes, calculate the absolute ID
257 absid = fGeometry->GetAbsCellIdFromCellIndexes(smNumber, iphi, ieta);
260 printf(" supModuleNumber %i : moduleNumber %i : yNumber %i : xNumber %i \n",
261 supModuleNumber, moduleNumber, yNumber, xNumber);
262 Fatal("StepManager()", "Wrong id : %i ", absid) ;
265 Float_t lightYield = depositedEnergy ;
266 // Apply Birk's law (copied from G3BIRK)
268 if (gMC->TrackCharge()!=0) { // Check
269 Float_t birkC1Mod = 0;
270 if (fBirkC0==1){ // Apply correction for higher charge states
271 if (TMath::Abs(gMC->TrackCharge())>=2) birkC1Mod = fBirkC1*7.2/12.6;
272 else birkC1Mod = fBirkC1;
276 if (gMC->TrackStep()>0) dedxcm=1000.*gMC->Edep()/gMC->TrackStep();
278 lightYield=lightYield/(1.+birkC1Mod*dedxcm+fBirkC2*dedxcm*dedxcm);
281 // use sampling fraction to get original energy --HG
282 // xyzte[4] = lightYield * fGeometry->GetSampling();
283 xyzte[4] = lightYield; // 15-dec-04
286 printf("#sm %2i #m %3i #x %1i #z %1i -> absid %i : xyzte[4] = %f\n",
287 supModuleNumber,moduleNumber,yNumber,xNumber,absid, xyzte[4]);
289 AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xyzte, pmom);
290 } // there is deposited energy