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 "AliESDEvent.h"
39 #include "AliESDVertex.h"
41 //====================================================================
42 ClassImp(AliFMDAnaParameters)
44 ; // This is here to keep Emacs for indenting the next line
47 //const char* AliFMDAnaParameters::fgkBackgroundCorrection = "FMD/Correction/Background";
48 //const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
49 const char* AliFMDAnaParameters::fgkBackgroundID = "background";
50 const char* AliFMDAnaParameters::fgkEnergyDistributionID = "energydistributions";
51 const char* AliFMDAnaParameters::fgkEventSelectionEffID = "eventselectionefficiency";
52 const char* AliFMDAnaParameters::fgkSharingEffID = "sharingefficiency";
53 //____________________________________________________________________
54 AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
56 //____________________________________________________________________
59 AliFMDAnaParameters::Instance()
61 // Get static instance
62 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
66 //____________________________________________________________________
67 AliFMDAnaParameters::AliFMDAnaParameters() :
70 fEnergyDistribution(0),
71 fEventSelectionEfficiency(0),
72 fSharingEfficiency(0),
73 fCorner1(4.2231, 26.6638),
74 fCorner2(1.8357, 27.9500),
75 fEnergyPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EnergyDistribution"),
76 fBackgroundPath("$ALICE_ROOT/PWG2/FORWARD/corrections/Background"),
77 fEventSelectionEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EventSelectionEfficiency"),
78 fSharingEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/SharingEfficiency"),
79 fProcessPrimary(kFALSE),
88 fSPDhighLimit(999999999),
89 fCentralSelection(kFALSE)
91 fPhysicsSelection = new AliPhysicsSelection;
92 //AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
94 //fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
95 //fPhysicsSelection->Initialize(104792);
96 // Do not use this - it is only for IO
98 // Default constructor
100 //____________________________________________________________________
101 char* AliFMDAnaParameters::GetPath(const char* species) {
105 if(species == fgkBackgroundID)
106 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
107 fBackgroundPath.Data(),
115 if(species == fgkEnergyDistributionID)
116 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
118 fgkEnergyDistributionID,
125 if(species == fgkEventSelectionEffID)
126 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
127 fEventSelectionEffPath.Data(),
128 fgkEventSelectionEffID,
135 if(species == fgkSharingEffID)
136 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
137 fSharingEffPath.Data(),
148 //____________________________________________________________________
149 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
151 // Initialize the parameters manager. We need to get stuff from the
153 if (forceReInit) fIsInit = kFALSE;
155 if (what & kBackgroundCorrection) InitBackground();
156 if (what & kEnergyDistributions) InitEnergyDists();
157 if (what & kEventSelectionEfficiency) InitEventSelectionEff();
158 if (what & kSharingEfficiency) InitSharingEff();
164 //____________________________________________________________________
166 void AliFMDAnaParameters::InitBackground() {
168 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
170 TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
174 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(fin->Get(fgkBackgroundID));
175 if (!fBackground) AliFatal("Invalid background object from CDB");
179 //____________________________________________________________________
181 void AliFMDAnaParameters::InitEnergyDists() {
183 TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
184 //AliCDBEntry* edist = GetEntry(fgkEnergyDists);
187 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(fin->Get(fgkEnergyDistributionID));
189 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
193 //____________________________________________________________________
195 void AliFMDAnaParameters::InitEventSelectionEff() {
197 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
198 TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
202 fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
203 if (!fEventSelectionEfficiency) AliFatal("Invalid background object from CDB");
206 //____________________________________________________________________
208 void AliFMDAnaParameters::PrintStatus() const
211 TString energystring;
214 energystring.Form("900 GeV"); break;
216 energystring.Form("7000 GeV"); break;
218 energystring.Form("10000 GeV"); break;
220 energystring.Form("14000 GeV"); break;
222 energystring.Form("invalid energy"); break;
224 TString triggerstring;
227 triggerstring.Form("Minimum bias 1"); break;
229 triggerstring.Form("Minimum bias 2"); break;
231 triggerstring.Form("SPD FAST OR"); break;
233 triggerstring.Form("NO TRIGGER TEST"); break;
235 energystring.Form("invalid trigger"); break;
240 magstring.Form("5 kGaus"); break;
242 magstring.Form("0 kGaus"); break;
244 magstring.Form("invalid mag field"); break;
246 TString collsystemstring;
249 collsystemstring.Form("p+p"); break;
251 collsystemstring.Form("Pb+Pb"); break;
253 collsystemstring.Form("invalid collision system"); break;
257 std::cout<<"Energy = "<<energystring.Data()<<std::endl;
258 std::cout<<"Trigger = "<<triggerstring.Data()<<std::endl;
259 std::cout<<"Mag Field = "<<magstring.Data()<<std::endl;
260 std::cout<<"Coll System = "<<collsystemstring.Data()<<std::endl;
266 //____________________________________________________________________
268 void AliFMDAnaParameters::InitSharingEff() {
270 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
271 TFile* fin = TFile::Open(GetPath(fgkSharingEffID));
275 fSharingEfficiency = dynamic_cast<AliFMDAnaCalibSharingEfficiency*>(fin->Get(fgkSharingEffID));
276 if (!fSharingEfficiency) AliFatal("Invalid background object from CDB");
279 //____________________________________________________________________
280 Float_t AliFMDAnaParameters::GetVtxCutZ() {
283 AliWarning("Not initialized yet. Call Init() to remedy");
287 return fBackground->GetVtxCutZ();
290 //____________________________________________________________________
291 Int_t AliFMDAnaParameters::GetNvtxBins() {
294 AliWarning("Not initialized yet. Call Init() to remedy");
298 return fBackground->GetNvtxBins();
300 //____________________________________________________________________
301 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
303 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
305 //____________________________________________________________________
306 TH1F* AliFMDAnaParameters::GetEmptyEnergyDistribution(Int_t det, Char_t ring) {
308 return fEnergyDistribution->GetEmptyEnergyDistribution(det, ring);
310 //____________________________________________________________________
311 TH1F* AliFMDAnaParameters::GetRingEnergyDistribution(Int_t det, Char_t ring) {
313 return fEnergyDistribution->GetRingEnergyDistribution(det, ring);
315 //____________________________________________________________________
316 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
319 AliWarning("Not initialized yet. Call Init() to remedy");
323 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
324 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
326 //AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
329 Float_t sigma = fitFunc->GetParameter(2);
334 //____________________________________________________________________
335 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
338 AliWarning("Not initialized yet. Call Init() to remedy");
341 //AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
342 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
343 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
345 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
346 std::cout<<hEnergyDist->GetEntries()<<" "<<GetEtaBin(eta)<<std::endl;
350 Float_t mpv = fitFunc->GetParameter(1);
353 //____________________________________________________________________
354 Float_t AliFMDAnaParameters::GetConstant(Int_t det, Char_t ring, Float_t eta) {
357 AliWarning("Not initialized yet. Call Init() to remedy");
361 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
362 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
364 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
368 Float_t mpv = fitFunc->GetParameter(0);
371 //____________________________________________________________________
372 Float_t AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta) {
375 AliWarning("Not initialized yet. Call Init() to remedy");
379 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
380 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
381 if(!fitFunc) return 0;
382 Float_t twoMIPweight = fitFunc->GetParameter(3);
386 if(twoMIPweight < 1e-05)
391 //____________________________________________________________________
392 Float_t AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta) {
395 AliWarning("Not initialized yet. Call Init() to remedy");
399 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
400 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
401 if(!fitFunc) return 0;
402 Float_t threeMIPweight = fitFunc->GetParameter(4);
404 if(threeMIPweight < 1e-05)
407 Float_t twoMIPweight = fitFunc->GetParameter(3);
409 if(twoMIPweight < 1e-05)
412 return threeMIPweight;
414 //____________________________________________________________________
415 Int_t AliFMDAnaParameters::GetNetaBins() {
416 return GetBackgroundCorrection(1,'I',0)->GetNbinsX();
419 //____________________________________________________________________
420 Float_t AliFMDAnaParameters::GetEtaMin() {
422 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmin();
424 //____________________________________________________________________
425 Float_t AliFMDAnaParameters::GetEtaMax() {
427 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmax();
430 //____________________________________________________________________
431 Int_t AliFMDAnaParameters::GetEtaBin(Float_t eta) {
432 TAxis testaxis(GetNetaBins(),GetEtaMin(),GetEtaMax());
433 Int_t binnumber = testaxis.FindBin(eta) ;
438 //____________________________________________________________________
440 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
445 AliWarning("Not initialized yet. Call Init() to remedy");
451 if(vtxbin > fBackground->GetNvtxBins()) {
452 AliWarning(Form("No background object for vertex bin %d", vtxbin));
456 return fBackground->GetBgCorrection(det,ring,vtxbin);
458 //____________________________________________________________________
460 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det,
464 AliWarning("Not initialized yet. Call Init() to remedy");
468 return fBackground->GetDoubleHitCorrection(det,ring);
470 //_____________________________________________________________________
471 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
473 AliWarning("Not initialized yet. Call Init() to remedy");
476 return fEventSelectionEfficiency->GetCorrection(vtxbin);
479 //_____________________________________________________________________
480 TH1F* AliFMDAnaParameters::GetSharingEfficiency(Int_t det, Char_t ring, Int_t vtxbin) {
482 AliWarning("Not initialized yet. Call Init() to remedy");
486 return fSharingEfficiency->GetSharingEff(det,ring,vtxbin);
489 //_____________________________________________________________________
490 TH1F* AliFMDAnaParameters::GetSharingEfficiencyTrVtx(Int_t det, Char_t ring, Int_t vtxbin) {
492 AliWarning("Not initialized yet. Call Init() to remedy");
496 return fSharingEfficiency->GetSharingEffTrVtx(det,ring,vtxbin);
499 //_____________________________________________________________________
500 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const{
507 AliWarning("Unknown ring - must be I or O!");
511 //_____________________________________________________________________
512 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
519 AliWarning("Unknown ring - must be I or O!");
524 //_____________________________________________________________________
525 void AliFMDAnaParameters::SetCorners(Char_t ring) {
528 fCorner1.Set(4.9895, 15.3560);
529 fCorner2.Set(1.8007, 17.2000);
532 fCorner1.Set(4.2231, 26.6638);
533 fCorner2.Set(1.8357, 27.9500);
537 //_____________________________________________________________________
538 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
540 Int_t nsec = (ring == 'I' ? 20 : 40);
543 basephi = 1.72787594;
544 if(det == 2 && ring == 'I')
545 basephi = 0.15707963;
546 if(det == 2 && ring == 'O')
547 basephi = 0.078539818;
548 if(det == 3 && ring == 'I')
549 basephi = 2.984513044;
550 if(det == 3 && ring == 'O')
551 basephi = 3.06305289;
553 Float_t step = 2*TMath::Pi() / nsec;
556 phi = basephi - sec*step;
558 phi = basephi + sec*step;
561 phi = phi +2*TMath::Pi();
562 if(phi > 2*TMath::Pi() )
563 phi = phi - 2*TMath::Pi();
567 //_____________________________________________________________________
568 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
570 // AliFMDRing fmdring(ring);
572 Float_t rad = GetMaxR(ring)-GetMinR(ring);
573 Float_t nStrips = (ring == 'I' ? 512 : 256);
574 Float_t segment = rad / nStrips;
575 Float_t r = GetMinR(ring) + segment*strip;
577 Int_t hybrid = sec / 2;
580 if(!(hybrid%2)) z = 320.266; else z = 319.766;
582 if(det == 2 && ring == 'I' ) {
583 if(!(hybrid%2)) z = 83.666; else z = 83.166;
585 if(det == 2 && ring == 'O' ) {
586 if(!(hybrid%2)) z = 74.966; else z = 75.466;
588 if(det == 3 && ring == 'I' ) {
589 if(!(hybrid%2)) z = -63.066; else z = -62.566;
591 if(det == 3 && ring == 'O' ) {
592 if(!(hybrid%2)) z = -74.966; else z = -75.466;
595 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
597 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
598 Float_t theta = TMath::ATan2(r,z-zvtx);
599 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
604 //_____________________________________________________________________
606 Bool_t AliFMDAnaParameters::GetVertex(AliESDEvent* esd, Double_t* vertexXYZ)
608 const AliESDVertex* vertex = 0;
609 vertex = esd->GetPrimaryVertexSPD();
612 vertex->GetXYZ(vertexXYZ);
614 //if(vertexXYZ[0] == 0 || vertexXYZ[1] == 0 )
617 if(vertex->GetNContributors() <= 0)
620 if(vertex->GetZRes() > 0.1 )
623 return vertex->GetStatus();
626 //____________________________________________________________________
627 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd, Trigger trig) {
629 Trigger old = fTrigger;
631 Bool_t retval = IsEventTriggered(esd);
636 //____________________________________________________________________
637 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd) const {
638 // check if the event was triggered
640 if (fCentralSelection) return kTRUE;
641 ULong64_t triggerMask = esd->GetTriggerMask();
643 TString triggers = esd->GetFiredTriggerClasses();
644 // std::cout<<triggers.Data()<<std::endl;
645 //if(triggers.Contains("CINT1B-ABCE-NOPF-ALL") || triggers.Contains("CINT1B-E-NOPF-ALL")) return kTRUE;
646 //else return kFALSE;
647 //if(triggers.Contains("CINT1B-E-NOPF-ALL")) return kFALSE;
649 // if(triggers.Contains("CINT1A-ABCE-NOPF-ALL")) return kFALSE;
650 // if(triggers.Contains("CINT1C-ABCE-NOPF-ALL")) return kFALSE;
652 // definitions from p-p.cfg
653 ULong64_t spdFO = (1 << 14);
654 ULong64_t v0left = (1 << 11);
655 ULong64_t v0right = (1 << 12);
656 AliTriggerAnalysis tAna;
658 //REMOVE WHEN FINISHED PLAYING WITH TRIGGERS!
659 //fPhysicsSelection->IsCollisionCandidate(esd);
664 //if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
665 // if(/*tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kMB1) &&*/ (triggers.Contains("CINT1B-ABCE-NOPF-ALL")))// || triggers.Contains("CINT1-E-NOPF-ALL")))
667 if( fPhysicsSelection->IsCollisionCandidate(esd))
670 // triggers.Contains("CINT1C-ABCE-NOPF-ALL") || triggers.Contains("CINT1A-ABCE-NOPF-ALL"))
674 if(triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
679 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
684 if (triggerMask & spdFO)
693 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL"))
702 //____________________________________________________________________
704 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
706 //AliFMDRing fmdring(ring);
709 Float_t rad = GetMaxR(ring)-GetMinR(ring);
710 Float_t nStrips = (ring == 'I' ? 512 : 256);
711 Float_t segment = rad / nStrips;
713 //TVector2* corner1 = fmdring.GetVertex(2);
714 // TVector2* corner2 = fmdring.GetVertex(3);
718 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
719 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
720 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
721 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
722 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
723 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
724 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
725 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
726 Float_t radius = GetMinR(ring) + strip*segment;
728 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
730 Float_t arclength = GetBaseStripLength(ring,strip);
733 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
734 Float_t y = slope*x + constant;
735 Float_t theta = TMath::ATan2(x,y);
737 if(x < fCorner1.X() && y > fCorner1.Y()) {
738 arclength = radius*theta; //One sector since theta is by definition half-hybrid
748 //____________________________________________________________________
750 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
752 // AliFMDRing fmdring(ring);
754 Float_t rad = GetMaxR(ring)-GetMinR(ring);
755 Float_t nStrips = (ring == 'I' ? 512 : 256);
756 Float_t nSec = (ring == 'I' ? 20 : 40);
757 Float_t segment = rad / nStrips;
758 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
759 Float_t radius = GetMinR(ring) + strip*segment;
760 Float_t basearclength = 0.5*basearc * radius; // One sector
762 return basearclength;
764 //____________________________________________________________________