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.1 2003/01/06 10:13:09 morsch
24 #include "AliFastMuonTriggerEff.h"
33 ClassImp(AliFastMuonTriggerEff);
35 AliFastMuonTriggerEff::AliFastMuonTriggerEff():
36 AliFastResponse("Efficiency", "Muon Trigger Efficiency")
39 // Default constructor
46 void AliFastMuonTriggerEff::Init()
51 printf("Initializing %s / %s", fName.Data(), fTitle.Data());
65 void AliFastMuonTriggerEff::InitTree()
68 // Initialize tables from tree
70 TTree *chain; // pointer to the analyzed TTree or TChain
72 Double_t pmin, pmax, tmin, tmax, phimin, phimax, bkg;
73 Double_t len50, hen50, leff, heff;
76 Char_t file[100]="$(ALICE_ROOT)/FASTSIM/data/vettorpara.root";
78 // Avoid memory leak in case of reinitialization
80 printf("\nWarning: reinitialization of an object of class: AliFastMuonTriggerEff\n");
81 for (Int_t i=0; i<fZones; i++) {
82 if(fEffLow [i])delete[] fEffLow[i];
83 if(fEffHigh[i])delete[] fEffHigh[i];
94 printf("AliFastMuonTriggerEff: Initialization\n");
95 TFile *f = new TFile(file);
97 printf("Cannot open file: %s\n",file);
102 TTree* tree = (TTree*)gDirectory->Get("fitPar");
107 chain->SetMakeClass(1);
109 chain->SetBranchAddress("nSim",&nSim);
110 chain->SetBranchAddress("nZona",&nZona);
111 chain->SetBranchAddress("ptmin",&pmin);
112 chain->SetBranchAddress("ptmax",&pmax);
113 chain->SetBranchAddress("Thetamin",&tmin);
114 chain->SetBranchAddress("Thetamax",&tmax);
115 chain->SetBranchAddress("Phimin",&phimin);
116 chain->SetBranchAddress("Phimax",&phimax);
117 chain->SetBranchAddress("Bkg",&bkg);
118 chain->SetBranchAddress("EffLPt",vLPt);
119 chain->SetBranchAddress("EffHPt",vHPt);
120 chain->SetBranchAddress("Pt0.5Low",&len50);
121 chain->SetBranchAddress("Pt0.5High",&hen50);
122 chain->SetBranchAddress("EffLowMax",&leff);
123 chain->SetBranchAddress("EffHighMax",&heff);
126 Int_t nentries = Int_t(chain->GetEntries());
127 Int_t nbytes = 0, nb = 0;
129 // Count the number of zones of the parametrization
130 Int_t nzone0=0, nzone1=0;
131 for (Int_t jentry=0; jentry<nentries; jentry++) {
132 nb = chain->GetEntry(jentry);
139 printf("Trigger parametrisation for %d zones for Pt: 0. 5. GeV/c\n",nzone0);
140 printf("and %d zones extended to 10. GeV/c\n",nzone1);
141 fZones=nzone0+nzone1;
144 printf("Number of zones must be greater than 0\n");
148 fEffLow =new Float_t*[fZones];
149 fEffHigh=new Float_t*[fZones];
150 for (Int_t i=0; i<fZones; i++) {
151 fEffLow [i]=new Float_t[50];
152 fEffHigh[i]=new Float_t[50];
155 // Initialize look-up table to standard values
156 Int_t isim, itheta, iphi;
157 for (isim=0; isim<2; isim++) {
158 for (itheta=0; itheta<10; itheta++) {
159 for (iphi=0; iphi<20; iphi++) {
160 fLook[isim][itheta][iphi]=0;
165 // Loading Trigger efficiencies
168 printf("Filling nSim nZona pmin pmax tmin tmax phimin phimax: ....\n");
170 for (Int_t jentry=0; jentry<nentries; jentry++) {
171 // Int_t ientry = LoadTree(jentry);
172 nb = chain->GetEntry(jentry);
175 printf("Getting entry %d... ",jentry);
177 // For the time being it works with background 0
178 if ((nSim == 0 || nSim == 1)&&bkg==0.) {
180 printf("Filling %d %d %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f: ",
181 nSim,nZona,pmin,pmax,tmin,tmax,phimin,phimax);
183 for (Int_t k = 0; k < 50; k++) {
184 fEffLow [myzone][k] = vLPt[k];
185 fEffHigh[myzone][k] = vHPt[k];
187 if(k<15)printf(" %5.3f",vLPt[k]);
194 iphi=Int_t(nZona/10)-10;
196 if(iphi<0||iphi>19||itheta<0||itheta>9) {
197 printf("The format of data file is not consistent\nwith this version of the code\n");
198 printf("This should never happen: iphi %d, itheta: %d\n",iphi,itheta);
201 fLook[nSim][itheta][iphi]=myzone;
203 printf("Skipping entry with nSim=%d, bkg=%f\n",nSim,bkg);
207 printf("This is the content of the LUT after first step of initialization\n");
208 for(isim=0; isim<2; isim++) {
209 printf("isim=%d\n",isim);
210 for(iphi=0; iphi<20; iphi++) {
211 printf("iphi: %2d:",iphi);
212 for(itheta=0; itheta<10; itheta++) {
213 printf(" %4d",fLook[isim][itheta][iphi]);
219 // Filling look=up table for the zones where the extended simulation does
221 for(iphi=0; iphi<20; iphi++) {
222 for(itheta=0; itheta<10; itheta++) {
223 if(fLook[0][itheta][iphi]==0) {
224 printf("Missing entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
227 if(fLook[0][itheta][iphi]<0||fLook[0][itheta][iphi]>fZones) {
228 printf("Problem with entry isim=%d itheta=%d iphi=%d\n",isim,itheta,iphi);
231 if(fLook[1][itheta][iphi]==0) {
232 fLook[1][itheta][iphi]=-fLook[0][itheta][iphi];
237 for(isim=0; isim<2; isim++) {
238 printf("isim=%d\n",isim);
239 for(iphi=0; iphi<20; iphi++) {
240 printf("iphi: %2d:",iphi);
241 for(itheta=0; itheta<10; itheta++) {
242 printf(" %4d",fLook[isim][itheta][iphi]);
247 for(iphi=0; iphi<20; iphi++) {
248 for(itheta=0; itheta<10; itheta++) {
249 for(isim=0; isim<2; isim++) {
250 printf("%d %2d %2d %4d:",isim,iphi,itheta,fLook[isim][itheta][iphi]);
251 if(fLook[isim][itheta][iphi]>0) {
252 myzone=fLook[isim][itheta][iphi]-1;
253 for(Int_t ipt=0; ipt<20; ipt++) {
254 //printf(" %5.3f",fEffLow[myzone][ipt]);
255 printf(" %5.3f",fEffHigh[myzone][ipt]);
258 for(Int_t ipt=40; ipt<50; ipt++) {
259 //printf(" %5.3f",fEffLow[myzone][ipt]);
260 printf(" %5.3f",fEffHigh[myzone][ipt]);
271 void AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
272 Float_t theta, Float_t phi,Float_t& effLow, Float_t& effHigh)
275 // Trigger efficiency for pt, theta, phi (low and high cut)
280 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
284 printf("Warning: pt: %f < 0. GeV/c\n",pt);
287 Int_t iPt = Int_t(pt/fDpt)%50;
288 Int_t iSim = Int_t(pt/fDpt)/50;
289 Int_t iPhi = Int_t((phi-fPhiMin)/fDphi);
290 if(phi<fPhiMin)iPhi=iPhi-1;
291 Int_t iTheta = Int_t((theta-fThetaMin)/fDtheta);
293 printf("iSim iPt iTheta iPhi: %d %d %d %d\n",iSim,iPt,iTheta,iPhi);
295 iPhi=iPhi-40*(iPhi/40);
297 printf("1: iPhi converted to: %d for angle equivalence\n",iPhi);
299 if(iPhi<0)iPhi=-iPhi-1;
300 if(iPhi>19)iPhi=39-iPhi;
302 printf("2: iPhi converted to: %d for the symmetry of the spectrometer\n",iPhi);
305 } else if(charge==-1.) {
308 printf("3: iPhi converted to: %d for charge symmetry\n",iPhi);
311 printf("Warning: not understand charge: %f\n",charge);
314 if(iTheta<0||iTheta>9) {
315 printf("Warning: theta: %f outside acceptance\n",theta);
319 printf("Warning: what do you mean with pt: %f <0?\n",pt);
326 printf("4: iSim iPt converted to: %d %d (last zone)\n",iSim,iPt);
329 Int_t iLook=fLook[iSim][iTheta][iPhi];
332 printf("5: iLook iPt: %d %d converted to: ",iLook,iPt);
337 printf("%d %d from look up table contents\n",iLook,iPt);
342 effLow=fEffLow[iLook][iPt];
343 effHigh=fEffHigh[iLook][iPt];
345 printf("6: charge, iSim, iTheta, iPhi, iPt: %f %d %d %d %d effLow: %f, effHigh: %f\n",
346 charge,iSim,iTheta,iPhi,iPt,effLow,effHigh);
349 //fEffLow [iPhi][iTheta][iPt];
350 //fEffHigh[iPhi][iTheta][iPt];
353 Float_t AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
354 Float_t theta, Float_t phi)
357 // Trigger efficiency for pt, theta, phi depending of fCut
360 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
364 Float_t effLow, effHigh;
366 Evaluate(charge,pt,theta,phi,effLow,effHigh);