]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MUONTriggerEfficiency.C
- Adding a new group for macros
[u/mrichter/AliRoot.git] / MUON / MUONTriggerEfficiency.C
CommitLineData
0cb382c1 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/* */
17
18//
19// Macro for checking trigger integrated efficiency for dimuons.
20// The efficiency is calculated with respect to the 3/4 coincidence.
21// Author: Fabien Guerin, LPC Clermont-Ferrand, Jan. 2006
22//
23
24#if !defined(__CINT__) || defined(__MAKECINT__)
25// ROOT includes
26#include "TBranch.h"
27#include "TClonesArray.h"
28#include "TObject.h"
29#include "TFile.h"
30#include "TH1.h"
31#include "TH2.h"
32#include "TTree.h"
33#include "TParticle.h"
34
35// STEER includes
36#include "AliRun.h"
37#include "AliRunLoader.h"
38#include "AliHeader.h"
39#include "AliLoader.h"
40#include "AliStack.h"
9665028d 41#include "AliCDBManager.h"
0cb382c1 42
43// MUON includes
44#include "AliMUON.h"
0cb382c1 45#include "AliMUONHit.h"
46#include "AliMUONConstants.h"
47#include "AliMUONDigit.h"
0cb382c1 48#include "AliMUONGlobalTrigger.h"
0cb382c1 49#include "AliMUONTrack.h"
b1f2fbb2 50
51#include "AliMUONDataInterface.h"
52#include "AliMUONMCDataInterface.h"
53#include "AliMUONVHitStore.h"
54#include "AliMUONVTriggerStore.h"
55
0cb382c1 56#endif
57
58// Upsilon(1S)
59
60
b1f2fbb2 61void MUONTriggerEfficiency(const char* filenameSim="galice_sim.root",
62 const char* filenameRec="galice.root",
63 Bool_t readFromRP = 0)
64{
65
9665028d 66 // Set default CDB storage
67 AliCDBManager* man = AliCDBManager::Instance();
68 man->SetDefaultStorage("local://$ALICE_ROOT");
69
b1f2fbb2 70 // output file
71
72 AliMUONMCDataInterface diSim(filenameSim);
73 AliMUONDataInterface diRec(filenameRec);
74
75 if (!diSim.IsValid())
76 {
77 cerr << "Cannot access " << filenameSim << endl;
78 return;
79 }
80
81 if (!diRec.IsValid())
82 {
83 cerr << "Cannot access " << filenameRec << endl;
84 return;
85 }
0cb382c1 86
b1f2fbb2 87 FILE* fdat = fopen("MUONTriggerEfficiency.out","w");
88 if (!fdat)
89 {
90 cerr << "Cannot create output file" << endl;
91 return;
92 }
0cb382c1 93
b1f2fbb2 94 Int_t coincmuon,muonlpt,muonhpt;
0cb382c1 95 Int_t CoincMuPlus,CoincMuMinus;
96 coincmuon=0;
0cb382c1 97 muonlpt=0;
394cb950 98 muonhpt=0;
b1f2fbb2 99
100 Int_t nevents = diSim.NumberOfEvents();
101
102 for (Int_t ievent=0; ievent<nevents; ++ievent)
103 {
104 CoincMuPlus=0;
105 CoincMuMinus=0;
0cb382c1 106
b1f2fbb2 107 if (ievent%1000==0) printf("\t Event = %d\n",ievent);
6b092dfc 108
b1f2fbb2 109 // Hits
110
111 Int_t NbHits[2][4];
112 for (Int_t j=0; j<2; j++)
113 {
114 for (Int_t jj=0; jj<4; jj++)
115 {
116 NbHits[j][jj]=0;
117 }
0cb382c1 118 }
6b092dfc 119
b1f2fbb2 120 Int_t ntracks = (Int_t) diSim.NumberOfTracks(ievent);
121
122 for ( Int_t itrack=0; itrack<ntracks; ++itrack )
123 {
124 AliMUONVHitStore* hitStore = diSim.HitStore(ievent,itrack);
0cb382c1 125 AliMUONHit* mHit;
b1f2fbb2 126 TIter next(hitStore->CreateIterator());
127
128 while ( ( mHit = static_cast<AliMUONHit*>(next()) ) )
129 {
130 Int_t Nch = mHit->Chamber();
131 Int_t hittrack = mHit->Track();
132 Float_t IdPart = mHit->Particle();
133
134 for (Int_t j=0;j<4;j++)
135 {
136 Int_t kch=11+j;
137 if (hittrack==1 || hittrack==2)
138 {
139 if (Nch==kch && IdPart==-13 && NbHits[0][j]==0) NbHits[0][j]++;
140 if (Nch==kch && IdPart==13 && NbHits[1][j]==0) NbHits[1][j]++;
0cb382c1 141 }
142 }
b1f2fbb2 143 }
0cb382c1 144 } // end track loop
145
b1f2fbb2 146 // 3/4 coincidence
147 Int_t SumNbHits=NbHits[0][0]+NbHits[0][1]+NbHits[0][2]+NbHits[0][3];
0cb382c1 148 if (SumNbHits==3 || SumNbHits==4) CoincMuPlus=1;
b1f2fbb2 149
0cb382c1 150 SumNbHits=NbHits[1][0]+NbHits[1][1]+NbHits[1][2]+NbHits[1][3];
151 if (SumNbHits==3 || SumNbHits==4) CoincMuMinus=1;
152
153 if (CoincMuPlus==1 && CoincMuMinus==1) coincmuon++;
b1f2fbb2 154
155 TString tree("D");
156 if ( readFromRP ) tree = "R";
6b092dfc 157
b1f2fbb2 158 AliMUONVTriggerStore* triggerStore = diRec.TriggerStore(ievent,tree.Data());
159
160 AliMUONGlobalTrigger* gloTrg = triggerStore->Global();
0cb382c1 161
b1f2fbb2 162 if (gloTrg->PairUnlikeLpt()>=1) muonlpt++;
163 if (gloTrg->PairUnlikeHpt()>=1) muonhpt++;
0cb382c1 164
165 } // end loop on event
0cb382c1 166
167 // calculate efficiency with as a ref. at least 3/4 planes fired
ad705f30 168 Float_t efficiencylpt,efficiencyhpt;
169 Double_t coincmu,lptmu,hptmu;
0cb382c1 170 Float_t error;
ad705f30 171 coincmu=Double_t(coincmuon);
0cb382c1 172 lptmu=Double_t(muonlpt);
173 hptmu=Double_t(muonhpt);
174
0cb382c1 175 // output
176 fprintf(fdat,"\n");
177 fprintf(fdat," Number of events = %d \n",nevents);
178 fprintf(fdat," Number of events with 3/4 coinc = %d \n",coincmuon);
0cb382c1 179 fprintf(fdat," Nomber of dimuons with 3/4 coinc Lpt cut = %d \n",muonlpt);
180 fprintf(fdat," Number of dimuons with 3/4 coinc Hpt cut = %d \n",muonhpt);
181 fprintf(fdat,"\n");
182
0cb382c1 183 efficiencylpt=lptmu/coincmu;
184 error=efficiencylpt*TMath::Sqrt((lptmu+coincmu)/(lptmu*coincmu));
185 fprintf(fdat," Efficiency Lpt cut = %4.4f +/- %4.4f\n",efficiencylpt,error);
186
187 efficiencyhpt=hptmu/coincmu;
188 error=efficiencyhpt*TMath::Sqrt((hptmu+coincmu)/(hptmu*coincmu));
189 fprintf(fdat," Efficiency Hpt cut = %4.4f +/- %4.4f\n",efficiencyhpt,error);
190
191
192 fclose(fdat);
193}
194
195
196
197
198