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).
21 // For intermediate background levels, the trigger response is linearly
22 // interpolated between these values.
23 // There is increased granularity in the pT region below 3 GeV. Although
24 // it does not seem to be necessary it is also possible to interpolate
25 // between pT bins using SetInt().
26 // Author: Pietro Cortese (Universita' del Piemonte Orientale - Alessandria
27 // and INFN of Torino)
30 #include "AliFastMuonTriggerEff.h"
35 #include "TObjString.h"
37 #define PLIN printf("%s: %d: ",__FILE__,__LINE__)
39 ClassImp(AliFastMuonTriggerEff)
41 AliFastMuonTriggerEff::AliFastMuonTriggerEff():
42 AliFastResponse("Efficiency", "Muon Trigger Efficiency"),
72 // Default constructor
76 AliFastMuonTriggerEff::AliFastMuonTriggerEff(const char* Name, const char* Title):
77 AliFastResponse(Name, Title),
106 // Another constructor
109 AliFastMuonTriggerEff::AliFastMuonTriggerEff(const AliFastMuonTriggerEff& eff)
110 :AliFastResponse(eff),
143 void AliFastMuonTriggerEff::SetCut(Int_t cut)
148 printf("Selecting Low Pt cut\n");
149 }else if(cut==kHigh){
150 printf("Selecting High Pt cut\n");
152 printf("Selecting Lowest Pt cut\n");
154 printf("Don't know cut %d! Selecting Low Pt cut\n",cut);
161 Int_t AliFastMuonTriggerEff::SetBkgLevel(Float_t Bkg)
164 // Set the background level
167 printf("%s: Warning: requested Bkg: %f\n",
170 printf("A consistent treatement of the trigger probability\n");
171 printf("within the framework of the fast simulation requires\n");
172 printf("requires background 0\n");
173 printf("%s: fBkg: set to %f\n",
184 Int_t AliFastMuonTriggerEff::ForceBkgLevel(Float_t Bkg)
187 // Check and enforce consistency of the background level
190 printf("%s: Warning: requested Bkg: %f\n",
192 printf("A consistent treatement of the trigger probability\n");
193 printf("within the framework of the fast simulation\n");
194 printf("requires background 0");
195 printf("%s: Continue with fBkg: %f\n",
205 Int_t AliFastMuonTriggerEff::LoadTables(Char_t *namet=""){
207 // Load the trigger tables
209 Char_t hNameA[100],hNameL[100],hNameH[100];
210 snprintf(hNameA, 100, "hEffAPt%s",namet);
211 snprintf(hNameL, 100, "hEffLPt%s",namet);
212 snprintf(hNameH, 100, "hEffHPt%s",namet);
213 fhEffAPt = (TH3F*)gDirectory->Get(hNameA);
214 fhEffLPt = (TH3F*)gDirectory->Get(hNameL);
215 fhEffHPt = (TH3F*)gDirectory->Get(hNameH);
217 PLIN; printf("%s: histogram %s not found\n",__FILE__,hNameA);
221 PLIN; printf("%s: histogram %s not found\n",__FILE__,hNameL);
225 PLIN; printf("%s: histogram %s not found\n",__FILE__,hNameH);
231 void AliFastMuonTriggerEff::Init()
237 Char_t file[100]="$(ALICE_ROOT)/FASTSIM/data/MUONtriggerLUT_V2.4nvdn.root";
238 printf("Initializing %s / %s\n", fName.Data(), fTitle.Data());
239 printf("using data from file: %s\n",file);
240 printf("AliFastMuonTriggerEff: Initialization with background level: %f\n",fBkg);
241 TFile *f = new TFile(file);
243 PLIN; printf("Cannot open file: %s\n",file);
249 if(TMath::Abs(fBkg)<0.00001){
250 snprintf(namet, 10, "00");
251 }else if(TMath::Abs(fBkg-0.5)<0.00001){
252 snprintf(namet, 10, "05");
253 }else if(TMath::Abs(fBkg-1.0)<0.00001){
254 snprintf(namet, 10, "10");
256 PLIN; printf("A table for Bkg level: %f does not exists\n",fBkg);
259 if(intb){ // Interpolation between background levels
260 PLIN; printf("Interpolating Bkg level: %f\n",fBkg);
261 TH3F* ha1,*hl1,*hh1,*ha2,*hl2,*hh2,*ha0,*hl0,*hh0;
262 Char_t name1[10],name2[10]; Float_t b1,b2;
263 if(fBkg>0&&fBkg<0.5){
264 snprintf(name1,10, "00");
265 snprintf(name2,10, "05");
269 snprintf(name1, 10, "05");
270 snprintf(name2, 10, "10");
274 for(Int_t i=0; i<10;i++){
275 PLIN; printf("WARNING!!!! You are extrapolating above background 1.0\n");
279 PLIN; printf("Bkg level: %f is not supported\n",fBkg);
282 if(LoadTables(name1)){
283 PLIN; printf("Error in loading trigger tables\n");
286 PLIN; printf("We use tables for %f and %f to interpolate %f Bkg level\n",b1,b2,fBkg);
287 ha0=(TH3F*)fhEffAPt->Clone("hEffAPtXX"); ha0->Reset();
288 hl0=(TH3F*)fhEffLPt->Clone("hEffLPtXX"); hl0->Reset();
289 hh0=(TH3F*)fhEffHPt->Clone("hEffHPtXX"); hh0->Reset();
293 if(LoadTables(name2)){
294 PLIN; printf("Error in loading trigger tables\n");
303 Int_t nnx=ha0->GetNbinsX()+1;
304 Int_t nny=ha0->GetNbinsY()+1;
305 Int_t nnz=ha0->GetNbinsZ()+1;
306 for(Int_t ix=0; ix<=nnx; ix++){
307 for(Int_t iy=0; iy<=nny; iy++){
308 for(Int_t iz=0; iz<=nnz; iz++){
309 Double_t y1,y2; Float_t cont;
310 y1=ha1->GetBinContent(ix,iy,iz); y2=ha2->GetBinContent(ix,iy,iz);
311 cont=Float_t(y1+(y2-y1)/(b2-b1)*(fBkg-b1)); if(cont>1)cont=1; if(cont<0)cont=0;
312 fhEffAPt->SetBinContent(ix,iy,iz,cont);
313 y1=hl1->GetBinContent(ix,iy,iz); y2=hl2->GetBinContent(ix,iy,iz);
314 cont=Float_t(y1+(y2-y1)/(b2-b1)*(fBkg-b1)); if(cont>1)cont=1; if(cont<0)cont=0;
315 fhEffLPt->SetBinContent(ix,iy,iz,cont);
316 y1=hh1->GetBinContent(ix,iy,iz); y2=hh2->GetBinContent(ix,iy,iz);
317 cont=Float_t(y1+(y2-y1)/(b2-b1)*(fBkg-b1)); if(cont>1)cont=1; if(cont<0)cont=0;
318 fhEffHPt->SetBinContent(ix,iy,iz,cont);
322 }else{ // Use tables computed for selected backgound levels
323 printf("Loading tables for background level: %f\n",fBkg);
324 if(LoadTables(namet)){
325 PLIN; printf("Error in loading trigger tables\n");
329 fhEffAPt->SetDirectory(0);
330 fhEffLPt->SetDirectory(0);
331 fhEffHPt->SetDirectory(0);
332 fhLX=fhEffLPt->GetXaxis();
333 fhLY=fhEffLPt->GetYaxis();
334 fhLZ=fhEffLPt->GetZaxis();
337 if(f->Get("Description"))
339 fDescription=((TObjString*)f->Get("Description"))->GetString();
340 printf("%s\n",fDescription.Data());
343 fThetaMin = fhEffLPt->GetXaxis()->GetXmin();
344 fThetaMax = fhEffLPt->GetXaxis()->GetXmax();
345 fnthetab=fhEffLPt->GetNbinsX();
346 fDtheta = (fThetaMax-fThetaMin)/fnthetab;
348 fPhiMin = fhEffLPt->GetYaxis()->GetXmin();
349 fPhiMax = fhEffLPt->GetYaxis()->GetXmax();
350 fnphib=fhEffLPt->GetNbinsY();
351 fDphi = (fPhiMax-fPhiMin)/fnphib;
353 fPtMin=fhEffLPt->GetZaxis()->GetXmin();
354 fPtMax=fhEffLPt->GetZaxis()->GetXmax();
355 fnptb=fhEffLPt->GetNbinsZ();
356 fDpt = (fPtMax-fPtMin)/fnptb;
358 printf("***** This version of AliFastMuonTriggerEff can use both *****\n");
359 printf("***** new and old ALICE reference frames depending on *****\n");
360 printf("***** which LUT has been loaded. You can find below some *****\n");
361 printf("***** information on the current parametrization: *****\n");
362 printf("%4d bins in theta [%f:%f]\n",fnthetab,fThetaMin,fThetaMax);
363 printf("%4d bins in phi [%f:%f]\n",fnphib,fPhiMin,fPhiMax);
364 printf("%4d bins in pt [%f:%f]\n",fnptb,fPtMin,fPtMax);
366 fZones=fnthetab*fnphib;
370 printf("Interpolation of trigger efficiencies is off!\n");
372 printf("Interpolation of trigger efficiencies is on!\n");
376 void AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,Float_t theta,
377 Float_t phi, Float_t& effLow, Float_t& effHigh, Float_t& effAny)
380 // Trigger efficiency for pt, theta, phi (low, high and "any" cut)
383 printf("Evaluate(ch=%2.0f, pt=%10.6f, theta=%7.2f, phi=%8.2f ...)\n",charge,pt,theta,phi);
389 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
393 printf("Warning: pt: %f < 0. GeV/c\n",pt);
397 Int_t iPt = fhLZ->FindBin((Double_t)pt);
398 if(iPt>fnptb)iPt=fnptb;
399 Int_t iPhi = Int_t((phi-fPhiMin)/fDphi);
400 if(phi<fPhiMin)iPhi=iPhi-1;
401 Int_t iTheta = fhLX->FindBin((Double_t)theta);
403 printf("Evaluate(ch=%2.0f, pt=%10.6f, theta=%7.2f, phi=%8.2f ...)\n",charge,pt,theta,phi);
404 printf(" 0:%1d iPt iTheta iPhi: %d %d %d\n",fInt,iPt,iTheta,iPhi);
406 iPhi=iPhi-2*fnphib*(iPhi/(2*fnphib));
408 printf(" 1:%1d iPhi converted to: %d for angle equivalence\n",fInt,iPhi);
410 if(iPhi<0)iPhi=-iPhi-1;
411 if(iPhi>(fnphib-1))iPhi=2*fnphib-1-iPhi;
413 printf(" 2:%1d iPhi converted to: %d for the symmetry of the spectrometer\n",fInt,iPhi);
416 } else if(charge==-1.) {
419 printf(" 3:%1d iPhi converted to: %d for the charge symmetry\n",fInt,iPhi);
422 printf("Warning: not understand charge: %f\n",charge);
425 if(iTheta<=0||iTheta>fnthetab) {
426 printf("Warning: theta: %f outside acceptance\n",theta);
430 printf("Warning: what do you mean with pt: %f <0?\n",pt);
435 printf(" 4:%1d Getting: iTheta, iPhi, iPt: %d %d %d\n",
436 fInt,iTheta,iPhi,iPt);
438 effLow =fhEffLPt->GetBinContent(iTheta,iPhi,iPt);
439 effHigh=fhEffHPt->GetBinContent(iTheta,iPhi,iPt);
440 effAny =fhEffAPt->GetBinContent(iTheta,iPhi,iPt);
442 printf(" 4:%1d Result: charge, iTheta, iPhi, iPt: %f %d %d %d effLow: %f, effHigh: %f, effAny: %f\n",
443 fInt,charge,iTheta,iPhi,iPt,effLow,effHigh,effAny);
447 Float_t angl,angh,anga;
448 Float_t effLowp,effHighp,effAnyp;
449 Float_t ptc=(iPt+0.5)*fDpt; // The center of current bin
451 printf(" 5:1 The center of current bin iPt: %d is: %f\n",iPt,ptc);
455 printf(" 6:1 No more points above! No interpolation is needed!\n");
460 printf(" 6:1 No interpolation is needed!\n");
464 // Looking for previous point
466 effLowp =fhEffLPt->GetBinContent(iTheta,iPhi,iPt-1);
467 effHighp=fhEffHPt->GetBinContent(iTheta,iPhi,iPt-1);
468 effAnyp =fhEffAPt->GetBinContent(iTheta,iPhi,iPt-1);
470 printf(" 7:1 A simple look to previous point: %d: %f %f\n",iPt-1,effLowp,effHighp);
477 printf(" 8:1 result is: %f %f %f\n",effLowp,effHighp,effAnyp);
480 angl=(effLow-effLowp)/fDpt;
481 angh=(effHigh-effHighp)/fDpt;
482 anga=(effAny-effAnyp)/fDpt;
484 // Looking for next point
486 effLowp =fhEffLPt->GetBinContent(iTheta,iPhi,iPt+1);
487 effHighp=fhEffHPt->GetBinContent(iTheta,iPhi,iPt+1);
488 effAnyp =fhEffAPt->GetBinContent(iTheta,iPhi,iPt+1);
490 printf(" 7:1 A simple look to next point: %d: %f %f %f\n",iPt-1,effLowp,effHighp,effAnyp);
497 printf(" 8:1 result is: pt: %f %f %f\n",effLowp,effHighp,effAnyp);
500 angl=(effLowp-effLow)/fDpt;
501 angh=(effHighp-effHigh)/fDpt;
502 anga=(effAnyp-effAny)/fDpt;
504 effLow=effLow+angl*(pt-ptc);
505 effHigh=effHigh+angh*(pt-ptc);
506 effAny=effAny+anga*(pt-ptc);
508 printf(" 9:1 the interpolation coefficients are: %f %f %f\n",angl,angh,anga);
512 printf("10:%1d effLow, effHigh=%f %f %f\n",fInt,effLow,effHigh,effAny);
519 Float_t AliFastMuonTriggerEff::Evaluate(Float_t charge, Float_t pt,
520 Float_t theta, Float_t phi)
523 // Trigger efficiency for pt, theta, phi depending of fCut
526 printf("Call to uninitialized object of class: AliFastMuonTriggerEff\n");
530 Float_t effLow, effHigh, effAny;
532 Evaluate(charge,pt,theta,phi,effLow,effHigh,effAny);
535 else if (fCut == kHigh)
537 else if (fCut == kAny)
545 AliFastMuonTriggerEff& AliFastMuonTriggerEff::operator=(const AliFastMuonTriggerEff& rhs)
547 // Assignment operator