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