]>
Commit | Line | Data |
---|---|---|
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" | |
41 | ||
42 | // MUON includes | |
43 | #include "AliMUON.h" | |
6b092dfc | 44 | #include "AliMUONSimData.h" |
45 | #include "AliMUONRecData.h" | |
0cb382c1 | 46 | #include "AliMUONHit.h" |
47 | #include "AliMUONConstants.h" | |
48 | #include "AliMUONDigit.h" | |
49 | #include "AliMUONRawCluster.h" | |
50 | #include "AliMUONGlobalTrigger.h" | |
51 | #include "AliMUONLocalTrigger.h" | |
52 | #include "AliMUONTrack.h" | |
53 | #endif | |
54 | ||
55 | // Upsilon(1S) | |
56 | ||
57 | ||
6b092dfc | 58 | void MUONTriggerEfficiency (char filenameSim[10]="galice_sim.root", |
59 | char filenameRec[10]="galice.root", | |
60 | Bool_t readFromRP = 0){ | |
0cb382c1 | 61 | |
62 | // output file | |
63 | char digitdat[100]; | |
64 | char currentfile[100]; | |
65 | sprintf(digitdat,"MUONTriggerEfficiency.out"); | |
66 | ||
67 | FILE *fdat=fopen(digitdat,"w"); | |
68 | ||
ad705f30 | 69 | Int_t nevents,coincmuon,muonlpt,muonhpt; |
0cb382c1 | 70 | Int_t CoincMuPlus,CoincMuMinus; |
71 | coincmuon=0; | |
0cb382c1 | 72 | muonlpt=0; |
394cb950 | 73 | muonhpt=0; |
0cb382c1 | 74 | |
75 | // Initialise AliRoot | |
76 | // Creating Run Loader and openning file containing Hits | |
6b092dfc | 77 | AliRunLoader * RunLoaderSim = AliRunLoader::Open(filenameSim,"MUONFolderSim","READ"); |
0cb382c1 | 78 | |
6b092dfc | 79 | if (RunLoaderSim ==0x0) { |
0cb382c1 | 80 | printf(">>> Error : Error Opening %s file \n",currentfile); |
81 | return; | |
82 | } | |
83 | ||
6b092dfc | 84 | AliRunLoader * RunLoaderRec = AliRunLoader::Open(filenameRec,"MUONFolder","READ"); |
85 | ||
86 | if (RunLoaderRec ==0x0) { | |
87 | printf(">>> Error : Error Opening %s file \n",currentfile); | |
88 | return; | |
89 | } | |
90 | ||
91 | nevents = RunLoaderSim->GetNumberOfEvents(); | |
0cb382c1 | 92 | |
394cb950 | 93 | |
6b092dfc | 94 | AliLoader * MUONLoaderSim = RunLoaderSim->GetLoader("MUONLoader"); |
95 | AliLoader * MUONLoaderRec = RunLoaderRec->GetLoader("MUONLoader"); | |
96 | ||
394cb950 | 97 | if (!readFromRP) { |
98 | cout << " reading from digits \n"; | |
6b092dfc | 99 | MUONLoaderSim->LoadDigits("READ"); |
394cb950 | 100 | } else { |
101 | cout << " reading from RecPoints \n"; | |
6b092dfc | 102 | MUONLoaderRec->LoadRecPoints("READ"); |
394cb950 | 103 | } |
6b092dfc | 104 | MUONLoaderSim->LoadHits("READ"); |
0cb382c1 | 105 | |
6b092dfc | 106 | // Creating MUON data containers |
107 | AliMUONSimData muondataSim(MUONLoaderSim,"MUON","MUON"); | |
108 | AliMUONRecData muondataRec(MUONLoaderRec,"MUON","MUON"); | |
394cb950 | 109 | |
0cb382c1 | 110 | TClonesArray * globalTrigger; |
111 | AliMUONGlobalTrigger * gloTrg; | |
112 | ||
113 | ||
114 | for (Int_t ievent=0; ievent<nevents; ievent++) { // event loop | |
115 | CoincMuPlus=0; | |
116 | CoincMuMinus=0; | |
6b092dfc | 117 | RunLoaderSim->GetEvent(ievent); |
118 | RunLoaderRec->GetEvent(ievent); | |
0cb382c1 | 119 | |
120 | if (ievent%1000==0) printf("\t Event = %d\n",ievent); | |
121 | ||
122 | // Hits | |
6b092dfc | 123 | muondataSim.SetTreeAddress("H"); |
0cb382c1 | 124 | |
125 | Int_t itrack, ntracks, NbHits[2][4]; | |
126 | Int_t SumNbHits; | |
127 | for (Int_t j=0; j<2; j++) { | |
128 | for (Int_t jj=0; jj<4; jj++) { | |
129 | NbHits[j][jj]=0; | |
130 | } | |
131 | } | |
6b092dfc | 132 | ntracks = (Int_t) muondataSim.GetNtracks(); |
0cb382c1 | 133 | for (itrack=0; itrack<ntracks; itrack++) { // Track loop |
6b092dfc | 134 | |
135 | muondataSim.GetTrack(itrack); | |
0cb382c1 | 136 | |
137 | Int_t ihit, nhits; | |
6b092dfc | 138 | nhits = (Int_t) muondataSim.Hits()->GetEntriesFast(); |
0cb382c1 | 139 | AliMUONHit* mHit; |
140 | for(ihit=0; ihit<nhits; ihit++) { | |
6b092dfc | 141 | mHit = static_cast<AliMUONHit*>(muondataSim.Hits()->At(ihit)); |
0cb382c1 | 142 | Int_t Nch = mHit->Chamber(); |
143 | Int_t hittrack = mHit->Track(); | |
144 | Float_t IdPart = mHit->Particle(); | |
145 | ||
146 | for (Int_t j=0;j<4;j++) { | |
147 | Int_t kch=11+j; | |
148 | if (hittrack==1 || hittrack==2) { | |
149 | if (Nch==kch && IdPart==-13 && NbHits[0][j]==0) NbHits[0][j]++; | |
150 | if (Nch==kch && IdPart==13 && NbHits[1][j]==0) NbHits[1][j]++; | |
151 | } | |
152 | } | |
153 | } | |
154 | ||
6b092dfc | 155 | muondataSim.ResetHits(); |
0cb382c1 | 156 | |
157 | } // end track loop | |
158 | ||
159 | // 3/4 coincidence | |
160 | SumNbHits=NbHits[0][0]+NbHits[0][1]+NbHits[0][2]+NbHits[0][3]; | |
161 | if (SumNbHits==3 || SumNbHits==4) CoincMuPlus=1; | |
162 | ||
163 | SumNbHits=NbHits[1][0]+NbHits[1][1]+NbHits[1][2]+NbHits[1][3]; | |
164 | if (SumNbHits==3 || SumNbHits==4) CoincMuMinus=1; | |
165 | ||
166 | if (CoincMuPlus==1 && CoincMuMinus==1) coincmuon++; | |
167 | ||
168 | // Trigger | |
394cb950 | 169 | if (!readFromRP) { |
6b092dfc | 170 | muondataSim.SetTreeAddress("D,GLT"); |
171 | muondataSim.GetTriggerD(); | |
172 | globalTrigger = muondataSim.GlobalTrigger(); | |
394cb950 | 173 | } else { |
6b092dfc | 174 | muondataRec.SetTreeAddress("RC,TC"); |
175 | muondataRec.GetTrigger(); | |
176 | globalTrigger = muondataRec.GlobalTrigger(); | |
394cb950 | 177 | } |
0cb382c1 | 178 | |
0cb382c1 | 179 | Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1 |
180 | ||
181 | for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger | |
6b092dfc | 182 | |
0cb382c1 | 183 | gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal)); |
6b092dfc | 184 | |
0cb382c1 | 185 | if (gloTrg->PairUnlikeLpt()>=1) muonlpt++; |
186 | if (gloTrg->PairUnlikeHpt()>=1) muonhpt++; | |
187 | ||
188 | } // end of loop on Global Trigger | |
189 | ||
6b092dfc | 190 | //if (!readFromRP) |
191 | muondataSim.ResetTrigger(); | |
192 | //else | |
193 | muondataRec.ResetTrigger(); | |
0cb382c1 | 194 | |
195 | } // end loop on event | |
196 | ||
6b092dfc | 197 | MUONLoaderSim->UnloadHits(); |
394cb950 | 198 | |
199 | if (!readFromRP) { | |
6b092dfc | 200 | MUONLoaderSim->UnloadDigits(); |
394cb950 | 201 | } else { |
6b092dfc | 202 | MUONLoaderRec->UnloadRecPoints(); |
394cb950 | 203 | } |
0cb382c1 | 204 | |
205 | // calculate efficiency with as a ref. at least 3/4 planes fired | |
ad705f30 | 206 | Float_t efficiencylpt,efficiencyhpt; |
207 | Double_t coincmu,lptmu,hptmu; | |
0cb382c1 | 208 | Float_t error; |
ad705f30 | 209 | coincmu=Double_t(coincmuon); |
0cb382c1 | 210 | lptmu=Double_t(muonlpt); |
211 | hptmu=Double_t(muonhpt); | |
212 | ||
213 | ||
214 | // output | |
215 | fprintf(fdat,"\n"); | |
216 | fprintf(fdat," Number of events = %d \n",nevents); | |
217 | fprintf(fdat," Number of events with 3/4 coinc = %d \n",coincmuon); | |
0cb382c1 | 218 | fprintf(fdat," Nomber of dimuons with 3/4 coinc Lpt cut = %d \n",muonlpt); |
219 | fprintf(fdat," Number of dimuons with 3/4 coinc Hpt cut = %d \n",muonhpt); | |
220 | fprintf(fdat,"\n"); | |
221 | ||
0cb382c1 | 222 | efficiencylpt=lptmu/coincmu; |
223 | error=efficiencylpt*TMath::Sqrt((lptmu+coincmu)/(lptmu*coincmu)); | |
224 | fprintf(fdat," Efficiency Lpt cut = %4.4f +/- %4.4f\n",efficiencylpt,error); | |
225 | ||
226 | efficiencyhpt=hptmu/coincmu; | |
227 | error=efficiencyhpt*TMath::Sqrt((hptmu+coincmu)/(hptmu*coincmu)); | |
228 | fprintf(fdat," Efficiency Hpt cut = %4.4f +/- %4.4f\n",efficiencyhpt,error); | |
229 | ||
230 | ||
231 | fclose(fdat); | |
232 | } | |
233 | ||
234 | ||
235 | ||
236 | ||
237 |