]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/macros/Trigger/triggerClusters.C
Coverity fix
[u/mrichter/AliRoot.git] / PHOS / macros / Trigger / triggerClusters.C
1 void triggerClusters(Float_t eClu=2., const char* file="AliESDs.root")
2 {
3   //Test macro.
4   //Illustrates how to use trigger info in the ESD.
5
6   //Prints fired 4x4 TRUs and respective PHOS clusters with energy>eClu positions.
7   //For TRU this is bottom-left cell of 4x4 region,
8   //for cluster it is the cell with the max. energy deposition.
9   
10   //Author: Boris Polishchuk (Boris.Polishchuk@cern.ch).
11
12   TChain* esdTree = new TChain("esdTree");
13   esdTree->Add(file);
14
15   AliESDEvent *esd = new AliESDEvent;
16   esd->ReadFromTree(esdTree);
17
18   AliPHOSGeometry* geom = AliPHOSGeometry::GetInstance("IHEP");
19
20   for(Int_t iEvent=0; iEvent<esdTree->GetEntries(); iEvent++){
21     
22     esdTree->GetEvent(iEvent);
23     TString trigClasses = esd->GetFiredTriggerClasses();
24
25     Int_t multClu = esd->GetNumberOfCaloClusters();
26     AliESDCaloCells *phsCells = esd->GetPHOSCells();
27
28     AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("PHOS");
29     trgESD->Reset();
30
31     if(trgESD->GetEntries())
32     printf("\nEvent %d: %d non-zero trigger digits %s\n",
33            iEvent,trgESD->GetEntries(),trigClasses.Data());
34
35     //Loop over 4x4 fired regions
36
37     while(trgESD->Next()) {
38
39       Int_t tmod,tabsId; // "Online" module number, bottom-left 4x4 edge cell absId
40       trgESD->GetPosition(tmod,tabsId);
41
42       Int_t trelid[4] ;
43       geom->AbsToRelNumbering(tabsId,trelid);
44
45       printf("\t4x4 position: (mod,X,Z)=(%d,%d,%d)\n",trelid[0],trelid[2],trelid[3]);
46
47       for (Int_t i=0; i<multClu; i++) {
48         
49         AliESDCaloCluster *c1 = esd->GetCaloCluster(i);
50         if(!c1->IsPHOS()) continue;
51         
52         Int_t maxId, relid[4];
53         MaxEnergyCellPos(phsCells,c1,maxId);
54         
55         geom->AbsToRelNumbering(maxId, relid);
56         if(c1->E()>eClu) printf("\t\tCluster: (mod,X,Z)=(%d,%d,%d), E=%.3f GeV\n",
57                relid[0],relid[2],relid[3],c1->E());
58       }
59
60     }
61     
62     
63     
64   }
65 }
66
67 void MaxEnergyCellPos(AliESDCaloCells *cells, AliESDCaloCluster* clu, Int_t& maxId)
68 {  
69   Double_t eMax = -111;
70   
71   for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) {
72     Int_t cellAbsId = clu->GetCellAbsId(iDig);
73     Double_t eCell = cells->GetCellAmplitude(cellAbsId)*clu->GetCellAmplitudeFraction(iDig);
74     if(eCell>eMax)  { 
75       eMax = eCell; 
76       maxId = cellAbsId;
77     }
78   }
79
80 }