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"
43 //====================================================================
44 ClassImp(AliFMDAnaParameters)
46 ; // This is here to keep Emacs for indenting the next line
49 //const char* AliFMDAnaParameters::fgkBackgroundCorrection = "FMD/Correction/Background";
50 //const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
51 const char* AliFMDAnaParameters::fgkBackgroundID = "background";
52 const char* AliFMDAnaParameters::fgkEnergyDistributionID = "energydistributions";
53 const char* AliFMDAnaParameters::fgkEventSelectionEffID = "eventselectionefficiency";
54 const char* AliFMDAnaParameters::fgkSharingEffID = "sharingefficiency";
55 //____________________________________________________________________
56 AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
58 //____________________________________________________________________
61 AliFMDAnaParameters::Instance()
63 // Get static instance
64 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
68 //____________________________________________________________________
69 AliFMDAnaParameters::AliFMDAnaParameters() :
72 fEnergyDistribution(0),
73 fEventSelectionEfficiency(0),
74 fSharingEfficiency(0),
75 fCorner1(4.2231, 26.6638),
76 fCorner2(1.8357, 27.9500),
77 fEnergyPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EnergyDistribution"),
78 fBackgroundPath("$ALICE_ROOT/PWG2/FORWARD/corrections/Background"),
79 fEventSelectionEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EventSelectionEfficiency"),
80 fSharingEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/SharingEfficiency"),
81 fProcessPrimary(kFALSE),
90 fSPDhighLimit(999999999),
91 fCentralSelection(kFALSE),
92 fSharingObjectPresent(kTRUE),
93 fNumberOfEtaBinsToCut(1),
98 fTriggerEmpty(kFALSE),
99 fUseBuiltInNSD(kFALSE),
102 fRunBFCorrelation(kTRUE),
103 fRunMultiplicity(kTRUE)
105 // Default constructor
106 // fPhysicsSelection = new AliPhysicsSelection;
107 // fPhysicsSelection->SetAnalyzeMC(kTRUE); //For the background correction. This is reset in Init if relevant
108 // fPhysicsSelection->SetUseBXNumbers(kFALSE);
111 // AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
112 // backgroundSelection->Init();
113 // fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
114 //fPhysicsSelection->Initialize(104792);
115 // Do not use this - it is only for IO
119 //____________________________________________________________________
120 const char* AliFMDAnaParameters::GetPath(const char* species) {
122 static TString* path = new TString();
124 if(species == fgkBackgroundID)
125 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
126 fBackgroundPath.Data(),
134 if(species == fgkEnergyDistributionID)
135 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
137 fgkEnergyDistributionID,
144 if(species == fgkEventSelectionEffID)
145 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
146 fEventSelectionEffPath.Data(),
147 fgkEventSelectionEffID,
154 if(species == fgkSharingEffID)
155 path->Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
156 fSharingEffPath.Data(),
166 //____________________________________________________________________
167 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
169 // Initialize the parameters manager. We need to get stuff from files here.
171 /* AliPhysicsSelection* test = (AliPhysicsSelection*)((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetEventSelection();
173 if(fPhysicsSelection) {
175 fPhysicsSelection->SetAnalyzeMC(kTRUE);
177 else fPhysicsSelection->SetAnalyzeMC(kFALSE);
180 if (forceReInit) fIsInit = kFALSE;
182 if (what & kBackgroundCorrection) InitBackground();
183 if (what & kEnergyDistributions) InitEnergyDists();
184 if (what & kEventSelectionEfficiency) InitEventSelectionEff();
185 if (what & kSharingEfficiency) InitSharingEff();
195 //____________________________________________________________________
197 void AliFMDAnaParameters::InitBackground() {
198 //Init background correction objects.
200 TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
204 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(fin->Get(fgkBackgroundID));
205 if (!fBackground) AliFatal("Invalid background object from CDB");
211 //____________________________________________________________________
213 void AliFMDAnaParameters::InitEnergyDists() {
214 //Init energy distributions
216 TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
220 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(fin->Get(fgkEnergyDistributionID));
222 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
226 //____________________________________________________________________
228 void AliFMDAnaParameters::InitEventSelectionEff() {
229 //Init event selection objects
231 TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
235 fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
236 if (!fEventSelectionEfficiency) AliFatal("Invalid background object from CDB");
240 //____________________________________________________________________
242 void AliFMDAnaParameters::InitSharingEff() {
244 fSharingObjectPresent = kTRUE;
245 TFile* fin = TFile::Open(GetPath(fgkSharingEffID));
248 fSharingObjectPresent = kFALSE;
252 fSharingEfficiency = dynamic_cast<AliFMDAnaCalibSharingEfficiency*>(fin->Get(fgkSharingEffID));
253 if (!fSharingEfficiency) {
254 fSharingObjectPresent = kFALSE;
259 //____________________________________________________________________
260 void AliFMDAnaParameters::FindEtaLimits() {
262 fEtaLowBinLimits.SetBins(4,0,4,2,0,2,GetNvtxBins(),0,GetNvtxBins());
263 fEtaHighBinLimits.SetBins(4,0,4,2,0,2,GetNvtxBins(),0,GetNvtxBins());
264 for(Int_t det=0; det<=3;det++) {
265 Int_t nRings = (det<=1 ? 1 : 2);
266 for (UShort_t ir = 0; ir < nRings; ir++) {
267 Char_t ringChar = (ir == 0 ? 'I' : 'O');
268 for(Int_t v =0; v<GetNvtxBins(); v++) {
269 fEtaLowBinLimits.SetBinContent(det,ir,v,GetFirstEtaBinFromMap(v, det, ringChar));
270 fEtaHighBinLimits.SetBinContent(det,ir,v,GetLastEtaBinFromMap(v, det, ringChar));
271 //std::cout<<det<<" "<<ringChar<<" "<<fEtaLowBinLimits.GetBinContent(det,ir,v)<<" "<<fEtaHighBinLimits.GetBinContent(det,ir,v)<<std::endl;
277 //____________________________________________________________________
278 void AliFMDAnaParameters::SetParametersFromESD(AliESDEvent* esd) {
280 Float_t energy = esd->GetBeamEnergy();
281 Float_t magfield = esd->GetCurrentL3();
282 TString beamtype = esd->GetBeamType();
284 if(TMath::Abs(energy - 450.) < 1) fEnergy = k900;
285 if(TMath::Abs(energy - 3500.) < 1) fEnergy = k7000;
286 if(TMath::Abs(energy - 2750.) < 20) fEnergy = k2750;
289 if(TMath::Abs(magfield - 30000.) < 10 ) fMagField = k5G;
290 if(TMath::Abs(magfield + 30000.) < 10 ) fMagField = k5Gnegative;
291 if(TMath::Abs(magfield) < 10 ) fMagField = k0G;
293 if(beamtype.Contains("p-p")) fSpecies = kPP;
294 if(beamtype.Contains("Pb-Pb")) fSpecies = kPbPb;
300 //____________________________________________________________________
302 void AliFMDAnaParameters::PrintStatus() const
304 //Print current status
305 TString energystring;
308 energystring.Form("900 GeV"); break;
310 energystring.Form("7000 GeV"); break;
312 energystring.Form("10000 GeV"); break;
314 energystring.Form("14000 GeV"); break;
316 energystring.Form("2750 GeV"); break;
318 energystring.Form("invalid energy"); break;
320 TString triggerstring;
323 triggerstring.Form("Minimum bias 1"); break;
325 triggerstring.Form("Minimum bias 2"); break;
327 triggerstring.Form("SPD FAST OR"); break;
329 triggerstring.Form("NO TRIGGER TEST"); break;
331 energystring.Form("invalid trigger"); break;
336 magstring.Form("5 kGaus"); break;
338 magstring.Form("0 kGaus"); break;
340 magstring.Form("-5 kGaus"); break;
342 magstring.Form("invalid mag field %d", fMagField); break;
344 TString collsystemstring;
347 collsystemstring.Form("p+p"); break;
349 collsystemstring.Form("Pb+Pb"); break;
351 collsystemstring.Form("invalid collision system"); break;
357 datastring.Form("Nature"); break;
359 datastring.Form("MC"); break;
361 datastring.Form("Unknown"); break ;
365 if(fInelGtZero) InelString = "INEL > 0";
366 else InelString = "INEL";
368 std::cout<<"Energy = "<<energystring.Data()<<std::endl;
369 std::cout<<"Trigger = "<<triggerstring.Data()<<std::endl;
370 std::cout<<"Mag Field = "<<magstring.Data()<<std::endl;
371 std::cout<<"Coll System = "<<collsystemstring.Data()<<std::endl;
372 std::cout<<"Data origin = "<<datastring.Data()<<std::endl;
373 std::cout<<"Basic trigger: "<<InelString.Data()<<std::endl;
378 //____________________________________________________________________
379 Float_t AliFMDAnaParameters::GetVtxCutZ() {
380 //Get the z vtx cut in analysis
382 AliWarning("Not initialized yet. Call Init() to remedy");
386 return fBackground->GetVtxCutZ();
389 //____________________________________________________________________
390 Int_t AliFMDAnaParameters::GetNvtxBins() {
391 //Get number of vtx bins
393 AliWarning("Not initialized yet. Call Init() to remedy");
397 return fBackground->GetNvtxBins();
399 //____________________________________________________________________
400 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
402 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
404 //____________________________________________________________________
405 TH1F* AliFMDAnaParameters::GetEmptyEnergyDistribution(Int_t det, Char_t ring) {
407 return fEnergyDistribution->GetEmptyEnergyDistribution(det, ring);
409 //____________________________________________________________________
410 TH1F* AliFMDAnaParameters::GetRingEnergyDistribution(Int_t det, Char_t ring) {
412 return fEnergyDistribution->GetRingEnergyDistribution(det, ring);
414 //____________________________________________________________________
415 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
416 //Get sigma of Landau fits
418 AliWarning("Not initialized yet. Call Init() to remedy");
422 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
423 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
425 //AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
428 Float_t sigma = fitFunc->GetParameter(2);
433 //____________________________________________________________________
434 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
435 //Get MPV of landau fits
437 AliWarning("Not initialized yet. Call Init() to remedy");
440 //AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
441 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
442 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
445 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
446 std::cout<<hEnergyDist->GetEntries()<<" "<<GetEtaBin(eta)<<std::endl;
450 Float_t mpv = fitFunc->GetParameter(1);
453 //____________________________________________________________________
454 Float_t AliFMDAnaParameters::GetConstant(Int_t det, Char_t ring, Float_t eta) {
455 //Get constant parameter of Landau fits
457 AliWarning("Not initialized yet. Call Init() to remedy");
461 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
462 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
464 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
468 Float_t mpv = fitFunc->GetParameter(0);
471 //____________________________________________________________________
472 Float_t AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta) {
473 //Get 2 MIP weights of convoluted Landau fits
475 AliWarning("Not initialized yet. Call Init() to remedy");
479 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
480 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
481 if(!fitFunc) return 0;
482 Float_t twoMIPweight = fitFunc->GetParameter(3);
486 if(twoMIPweight < 1e-05)
491 //____________________________________________________________________
492 Float_t AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta) {
493 //Get 3 MIP weights of convoluted Landau fits
495 AliWarning("Not initialized yet. Call Init() to remedy");
499 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
500 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
501 if(!fitFunc) return 0;
502 Float_t threeMIPweight = fitFunc->GetParameter(4);
504 if(threeMIPweight < 1e-05)
507 Float_t twoMIPweight = fitFunc->GetParameter(3);
509 if(twoMIPweight < 1e-05)
512 return threeMIPweight;
514 //____________________________________________________________________
515 Int_t AliFMDAnaParameters::GetNetaBins() {
516 return GetBackgroundCorrection(1,'I',5)->GetNbinsX();
519 //____________________________________________________________________
520 Float_t AliFMDAnaParameters::GetEtaMin() {
522 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmin();
524 //____________________________________________________________________
525 Float_t AliFMDAnaParameters::GetEtaMax() {
527 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmax();
530 //____________________________________________________________________
531 Int_t AliFMDAnaParameters::GetEtaBin(Float_t eta) {
533 TAxis testaxis(GetNetaBins(),GetEtaMin(),GetEtaMax());
534 Int_t binnumber = testaxis.FindBin(eta) ;
539 //____________________________________________________________________
541 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
544 //Get background correction histogram
546 AliWarning("Not initialized yet. Call Init() to remedy");
552 if(vtxbin > fBackground->GetNvtxBins()) {
553 AliWarning(Form("No background object for vertex bin %d", vtxbin));
557 return fBackground->GetBgCorrection(det,ring,vtxbin);
559 //____________________________________________________________________
560 TH2F* AliFMDAnaParameters::GetBackgroundCorrectionNSD(Int_t det,
563 //Get background correction histogram for NSD event class
565 AliWarning("Not initialized yet. Call Init() to remedy");
569 if(vtxbin > fBackground->GetNvtxBins()) {
570 AliWarning(Form("No background object for vertex bin %d", vtxbin));
574 if(fBackground->GetNSDBgCorrection(det,ring,vtxbin))
575 return fBackground->GetNSDBgCorrection(det,ring,vtxbin);
577 AliWarning("No NSD background map. You get usual one. Difference is probably negligible");
579 return fBackground->GetBgCorrection(det,ring,vtxbin);
581 //____________________________________________________________________
583 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det,
585 //Get correction for several hits in strips for p+p
587 AliWarning("Not initialized yet. Call Init() to remedy");
591 return fBackground->GetDoubleHitCorrection(det,ring);
593 //_____________________________________________________________________
594 TH1F* AliFMDAnaParameters::GetSPDDeadCorrection(Int_t vtxbin) {
596 //Get correction for several hits in strips for p+p
598 AliWarning("Not initialized yet. Call Init() to remedy");
602 return fBackground->GetSPDDeadCorrection(vtxbin);
604 //_____________________________________________________________________
605 TH1F* AliFMDAnaParameters::GetFMDDeadCorrection(Int_t vtxbin) {
607 //Get correction for several hits in strips for p+p
609 AliWarning("Not initialized yet. Call Init() to remedy");
613 return fBackground->GetFMDDeadCorrection(vtxbin);
615 //_____________________________________________________________________
616 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
617 //Get event selection efficiency object
619 AliWarning("Not initialized yet. Call Init() to remedy");
622 return fEventSelectionEfficiency->GetCorrection(vtxbin);
625 //_____________________________________________________________________
626 Float_t AliFMDAnaParameters::GetVtxSelectionEffFromMC() {
629 AliWarning("Not initialized yet. Call Init() to remedy");
632 return fEventSelectionEfficiency->GetVtxToTriggerRatio();
636 //_____________________________________________________________________
637 TH2F* AliFMDAnaParameters::GetEventSelectionEfficiency(TString trig, Int_t vtxbin, Char_t ring) {
638 //Get event selection efficiency object
640 //TString test = trig;
641 if(!trig.Contains("NSD") && !trig.Contains("INEL")) {
642 AliWarning("Event selection efficiency only available for INEL and NSD");
646 AliWarning("Not initialized yet. Call Init() to remedy");
649 return fEventSelectionEfficiency->GetCorrection(trig,vtxbin,ring);
652 //_____________________________________________________________________
653 TH1F* AliFMDAnaParameters::GetSharingEfficiency(Int_t det, Char_t ring, Int_t vtxbin) {
654 //Get sharing efficiency object
656 AliWarning("Not initialized yet. Call Init() to remedy");
660 return fSharingEfficiency->GetSharingEff(det,ring,vtxbin);
663 //_____________________________________________________________________
664 TH1F* AliFMDAnaParameters::GetSharingEfficiencyTrVtx(Int_t det, Char_t ring, Int_t vtxbin) {
665 //Get sharing efficiency object TrVtx
667 AliWarning("Not initialized yet. Call Init() to remedy");
671 return fSharingEfficiency->GetSharingEffTrVtx(det,ring,vtxbin);
674 //_____________________________________________________________________
675 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const {
683 AliWarning("Unknown ring - must be I or O!");
687 //_____________________________________________________________________
688 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
696 AliWarning("Unknown ring - must be I or O!");
701 //_____________________________________________________________________
702 void AliFMDAnaParameters::SetCorners(Char_t ring) {
703 //Set corners (taken from nominal geometry)
705 fCorner1.Set(4.9895, 15.3560);
706 fCorner2.Set(1.8007, 17.2000);
709 fCorner1.Set(4.2231, 26.6638);
710 fCorner2.Set(1.8357, 27.9500);
714 //_____________________________________________________________________
715 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
717 //Get phi from sector
718 Int_t nsec = (ring == 'I' ? 20 : 40);
721 basephi = 1.72787594;
722 if(det == 2 && ring == 'I')
723 basephi = 0.15707963;
724 if(det == 2 && ring == 'O')
725 basephi = 0.078539818;
726 if(det == 3 && ring == 'I')
727 basephi = 2.984513044;
728 if(det == 3 && ring == 'O')
729 basephi = 3.06305289;
731 Float_t step = 2*TMath::Pi() / nsec;
734 phi = basephi - sec*step;
736 phi = basephi + sec*step;
739 phi = phi +2*TMath::Pi();
740 if(phi > 2*TMath::Pi() )
741 phi = phi - 2*TMath::Pi();
745 //_____________________________________________________________________
746 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
748 //Calculate eta from strip with vertex (redundant with AliESDFMD::Eta)
749 Float_t rad = GetMaxR(ring)-GetMinR(ring);
750 Float_t nStrips = (ring == 'I' ? 512 : 256);
751 Float_t segment = rad / nStrips;
752 Float_t r = GetMinR(ring) + segment*strip;
754 Int_t hybrid = sec / 2;
757 if(!(hybrid%2)) z = 320.266; else z = 319.766;
759 if(det == 2 && ring == 'I' ) {
760 if(!(hybrid%2)) z = 83.666; else z = 83.166;
762 if(det == 2 && ring == 'O' ) {
763 if(!(hybrid%2)) z = 74.966; else z = 75.466;
765 if(det == 3 && ring == 'I' ) {
766 if(!(hybrid%2)) z = -63.066; else z = -62.566;
768 if(det == 3 && ring == 'O' ) {
769 if(!(hybrid%2)) z = -74.966; else z = -75.466;
772 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
774 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
775 Float_t theta = TMath::ATan2(r,z-zvtx);
776 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
781 //_____________________________________________________________________
783 Bool_t AliFMDAnaParameters::GetVertex(const AliESDEvent* esd, Double_t* vertexXYZ)
785 //Get the vertex from the ESD
786 const AliESDVertex* vertex = 0;
787 vertex = esd->GetPrimaryVertexSPD();
790 vertex->GetXYZ(vertexXYZ);
792 //if(vertexXYZ[0] == 0 || vertexXYZ[1] == 0 )
795 if(vertex->GetNContributors() <= 0)
798 if(vertex->GetZRes() > 0.1 )
801 return vertex->GetStatus();
804 //____________________________________________________________________
805 void AliFMDAnaParameters::SetTriggerStatus(const AliESDEvent *esd) {
807 //ULong64_t triggerMask = esd->GetTriggerMask();
809 AliPhysicsSelection* centralPhysicsSelection = (AliPhysicsSelection*)((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetEventSelection();
811 if(!centralPhysicsSelection && !fPhysicsSelection) {
813 std::cout<<"Creating AliPhysicsSelection object due to absence of central object"<<std::endl;
814 fPhysicsSelection = new AliPhysicsSelection;
815 fPhysicsSelection->SetAnalyzeMC(!fRealData);
816 // fPhysicsSelection->SetUseBXNumbers(kFALSE);
819 AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
820 backgroundSelection->Init();
821 fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
825 TString triggers = esd->GetFiredTriggerClasses();
827 AliTriggerAnalysis tAna;
829 fTriggerInel = kFALSE;
830 fTriggerNSD = kFALSE;
831 fTriggerEmpty = kFALSE;
833 UInt_t inel = kFALSE;
835 if(centralPhysicsSelection) {
836 inel= ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
839 inel = fPhysicsSelection->IsCollisionCandidate(esd);
843 if(fInelGtZero && inel) {
844 const AliMultiplicity* spdmult = esd->GetMultiplicity();
845 Int_t nCentralTracklets = 0;
847 while( nCentralTracklets < 1 && j< spdmult->GetNumberOfTracklets() ) {
848 if(TMath::Abs(spdmult->GetEta(j)) < 1) nCentralTracklets++;
851 if(nCentralTracklets < 1) inel = kFALSE;
854 //std::cout<<fTriggerInel<<std::endl;
856 fTriggerInel = kTRUE;
861 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))
864 else nsd = tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1);
866 if(fTriggerInel && nsd) {
869 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL")) {
870 fTriggerEmpty = kTRUE;
874 /*switch (fTrigger) {
876 if( fPhysicsSelection->IsCollisionCandidate(esd)) {
877 fTriggerInel = kTRUE;
883 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
888 if (triggerMask & spdFO)
897 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL"))
902 if(fPhysicsSelection->IsCollisionCandidate(esd) && tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1))
912 //____________________________________________________________________
913 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd, Trigger trig) {
914 //Did we have trig trigger ?
915 Trigger old = fTrigger;
917 Bool_t retval = IsEventTriggered(esd);
923 //____________________________________________________________________
924 Bool_t AliFMDAnaParameters::IsEventTriggered(Trigger trigger) {
925 // check if the event was triggered
927 if (fCentralSelection) return kTRUE;
937 return fTriggerEmpty;
943 AliWarning("Trigger not implemented!!!");
952 //____________________________________________________________________
954 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
956 //Get length of a strip
958 Float_t rad = GetMaxR(ring)-GetMinR(ring);
959 Float_t nStrips = (ring == 'I' ? 512 : 256);
960 Float_t segment = rad / nStrips;
962 //TVector2* corner1 = fmdring.GetVertex(2);
963 // TVector2* corner2 = fmdring.GetVertex(3);
967 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
968 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
969 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
970 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
971 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
972 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
973 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
974 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
975 Float_t radius = GetMinR(ring) + strip*segment;
977 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
979 Float_t arclength = GetBaseStripLength(ring,strip);
982 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
983 Float_t y = slope*x + constant;
984 Float_t theta = TMath::ATan2(x,y);
986 if(x < fCorner1.X() && y > fCorner1.Y()) {
987 arclength = radius*theta; //One sector since theta is by definition half-hybrid
997 //____________________________________________________________________
999 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
1001 //Get length of strip assuming that corners are not cut away
1002 Float_t rad = GetMaxR(ring)-GetMinR(ring);
1003 Float_t nStrips = (ring == 'I' ? 512 : 256);
1004 Float_t nSec = (ring == 'I' ? 20 : 40);
1005 Float_t segment = rad / nStrips;
1006 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
1007 Float_t radius = GetMinR(ring) + strip*segment;
1008 Float_t basearclength = 0.5*basearc * radius; // One sector
1010 return basearclength;
1012 //____________________________________________________________________
1013 Int_t AliFMDAnaParameters::GetFirstEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
1015 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
1017 if(det == 0) return hBg->GetXaxis()->FindBin(-1.95);
1019 Int_t firstbin = -1;
1020 Int_t nNonZeroFirst = 0;
1022 for(Int_t i=1;i<=hBg->GetNbinsX();i++) {
1023 if(nNonZeroFirst == fNumberOfEtaBinsToCut && firstbin==-1) firstbin = i;
1025 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
1027 Float_t value = hBg->GetBinContent(i,j);
1029 if(value > 0.001 && nNonZeroFirst<fNumberOfEtaBinsToCut)
1030 {nNonZeroFirst++; break;}
1039 //____________________________________________________________________
1040 Int_t AliFMDAnaParameters::GetLastEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
1042 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
1044 Int_t nNonZeroLast = 0;
1046 if(det == 0) return hBg->GetXaxis()->FindBin(1.95);
1048 for(Int_t i=hBg->GetNbinsX();i>0;i--) {
1049 if(nNonZeroLast == fNumberOfEtaBinsToCut && lastbin==-1) lastbin = i;
1051 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
1053 Float_t value = hBg->GetBinContent(i,j);
1055 if(value > 0.001 && nNonZeroLast<fNumberOfEtaBinsToCut)
1056 {nNonZeroLast++; break; }
1065 //____________________________________________________________________
1066 Int_t AliFMDAnaParameters::GetFirstEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
1068 Int_t ringNumber = (ring == 'I' ? 0 : 1);
1069 return fEtaLowBinLimits.GetBinContent(det,ringNumber,vtxbin);
1073 //____________________________________________________________________
1074 Int_t AliFMDAnaParameters::GetLastEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
1076 Int_t ringNumber = (ring == 'I' ? 0 : 1);
1077 return fEtaHighBinLimits.GetBinContent(det,ringNumber,vtxbin);
1080 //____________________________________________________________________