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 **************************************************************************/
17 The trigger parametrization is computed for background levels 0., 0.5 and 1.
18 In order to set a background level different from 0 it is necessary to
19 explicitly force it with:
20 ForceBkgLevel(BkgLevel).
22 For intermediate background levels, the trigger response is linearly
23 interpolated between these values.
25 There is increased granularity in the pT region below 3 GeV. Although
26 it does not seem to be necessary it is also possible to interpolate
27 between pT bins using SetInt().
30 Revision 1.10 2006/04/19 21:58:28 morsch
31 Coding rule violations corrected
33 Revision 1.9 2005/09/24 03:51:43 hristov
34 Removing extra semicolon (Fedora Core 4)
36 Revision 1.8 2005/09/22 11:31:42 morsch
37 Completely revised version. (P. Cortese)
41 #include "AliFastMuonTriggerEff.h"
46 #include "TObjString.h"
48 #define PLIN printf("%s: %d: ",__FILE__,__LINE__)
50 ClassImp(AliFastMuonTriggerEff)
52 AliFastMuonTriggerEff::AliFastMuonTriggerEff():
53 AliFastResponse("Efficiency", "Muon Trigger Efficiency")
56 // Default constructor
64 void AliFastMuonTriggerEff::SetCut(Int_t cut)
69 printf("Selecting Low Pt cut\n");
71 printf("Selecting High Pt cut\n");
73 printf("Selecting Lowest Pt cut\n");
75 printf("Don't know cut %d! Selecting Low Pt cut\n",cut);
82 Int_t AliFastMuonTriggerEff::SetBkgLevel(Float_t Bkg)
85 // Set the background level
88 printf("%s: Warning: requested Bkg: %f\n",
91 printf("A consistent treatement of the trigger probability\n");
92 printf("within the framework of the fast simulation requires\n");
93 printf("requires background 0\n");
94 printf("%s: fBkg: set to %f\n",
105 Int_t AliFastMuonTriggerEff::ForceBkgLevel(Float_t Bkg)
108 // Check and enforce consistency of the background level
111 printf("%s: Warning: requested Bkg: %f\n",
113 printf("A consistent treatement of the trigger probability\n");
114 printf("within the framework of the fast simulation\n");
115 printf("requires background 0");
116 printf("%s: Continue with fBkg: %f\n",
126 Int_t AliFastMuonTriggerEff::LoadTables(Char_t *namet=""){
128 // Load the trigger tables
130 Char_t hNameA[100],hNameL[100],hNameH[100];
131 sprintf(hNameA,"hEffAPt%s",namet);
132 sprintf(hNameL,"hEffLPt%s",namet);
133 sprintf(hNameH,"hEffHPt%s",namet);
134 fhEffAPt = (TH3F*)gDirectory->Get(hNameA);
135 fhEffLPt = (TH3F*)gDirectory->Get(hNameL);
136 fhEffHPt = (TH3F*)gDirectory->Get(hNameH);
138 PLIN; printf("%s: histogram %s not found\n",__FILE__,hNameA);
142 PLIN; printf("%s: histogram %s not found\n",__FILE__,hNameL);
146 PLIN; printf("%s: histogram %s not found\n",__FILE__,hNameH);
152 void AliFastMuonTriggerEff::Init()
158 Char_t file[100]="$(ALICE_ROOT)/FASTSIM/data/MUONtriggerLUT_V2.4nvdn.root";
159 printf("Initializing %s / %s\n", fName.Data(), fTitle.Data());
160 printf("using data from file: %s\n",file);
161 printf("AliFastMuonTriggerEff: Initialization with background level: %f\n",fBkg);
162 TFile *f = new TFile(file);
164 PLIN; printf("Cannot open file: %s\n",file);
170 if(TMath::Abs(fBkg)<0.00001){
172 }else if(TMath::Abs(fBkg-0.5)<0.00001){
174 }else if(TMath::Abs(fBkg-1.0)<0.00001){
177 PLIN; printf("A table for Bkg level: %f does not exists\n",fBkg);
180 if(intb){ // Interpolation between background levels
181 PLIN; printf("Interpolating Bkg level: %f\n",fBkg);
182 TH3F* ha1,*hl1,*hh1,*ha2,*hl2,*hh2,*ha0,*hl0,*hh0;
183 Char_t name1[10],name2[10]; Float_t b1,b2;
184 if(fBkg>0&&fBkg<0.5){
195 for(Int_t i=0; i<10;i++){
196 PLIN; printf("WARNING!!!! You are extrapolating above background 1.0\n");
200 PLIN; printf("Bkg level: %f is not supported\n",fBkg);
203 if(LoadTables(name1)){
204 PLIN; printf("Error in loading trigger tables\n");
207 PLIN; printf("We use tables for %f and %f to interpolate %f Bkg level\n",b1,b2,fBkg);
208 ha0=(TH3F*)fhEffAPt->Clone("hEffAPtXX"); ha0->Reset();
209 hl0=(TH3F*)fhEffLPt->Clone("hEffLPtXX"); hl0->Reset();
210 hh0=(TH3F*)fhEffHPt->Clone("hEffHPtXX"); hh0->Reset();
214 if(LoadTables(name2)){
215 PLIN; printf("Error in loading trigger tables\n");
224 Int_t nnx=ha0->GetNbinsX()+1;
225 Int_t nny=ha0->GetNbinsY()+1;
226 Int_t nnz=ha0->GetNbinsZ()+1;
227 for(Int_t ix=0; ix<=nnx; ix++){
228 for(Int_t iy=0; iy<=nny; iy++){
229 for(Int_t iz=0; iz<=nnz; iz++){
230 Double_t y1,y2; Float_t cont;
231 y1=ha1->GetBinContent(ix,iy,iz); y2=ha2->GetBinContent(ix,iy,iz);
232 cont=Float_t(y1+(y2-y1)/(b2-b1)*(fBkg-b1)); if(cont>1)cont=1; if(cont<0)cont=0;
233 fhEffAPt->SetBinContent(ix,iy,iz,cont);
234 y1=hl1->GetBinContent(ix,iy,iz); y2=hl2->GetBinContent(ix,iy,iz);
235 cont=Float_t(y1+(y2-y1)/(b2-b1)*(fBkg-b1)); if(cont>1)cont=1; if(cont<0)cont=0;
236 fhEffLPt->SetBinContent(ix,iy,iz,cont);
237 y1=hh1->GetBinContent(ix,iy,iz); y2=hh2->GetBinContent(ix,iy,iz);
238 cont=Float_t(y1+(y2-y1)/(b2-b1)*(fBkg-b1)); if(cont>1)cont=1; if(cont<0)cont=0;
239 fhEffHPt->SetBinContent(ix,iy,iz,cont);
243 }else{ // Use tables computed for selected backgound levels
244 printf("Loading tables for background level: %f\n",fBkg);
245 if(LoadTables(namet)){
246 PLIN; printf("Error in loading trigger tables\n");
250 fhEffAPt->SetDirectory(0);
251 fhEffLPt->SetDirectory(0);
252 fhEffHPt->SetDirectory(0);
253 fhLX=fhEffLPt->GetXaxis();
254 fhLY=fhEffLPt->GetYaxis();
255 fhLZ=fhEffLPt->GetZaxis();
258 if(f->Get("Description"))
260 fDescription=((TObjString*)f->Get("Description"))->GetString();
261 printf("%s\n",fDescription.Data());
264 fThetaMin = fhEffLPt->GetXaxis()->GetXmin();
265 fThetaMax = fhEffLPt->GetXaxis()->GetXmax();
266 fnthetab=fhEffLPt->GetNbinsX();
267 fDtheta = (fThetaMax-fThetaMin)/fnthetab;
269 fPhiMin = fhEffLPt->GetYaxis()->GetXmin();
270 fPhiMax = fhEffLPt->GetYaxis()->GetXmax();
271 fnphib=fhEffLPt->GetNbinsY();
272 fDphi = (fPhiMax-fPhiMin)/fnphib;
274 fPtMin=fhEffLPt->GetZaxis()->GetXmin();
275 fPtMax=fhEffLPt->GetZaxis()->GetXmax();
276 fnptb=fhEffLPt->GetNbinsZ();
277 fDpt = (fPtMax-fPtMin)/fnptb;
279 printf("%4d bins in theta [%f:%f]\n",fnthetab,fThetaMin,fThetaMax);
280 printf("%4d bins in phi [%f:%f]\n",fnphib,fPhiMin,fPhiMax);
281 printf("%4d bins in pt [%f:%f]\n",fnptb,fPtMin,fPtMax);
283 fZones=fnthetab*fnphib;
287 printf("Interpolation of trigger efficiencies is off!\n");
289 printf("Interpolation of trigger efficiencies is on!\n");
293 void AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,Float_t theta,
294 Float_t phi, Float_t& effLow, Float_t& effHigh, Float_t& effAny)
297 // Trigger efficiency for pt, theta, phi (low, high and "any" cut)
300 printf("Evaluate(ch=%2.0f, pt=%10.6f, theta=%7.2f, phi=%8.2f ...)\n",charge,pt,theta,phi);
306 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
310 printf("Warning: pt: %f < 0. GeV/c\n",pt);
314 Int_t iPt = fhLZ->FindBin((Double_t)pt);
315 if(iPt>fnptb)iPt=fnptb;
316 Int_t iPhi = Int_t((phi-fPhiMin)/fDphi);
317 if(phi<fPhiMin)iPhi=iPhi-1;
318 Int_t iTheta = fhLX->FindBin((Double_t)theta);
320 printf("Evaluate(ch=%2.0f, pt=%10.6f, theta=%7.2f, phi=%8.2f ...)\n",charge,pt,theta,phi);
321 printf(" 0:%1d iPt iTheta iPhi: %d %d %d\n",fInt,iPt,iTheta,iPhi);
323 iPhi=iPhi-2*fnphib*(iPhi/(2*fnphib));
325 printf(" 1:%1d iPhi converted to: %d for angle equivalence\n",fInt,iPhi);
327 if(iPhi<0)iPhi=-iPhi-1;
328 if(iPhi>(fnphib-1))iPhi=2*fnphib-1-iPhi;
330 printf(" 2:%1d iPhi converted to: %d for the symmetry of the spectrometer\n",fInt,iPhi);
333 } else if(charge==-1.) {
336 printf(" 3:%1d iPhi converted to: %d for the charge symmetry\n",fInt,iPhi);
339 printf("Warning: not understand charge: %f\n",charge);
342 if(iTheta<=0||iTheta>fnthetab) {
343 printf("Warning: theta: %f outside acceptance\n",theta);
347 printf("Warning: what do you mean with pt: %f <0?\n",pt);
352 printf(" 4:%1d Getting: iTheta, iPhi, iPt: %d %d %d\n",
353 fInt,iTheta,iPhi,iPt);
355 effLow =fhEffLPt->GetBinContent(iTheta,iPhi,iPt);
356 effHigh=fhEffHPt->GetBinContent(iTheta,iPhi,iPt);
357 effAny =fhEffAPt->GetBinContent(iTheta,iPhi,iPt);
359 printf(" 4:%1d Result: charge, iTheta, iPhi, iPt: %f %d %d %d effLow: %f, effHigh: %f, effAny: %f\n",
360 fInt,charge,iTheta,iPhi,iPt,effLow,effHigh,effAny);
364 Float_t angl,angh,anga;
365 Float_t effLowp,effHighp,effAnyp;
366 Float_t ptc=(iPt+0.5)*fDpt; // The center of current bin
368 printf(" 5:1 The center of current bin iPt: %d is: %f\n",iPt,ptc);
372 printf(" 6:1 No more points above! No interpolation is needed!\n");
377 printf(" 6:1 No interpolation is needed!\n");
381 // Looking for previous point
383 effLowp =fhEffLPt->GetBinContent(iTheta,iPhi,iPt-1);
384 effHighp=fhEffHPt->GetBinContent(iTheta,iPhi,iPt-1);
385 effAnyp =fhEffAPt->GetBinContent(iTheta,iPhi,iPt-1);
387 printf(" 7:1 A simple look to previous point: %d: %f %f\n",iPt-1,effLowp,effHighp);
394 printf(" 8:1 result is: %f %f %f\n",effLowp,effHighp,effAnyp);
397 angl=(effLow-effLowp)/fDpt;
398 angh=(effHigh-effHighp)/fDpt;
399 anga=(effAny-effAnyp)/fDpt;
401 // Looking for next point
403 effLowp =fhEffLPt->GetBinContent(iTheta,iPhi,iPt+1);
404 effHighp=fhEffHPt->GetBinContent(iTheta,iPhi,iPt+1);
405 effAnyp =fhEffAPt->GetBinContent(iTheta,iPhi,iPt+1);
407 printf(" 7:1 A simple look to next point: %d: %f %f %f\n",iPt-1,effLowp,effHighp,effAnyp);
414 printf(" 8:1 result is: pt: %f %f %f\n",effLowp,effHighp,effAnyp);
417 angl=(effLowp-effLow)/fDpt;
418 angh=(effHighp-effHigh)/fDpt;
419 anga=(effAnyp-effAny)/fDpt;
421 effLow=effLow+angl*(pt-ptc);
422 effHigh=effHigh+angh*(pt-ptc);
423 effAny=effAny+anga*(pt-ptc);
425 printf(" 9:1 the interpolation coefficients are: %f %f %f\n",angl,angh,anga);
429 printf("10:%1d effLow, effHigh=%f %f %f\n",fInt,effLow,effHigh,effAny);
436 Float_t AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
437 Float_t theta, Float_t phi)
440 // Trigger efficiency for pt, theta, phi depending of fCut
443 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
447 Float_t effLow, effHigh, effAny;
449 Evaluate(charge,pt,theta,phi,effLow,effHigh,effAny);
452 else if (fCut == kHigh)
454 else if (fCut == kAny)