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 "AliMUONHit.h"
45 #include "AliMUONConstants.h"
46 #include "AliMUONDigit.h"
47 #include "AliMUONRawCluster.h"
48 #include "AliMUONGlobalTrigger.h"
49 #include "AliMUONTrack.h"
51 #include "AliMUONDataInterface.h"
52 #include "AliMUONMCDataInterface.h"
53 #include "AliMUONVHitStore.h"
54 #include "AliMUONVTriggerStore.h"
61 void MUONTriggerEfficiency(const char* filenameSim="galice_sim.root",
62 const char* filenameRec="galice.root",
63 Bool_t readFromRP = 0)
68 AliMUONMCDataInterface diSim(filenameSim);
69 AliMUONDataInterface diRec(filenameRec);
73 cerr << "Cannot access " << filenameSim << endl;
79 cerr << "Cannot access " << filenameRec << endl;
83 FILE* fdat = fopen("MUONTriggerEfficiency.out","w");
86 cerr << "Cannot create output file" << endl;
90 Int_t coincmuon,muonlpt,muonhpt;
91 Int_t CoincMuPlus,CoincMuMinus;
96 Int_t nevents = diSim.NumberOfEvents();
98 for (Int_t ievent=0; ievent<nevents; ++ievent)
103 if (ievent%1000==0) printf("\t Event = %d\n",ievent);
108 for (Int_t j=0; j<2; j++)
110 for (Int_t jj=0; jj<4; jj++)
116 Int_t ntracks = (Int_t) diSim.NumberOfTracks(ievent);
118 for ( Int_t itrack=0; itrack<ntracks; ++itrack )
120 AliMUONVHitStore* hitStore = diSim.HitStore(ievent,itrack);
122 TIter next(hitStore->CreateIterator());
124 while ( ( mHit = static_cast<AliMUONHit*>(next()) ) )
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++)
133 if (hittrack==1 || hittrack==2)
135 if (Nch==kch && IdPart==-13 && NbHits[0][j]==0) NbHits[0][j]++;
136 if (Nch==kch && IdPart==13 && NbHits[1][j]==0) NbHits[1][j]++;
143 Int_t SumNbHits=NbHits[0][0]+NbHits[0][1]+NbHits[0][2]+NbHits[0][3];
144 if (SumNbHits==3 || SumNbHits==4) CoincMuPlus=1;
146 SumNbHits=NbHits[1][0]+NbHits[1][1]+NbHits[1][2]+NbHits[1][3];
147 if (SumNbHits==3 || SumNbHits==4) CoincMuMinus=1;
149 if (CoincMuPlus==1 && CoincMuMinus==1) coincmuon++;
152 if ( readFromRP ) tree = "R";
154 AliMUONVTriggerStore* triggerStore = diRec.TriggerStore(ievent,tree.Data());
156 AliMUONGlobalTrigger* gloTrg = triggerStore->Global();
158 if (gloTrg->PairUnlikeLpt()>=1) muonlpt++;
159 if (gloTrg->PairUnlikeHpt()>=1) muonhpt++;
161 } // end loop on event
163 // calculate efficiency with as a ref. at least 3/4 planes fired
164 Float_t efficiencylpt,efficiencyhpt;
165 Double_t coincmu,lptmu,hptmu;
167 coincmu=Double_t(coincmuon);
168 lptmu=Double_t(muonlpt);
169 hptmu=Double_t(muonhpt);
173 fprintf(fdat," Number of events = %d \n",nevents);
174 fprintf(fdat," Number of events with 3/4 coinc = %d \n",coincmuon);
175 fprintf(fdat," Nomber of dimuons with 3/4 coinc Lpt cut = %d \n",muonlpt);
176 fprintf(fdat," Number of dimuons with 3/4 coinc Hpt cut = %d \n",muonhpt);
179 efficiencylpt=lptmu/coincmu;
180 error=efficiencylpt*TMath::Sqrt((lptmu+coincmu)/(lptmu*coincmu));
181 fprintf(fdat," Efficiency Lpt cut = %4.4f +/- %4.4f\n",efficiencylpt,error);
183 efficiencyhpt=hptmu/coincmu;
184 error=efficiencyhpt*TMath::Sqrt((hptmu+coincmu)/(hptmu*coincmu));
185 fprintf(fdat," Efficiency Hpt cut = %4.4f +/- %4.4f\n",efficiencyhpt,error);