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"
28 ClassImp(AliFastMuonTriggerEff)
30 AliFastMuonTriggerEff::AliFastMuonTriggerEff():
31 AliFastResponse("Efficiency", "Muon Trigger Efficiency")
34 // Default constructor
41 void AliFastMuonTriggerEff::Init()
46 printf("Initializing %s / %s", fName.Data(), fTitle.Data());
60 void AliFastMuonTriggerEff::InitTree()
63 // Initialize tables from tree
65 TTree *chain; // pointer to the analyzed TTree or TChain
67 Double_t pmin, pmax, tmin, tmax, phimin, phimax, bkg;
68 Double_t len50, hen50, leff, heff;
71 Char_t file[100]="$(ALICE_ROOT)/FASTSIM/data/vettorpara.root";
73 // Avoid memory leak in case of reinitialization
75 printf("\nWarning: reinitialization of an object of class: AliFastMuonTriggerEff\n");
76 for (Int_t i=0; i<fZones; i++) {
77 if(fEffLow [i])delete[] fEffLow[i];
78 if(fEffHigh[i])delete[] fEffHigh[i];
89 printf("AliFastMuonTriggerEff: Initialization\n");
90 TFile *f = new TFile(file);
92 printf("Cannot open file: %s\n",file);
97 TTree* tree = (TTree*)gDirectory->Get("fitPar");
102 chain->SetMakeClass(1);
104 chain->SetBranchAddress("nSim",&nSim);
105 chain->SetBranchAddress("nZona",&nZona);
106 chain->SetBranchAddress("ptmin",&pmin);
107 chain->SetBranchAddress("ptmax",&pmax);
108 chain->SetBranchAddress("Thetamin",&tmin);
109 chain->SetBranchAddress("Thetamax",&tmax);
110 chain->SetBranchAddress("Phimin",&phimin);
111 chain->SetBranchAddress("Phimax",&phimax);
112 chain->SetBranchAddress("Bkg",&bkg);
113 chain->SetBranchAddress("EffLPt",vLPt);
114 chain->SetBranchAddress("EffHPt",vHPt);
115 chain->SetBranchAddress("Pt0.5Low",&len50);
116 chain->SetBranchAddress("Pt0.5High",&hen50);
117 chain->SetBranchAddress("EffLowMax",&leff);
118 chain->SetBranchAddress("EffHighMax",&heff);
121 Int_t nentries = Int_t(chain->GetEntries());
122 Int_t nbytes = 0, nb = 0;
124 // Count the number of zones of the parametrization
125 Int_t nzone0=0, nzone1=0;
126 for (Int_t jentry=0; jentry<nentries; jentry++) {
127 nb = chain->GetEntry(jentry);
134 printf("Trigger parametrisation for %d zones for Pt: 0. 5. GeV/c\n",nzone0);
135 printf("and %d zones extended to 10. GeV/c\n",nzone1);
136 fZones=nzone0+nzone1;
139 printf("Number of zones must be greater than 0\n");
143 fEffLow =new Float_t*[fZones];
144 fEffHigh=new Float_t*[fZones];
145 for (Int_t i=0; i<fZones; i++) {
146 fEffLow [i]=new Float_t[50];
147 fEffHigh[i]=new Float_t[50];
150 // Initialize look-up table to standard values
151 Int_t isim, itheta, iphi;
152 for (isim=0; isim<2; isim++) {
153 for (itheta=0; itheta<10; itheta++) {
154 for (iphi=0; iphi<20; iphi++) {
155 fLook[isim][itheta][iphi]=0;
160 // Loading Trigger efficiencies
163 printf("Filling nSim nZona pmin pmax tmin tmax phimin phimax: ....\n");
165 for (Int_t jentry=0; jentry<nentries; jentry++) {
166 // Int_t ientry = LoadTree(jentry);
167 nb = chain->GetEntry(jentry);
170 printf("Getting entry %d... ",jentry);
172 // For the time being it works with background 0
173 if ((nSim == 0 || nSim == 1)&&bkg==0.) {
175 printf("Filling %d %d %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f: ",
176 nSim,nZona,pmin,pmax,tmin,tmax,phimin,phimax);
178 for (Int_t k = 0; k < 50; k++) {
179 fEffLow [myzone][k] = vLPt[k];
180 fEffHigh[myzone][k] = vHPt[k];
182 if(k<15)printf(" %5.3f",vLPt[k]);
189 iphi=Int_t(nZona/10)-10;
191 if(iphi<0||iphi>19||itheta<0||itheta>9) {
192 printf("The format of data file is not consistent\nwith this version of the code\n");
193 printf("This should never happen: iphi %d, itheta: %d\n",iphi,itheta);
196 fLook[nSim][itheta][iphi]=myzone;
198 printf("Skipping entry with nSim=%d, bkg=%f\n",nSim,bkg);
202 printf("This is the content of the LUT after first step of initialization\n");
203 for(isim=0; isim<2; isim++) {
204 printf("isim=%d\n",isim);
205 for(iphi=0; iphi<20; iphi++) {
206 printf("iphi: %2d:",iphi);
207 for(itheta=0; itheta<10; itheta++) {
208 printf(" %4d",fLook[isim][itheta][iphi]);
214 // Filling look=up table for the zones where the extended simulation does
216 for(iphi=0; iphi<20; iphi++) {
217 for(itheta=0; itheta<10; itheta++) {
218 if(fLook[0][itheta][iphi]==0) {
219 printf("Missing entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
222 if(fLook[0][itheta][iphi]<0||fLook[0][itheta][iphi]>fZones) {
223 printf("Problem with entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
226 if(fLook[1][itheta][iphi]==0) {
227 fLook[1][itheta][iphi]=-fLook[0][itheta][iphi];
232 for(isim=0; isim<2; isim++) {
233 printf("isim=%d\n",isim);
234 for(iphi=0; iphi<20; iphi++) {
235 printf("iphi: %2d:",iphi);
236 for(itheta=0; itheta<10; itheta++) {
237 printf(" %4d",fLook[isim][itheta][iphi]);
242 for(iphi=0; iphi<20; iphi++) {
243 for(itheta=0; itheta<10; itheta++) {
244 for(isim=0; isim<2; isim++) {
245 printf("%d %2d %2d %4d:",isim,iphi,itheta,fLook[isim][itheta][iphi]);
246 if(fLook[isim][itheta][iphi]>0) {
247 myzone=fLook[isim][itheta][iphi]-1;
248 for(Int_t ipt=0; ipt<20; ipt++) {
249 //printf(" %5.3f",fEffLow[myzone][ipt]);
250 printf(" %5.3f",fEffHigh[myzone][ipt]);
253 for(Int_t ipt=40; ipt<50; ipt++) {
254 //printf(" %5.3f",fEffLow[myzone][ipt]);
255 printf(" %5.3f",fEffHigh[myzone][ipt]);
266 void AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
267 Float_t theta, Float_t phi,Float_t& effLow, Float_t& effHigh,
271 // Trigger efficiency for pt, theta, phi (low and high cut)
276 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
280 printf("Warning: pt: %f < 0. GeV/c\n",pt);
283 Int_t iPt = Int_t(pt/fDpt)%50;
284 Int_t iSim = Int_t(pt/fDpt)/50;
285 Int_t iPhi = Int_t((phi-fPhiMin)/fDphi);
286 if(phi<fPhiMin)iPhi=iPhi-1;
287 Int_t iTheta = Int_t((theta-fThetaMin)/fDtheta);
289 printf("iSim iPt iTheta iPhi: %d %d %d %d\n",iSim,iPt,iTheta,iPhi);
291 iPhi=iPhi-40*(iPhi/40);
293 printf("1: iPhi converted to: %d for angle equivalence\n",iPhi);
295 if(iPhi<0)iPhi=-iPhi-1;
296 if(iPhi>19)iPhi=39-iPhi;
298 printf("2: iPhi converted to: %d for the symmetry of the spectrometer\n",iPhi);
301 } else if(charge==-1.) {
304 printf("3: iPhi converted to: %d for charge symmetry\n",iPhi);
307 printf("Warning: not understand charge: %f\n",charge);
310 if(iTheta<0||iTheta>9) {
311 printf("Warning: theta: %f outside acceptance\n",theta);
315 printf("Warning: what do you mean with pt: %f <0?\n",pt);
322 printf("4: iSim iPt converted to: %d %d (last zone)\n",iSim,iPt);
325 Int_t iLook=fLook[iSim][iTheta][iPhi];
328 printf("5: iLook iPt: %d %d converted to: ",iLook,iPt);
333 printf("%d %d from look up table contents\n",iLook,iPt);
338 effLow=fEffLow[iLook][iPt];
339 effHigh=fEffHigh[iLook][iPt];
341 printf("6: charge, iSim, iTheta, iPhi, iPt: %f %d %d %d %d effLow: %f, effHigh: %f\n",
342 charge,iSim,iTheta,iPhi,iPt,effLow,effHigh);
345 //fEffLow [iPhi][iTheta][iPt];
346 //fEffHigh[iPhi][iTheta][iPt];
349 Float_t AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
350 Float_t theta, Float_t phi)
353 // Trigger efficiency for pt, theta, phi depending of fCut
356 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
360 Float_t effLow, effHigh;
362 Evaluate(charge,pt,theta,phi,effLow,effHigh);