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 : Aleksei 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.
28 // --- ROOT system ---
29 #include "AliEMCALv3.h"
30 #include "AliEMCALHitv1.h"
32 #include "TParticle.h"
33 #include "TVirtualMC.h"
38 // --- Standard library ---
40 // --- AliRoot header files ---
41 #include "AliEMCALGeometry.h"
43 #include "AliHeader.h"
50 //extern "C" void gdaxis_(float &x0, float &y0, float &z0, float &axsiz);
53 //______________________________________________________________________
54 AliEMCALv3::AliEMCALv3():AliEMCALv1(){
59 //______________________________________________________________________
60 AliEMCALv3::AliEMCALv3(const char *name, const char *title): AliEMCALv1(name,title) {
63 fHits= new TClonesArray("AliEMCALHitv1",2000);
64 gAlice->GetMCApp()->AddHitList(fHits);
67 fIshunt = 2; // All hits are associated with particles entering the calorimeter
70 fGeometry = GetGeometry();
73 //______________________________________________________________________
74 AliEMCALv3::AliEMCALv3(const AliEMCALv3 & emcal):AliEMCALv1(emcal)
76 fGeometry = emcal.fGeometry;
79 //______________________________________________________________________
80 AliEMCALv3::~AliEMCALv3(){
90 //______________________________________________________________________
91 void AliEMCALv3::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
92 Int_t id, Float_t * hits,Float_t * p){
93 // Add a hit to the hit list.
94 // An EMCAL hit is the sum of all hits in a tower section
95 // originating from the same entering particle
96 static Int_t hitCounter;
97 static AliEMCALHitv1 *newHit, *curHit;
102 newHit = new AliEMCALHitv1(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
103 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
104 curHit = (AliEMCALHitv1*) (*fHits)[hitCounter];
105 // We add hits with the same tracknumber, while GEANT treats
106 // primaries succesively
107 if(curHit->GetPrimary() != primary)
109 if( *curHit == *newHit ) {
110 *curHit = *curHit + *newHit;
112 // break; // 30-aug-04 by PAI
114 } // end for hitCounter
117 new((*fHits)[fNhits]) AliEMCALHitv1(*newHit);
120 // printf(" fNhits %i \n", fNhits);
123 //______________________________________________________________________
124 void AliEMCALv3::StepManager(void){
125 // Accumulates hits as long as the track stays in a tower
127 // position wrt MRS and energy deposited
128 static Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
129 static Float_t pmom[4]={0.,0.,0.,0.};
130 static TLorentzVector pos; // Lorentz vector of the track current position.
131 static TLorentzVector mom; // Lorentz vector of the track current momentum.
132 static Float_t ienergy = 0;
133 static TString curVolName;
134 static int supModuleNumber, moduleNumber, yNumber, xNumber, absid;
135 static int keyGeom=0;
136 static char *vn = "SX"; // 15-mar-05
137 static int nSMOP[7]={1,3,5,7,9,11}; // 30-mar-05
138 static int nSMON[7]={2,4,6,8,10,12};
139 static Float_t depositedEnergy=0.0;
143 if(gMC->VolId("PBMO")==0 || gMC->VolId("WSUC")==1) {
144 vn = "SCMX"; // old TRD2(TRD1) or WSUC
147 printf("AliEMCALv3::StepManager(): keyGeom %i : Sensetive volume %s \n",
149 if(gMC->VolId("WSUC")==1) printf(" WSUC - cosmic ray stand geometry \n");
151 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
153 curVolName = gMC->CurrentVolName();
154 if(curVolName.Contains(vn)) { // We are in a scintillator layer
155 // printf(" keyGeom %i : Sensetive volume %s (%s) \n", keyGeom, curVolName.Data(), vn);
157 if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy
158 // Info("StepManager "," entry %i DE %f",++ientry, depositedEnergy); // for testing
160 fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber);
162 if (fCurParent==-1 || tracknumber != fCurTrack) {
164 Int_t parent=tracknumber;
165 if (fCurParent != -1) {
166 while (parent != fCurParent && parent != -1) {
167 TParticle *part=gAlice->GetMCApp()->Particle(parent);
168 parent=part->GetFirstMother();
171 if (fCurParent==-1 || parent==-1) {
172 Int_t parent=tracknumber;
173 TParticle *part=gAlice->GetMCApp()->Particle(parent);
174 while (parent != -1 && fGeometry->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
175 parent=part->GetFirstMother();
177 part=gAlice->GetMCApp()->Particle(parent);
181 Error("StepManager","Cannot find parent");
183 TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
184 ienergy = part->Energy();
186 while (parent != -1) {
187 part=gAlice->GetMCApp()->Particle(parent);
188 part->SetBit(kKeepBit);
189 parent=part->GetFirstMother();
192 fCurTrack=tracknumber;
194 gMC->TrackPosition(pos);
198 xyzte[3] = gMC->TrackTime() ;
200 gMC->TrackMomentum(mom);
206 // if(ientry%200 > 0) return; // testing
207 supModuleNumber = moduleNumber = yNumber = xNumber = absid = 0;
208 if(keyGeom >= 1) { // old style
209 gMC->CurrentVolOffID(4, supModuleNumber);
210 gMC->CurrentVolOffID(3, moduleNumber);
211 gMC->CurrentVolOffID(1, yNumber);
212 gMC->CurrentVolOffID(0, xNumber); // really x number now
213 if(strcmp(gMC->CurrentVolOffName(4),"SM10")==0) supModuleNumber += 10; // 13-oct-05
215 gMC->CurrentVolOffID(5, supModuleNumber);
216 gMC->CurrentVolOffID(4, moduleNumber);
217 gMC->CurrentVolOffID(1, yNumber);
218 gMC->CurrentVolOffID(0, xNumber);
219 if (strcmp(gMC->CurrentVolOffName(5),"SMOP")==0) supModuleNumber = nSMOP[supModuleNumber-1];
220 else if(strcmp(gMC->CurrentVolOffName(5),"SMON")==0) supModuleNumber = nSMON[supModuleNumber-1];
221 else assert(0); // something wrong
223 absid = fGeometry->GetAbsCellId(supModuleNumber, moduleNumber, yNumber, xNumber);
225 if (absid == -1) Fatal("StepManager()", "Wrong id ") ;
227 Float_t lightYield = depositedEnergy ;
228 // Apply Birk's law (copied from G3BIRK)
230 if (gMC->TrackCharge()!=0) { // Check
231 Float_t BirkC1_mod = 0;
232 if (fBirkC0==1){ // Apply correction for higher charge states
233 if (TMath::Abs(gMC->TrackCharge())>=2) BirkC1_mod=fBirkC1*7.2/12.6;
234 else BirkC1_mod=fBirkC1;
238 if (gMC->TrackStep()>0) dedxcm=1000.*gMC->Edep()/gMC->TrackStep();
240 lightYield=lightYield/(1.+BirkC1_mod*dedxcm+fBirkC2*dedxcm*dedxcm);
243 xyzte[4] = lightYield; // 15-dec-04
244 Float_t xd[5]; // see Gmtod
245 gMC->Gmtod(xyzte, xd, 1);
248 // printf(" x %7.2f y %7.2f z %7.2f de %f\n", xd[0], xd[1], xd[2], xd[4]);
251 printf("#sm %2i #m %3i #x %1i #z %1i -> absid %i : xyzte[4] = %f\n",
252 supModuleNumber,moduleNumber,yNumber,xNumber,absid, xd[4]);
254 AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xd, pmom);
255 } // there is deposited energy
259 //_____________________________________________
260 void AliEMCALv3::Browse(TBrowser* b)