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 #include "AliFastMuonTriggerEff.h"
27 ClassImp(AliFastMuonTriggerEff);
29 AliFastMuonTriggerEff::AliFastMuonTriggerEff():
30 AliFastResponse("Efficiency", "Muon Trigger Efficiency")
33 // Default constructor
40 void AliFastMuonTriggerEff::Init()
45 printf("Initializing %s / %s", fName.Data(), fTitle.Data());
59 void AliFastMuonTriggerEff::InitTree()
62 // Initialize tables from tree
64 TTree *chain; // pointer to the analyzed TTree or TChain
66 Double_t pmin, pmax, tmin, tmax, phimin, phimax, bkg;
67 Double_t len50, hen50, leff, heff;
70 Char_t file[100]="$(ALICE_ROOT)/FASTSIM/data/vettorpara.root";
72 // Avoid memory leak in case of reinitialization
74 printf("\nWarning: reinitialization of an object of class: AliFastMuonTriggerEff\n");
75 for (Int_t i=0; i<fZones; i++) {
76 if(fEffLow [i])delete[] fEffLow[i];
77 if(fEffHigh[i])delete[] fEffHigh[i];
88 printf("AliFastMuonTriggerEff: Initialization\n");
89 TFile *f = new TFile(file);
91 printf("Cannot open file: %s\n",file);
96 TTree* tree = (TTree*)gDirectory->Get("fitPar");
101 chain->SetMakeClass(1);
103 chain->SetBranchAddress("nSim",&nSim);
104 chain->SetBranchAddress("nZona",&nZona);
105 chain->SetBranchAddress("ptmin",&pmin);
106 chain->SetBranchAddress("ptmax",&pmax);
107 chain->SetBranchAddress("Thetamin",&tmin);
108 chain->SetBranchAddress("Thetamax",&tmax);
109 chain->SetBranchAddress("Phimin",&phimin);
110 chain->SetBranchAddress("Phimax",&phimax);
111 chain->SetBranchAddress("Bkg",&bkg);
112 chain->SetBranchAddress("EffLPt",vLPt);
113 chain->SetBranchAddress("EffHPt",vHPt);
114 chain->SetBranchAddress("Pt0.5Low",&len50);
115 chain->SetBranchAddress("Pt0.5High",&hen50);
116 chain->SetBranchAddress("EffLowMax",&leff);
117 chain->SetBranchAddress("EffHighMax",&heff);
120 Int_t nentries = Int_t(chain->GetEntries());
121 Int_t nbytes = 0, nb = 0;
123 // Count the number of zones of the parametrization
124 Int_t nzone0=0, nzone1=0;
125 for (Int_t jentry=0; jentry<nentries; jentry++) {
126 nb = chain->GetEntry(jentry);
133 printf("Trigger parametrisation for %d zones for Pt: 0. 5. GeV/c\n",nzone0);
134 printf("and %d zones extended to 10. GeV/c\n",nzone1);
135 fZones=nzone0+nzone1;
138 printf("Number of zones must be greater than 0\n");
142 fEffLow =new Float_t*[fZones];
143 fEffHigh=new Float_t*[fZones];
144 for (Int_t i=0; i<fZones; i++) {
145 fEffLow [i]=new Float_t[50];
146 fEffHigh[i]=new Float_t[50];
149 // Initialize look-up table to standard values
150 Int_t isim, itheta, iphi;
151 for (isim=0; isim<2; isim++) {
152 for (itheta=0; itheta<10; itheta++) {
153 for (iphi=0; iphi<20; iphi++) {
154 fLook[isim][itheta][iphi]=0;
159 // Loading Trigger efficiencies
162 printf("Filling nSim nZona pmin pmax tmin tmax phimin phimax: ....\n");
164 for (Int_t jentry=0; jentry<nentries; jentry++) {
165 // Int_t ientry = LoadTree(jentry);
166 nb = chain->GetEntry(jentry);
169 printf("Getting entry %d... ",jentry);
171 // For the time being it works with background 0
172 if ((nSim == 0 || nSim == 1)&&bkg==0.) {
174 printf("Filling %d %d %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f: ",
175 nSim,nZona,pmin,pmax,tmin,tmax,phimin,phimax);
177 for (Int_t k = 0; k < 50; k++) {
178 fEffLow [myzone][k] = vLPt[k];
179 fEffHigh[myzone][k] = vHPt[k];
181 if(k<15)printf(" %5.3f",vLPt[k]);
188 iphi=Int_t(nZona/10)-10;
190 if(iphi<0||iphi>19||itheta<0||itheta>9) {
191 printf("The format of data file is not consistent\nwith this version of the code\n");
192 printf("This should never happen: iphi %d, itheta: %d\n",iphi,itheta);
195 fLook[nSim][itheta][iphi]=myzone;
197 printf("Skipping entry with nSim=%d, bkg=%f\n",nSim,bkg);
201 printf("This is the content of the LUT after first step of initialization\n");
202 for(isim=0; isim<2; isim++) {
203 printf("isim=%d\n",isim);
204 for(iphi=0; iphi<20; iphi++) {
205 printf("iphi: %2d:",iphi);
206 for(itheta=0; itheta<10; itheta++) {
207 printf(" %4d",fLook[isim][itheta][iphi]);
213 // Filling look=up table for the zones where the extended simulation does
215 for(iphi=0; iphi<20; iphi++) {
216 for(itheta=0; itheta<10; itheta++) {
217 if(fLook[0][itheta][iphi]==0) {
218 printf("Missing entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
221 if(fLook[0][itheta][iphi]<0||fLook[0][itheta][iphi]>fZones) {
222 printf("Problem with entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
225 if(fLook[1][itheta][iphi]==0) {
226 fLook[1][itheta][iphi]=-fLook[0][itheta][iphi];
231 for(isim=0; isim<2; isim++) {
232 printf("isim=%d\n",isim);
233 for(iphi=0; iphi<20; iphi++) {
234 printf("iphi: %2d:",iphi);
235 for(itheta=0; itheta<10; itheta++) {
236 printf(" %4d",fLook[isim][itheta][iphi]);
241 for(iphi=0; iphi<20; iphi++) {
242 for(itheta=0; itheta<10; itheta++) {
243 for(isim=0; isim<2; isim++) {
244 printf("%d %2d %2d %4d:",isim,iphi,itheta,fLook[isim][itheta][iphi]);
245 if(fLook[isim][itheta][iphi]>0) {
246 myzone=fLook[isim][itheta][iphi]-1;
247 for(Int_t ipt=0; ipt<20; ipt++) {
248 //printf(" %5.3f",fEffLow[myzone][ipt]);
249 printf(" %5.3f",fEffHigh[myzone][ipt]);
252 for(Int_t ipt=40; ipt<50; ipt++) {
253 //printf(" %5.3f",fEffLow[myzone][ipt]);
254 printf(" %5.3f",fEffHigh[myzone][ipt]);
265 void AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
266 Float_t theta, Float_t phi,Float_t& effLow, Float_t& effHigh)
269 // Trigger efficiency for pt, theta, phi (low and high cut)
274 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
278 printf("Warning: pt: %f < 0. GeV/c\n",pt);
281 Int_t iPt = Int_t(pt/fDpt)%50;
282 Int_t iSim = Int_t(pt/fDpt)/50;
283 Int_t iPhi = Int_t((phi-fPhiMin)/fDphi);
284 if(phi<fPhiMin)iPhi=iPhi-1;
285 Int_t iTheta = Int_t((theta-fThetaMin)/fDtheta);
287 printf("iSim iPt iTheta iPhi: %d %d %d %d\n",iSim,iPt,iTheta,iPhi);
289 iPhi=iPhi-40*(iPhi/40);
291 printf("1: iPhi converted to: %d for angle equivalence\n",iPhi);
293 if(iPhi<0)iPhi=-iPhi-1;
294 if(iPhi>19)iPhi=39-iPhi;
296 printf("2: iPhi converted to: %d for the symmetry of the spectrometer\n",iPhi);
299 } else if(charge==-1.) {
302 printf("3: iPhi converted to: %d for charge symmetry\n",iPhi);
305 printf("Warning: not understand charge: %f\n",charge);
308 if(iTheta<0||iTheta>9) {
309 printf("Warning: theta: %f outside acceptance\n",theta);
313 printf("Warning: what do you mean with pt: %f <0?\n",pt);
320 printf("4: iSim iPt converted to: %d %d (last zone)\n",iSim,iPt);
323 Int_t iLook=fLook[iSim][iTheta][iPhi];
326 printf("5: iLook iPt: %d %d converted to: ",iLook,iPt);
331 printf("%d %d from look up table contents\n",iLook,iPt);
336 effLow=fEffLow[iLook][iPt];
337 effHigh=fEffHigh[iLook][iPt];
339 printf("6: charge, iSim, iTheta, iPhi, iPt: %f %d %d %d %d effLow: %f, effHigh: %f\n",
340 charge,iSim,iTheta,iPhi,iPt,effLow,effHigh);
343 //fEffLow [iPhi][iTheta][iPt];
344 //fEffHigh[iPhi][iTheta][iPt];
347 Float_t AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
348 Float_t theta, Float_t phi)
351 // Trigger efficiency for pt, theta, phi depending of fCut
354 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
358 Float_t effLow, effHigh;
360 Evaluate(charge,pt,theta,phi,effLow,effHigh);