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)
303 if (sys.Contains("p-p")) fSpecies = kPP;
304 else if (sys.Contains("Pb-Pb")) fSpecies = kPbPb;
305 else if (sys.Contains("A-A")) fSpecies = kPbPb;
308 //____________________________________________________________________
309 void AliFMDAnaParameters::SetParametersFromESD(AliESDEvent* esd)
312 Float_t magfield = esd->GetCurrentL3();
314 SetCollisionSystem(esd->GetBeamType());
315 SetEnergy(2*esd->GetBeamEnergy());
316 if (TMath::Abs(magfield - 30000.) < 10 ) fMagField = k5G;
317 if (TMath::Abs(magfield + 30000.) < 10 ) fMagField = k5Gnegative;
318 if (TMath::Abs(magfield) < 10 ) fMagField = k0G;
326 //____________________________________________________________________
328 void AliFMDAnaParameters::PrintStatus(Bool_t showpaths) const
330 //Print current status
331 TString energystring;
334 energystring.Form("900 GeV"); break;
336 energystring.Form("2400 GeV"); break;
338 energystring.Form("2750 GeV"); break;
340 energystring.Form("5500 GeV"); break;
342 energystring.Form("7000 GeV"); break;
344 energystring.Form("10000 GeV"); break;
346 energystring.Form("14000 GeV"); break;
348 energystring.Form("invalid energy"); break;
350 TString triggerstring;
353 triggerstring.Form("Minimum bias 1"); break;
355 triggerstring.Form("Minimum bias 2"); break;
357 triggerstring.Form("SPD FAST OR"); break;
359 triggerstring.Form("NO TRIGGER TEST"); break;
361 energystring.Form("invalid trigger"); break;
366 magstring.Form("5 kGaus"); break;
368 magstring.Form("0 kGaus"); break;
370 magstring.Form("-5 kGaus"); break;
372 magstring.Form("invalid mag field %d", fMagField); break;
374 TString collsystemstring;
377 collsystemstring.Form("p+p"); break;
379 collsystemstring.Form("Pb+Pb"); break;
381 collsystemstring.Form("invalid collision system"); break;
387 datastring.Form("Nature"); break;
389 datastring.Form("MC"); break;
391 datastring.Form("Unknown"); break ;
395 if(fInelGtZero) InelString = "INEL > 0";
396 else InelString = "INEL";
398 std::cout<<"Energy = "<<energystring.Data()<<std::endl;
399 std::cout<<"Trigger = "<<triggerstring.Data()<<std::endl;
400 std::cout<<"Mag Field = "<<magstring.Data()<<std::endl;
401 std::cout<<"Coll System = "<<collsystemstring.Data()<<std::endl;
402 std::cout<<"Data origin = "<<datastring.Data()<<std::endl;
403 std::cout<<"Basic trigger: "<<InelString.Data()<<std::endl;
406 TString bg = GetPath(fgkBackgroundID);
407 TString es = GetPath(fgkEventSelectionEffID);
408 TString ed = GetPath(fgkEnergyDistributionID);
409 TString me = GetPath(fgkSharingEffID);
410 std::cout << "2nd maps: " << bg << "\n"
411 << "Event sel.: " << es << "\n"
412 << "Energy dist.: " << ed << "\n"
413 << "Merge eff.: " << me << std::endl;
418 //____________________________________________________________________
419 Float_t AliFMDAnaParameters::GetVtxCutZ() {
420 //Get the z vtx cut in analysis
422 AliWarning("Not initialized yet. Call Init() to remedy");
426 return fBackground->GetVtxCutZ();
429 //____________________________________________________________________
430 Int_t AliFMDAnaParameters::GetNvtxBins() {
431 //Get number of vtx bins
433 AliWarning("Not initialized yet. Call Init() to remedy");
437 return fBackground->GetNvtxBins();
439 //____________________________________________________________________
440 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
442 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
444 //____________________________________________________________________
445 TH1F* AliFMDAnaParameters::GetEmptyEnergyDistribution(Int_t det, Char_t ring) {
447 return fEnergyDistribution->GetEmptyEnergyDistribution(det, ring);
449 //____________________________________________________________________
450 TH1F* AliFMDAnaParameters::GetRingEnergyDistribution(Int_t det, Char_t ring) {
452 return fEnergyDistribution->GetRingEnergyDistribution(det, ring);
454 //____________________________________________________________________
455 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
456 //Get sigma of Landau fits
458 AliWarning("Not initialized yet. Call Init() to remedy");
462 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
463 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
465 //AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
468 Float_t sigma = fitFunc->GetParameter(2);
473 //____________________________________________________________________
474 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
475 //Get MPV of landau fits
477 AliWarning("Not initialized yet. Call Init() to remedy");
480 //AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
481 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
482 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
485 AliWarning(Form("No function for FMD%d%c, eta %f (%d)",det,ring,eta,
490 Float_t mpv = fitFunc->GetParameter(1);
493 //____________________________________________________________________
494 Float_t AliFMDAnaParameters::GetConstant(Int_t det, Char_t ring, Float_t eta) {
495 //Get constant parameter of Landau fits
497 AliWarning("Not initialized yet. Call Init() to remedy");
501 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
502 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
504 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
508 Float_t mpv = fitFunc->GetParameter(0);
511 //____________________________________________________________________
513 AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta)
515 //Get 2 MIP weights of convoluted Landau fits
517 AliWarning("Not initialized yet. Call Init() to remedy");
521 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
522 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
523 if(!fitFunc) return 0;
524 Float_t twoMIPweight = fitFunc->GetParameter(3);
528 if(twoMIPweight < 1e-05)
533 //____________________________________________________________________
535 AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta)
537 //Get 3 MIP weights of convoluted Landau fits
539 AliWarning("Not initialized yet. Call Init() to remedy");
543 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
544 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
545 if(!fitFunc) return 0;
546 Float_t threeMIPweight = fitFunc->GetParameter(4);
548 if(threeMIPweight < 1e-05)
551 Float_t twoMIPweight = fitFunc->GetParameter(3);
553 if(twoMIPweight < 1e-05)
556 return threeMIPweight;
558 //____________________________________________________________________
559 Int_t AliFMDAnaParameters::GetNetaBins()
561 return GetBackgroundCorrection(1,'I',5)->GetNbinsX();
563 //____________________________________________________________________
564 Float_t AliFMDAnaParameters::GetEtaMin()
566 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmin();
568 //____________________________________________________________________
569 Float_t AliFMDAnaParameters::GetEtaMax()
571 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmax();
573 //____________________________________________________________________
574 Int_t AliFMDAnaParameters::GetEtaBin(Float_t eta)
576 TAxis testaxis(GetNetaBins(),GetEtaMin(),GetEtaMax());
577 Int_t binnumber = testaxis.FindBin(eta) ;
581 //____________________________________________________________________
583 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
586 //Get background correction histogram
588 AliWarning("Not initialized yet. Call Init() to remedy");
594 if(vtxbin > fBackground->GetNvtxBins()) {
595 AliWarning(Form("No background object for vertex bin %d", vtxbin));
599 return fBackground->GetBgCorrection(det,ring,vtxbin);
601 //____________________________________________________________________
602 TH2F* AliFMDAnaParameters::GetBackgroundCorrectionNSD(Int_t det,
605 //Get background correction histogram for NSD event class
607 AliWarning("Not initialized yet. Call Init() to remedy");
611 if(vtxbin > fBackground->GetNvtxBins()) {
612 AliWarning(Form("No background object for vertex bin %d", vtxbin));
616 if(fBackground->GetNSDBgCorrection(det,ring,vtxbin))
617 return fBackground->GetNSDBgCorrection(det,ring,vtxbin);
619 AliWarning("No NSD background map. You get usual one. "
620 "Difference is probably negligible");
622 return fBackground->GetBgCorrection(det,ring,vtxbin);
624 //____________________________________________________________________
626 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det,
628 //Get correction for several hits in strips for p+p
630 AliWarning("Not initialized yet. Call Init() to remedy");
634 return fBackground->GetDoubleHitCorrection(det,ring);
636 //_____________________________________________________________________
637 TH1F* AliFMDAnaParameters::GetSPDDeadCorrection(Int_t vtxbin) {
639 //Get correction for several hits in strips for p+p
641 AliWarning("Not initialized yet. Call Init() to remedy");
645 return fBackground->GetSPDDeadCorrection(vtxbin);
647 //_____________________________________________________________________
648 TH1F* AliFMDAnaParameters::GetFMDDeadCorrection(Int_t vtxbin) {
650 //Get correction for several hits in strips for p+p
652 AliWarning("Not initialized yet. Call Init() to remedy");
656 return fBackground->GetFMDDeadCorrection(vtxbin);
658 //_____________________________________________________________________
659 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
660 //Get event selection efficiency object
662 AliWarning("Not initialized yet. Call Init() to remedy");
665 return fEventSelectionEfficiency->GetCorrection(vtxbin);
668 //_____________________________________________________________________
669 Float_t AliFMDAnaParameters::GetVtxSelectionEffFromMC() {
672 AliWarning("Not initialized yet. Call Init() to remedy");
675 return fEventSelectionEfficiency->GetVtxToTriggerRatio();
679 //_____________________________________________________________________
680 TH2F* AliFMDAnaParameters::GetEventSelectionEfficiency(TString trig, Int_t vtxbin, Char_t ring) {
681 //Get event selection efficiency object
683 //TString test = trig;
684 if(!trig.Contains("NSD") && !trig.Contains("INEL")) {
685 AliWarning("Event selection efficiency only available for INEL and NSD");
689 AliWarning("Not initialized yet. Call Init() to remedy");
692 return fEventSelectionEfficiency->GetCorrection(trig,vtxbin,ring);
695 //_____________________________________________________________________
696 TH1F* AliFMDAnaParameters::GetSharingEfficiency(Int_t det, Char_t ring, Int_t vtxbin) {
697 //Get sharing efficiency object
699 AliWarning("Not initialized yet. Call Init() to remedy");
703 return fSharingEfficiency->GetSharingEff(det,ring,vtxbin);
706 //_____________________________________________________________________
707 TH1F* AliFMDAnaParameters::GetSharingEfficiencyTrVtx(Int_t det, Char_t ring, Int_t vtxbin) {
708 //Get sharing efficiency object TrVtx
710 AliWarning("Not initialized yet. Call Init() to remedy");
714 return fSharingEfficiency->GetSharingEffTrVtx(det,ring,vtxbin);
717 //_____________________________________________________________________
718 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const {
726 AliWarning("Unknown ring - must be I or O!");
730 //_____________________________________________________________________
731 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
739 AliWarning("Unknown ring - must be I or O!");
744 //_____________________________________________________________________
745 void AliFMDAnaParameters::SetCorners(Char_t ring) {
746 //Set corners (taken from nominal geometry)
748 fCorner1.Set(4.9895, 15.3560);
749 fCorner2.Set(1.8007, 17.2000);
752 fCorner1.Set(4.2231, 26.6638);
753 fCorner2.Set(1.8357, 27.9500);
757 //_____________________________________________________________________
758 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
760 //Get phi from sector
761 Int_t nsec = (ring == 'I' ? 20 : 40);
764 basephi = 1.72787594;
765 if(det == 2 && ring == 'I')
766 basephi = 0.15707963;
767 if(det == 2 && ring == 'O')
768 basephi = 0.078539818;
769 if(det == 3 && ring == 'I')
770 basephi = 2.984513044;
771 if(det == 3 && ring == 'O')
772 basephi = 3.06305289;
774 Float_t step = 2*TMath::Pi() / nsec;
777 phi = basephi - sec*step;
779 phi = basephi + sec*step;
782 phi = phi +2*TMath::Pi();
783 if(phi > 2*TMath::Pi() )
784 phi = phi - 2*TMath::Pi();
788 //_____________________________________________________________________
789 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
791 //Calculate eta from strip with vertex (redundant with AliESDFMD::Eta)
792 Float_t rad = GetMaxR(ring)-GetMinR(ring);
793 Float_t nStrips = (ring == 'I' ? 512 : 256);
794 Float_t segment = rad / nStrips;
795 Float_t r = GetMinR(ring) + segment*strip;
797 Int_t hybrid = sec / 2;
800 if(!(hybrid%2)) z = 320.266; else z = 319.766;
802 if(det == 2 && ring == 'I' ) {
803 if(!(hybrid%2)) z = 83.666; else z = 83.166;
805 if(det == 2 && ring == 'O' ) {
806 if(!(hybrid%2)) z = 74.966; else z = 75.466;
808 if(det == 3 && ring == 'I' ) {
809 if(!(hybrid%2)) z = -63.066; else z = -62.566;
811 if(det == 3 && ring == 'O' ) {
812 if(!(hybrid%2)) z = -74.966; else z = -75.466;
815 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
817 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
818 Float_t theta = TMath::ATan2(r,z-zvtx);
819 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
824 //_____________________________________________________________________
826 Bool_t AliFMDAnaParameters::GetVertex(const AliESDEvent* esd, Double_t* vertexXYZ)
828 //Get the vertex from the ESD
829 const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
831 if (!vertex) return kFALSE;
833 vertex->GetXYZ(vertexXYZ);
835 //if(vertexXYZ[0] == 0 || vertexXYZ[1] == 0 )
838 if(vertex->GetNContributors() <= 0)
841 if(vertex->GetZRes() > 0.1 )
844 return vertex->GetStatus();
847 //____________________________________________________________________
848 void AliFMDAnaParameters::SetTriggerStatus(const AliESDEvent *esd) {
850 //ULong64_t triggerMask = esd->GetTriggerMask();
852 AliPhysicsSelection* centralPhysicsSelection = (AliPhysicsSelection*)((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetEventSelection();
854 if(!centralPhysicsSelection && !fPhysicsSelection) {
856 std::cout<<"Creating AliPhysicsSelection object due to absence of central object"<<std::endl;
857 fPhysicsSelection = new AliPhysicsSelection;
858 fPhysicsSelection->SetAnalyzeMC(!fRealData);
859 // fPhysicsSelection->SetUseBXNumbers(kFALSE);
862 AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
863 backgroundSelection->Init();
864 fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
868 TString triggers = esd->GetFiredTriggerClasses();
870 AliTriggerAnalysis tAna;
872 fTriggerInel = kFALSE;
873 fTriggerNSD = kFALSE;
874 fTriggerEmpty = kFALSE;
876 UInt_t inel = kFALSE;
878 if(centralPhysicsSelection) {
879 inel= ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
882 inel = fPhysicsSelection->IsCollisionCandidate(esd);
886 if(fInelGtZero && inel) {
887 const AliMultiplicity* spdmult = esd->GetMultiplicity();
888 Int_t nCentralTracklets = 0;
890 while( nCentralTracklets < 1 && j< spdmult->GetNumberOfTracklets() ) {
891 if(TMath::Abs(spdmult->GetEta(j)) < 1) nCentralTracklets++;
894 if(nCentralTracklets < 1) inel = kFALSE;
897 //std::cout<<fTriggerInel<<std::endl;
899 fTriggerInel = kTRUE;
904 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))
907 else nsd = tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1);
909 if(fTriggerInel && nsd) {
912 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL")) {
913 fTriggerEmpty = kTRUE;
917 /*switch (fTrigger) {
919 if( fPhysicsSelection->IsCollisionCandidate(esd)) {
920 fTriggerInel = kTRUE;
926 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
931 if (triggerMask & spdFO)
940 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL"))
945 if(fPhysicsSelection->IsCollisionCandidate(esd) && tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1))
955 //____________________________________________________________________
956 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd, Trigger trig) {
957 //Did we have trig trigger ?
958 Trigger old = fTrigger;
960 Bool_t retval = IsEventTriggered(esd);
966 //____________________________________________________________________
967 Bool_t AliFMDAnaParameters::IsEventTriggered(Trigger trigger) {
968 // check if the event was triggered
970 if (fCentralSelection) return kTRUE;
980 return fTriggerEmpty;
986 AliWarning("Trigger not implemented!!!");
995 //____________________________________________________________________
997 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
999 //Get length of a strip
1001 Float_t rad = GetMaxR(ring)-GetMinR(ring);
1002 Float_t nStrips = (ring == 'I' ? 512 : 256);
1003 Float_t segment = rad / nStrips;
1005 //TVector2* corner1 = fmdring.GetVertex(2);
1006 // TVector2* corner2 = fmdring.GetVertex(3);
1010 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
1011 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
1012 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
1013 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
1014 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
1015 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
1016 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
1017 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
1018 Float_t radius = GetMinR(ring) + strip*segment;
1020 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
1022 Float_t arclength = GetBaseStripLength(ring,strip);
1025 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
1026 Float_t y = slope*x + constant;
1027 Float_t theta = TMath::ATan2(x,y);
1029 if(x < fCorner1.X() && y > fCorner1.Y()) {
1030 arclength = radius*theta; //One sector since theta is by definition half-hybrid
1040 //____________________________________________________________________
1042 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
1044 //Get length of strip assuming that corners are not cut away
1045 Float_t rad = GetMaxR(ring)-GetMinR(ring);
1046 Float_t nStrips = (ring == 'I' ? 512 : 256);
1047 Float_t nSec = (ring == 'I' ? 20 : 40);
1048 Float_t segment = rad / nStrips;
1049 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
1050 Float_t radius = GetMinR(ring) + strip*segment;
1051 Float_t basearclength = 0.5*basearc * radius; // One sector
1053 return basearclength;
1055 //____________________________________________________________________
1056 Int_t AliFMDAnaParameters::GetFirstEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
1058 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
1060 if(det == 0) return hBg->GetXaxis()->FindBin(-1.95);
1062 Int_t firstbin = -1;
1063 Int_t nNonZeroFirst = 0;
1065 for(Int_t i=1;i<=hBg->GetNbinsX();i++) {
1066 if(nNonZeroFirst == fNumberOfEtaBinsToCut && firstbin==-1) firstbin = i;
1068 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
1070 Float_t value = hBg->GetBinContent(i,j);
1072 if(value > 0.001 && nNonZeroFirst<fNumberOfEtaBinsToCut)
1073 {nNonZeroFirst++; break;}
1082 //____________________________________________________________________
1083 Int_t AliFMDAnaParameters::GetLastEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
1085 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
1087 Int_t nNonZeroLast = 0;
1089 if(det == 0) return hBg->GetXaxis()->FindBin(1.95);
1091 for(Int_t i=hBg->GetNbinsX();i>0;i--) {
1092 if(nNonZeroLast == fNumberOfEtaBinsToCut && lastbin==-1) lastbin = i;
1094 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
1096 Float_t value = hBg->GetBinContent(i,j);
1098 if(value > 0.001 && nNonZeroLast<fNumberOfEtaBinsToCut)
1099 {nNonZeroLast++; break; }
1108 //____________________________________________________________________
1109 Int_t AliFMDAnaParameters::GetFirstEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
1111 Int_t ringNumber = (ring == 'I' ? 0 : 1);
1112 return fEtaLowBinLimits.GetBinContent(det,ringNumber,vtxbin);
1116 //____________________________________________________________________
1117 Int_t AliFMDAnaParameters::GetLastEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
1119 Int_t ringNumber = (ring == 'I' ? 0 : 1);
1120 return fEtaHighBinLimits.GetBinContent(det,ringNumber,vtxbin);
1123 //____________________________________________________________________