1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
24 #if !defined(__CINT__) || defined(__MAKECINT__)
27 #include "TClonesArray.h"
33 #include "TParticle.h"
37 #include "AliRunLoader.h"
38 #include "AliHeader.h"
39 #include "AliLoader.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"
57 void MUONTriggerEfficiency (char filename[10]="galice.root"){
61 char currentfile[100];
62 sprintf(digitdat,"MUONTriggerEfficiency.out");
64 FILE *fdat=fopen(digitdat,"w");
66 Int_t nevents,coincmuon,muonlpt,muonhpt;
67 Int_t CoincMuPlus,CoincMuMinus;
74 // Creating Run Loader and openning file containing Hits
75 AliRunLoader * RunLoader = AliRunLoader::Open(filename,"MUONFolder","READ");
77 if (RunLoader ==0x0) {
78 printf(">>> Error : Error Opening %s file \n",currentfile);
82 nevents = RunLoader->GetNumberOfEvents();
85 AliLoader * MUONHits = RunLoader->GetLoader("MUONLoader");
86 MUONHits->LoadHits("READ");
87 AliMUONData data_hits(MUONHits,"MUON","MUON");
90 AliLoader * MUONDigits = RunLoader->GetLoader("MUONLoader");
91 MUONDigits->LoadDigits("READ");
92 AliMUONData data_digits(MUONDigits,"MUON","MUON");
94 TClonesArray * globalTrigger;
95 AliMUONGlobalTrigger * gloTrg;
98 for (Int_t ievent=0; ievent<nevents; ievent++) { // event loop
103 RunLoader->GetEvent(ievent);
105 if (ievent%1000==0) printf("\t Event = %d\n",ievent);
108 data_hits.SetTreeAddress("H");
110 Int_t itrack, ntracks, NbHits[2][4];
112 for (Int_t j=0; j<2; j++) {
113 for (Int_t jj=0; jj<4; jj++) {
117 ntracks = (Int_t) data_hits.GetNtracks();
118 for (itrack=0; itrack<ntracks; itrack++) { // Track loop
119 data_hits.GetTrack(itrack);
122 nhits = (Int_t) data_hits.Hits()->GetEntriesFast();
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();
130 for (Int_t j=0;j<4;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]++;
139 data_hits.ResetHits();
144 SumNbHits=NbHits[0][0]+NbHits[0][1]+NbHits[0][2]+NbHits[0][3];
145 if (SumNbHits==3 || SumNbHits==4) CoincMuPlus=1;
147 SumNbHits=NbHits[1][0]+NbHits[1][1]+NbHits[1][2]+NbHits[1][3];
148 if (SumNbHits==3 || SumNbHits==4) CoincMuMinus=1;
150 if (CoincMuPlus==1 && CoincMuMinus==1) coincmuon++;
153 data_digits.SetTreeAddress("D,GLT");
154 data_digits.GetTriggerD();
156 globalTrigger = data_digits.GlobalTrigger();
158 Int_t nglobals = (Int_t) globalTrigger->GetEntriesFast(); // should be 1
160 for (Int_t iglobal=0; iglobal<nglobals; iglobal++) { // Global Trigger
161 gloTrg = static_cast<AliMUONGlobalTrigger*>(globalTrigger->At(iglobal));
163 if (gloTrg->PairUnlikeLpt()>=1) muonlpt++;
164 if (gloTrg->PairUnlikeHpt()>=1) muonhpt++;
166 } // end of loop on Global Trigger
168 data_digits.ResetTrigger();
170 } // end loop on event
172 MUONHits->UnloadHits();
173 MUONDigits->UnloadDigits();
176 // calculate efficiency with as a ref. at least 3/4 planes fired
177 Float_t efficiencylpt,efficiencyhpt;
178 Double_t coincmu,lptmu,hptmu;
180 coincmu=Double_t(coincmuon);
181 lptmu=Double_t(muonlpt);
182 hptmu=Double_t(muonhpt);
187 fprintf(fdat," Number of events = %d \n",nevents);
188 fprintf(fdat," Number of events with 3/4 coinc = %d \n",coincmuon);
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);
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);
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);