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.
29 // --- ROOT system ---
31 #include <TClonesArray.h>
34 #include <TParticle.h>
36 #include <TVirtualMC.h>
38 // --- Standard library ---
40 // --- AliRoot header files ---
41 #include "AliEMCALv2.h"
42 #include "AliEMCALHit.h"
43 #include "AliEMCALGeometry.h"
45 #include "AliHeader.h"
48 #include "AliPoints.h"
49 // for TRD1 case only; May 31,2006
53 //______________________________________________________________________
54 AliEMCALv2::AliEMCALv2()
62 //______________________________________________________________________
63 AliEMCALv2::AliEMCALv2(const char *name, const char *title)
64 : AliEMCALv1(name,title),
70 fHits= new TClonesArray("AliEMCALHit",1000);
71 gAlice->GetMCApp()->AddHitList(fHits);
74 fIshunt = 2; // All hits are associated with particles entering the calorimeter
77 fGeometry = GetGeometry();
82 fHDe = new TH1F("fHDe","De in EMCAL", 1000, 0., 10.);
83 fHNhits = new TH1F("fHNhits","#hits in EMCAL", 2001, -0.5, 2000.5);
84 fHistograms->Add(fHDe);
85 fHistograms->Add(fHNhits);
90 //______________________________________________________________________
91 AliEMCALv2::~AliEMCALv2(){
101 //______________________________________________________________________
102 void AliEMCALv2::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
103 Int_t id, Float_t * hits,Float_t * p){
104 // Add a hit to the hit list.
105 // An EMCAL hit is the sum of all hits in a tower section
106 // originating from the same entering particle
107 static Int_t hitCounter;
108 static AliEMCALHit *newHit, *curHit;
113 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
114 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
115 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
116 // We add hits with the same tracknumber, while GEANT treats
117 // primaries succesively
118 if(curHit->GetPrimary() != primary)
120 if( *curHit == *newHit ) {
121 *curHit = *curHit + *newHit;
123 // break; // 30-aug-04 by PAI
125 } // end for hitCounter
128 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
131 // printf(" fNhits %i \n", fNhits);
135 //______________________________________________________________________
136 void AliEMCALv2::StepManager(void){
137 // Accumulates hits as long as the track stays in a tower
139 // position wrt MRS and energy deposited
140 static Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
141 static Float_t pmom[4]={0.,0.,0.,0.};
142 static TLorentzVector pos; // Lorentz vector of the track current position.
143 static TLorentzVector mom; // Lorentz vector of the track current momentum.
144 static Float_t ienergy = 0; // part->Energy();
145 static TString curVolName;
146 static int supModuleNumber, moduleNumber, yNumber, xNumber, absid;
147 static int keyGeom=1; //real TRD1 geometry
148 static char *vn = "SCMX"; // Apr 13, 2006 - only TRD1 case now
149 static int nSMOP[7]={1,3,5,7,9,11}; // 30-mar-05
150 static int nSMON[7]={2,4,6,8,10,12};
151 static Float_t depositedEnergy=0.0;
155 if(gMC->VolId("PBMO")==0 || gMC->VolId("WSUC")==1) {
156 vn = "SCMX"; // old TRD2(TRD1) or WSUC
159 printf("AliEMCALv2::StepManager(): keyGeom %i : Sensetive volume %s \n",
161 if(gMC->VolId("WSUC")==1) printf(" WSUC - cosmic ray stand geometry \n");
163 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber();
167 curVolName = gMC->CurrentVolName();
168 if(curVolName.Contains(vn) || curVolName.Contains("SCX")) { // We are in a scintillator layer; SCX for 3X3
170 if( ((depositedEnergy = gMC->Edep()) > 0.) && (gMC->TrackTime() < fTimeCut)){// Track is inside a scintillator and deposits some energy
171 // Info("StepManager "," entry %i DE %f",++ientry, depositedEnergy); // for testing
173 fCurPrimary=gAlice->GetMCApp()->GetPrimary(tracknumber);
175 if (fCurParent==-1 || tracknumber != fCurTrack) {
177 //Int_t parent=tracknumber;
179 if (fCurParent != -1) {
180 while (parent != fCurParent && parent != -1) {
181 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
182 part=gAlice->GetMCApp()->Particle(parent);
183 parent=part->GetFirstMother();
186 if (fCurParent==-1 || parent==-1) {
187 //Int_t parent=tracknumber;
188 //TParticle *part=gAlice->GetMCApp()->Particle(parent);
190 part=gAlice->GetMCApp()->Particle(parent);
191 while (parent != -1 && fGeometry->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
192 parent=part->GetFirstMother();
194 part=gAlice->GetMCApp()->Particle(parent);
198 Error("StepManager","Cannot find parent");
200 //TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
201 part=gAlice->GetMCApp()->Particle(fCurParent);
202 ienergy = part->Energy();
204 while (parent != -1) {
205 part=gAlice->GetMCApp()->Particle(parent);
206 part->SetBit(kKeepBit);
207 parent=part->GetFirstMother();
210 fCurTrack=tracknumber;
212 gMC->TrackPosition(pos);
216 xyzte[3] = gMC->TrackTime() ;
218 gMC->TrackMomentum(mom);
224 // if(ientry%200 > 0) return; // testing
225 supModuleNumber = moduleNumber = yNumber = xNumber = absid = 0;
226 if(keyGeom >= 1) { // TRD1 case now
227 gMC->CurrentVolOffID(4, supModuleNumber);
228 gMC->CurrentVolOffID(3, moduleNumber);
229 gMC->CurrentVolOffID(1, yNumber);
230 gMC->CurrentVolOffID(0, xNumber); // really x number now
231 if(strcmp(gMC->CurrentVolOffName(4),"SM10")==0) supModuleNumber += 10; // 13-oct-05
233 if(strcmp(gMC->CurrentVolOffName(0),vn) != 0) { // 3X3 case
234 if (strcmp(gMC->CurrentVolOffName(0),"SCX1")==0) xNumber=1;
235 else if(strcmp(gMC->CurrentVolOffName(0),"SCX2")==0) xNumber=2;
236 else if(strcmp(gMC->CurrentVolOffName(0),"SCX3")==0) xNumber=3;
237 else Fatal("StepManager()", "Wrong name of sensetive volume in 3X3 case : %s ", gMC->CurrentVolOffName(0));
240 gMC->CurrentVolOffID(5, supModuleNumber);
241 gMC->CurrentVolOffID(4, moduleNumber);
242 gMC->CurrentVolOffID(1, yNumber);
243 gMC->CurrentVolOffID(0, xNumber);
244 if (strcmp(gMC->CurrentVolOffName(5),"SMOP")==0) supModuleNumber = nSMOP[supModuleNumber-1];
245 else if(strcmp(gMC->CurrentVolOffName(5),"SMON")==0) supModuleNumber = nSMON[supModuleNumber-1];
246 else assert(0); // something wrong
248 absid = fGeometry->GetAbsCellId(supModuleNumber-1, moduleNumber-1, yNumber-1, xNumber-1);
251 printf(" supModuleNumber %i : moduleNumber %i : yNumber %i : xNumber %i \n",
252 supModuleNumber, moduleNumber, yNumber, xNumber);
253 Fatal("StepManager()", "Wrong id : %i ", absid) ;
256 Float_t lightYield = depositedEnergy ;
257 // Apply Birk's law (copied from G3BIRK)
259 if (gMC->TrackCharge()!=0) { // Check
260 Float_t birkC1Mod = 0;
261 if (fBirkC0==1){ // Apply correction for higher charge states
262 if (TMath::Abs(gMC->TrackCharge())>=2) birkC1Mod = fBirkC1*7.2/12.6;
263 else birkC1Mod = fBirkC1;
267 if (gMC->TrackStep()>0) dedxcm=1000.*gMC->Edep()/gMC->TrackStep();
269 lightYield=lightYield/(1.+birkC1Mod*dedxcm+fBirkC2*dedxcm*dedxcm);
272 // use sampling fraction to get original energy --HG
273 // xyzte[4] = lightYield * fGeometry->GetSampling();
274 xyzte[4] = lightYield; // 15-dec-04
277 printf("#sm %2i #m %3i #x %1i #z %1i -> absid %i : xyzte[4] = %f\n",
278 supModuleNumber,moduleNumber,yNumber,xNumber,absid, xyzte[4]);
280 AddHit(fIshunt, fCurPrimary,tracknumber, fCurParent, ienergy, absid, xyzte, pmom);
281 } // there is deposited energy
285 //_________________________________________________________________
286 void AliEMCALv2::FinishEvent()
288 // Calculate deposit energy and fill control histogram; 26-may-05
290 fHNhits->Fill(double(fHits->GetEntries()));
291 de = GetDepositEnergy(0);
292 if(fHDe) fHDe->Fill(de);
295 //_________________________________________________________________
296 Double_t AliEMCALv2::GetDepositEnergy(int print)
298 // 23-mar-05 - for testing
299 if(fHits == 0) return 0.;
302 for(int ih=0; ih<fHits->GetEntries(); ih++) {
303 hit = (AliEMCALHit*)fHits->UncheckedAt(ih);
304 de += hit->GetEnergy();
307 cout<<"AliEMCALv2::GetDepositEnergy() : fHits "<<fHits<<endl;
308 printf(" #hits %i de %f \n", fHits->GetEntries(), de);
310 printf(" #primary particles %i\n", gAlice->GetHeader()->GetNprimary());
316 //___________________________________________________________
317 void AliEMCALv2::Browse(TBrowser* b)
322 //___________________________________________________________
323 void AliEMCALv2::DrawCalorimeterCut(const char *name, int axis, double dcut)
325 // Size of tower is 5.6x5.6x24.8 (25.0); cut on Z axiz
326 TString g(fGeometry->GetName());
328 gMC->Gsatt("*", "seen", 0);
332 if(axis!=1) SetVolumeAttributes("STPL", 1, 1, fill);
336 if(sn.Contains("SCM")) colo=5;
337 SetVolumeAttributes(name, 1, colo, fill);
338 if(g.Contains("110DEG") && sn=="SMOD") SetVolumeAttributes("SM10", 1, colo, fill);
340 TString st(GetTitle());
344 char *optShad = "on", *optHide="on";
348 // optHide = optShad = "off";
350 if(dcut==0.) SetVolumeAttributes("SCM0", 1, 5, fill); // yellow
353 gMC->Gdopt("hide", optHide);
354 gMC->Gdopt("shad", optShad);
356 gROOT->ProcessLine("TGeant3 *g3 = (TGeant3*)gMC");
358 sprintf(cmd,"g3->Gdrawc(\"XEN1\", %i, %5.1f, 12., 8., %3.2f, %3.2f)\n", axis, dcut, cxy,cxy);
359 printf("\n%s\n",cmd); gROOT->ProcessLine(cmd);
361 sprintf(cmd,"gMC->Gdhead(1111, \"%s\")\n", st.Data());
362 printf("%s\n",cmd); gROOT->ProcessLine(cmd);
365 //___________________________________________________________
366 void AliEMCALv2::DrawSuperModuleCut(const char *name, int axis, double dcut, int fill)
368 // Size of tower is 5.6x5.6x24.8 (25.0); cut on Z axiz
369 TString sn(GetGeometry()->GetName());
371 char *tit[3]={"xcut", "ycut", "zcut"};
372 if(axis<1) axis=1; if(axis>3) axis=3;
374 gMC->Gsatt("*", "seen", 0);
377 // SetVolumeAttributes("SMOD", 1, 1, fill); // black
378 SetVolumeAttributes(name, 1, 5, fill); // yellow
380 double cxy=0.055, x0=10., y0=10.;
381 char *optShad = "on", *optHide="on";
382 SetVolumeAttributes("STPL", 1, 3, fill); // green
384 gMC->Gsatt("STPL", "seen", 0);
388 } else if(axis==3) cxy = 0.1;
390 gMC->Gdopt("hide", optHide);
391 gMC->Gdopt("shad", optShad);
393 TString st("Shish-Kebab, Compact, SMOD, ");
396 gROOT->ProcessLine("TGeant3 *g3 = (TGeant3*)gMC");
398 sprintf(cmd,"g3->Gdrawc(\"SMOD\", %i, %6.3f, %5.1f, %5.1f, %5.3f, %5.3f)\n",axis,dcut,x0,y0,cxy,cxy);
399 printf("\n%s\n",cmd); gROOT->ProcessLine(cmd);
401 sprintf(cmd,"gMC->Gdhead(1111, \"%s\")\n", st.Data());
402 printf("%s\n",cmd); gROOT->ProcessLine(cmd);
404 printf("Begin of super module\n");
405 printf("g3->Gdrawc(\"SMOD\", 2, 0.300, 89., 10., 0.5, 0.5)\n");
406 printf("Center of super modules\n");
407 printf("g3->Gdrawc(\"SMOD\", 2, 0.300, 0., 10., 0.5, 0.5)\n");
408 printf("end of super modules\n");
409 printf("g3->Gdrawc(\"SMOD\", 2, 0.300, -70., 10., 0.5, 0.5)\n");
412 //___________________________________________________________
413 void AliEMCALv2::DrawTowerCut(const char *name, int axis, double dcut, int fill, char *optShad)
415 // Size of tower is 5.6x5.6x24.8 (25.0); cut on Z axiz
416 if(axis<1) axis=1; if(axis>3) axis=3;
417 TString mn(name); mn.ToUpper();
418 TString sn(GetGeometry()->GetName());
420 gMC->Gsatt("*", "seen", 0);
421 gMC->Gsatt("*", "fill", fill);
423 // int mainColo=5; // yellow
425 SetVolumeAttributes(mn.Data(), 1, 1, fill);
426 SetVolumeAttributes("SCM0", 1, 5, fill); // yellow
427 SetVolumeAttributes("SCPA", 1, 3, fill); // green - 13-may-05
428 } else if(mn == "SCM0") { // first division
429 SetVolumeAttributes(mn.Data(), 1, 1, fill);
430 SetVolumeAttributes("SCMY", 1, 5, fill); // yellow
431 } else if(mn == "SCMY") { // first division
432 SetVolumeAttributes(mn.Data(), 1, 1, fill);
433 SetVolumeAttributes("SCMX", 1, 5, fill); // yellow
434 } else if(mn == "SCMX" || mn.Contains("SCX")) {
435 SetVolumeAttributes(mn.Data(), 1, 5, fill);// yellow
436 SetVolumeAttributes("PBTI", 1, 4, fill);
438 printf("<W> for volume |%s| did not defined volume attributes\n", mn.Data());
441 TString st("Shashlyk, 2x2 mm sampling, 77 layers, ");
444 gROOT->ProcessLine("TGeant3 *g3 = (TGeant3*)gMC");
445 double cx=0.78, cy=2.;
446 if (mn.Contains("EMOD")) {
451 gMC->Gdopt("hide", optShad);
452 gMC->Gdopt("shad", optShad);
454 sprintf(cmd,"g3->Gdrawc(\"%s\", %i, %6.2f, 10., 10., %5.3f, %5.3f)\n",name, axis,dcut,cx,cy);
455 printf("\n%s\n",cmd); gROOT->ProcessLine(cmd);
457 sprintf(cmd,"gMC->Gdhead(1111, \"%s\")\n", st.Data());
458 printf("%s\n",cmd); gROOT->ProcessLine(cmd);
461 //___________________________________________________________
462 void AliEMCALv2::DrawAlicWithHits(int mode)
464 // 20-sep-04; does not work now
466 if(h2==0) h2 = new TH2F("h2","test fo hits", 60,0.5,60.5, 28,0.5,28.5);
469 gROOT->ProcessLine("TGeant3 *g3 = (TGeant3*)gMC");
470 gMC->Gsatt("*","seen",0);
471 gMC->Gsatt("scm0","seen",5);
473 gROOT->ProcessLine("g3->Gdrawc(\"ALIC\", 1, 2.0, 12., -130, 0.3, 0.3)");
474 // g3->Gdrawc("ALIC", 1, 2.0, 10., -14, 0.05, 0.05)
477 TClonesArray *hits = Hits();
478 Int_t nhits = hits->GetEntries(), absId, nSupMod, nModule, nIphi, nIeta, iphi, ieta;
479 AliEMCALHit *hit = 0;
481 for(Int_t i=0; i<nhits; i++) {
482 hit = (AliEMCALHit*)hits->UncheckedAt(i);
483 absId = hit->GetId();
484 de = hit->GetEnergy();
486 if(fGeometry->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta)){
487 // printf(" de %f abs id %i smod %i tower %i | cell iphi %i : ieta %i\n",
488 // de, absId, nSupMod, nModule, nIphi, nIeta);
490 fGeometry->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
491 // printf(" iphi %i : ieta %i\n", iphi,ieta);
492 h2->Fill(double(ieta),double(iphi), de);
497 printf(" #hits %i : sum de %f -> %f \n", nhits, des, h2->Integral());
498 if(mode>0 && h2->Integral()>0.) h2->Draw();
501 //___________________________________________________________
502 void AliEMCALv2::SetVolumeAttributes(const char *name, int seen, int color, int fill)
504 /* seen=-2:volume is visible but none of its descendants;
505 -1:volume is not visible together with all its descendants;
506 0:volume is not visible;
507 1:volume is visible. */
508 gMC->Gsatt(name, "seen", seen);
509 gMC->Gsatt(name, "colo", color);
510 gMC->Gsatt(name, "fill", fill);
511 printf(" %s : seen %i color %i fill %i \n", name, seen, color, fill);
514 //___________________________________________________________
515 void AliEMCALv2::TestIndexTransition(int pri, int idmax)
517 // Test for EMCAL SHISHKEBAB geometry
519 Int_t nSupMod, nModule, nIphi, nIeta, idNew, nGood=0;
520 if(idmax==0) idmax = fGeometry->GetNCells();
521 for(Int_t id=1; id<=idmax; id++) {
522 if(!fGeometry->GetCellIndex(id, nSupMod, nModule, nIphi, nIeta)){
523 printf(" Wrong abs ID %i : #cells %i\n", id, fGeometry->GetNCells());
526 idNew = fGeometry->GetAbsCellId(nSupMod, nModule, nIphi, nIeta);
527 if(id != idNew || pri>0) {
528 printf(" ID %i : %i <- new id\n", id, idNew);
529 printf(" nSupMod %i ", nSupMod);
530 printf(" nModule %i ", nModule);
531 printf(" nIphi %i ", nIphi);
532 printf(" nIeta %i \n", nIeta);
536 printf(" Good decoding %i : %i <- #cells \n", nGood, fGeometry->GetNCells());