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