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 **************************************************************************/
16 //The design of this class is based on the AliFMDParameters class. Its purpose
17 //is to hold parameters for the analysis such as background correction and
20 //Author: Hans Hjersing Dalsgaard, NBI, hans.dalsgaard@cern.ch
23 // #include "AliFMDDebug.h" // ALILOG_H
24 #include "AliFMDAnaParameters.h" // ALIFMDPARAMETERS_H
25 //#include <AliCDBManager.h> // ALICDBMANAGER_H
26 //#include <AliCDBEntry.h> // ALICDBMANAGER_H
27 //#include "AliFMDRing.h"
29 #include <Riostream.h>
35 #include "AliTriggerAnalysis.h"
36 #include "AliPhysicsSelection.h"
37 #include "AliBackgroundSelection.h"
38 #include "AliMultiplicity.h"
39 #include "AliESDEvent.h"
40 #include "AliESDVertex.h"
41 #include "AliFMDAnaCalibBackgroundCorrection.h"
42 #include "AliFMDAnaCalibEnergyDistribution.h"
43 #include "AliFMDAnaCalibEventSelectionEfficiency.h"
44 #include "AliFMDAnaCalibSharingEfficiency.h"
47 //====================================================================
48 ClassImp(AliFMDAnaParameters)
50 ; // This is here to keep Emacs for indenting the next line
53 //const char* AliFMDAnaParameters::fgkBackgroundCorrection = "FMD/Correction/Background";
54 //const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
55 const char* AliFMDAnaParameters::fgkBackgroundID = "background";
56 const char* AliFMDAnaParameters::fgkEnergyDistributionID = "energydistributions";
57 const char* AliFMDAnaParameters::fgkEventSelectionEffID = "eventselectionefficiency";
58 const char* AliFMDAnaParameters::fgkSharingEffID = "sharingefficiency";
59 //____________________________________________________________________
60 AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
62 //____________________________________________________________________
65 AliFMDAnaParameters::Instance()
67 // Get static instance
68 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
72 //____________________________________________________________________
73 AliFMDAnaParameters::AliFMDAnaParameters() :
76 fEnergyDistribution(0),
77 fEventSelectionEfficiency(0),
78 fSharingEfficiency(0),
79 fCorner1(4.2231, 26.6638),
80 fCorner2(1.8357, 27.9500),
81 fEnergyPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EnergyDistribution"),
82 fBackgroundPath("$ALICE_ROOT/PWG2/FORWARD/corrections/Background"),
83 fEventSelectionEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EventSelectionEfficiency"),
84 fSharingEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/SharingEfficiency"),
85 fProcessPrimary(kFALSE),
94 fSPDhighLimit(999999999),
95 fCentralSelection(kFALSE),
96 fSharingObjectPresent(kTRUE),
97 fNumberOfEtaBinsToCut(1),
100 fTriggerInel(kFALSE),
102 fTriggerEmpty(kFALSE),
103 fUseBuiltInNSD(kFALSE),
106 fRunBFCorrelation(kTRUE),
107 fRunMultiplicity(kTRUE)
109 // Default constructor
110 // fPhysicsSelection = new AliPhysicsSelection;
111 // fPhysicsSelection->SetAnalyzeMC(kTRUE); //For the background correction. This is reset in Init if relevant
112 // fPhysicsSelection->SetUseBXNumbers(kFALSE);
115 // AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
116 // backgroundSelection->Init();
117 // fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
118 //fPhysicsSelection->Initialize(104792);
119 // Do not use this - it is only for IO
123 //____________________________________________________________________
124 const char* AliFMDAnaParameters::GetPath(const char* species) const
127 static TString* path = new TString();
129 if(species == fgkBackgroundID)
130 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
131 fBackgroundPath.Data(),
139 if(species == fgkEnergyDistributionID)
140 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
142 fgkEnergyDistributionID,
149 if(species == fgkEventSelectionEffID)
150 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
151 fEventSelectionEffPath.Data(),
152 fgkEventSelectionEffID,
159 if(species == fgkSharingEffID)
160 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
161 fSharingEffPath.Data(),
171 //____________________________________________________________________
172 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
174 // Initialize the parameters manager. We need to get stuff from files here.
176 /* AliPhysicsSelection* test = (AliPhysicsSelection*)((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetEventSelection();
178 if(fPhysicsSelection) {
180 fPhysicsSelection->SetAnalyzeMC(kTRUE);
182 else fPhysicsSelection->SetAnalyzeMC(kFALSE);
185 if (forceReInit) fIsInit = kFALSE;
187 if (what & kBackgroundCorrection) InitBackground();
188 if (what & kEnergyDistributions) InitEnergyDists();
189 if (what & kEventSelectionEfficiency) InitEventSelectionEff();
190 if (what & kSharingEfficiency) InitSharingEff();
200 //____________________________________________________________________
202 void AliFMDAnaParameters::InitBackground() {
203 //Init background correction objects.
205 TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
209 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(fin->Get(fgkBackgroundID));
210 if (!fBackground) AliFatal("Invalid background object from CDB");
216 //____________________________________________________________________
218 void AliFMDAnaParameters::InitEnergyDists() {
219 //Init energy distributions
221 TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
225 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(fin->Get(fgkEnergyDistributionID));
227 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
231 //____________________________________________________________________
233 void AliFMDAnaParameters::InitEventSelectionEff() {
234 //Init event selection objects
236 TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
240 fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
241 if (!fEventSelectionEfficiency) AliFatal("Invalid background object from CDB");
245 //____________________________________________________________________
247 void AliFMDAnaParameters::InitSharingEff() {
249 fSharingObjectPresent = kTRUE;
250 TFile* fin = TFile::Open(GetPath(fgkSharingEffID));
253 fSharingObjectPresent = kFALSE;
257 fSharingEfficiency = dynamic_cast<AliFMDAnaCalibSharingEfficiency*>(fin->Get(fgkSharingEffID));
258 if (!fSharingEfficiency) {
259 fSharingObjectPresent = kFALSE;
264 //____________________________________________________________________
265 void AliFMDAnaParameters::FindEtaLimits() {
267 fEtaLowBinLimits.SetBins(4,0,4,2,0,2,GetNvtxBins(),0,GetNvtxBins());
268 fEtaHighBinLimits.SetBins(4,0,4,2,0,2,GetNvtxBins(),0,GetNvtxBins());
269 for(Int_t det=0; det<=3;det++) {
270 Int_t nRings = (det<=1 ? 1 : 2);
271 for (UShort_t ir = 0; ir < nRings; ir++) {
272 Char_t ringChar = (ir == 0 ? 'I' : 'O');
273 for(Int_t v =0; v<GetNvtxBins(); v++) {
274 fEtaLowBinLimits.SetBinContent(det,ir,v,GetFirstEtaBinFromMap(v, det, ringChar));
275 fEtaHighBinLimits.SetBinContent(det,ir,v,GetLastEtaBinFromMap(v, det, ringChar));
276 //std::cout<<det<<" "<<ringChar<<" "<<fEtaLowBinLimits.GetBinContent(det,ir,v)<<" "<<fEtaHighBinLimits.GetBinContent(det,ir,v)<<std::endl;
282 //____________________________________________________________________
283 void AliFMDAnaParameters::SetEnergy(Float_t cmsNNGeV)
285 if (TMath::Abs(cmsNNGeV - 900.) < 10) fEnergy = k900;
286 if (TMath::Abs(cmsNNGeV - 2400.) < 10) fEnergy = k2400;
287 if (TMath::Abs(cmsNNGeV - 2750.) < 10) fEnergy = k2750;
288 if (TMath::Abs(cmsNNGeV - 5500.) < 40) fEnergy = k5500;
289 if (TMath::Abs(cmsNNGeV - 7000.) < 10) fEnergy = k7000;
290 if (TMath::Abs(cmsNNGeV - 10000.) < 10) fEnergy = k10000;
291 if (TMath::Abs(cmsNNGeV - 14000.) < 10) fEnergy = k14000;
293 //____________________________________________________________________
294 void AliFMDAnaParameters::SetMagField(Float_t bkG)
296 if (TMath::Abs(bkG - 5.) < 1 ) fMagField = k5G;
297 if (TMath::Abs(bkG + 5.) < 1 ) fMagField = k5Gnegative;
298 if (TMath::Abs(bkG) < 1) fMagField = k0G;
300 //____________________________________________________________________
301 void AliFMDAnaParameters::SetCollisionSystem(const TString& sys)
305 if (s.Contains("p-p") || s.Contains("pp")) fSpecies = kPP;
306 else if (s.Contains("pb-pb") || s.Contains("pbpb")) fSpecies = kPbPb;
307 else if (s.Contains("a-a") || s.Contains("aa")) fSpecies = kPbPb;
310 //____________________________________________________________________
311 void AliFMDAnaParameters::SetParametersFromESD(AliESDEvent* esd)
315 SetCollisionSystem(esd->GetBeamType());
317 Float_t energy = esd->GetBeamEnergy();
318 // Correct to center of mass per nucleon (cmsNN) - LHC gives it as
320 if (fSpecies == kPbPb) energy = energy / 208 * 82;
322 SetMagField(esd->GetMagneticField());
324 // Float_t magfield = esd->GetCurrentL3();
325 // if (TMath::Abs(magfield - 30000.) < 10 ) fMagField = k5G;
326 // if (TMath::Abs(magfield + 30000.) < 10 ) fMagField = k5Gnegative;
327 // if (TMath::Abs(magfield) < 10 ) fMagField = k0G;
335 //____________________________________________________________________
337 void AliFMDAnaParameters::PrintStatus(Bool_t showpaths) const
339 //Print current status
340 TString energystring;
343 energystring.Form("900 GeV"); break;
345 energystring.Form("2400 GeV"); break;
347 energystring.Form("2750 GeV"); break;
349 energystring.Form("5500 GeV"); break;
351 energystring.Form("7000 GeV"); break;
353 energystring.Form("10000 GeV"); break;
355 energystring.Form("14000 GeV"); break;
357 energystring.Form("invalid energy"); break;
359 TString triggerstring;
362 triggerstring.Form("Minimum bias 1"); break;
364 triggerstring.Form("Minimum bias 2"); break;
366 triggerstring.Form("SPD FAST OR"); break;
368 triggerstring.Form("NO TRIGGER TEST"); break;
370 energystring.Form("invalid trigger"); break;
375 magstring.Form("+5 kGaus"); break;
377 magstring.Form("0 kGaus"); break;
379 magstring.Form("-5 kGaus"); break;
381 magstring.Form("invalid mag field %d", fMagField); break;
383 TString collsystemstring;
386 collsystemstring.Form("p-p"); break;
388 collsystemstring.Form("Pb-Pb"); break;
390 collsystemstring.Form("invalid collision system"); break;
396 datastring.Form("Nature"); break;
398 datastring.Form("MC"); break;
400 datastring.Form("Unknown"); break ;
404 if(fInelGtZero) InelString = "INEL > 0";
405 else InelString = "INEL";
407 std::cout<<"Energy = "<<energystring.Data()<<std::endl;
408 std::cout<<"Trigger = "<<triggerstring.Data()<<std::endl;
409 std::cout<<"Mag Field = "<<magstring.Data()<<std::endl;
410 std::cout<<"Coll System = "<<collsystemstring.Data()<<std::endl;
411 std::cout<<"Data origin = "<<datastring.Data()<<std::endl;
412 std::cout<<"Basic trigger: "<<InelString.Data()<<std::endl;
415 TString bg = GetPath(fgkBackgroundID);
416 TString es = GetPath(fgkEventSelectionEffID);
417 TString ed = GetPath(fgkEnergyDistributionID);
418 TString me = GetPath(fgkSharingEffID);
419 std::cout << "2nd maps: " << bg << "\n"
420 << "Event sel.: " << es << "\n"
421 << "Energy dist.: " << ed << "\n"
422 << "Merge eff.: " << me << std::endl;
427 //____________________________________________________________________
428 Float_t AliFMDAnaParameters::GetVtxCutZ() {
429 //Get the z vtx cut in analysis
431 AliWarning("Not initialized yet. Call Init() to remedy");
435 return fBackground->GetVtxCutZ();
438 //____________________________________________________________________
439 Int_t AliFMDAnaParameters::GetNvtxBins() {
440 //Get number of vtx bins
442 AliWarning("Not initialized yet. Call Init() to remedy");
446 return fBackground->GetNvtxBins();
448 //____________________________________________________________________
449 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
451 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
453 //____________________________________________________________________
454 TH1F* AliFMDAnaParameters::GetEmptyEnergyDistribution(Int_t det, Char_t ring) {
456 return fEnergyDistribution->GetEmptyEnergyDistribution(det, ring);
458 //____________________________________________________________________
459 TH1F* AliFMDAnaParameters::GetRingEnergyDistribution(Int_t det, Char_t ring) {
461 return fEnergyDistribution->GetRingEnergyDistribution(det, ring);
463 //____________________________________________________________________
464 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
465 //Get sigma of Landau fits
467 AliWarning("Not initialized yet. Call Init() to remedy");
471 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
472 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
474 //AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
477 Float_t sigma = fitFunc->GetParameter(2);
482 //____________________________________________________________________
483 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
484 //Get MPV of landau fits
486 AliWarning("Not initialized yet. Call Init() to remedy");
489 //AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
490 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
491 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
494 AliWarning(Form("No function for FMD%d%c, eta %f (%d)",det,ring,eta,
499 Float_t mpv = fitFunc->GetParameter(1);
502 //____________________________________________________________________
503 Float_t AliFMDAnaParameters::GetConstant(Int_t det, Char_t ring, Float_t eta) {
504 //Get constant parameter of Landau fits
506 AliWarning("Not initialized yet. Call Init() to remedy");
510 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
511 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
513 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
517 Float_t mpv = fitFunc->GetParameter(0);
520 //____________________________________________________________________
522 AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta)
524 //Get 2 MIP weights of convoluted Landau fits
526 AliWarning("Not initialized yet. Call Init() to remedy");
530 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
531 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
532 if(!fitFunc) return 0;
533 Float_t twoMIPweight = fitFunc->GetParameter(3);
537 if(twoMIPweight < 1e-05)
542 //____________________________________________________________________
544 AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta)
546 //Get 3 MIP weights of convoluted Landau fits
548 AliWarning("Not initialized yet. Call Init() to remedy");
552 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
553 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
554 if(!fitFunc) return 0;
555 Float_t threeMIPweight = fitFunc->GetParameter(4);
557 if(threeMIPweight < 1e-05)
560 Float_t twoMIPweight = fitFunc->GetParameter(3);
562 if(twoMIPweight < 1e-05)
565 return threeMIPweight;
567 //____________________________________________________________________
568 Int_t AliFMDAnaParameters::GetNetaBins()
570 return GetBackgroundCorrection(1,'I',5)->GetNbinsX();
572 //____________________________________________________________________
573 Float_t AliFMDAnaParameters::GetEtaMin()
575 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmin();
577 //____________________________________________________________________
578 Float_t AliFMDAnaParameters::GetEtaMax()
580 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmax();
582 //____________________________________________________________________
583 Int_t AliFMDAnaParameters::GetEtaBin(Float_t eta)
585 TAxis testaxis(GetNetaBins(),GetEtaMin(),GetEtaMax());
586 Int_t binnumber = testaxis.FindBin(eta) ;
590 //____________________________________________________________________
592 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
595 //Get background correction histogram
597 AliWarning("Not initialized yet. Call Init() to remedy");
603 if(vtxbin > fBackground->GetNvtxBins()) {
604 AliWarning(Form("No background object for vertex bin %d", vtxbin));
608 return fBackground->GetBgCorrection(det,ring,vtxbin);
610 //____________________________________________________________________
611 TH2F* AliFMDAnaParameters::GetBackgroundCorrectionNSD(Int_t det,
614 //Get background correction histogram for NSD event class
616 AliWarning("Not initialized yet. Call Init() to remedy");
620 if(vtxbin > fBackground->GetNvtxBins()) {
621 AliWarning(Form("No background object for vertex bin %d", vtxbin));
625 if(fBackground->GetNSDBgCorrection(det,ring,vtxbin))
626 return fBackground->GetNSDBgCorrection(det,ring,vtxbin);
628 AliWarning("No NSD background map. You get usual one. "
629 "Difference is probably negligible");
631 return fBackground->GetBgCorrection(det,ring,vtxbin);
633 //____________________________________________________________________
635 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det,
637 //Get correction for several hits in strips for p+p
639 AliWarning("Not initialized yet. Call Init() to remedy");
643 return fBackground->GetDoubleHitCorrection(det,ring);
645 //_____________________________________________________________________
646 TH1F* AliFMDAnaParameters::GetSPDDeadCorrection(Int_t vtxbin) {
648 //Get correction for several hits in strips for p+p
650 AliWarning("Not initialized yet. Call Init() to remedy");
654 return fBackground->GetSPDDeadCorrection(vtxbin);
656 //_____________________________________________________________________
657 TH1F* AliFMDAnaParameters::GetFMDDeadCorrection(Int_t vtxbin) {
659 //Get correction for several hits in strips for p+p
661 AliWarning("Not initialized yet. Call Init() to remedy");
665 return fBackground->GetFMDDeadCorrection(vtxbin);
667 //_____________________________________________________________________
668 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
669 //Get event selection efficiency object
671 AliWarning("Not initialized yet. Call Init() to remedy");
674 return fEventSelectionEfficiency->GetCorrection(vtxbin);
677 //_____________________________________________________________________
678 Float_t AliFMDAnaParameters::GetVtxSelectionEffFromMC() {
681 AliWarning("Not initialized yet. Call Init() to remedy");
684 return fEventSelectionEfficiency->GetVtxToTriggerRatio();
688 //_____________________________________________________________________
689 TH2F* AliFMDAnaParameters::GetEventSelectionEfficiency(TString trig, Int_t vtxbin, Char_t ring) {
690 //Get event selection efficiency object
692 //TString test = trig;
693 if(!trig.Contains("NSD") && !trig.Contains("INEL")) {
694 AliWarning("Event selection efficiency only available for INEL and NSD");
698 AliWarning("Not initialized yet. Call Init() to remedy");
701 return fEventSelectionEfficiency->GetCorrection(trig,vtxbin,ring);
704 //_____________________________________________________________________
705 TH1F* AliFMDAnaParameters::GetSharingEfficiency(Int_t det, Char_t ring, Int_t vtxbin) {
706 //Get sharing efficiency object
708 AliWarning("Not initialized yet. Call Init() to remedy");
712 return fSharingEfficiency->GetSharingEff(det,ring,vtxbin);
715 //_____________________________________________________________________
716 TH1F* AliFMDAnaParameters::GetSharingEfficiencyTrVtx(Int_t det, Char_t ring, Int_t vtxbin) {
717 //Get sharing efficiency object TrVtx
719 AliWarning("Not initialized yet. Call Init() to remedy");
723 return fSharingEfficiency->GetSharingEffTrVtx(det,ring,vtxbin);
726 //_____________________________________________________________________
727 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const {
735 AliWarning("Unknown ring - must be I or O!");
739 //_____________________________________________________________________
740 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
748 AliWarning("Unknown ring - must be I or O!");
753 //_____________________________________________________________________
754 void AliFMDAnaParameters::SetCorners(Char_t ring) {
755 //Set corners (taken from nominal geometry)
757 fCorner1.Set(4.9895, 15.3560);
758 fCorner2.Set(1.8007, 17.2000);
761 fCorner1.Set(4.2231, 26.6638);
762 fCorner2.Set(1.8357, 27.9500);
766 //_____________________________________________________________________
767 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
769 //Get phi from sector
770 Int_t nsec = (ring == 'I' ? 20 : 40);
773 basephi = 1.72787594;
774 if(det == 2 && ring == 'I')
775 basephi = 0.15707963;
776 if(det == 2 && ring == 'O')
777 basephi = 0.078539818;
778 if(det == 3 && ring == 'I')
779 basephi = 2.984513044;
780 if(det == 3 && ring == 'O')
781 basephi = 3.06305289;
783 Float_t step = 2*TMath::Pi() / nsec;
786 phi = basephi - sec*step;
788 phi = basephi + sec*step;
791 phi = phi +2*TMath::Pi();
792 if(phi > 2*TMath::Pi() )
793 phi = phi - 2*TMath::Pi();
797 //_____________________________________________________________________
798 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
800 //Calculate eta from strip with vertex (redundant with AliESDFMD::Eta)
801 Float_t rad = GetMaxR(ring)-GetMinR(ring);
802 Float_t nStrips = (ring == 'I' ? 512 : 256);
803 Float_t segment = rad / nStrips;
804 Float_t r = GetMinR(ring) + segment*strip;
806 Int_t hybrid = sec / 2;
809 if(!(hybrid%2)) z = 320.266; else z = 319.766;
811 if(det == 2 && ring == 'I' ) {
812 if(!(hybrid%2)) z = 83.666; else z = 83.166;
814 if(det == 2 && ring == 'O' ) {
815 if(!(hybrid%2)) z = 74.966; else z = 75.466;
817 if(det == 3 && ring == 'I' ) {
818 if(!(hybrid%2)) z = -63.066; else z = -62.566;
820 if(det == 3 && ring == 'O' ) {
821 if(!(hybrid%2)) z = -74.966; else z = -75.466;
824 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
826 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
827 Float_t theta = TMath::ATan2(r,z-zvtx);
828 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
833 //_____________________________________________________________________
835 Bool_t AliFMDAnaParameters::GetVertex(const AliESDEvent* esd, Double_t* vertexXYZ)
837 //Get the vertex from the ESD
838 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
840 if (!vertex) return kFALSE;
842 vertex->GetXYZ(vertexXYZ);
844 //if(vertexXYZ[0] == 0 || vertexXYZ[1] == 0 )
847 if(vertex->GetNContributors() <= 0)
850 if(vertex->GetZRes() > 0.1 )
853 return vertex->GetStatus();
856 //____________________________________________________________________
857 void AliFMDAnaParameters::SetTriggerStatus(const AliESDEvent *esd) {
859 //ULong64_t triggerMask = esd->GetTriggerMask();
861 AliPhysicsSelection* centralPhysicsSelection = (AliPhysicsSelection*)((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetEventSelection();
863 if(!centralPhysicsSelection && !fPhysicsSelection) {
865 std::cout<<"Creating AliPhysicsSelection object due to absence of central object"<<std::endl;
866 fPhysicsSelection = new AliPhysicsSelection;
867 fPhysicsSelection->SetAnalyzeMC(!fRealData);
868 // fPhysicsSelection->SetUseBXNumbers(kFALSE);
871 AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
872 backgroundSelection->Init();
873 fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
877 TString triggers = esd->GetFiredTriggerClasses();
879 AliTriggerAnalysis tAna;
881 fTriggerInel = kFALSE;
882 fTriggerNSD = kFALSE;
883 fTriggerEmpty = kFALSE;
885 UInt_t inel = kFALSE;
887 if(centralPhysicsSelection) {
888 inel= ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
891 inel = fPhysicsSelection->IsCollisionCandidate(esd);
895 if(fInelGtZero && inel) {
896 const AliMultiplicity* spdmult = esd->GetMultiplicity();
897 Int_t nCentralTracklets = 0;
899 while( nCentralTracklets < 1 && j< spdmult->GetNumberOfTracklets() ) {
900 if(TMath::Abs(spdmult->GetEta(j)) < 1) nCentralTracklets++;
903 if(nCentralTracklets < 1) inel = kFALSE;
906 //std::cout<<fTriggerInel<<std::endl;
908 fTriggerInel = kTRUE;
913 if ((tAna.FMDTrigger(esd, AliTriggerAnalysis::kASide) || tAna.V0Trigger(esd, AliTriggerAnalysis::kASide, kFALSE) == AliTriggerAnalysis::kV0BB) && (tAna.FMDTrigger(esd, AliTriggerAnalysis::kCSide) || tAna.V0Trigger(esd, AliTriggerAnalysis::kCSide, kFALSE) == AliTriggerAnalysis::kV0BB))
916 else nsd = tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1);
918 if(fTriggerInel && nsd) {
921 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL")) {
922 fTriggerEmpty = kTRUE;
926 /*switch (fTrigger) {
928 if( fPhysicsSelection->IsCollisionCandidate(esd)) {
929 fTriggerInel = kTRUE;
935 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
940 if (triggerMask & spdFO)
949 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL"))
954 if(fPhysicsSelection->IsCollisionCandidate(esd) && tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1))
964 //____________________________________________________________________
965 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd, Trigger trig) {
966 //Did we have trig trigger ?
967 Trigger old = fTrigger;
969 Bool_t retval = IsEventTriggered(esd);
975 //____________________________________________________________________
976 Bool_t AliFMDAnaParameters::IsEventTriggered(Trigger trigger) {
977 // check if the event was triggered
979 if (fCentralSelection) return kTRUE;
989 return fTriggerEmpty;
995 AliWarning("Trigger not implemented!!!");
1004 //____________________________________________________________________
1006 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
1008 //Get length of a strip
1010 Float_t rad = GetMaxR(ring)-GetMinR(ring);
1011 Float_t nStrips = (ring == 'I' ? 512 : 256);
1012 Float_t segment = rad / nStrips;
1014 //TVector2* corner1 = fmdring.GetVertex(2);
1015 // TVector2* corner2 = fmdring.GetVertex(3);
1019 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
1020 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
1021 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
1022 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
1023 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
1024 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
1025 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
1026 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
1027 Float_t radius = GetMinR(ring) + strip*segment;
1029 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
1031 Float_t arclength = GetBaseStripLength(ring,strip);
1034 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
1035 Float_t y = slope*x + constant;
1036 Float_t theta = TMath::ATan2(x,y);
1038 if(x < fCorner1.X() && y > fCorner1.Y()) {
1039 arclength = radius*theta; //One sector since theta is by definition half-hybrid
1049 //____________________________________________________________________
1051 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
1053 //Get length of strip assuming that corners are not cut away
1054 Float_t rad = GetMaxR(ring)-GetMinR(ring);
1055 Float_t nStrips = (ring == 'I' ? 512 : 256);
1056 Float_t nSec = (ring == 'I' ? 20 : 40);
1057 Float_t segment = rad / nStrips;
1058 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
1059 Float_t radius = GetMinR(ring) + strip*segment;
1060 Float_t basearclength = 0.5*basearc * radius; // One sector
1062 return basearclength;
1064 //____________________________________________________________________
1065 Int_t AliFMDAnaParameters::GetFirstEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
1067 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
1069 if(det == 0) return hBg->GetXaxis()->FindBin(-1.95);
1071 Int_t firstbin = -1;
1072 Int_t nNonZeroFirst = 0;
1074 for(Int_t i=1;i<=hBg->GetNbinsX();i++) {
1075 if(nNonZeroFirst == fNumberOfEtaBinsToCut && firstbin==-1) firstbin = i;
1077 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
1079 Float_t value = hBg->GetBinContent(i,j);
1081 if(value > 0.001 && nNonZeroFirst<fNumberOfEtaBinsToCut)
1082 {nNonZeroFirst++; break;}
1091 //____________________________________________________________________
1092 Int_t AliFMDAnaParameters::GetLastEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
1094 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
1096 Int_t nNonZeroLast = 0;
1098 if(det == 0) return hBg->GetXaxis()->FindBin(1.95);
1100 for(Int_t i=hBg->GetNbinsX();i>0;i--) {
1101 if(nNonZeroLast == fNumberOfEtaBinsToCut && lastbin==-1) lastbin = i;
1103 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
1105 Float_t value = hBg->GetBinContent(i,j);
1107 if(value > 0.001 && nNonZeroLast<fNumberOfEtaBinsToCut)
1108 {nNonZeroLast++; break; }
1117 //____________________________________________________________________
1118 Int_t AliFMDAnaParameters::GetFirstEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
1120 Int_t ringNumber = (ring == 'I' ? 0 : 1);
1121 return fEtaLowBinLimits.GetBinContent(det,ringNumber,vtxbin);
1125 //____________________________________________________________________
1126 Int_t AliFMDAnaParameters::GetLastEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
1128 Int_t ringNumber = (ring == 'I' ? 0 : 1);
1129 return fEtaHighBinLimits.GetBinContent(det,ringNumber,vtxbin);
1132 //____________________________________________________________________