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 **************************************************************************/
18 Revision 1.2.2.1 2003/04/15 15:57:31 hristov
21 Revision 1.2 2003/01/21 10:49:17 morsch
22 Corrected path for vettotpara.root
24 Revision 1.1 2003/01/06 10:13:09 morsch
30 #include "AliFastMuonTriggerEff.h"
39 ClassImp(AliFastMuonTriggerEff);
41 AliFastMuonTriggerEff::AliFastMuonTriggerEff():
42 AliFastResponse("Efficiency", "Muon Trigger Efficiency")
45 // Default constructor
52 void AliFastMuonTriggerEff::Init()
57 printf("Initializing %s / %s", fName.Data(), fTitle.Data());
71 void AliFastMuonTriggerEff::InitTree()
74 // Initialize tables from tree
76 TTree *chain; // pointer to the analyzed TTree or TChain
78 Double_t pmin, pmax, tmin, tmax, phimin, phimax, bkg;
79 Double_t len50, hen50, leff, heff;
82 Char_t file[100]="$(ALICE_ROOT)/FASTSIM/data/vettorpara.root";
84 // Avoid memory leak in case of reinitialization
86 printf("\nWarning: reinitialization of an object of class: AliFastMuonTriggerEff\n");
87 for (Int_t i=0; i<fZones; i++) {
88 if(fEffLow [i])delete[] fEffLow[i];
89 if(fEffHigh[i])delete[] fEffHigh[i];
100 printf("AliFastMuonTriggerEff: Initialization\n");
101 TFile *f = new TFile(file);
103 printf("Cannot open file: %s\n",file);
108 TTree* tree = (TTree*)gDirectory->Get("fitPar");
113 chain->SetMakeClass(1);
115 chain->SetBranchAddress("nSim",&nSim);
116 chain->SetBranchAddress("nZona",&nZona);
117 chain->SetBranchAddress("ptmin",&pmin);
118 chain->SetBranchAddress("ptmax",&pmax);
119 chain->SetBranchAddress("Thetamin",&tmin);
120 chain->SetBranchAddress("Thetamax",&tmax);
121 chain->SetBranchAddress("Phimin",&phimin);
122 chain->SetBranchAddress("Phimax",&phimax);
123 chain->SetBranchAddress("Bkg",&bkg);
124 chain->SetBranchAddress("EffLPt",vLPt);
125 chain->SetBranchAddress("EffHPt",vHPt);
126 chain->SetBranchAddress("Pt0.5Low",&len50);
127 chain->SetBranchAddress("Pt0.5High",&hen50);
128 chain->SetBranchAddress("EffLowMax",&leff);
129 chain->SetBranchAddress("EffHighMax",&heff);
132 Int_t nentries = Int_t(chain->GetEntries());
133 Int_t nbytes = 0, nb = 0;
135 // Count the number of zones of the parametrization
136 Int_t nzone0=0, nzone1=0;
137 for (Int_t jentry=0; jentry<nentries; jentry++) {
138 nb = chain->GetEntry(jentry);
145 printf("Trigger parametrisation for %d zones for Pt: 0. 5. GeV/c\n",nzone0);
146 printf("and %d zones extended to 10. GeV/c\n",nzone1);
147 fZones=nzone0+nzone1;
150 printf("Number of zones must be greater than 0\n");
154 fEffLow =new Float_t*[fZones];
155 fEffHigh=new Float_t*[fZones];
156 for (Int_t i=0; i<fZones; i++) {
157 fEffLow [i]=new Float_t[50];
158 fEffHigh[i]=new Float_t[50];
161 // Initialize look-up table to standard values
162 Int_t isim, itheta, iphi;
163 for (isim=0; isim<2; isim++) {
164 for (itheta=0; itheta<10; itheta++) {
165 for (iphi=0; iphi<20; iphi++) {
166 fLook[isim][itheta][iphi]=0;
171 // Loading Trigger efficiencies
174 printf("Filling nSim nZona pmin pmax tmin tmax phimin phimax: ....\n");
176 for (Int_t jentry=0; jentry<nentries; jentry++) {
177 // Int_t ientry = LoadTree(jentry);
178 nb = chain->GetEntry(jentry);
181 printf("Getting entry %d... ",jentry);
183 // For the time being it works with background 0
184 if ((nSim == 0 || nSim == 1)&&bkg==0.) {
186 printf("Filling %d %d %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f: ",
187 nSim,nZona,pmin,pmax,tmin,tmax,phimin,phimax);
189 for (Int_t k = 0; k < 50; k++) {
190 fEffLow [myzone][k] = vLPt[k];
191 fEffHigh[myzone][k] = vHPt[k];
193 if(k<15)printf(" %5.3f",vLPt[k]);
200 iphi=Int_t(nZona/10)-10;
202 if(iphi<0||iphi>19||itheta<0||itheta>9) {
203 printf("The format of data file is not consistent\nwith this version of the code\n");
204 printf("This should never happen: iphi %d, itheta: %d\n",iphi,itheta);
207 fLook[nSim][itheta][iphi]=myzone;
209 printf("Skipping entry with nSim=%d, bkg=%f\n",nSim,bkg);
213 printf("This is the content of the LUT after first step of initialization\n");
214 for(isim=0; isim<2; isim++) {
215 printf("isim=%d\n",isim);
216 for(iphi=0; iphi<20; iphi++) {
217 printf("iphi: %2d:",iphi);
218 for(itheta=0; itheta<10; itheta++) {
219 printf(" %4d",fLook[isim][itheta][iphi]);
225 // Filling look=up table for the zones where the extended simulation does
227 for(iphi=0; iphi<20; iphi++) {
228 for(itheta=0; itheta<10; itheta++) {
229 if(fLook[0][itheta][iphi]==0) {
230 printf("Missing entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
233 if(fLook[0][itheta][iphi]<0||fLook[0][itheta][iphi]>fZones) {
234 printf("Problem with entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
237 if(fLook[1][itheta][iphi]==0) {
238 fLook[1][itheta][iphi]=-fLook[0][itheta][iphi];
243 for(isim=0; isim<2; isim++) {
244 printf("isim=%d\n",isim);
245 for(iphi=0; iphi<20; iphi++) {
246 printf("iphi: %2d:",iphi);
247 for(itheta=0; itheta<10; itheta++) {
248 printf(" %4d",fLook[isim][itheta][iphi]);
253 for(iphi=0; iphi<20; iphi++) {
254 for(itheta=0; itheta<10; itheta++) {
255 for(isim=0; isim<2; isim++) {
256 printf("%d %2d %2d %4d:",isim,iphi,itheta,fLook[isim][itheta][iphi]);
257 if(fLook[isim][itheta][iphi]>0) {
258 myzone=fLook[isim][itheta][iphi]-1;
259 for(Int_t ipt=0; ipt<20; ipt++) {
260 //printf(" %5.3f",fEffLow[myzone][ipt]);
261 printf(" %5.3f",fEffHigh[myzone][ipt]);
264 for(Int_t ipt=40; ipt<50; ipt++) {
265 //printf(" %5.3f",fEffLow[myzone][ipt]);
266 printf(" %5.3f",fEffHigh[myzone][ipt]);
277 void AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
278 Float_t theta, Float_t phi,Float_t& effLow, Float_t& effHigh)
281 // Trigger efficiency for pt, theta, phi (low and high cut)
286 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
290 printf("Warning: pt: %f < 0. GeV/c\n",pt);
293 Int_t iPt = Int_t(pt/fDpt)%50;
294 Int_t iSim = Int_t(pt/fDpt)/50;
295 Int_t iPhi = Int_t((phi-fPhiMin)/fDphi);
296 if(phi<fPhiMin)iPhi=iPhi-1;
297 Int_t iTheta = Int_t((theta-fThetaMin)/fDtheta);
299 printf("iSim iPt iTheta iPhi: %d %d %d %d\n",iSim,iPt,iTheta,iPhi);
301 iPhi=iPhi-40*(iPhi/40);
303 printf("1: iPhi converted to: %d for angle equivalence\n",iPhi);
305 if(iPhi<0)iPhi=-iPhi-1;
306 if(iPhi>19)iPhi=39-iPhi;
308 printf("2: iPhi converted to: %d for the symmetry of the spectrometer\n",iPhi);
311 } else if(charge==-1.) {
314 printf("3: iPhi converted to: %d for charge symmetry\n",iPhi);
317 printf("Warning: not understand charge: %f\n",charge);
320 if(iTheta<0||iTheta>9) {
321 printf("Warning: theta: %f outside acceptance\n",theta);
325 printf("Warning: what do you mean with pt: %f <0?\n",pt);
332 printf("4: iSim iPt converted to: %d %d (last zone)\n",iSim,iPt);
335 Int_t iLook=fLook[iSim][iTheta][iPhi];
338 printf("5: iLook iPt: %d %d converted to: ",iLook,iPt);
343 printf("%d %d from look up table contents\n",iLook,iPt);
348 effLow=fEffLow[iLook][iPt];
349 effHigh=fEffHigh[iLook][iPt];
351 printf("6: charge, iSim, iTheta, iPhi, iPt: %f %d %d %d %d effLow: %f, effHigh: %f\n",
352 charge,iSim,iTheta,iPhi,iPt,effLow,effHigh);
355 //fEffLow [iPhi][iTheta][iPt];
356 //fEffHigh[iPhi][iTheta][iPt];
359 Float_t AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
360 Float_t theta, Float_t phi)
363 // Trigger efficiency for pt, theta, phi depending of fCut
366 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
370 Float_t effLow, effHigh;
372 Evaluate(charge,pt,theta,phi,effLow,effHigh);