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 "AliESDEvent.h"
36 #include "AliESDVertex.h"
38 //====================================================================
39 ClassImp(AliFMDAnaParameters)
41 ; // This is here to keep Emacs for indenting the next line
44 //const char* AliFMDAnaParameters::fgkBackgroundCorrection = "FMD/Correction/Background";
45 //const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
46 const char* AliFMDAnaParameters::fgkBackgroundID = "background";
47 const char* AliFMDAnaParameters::fgkEnergyDistributionID = "energydistributions";
48 const char* AliFMDAnaParameters::fgkEventSelectionEffID = "eventselectionefficiency";
49 const char* AliFMDAnaParameters::fgkSharingEffID = "sharingefficiency";
50 //____________________________________________________________________
51 AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
53 //____________________________________________________________________
56 AliFMDAnaParameters::Instance()
58 // Get static instance
59 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
63 //____________________________________________________________________
64 AliFMDAnaParameters::AliFMDAnaParameters() :
67 fEnergyDistribution(0),
68 fEventSelectionEfficiency(0),
69 fCorner1(4.2231, 26.6638),
70 fCorner2(1.8357, 27.9500),
71 fEnergyPath("$ALICE_ROOT/FMD/Correction/EnergyDistribution"),
72 fBackgroundPath("$ALICE_ROOT/FMD/Correction/Background"),
73 fEventSelectionEffPath("$ALICE_ROOT/FMD/Correction/EventSelectionEfficiency"),
74 fSharingEffPath("$ALICE_ROOT/FMD/Correction/SharingEfficiency"),
75 fProcessPrimary(kFALSE),
84 //fVerticies.Add(new TVector2(4.2231, 26.6638));
85 // fVerticies.Add(new TVector2(1.8357, 27.9500));
86 // Default constructor
88 //____________________________________________________________________
89 char* AliFMDAnaParameters::GetPath(const char* species) {
93 if(species == fgkBackgroundID)
94 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
95 fBackgroundPath.Data(),
103 if(species == fgkEnergyDistributionID)
104 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
106 fgkEnergyDistributionID,
113 if(species == fgkEventSelectionEffID)
114 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
115 fEventSelectionEffPath.Data(),
116 fgkEventSelectionEffID,
123 if(species == fgkSharingEffID)
124 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
125 fSharingEffPath.Data(),
136 //____________________________________________________________________
137 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
139 // Initialize the parameters manager. We need to get stuff from the
141 if (forceReInit) fIsInit = kFALSE;
143 if (what & kBackgroundCorrection) InitBackground();
144 if (what & kEnergyDistributions) InitEnergyDists();
145 if (what & kEventSelectionEfficiency) InitEventSelectionEff();
146 if (what & kSharingEfficiency) InitSharingEff();
150 //____________________________________________________________________
152 void AliFMDAnaParameters::InitBackground() {
154 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
156 TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
160 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(fin->Get(fgkBackgroundID));
161 if (!fBackground) AliFatal("Invalid background object from CDB");
165 //____________________________________________________________________
167 void AliFMDAnaParameters::InitEnergyDists() {
169 TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
170 //AliCDBEntry* edist = GetEntry(fgkEnergyDists);
173 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(fin->Get(fgkEnergyDistributionID));
175 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
179 //____________________________________________________________________
181 void AliFMDAnaParameters::InitEventSelectionEff() {
183 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
184 TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
188 fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
189 if (!fEventSelectionEfficiency) AliFatal("Invalid background object from CDB");
192 //____________________________________________________________________
194 void AliFMDAnaParameters::InitSharingEff() {
196 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
197 TFile* fin = TFile::Open(GetPath(fgkSharingEffID));
201 fSharingEfficiency = dynamic_cast<AliFMDAnaCalibSharingEfficiency*>(fin->Get(fgkSharingEffID));
202 if (!fSharingEfficiency) AliFatal("Invalid background object from CDB");
205 //____________________________________________________________________
206 Float_t AliFMDAnaParameters::GetVtxCutZ() {
209 AliWarning("Not initialized yet. Call Init() to remedy");
213 return fBackground->GetVtxCutZ();
216 //____________________________________________________________________
217 Int_t AliFMDAnaParameters::GetNvtxBins() {
220 AliWarning("Not initialized yet. Call Init() to remedy");
224 return fBackground->GetNvtxBins();
226 //____________________________________________________________________
227 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
229 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
231 //____________________________________________________________________
232 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
235 AliWarning("Not initialized yet. Call Init() to remedy");
239 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
240 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
242 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
245 Float_t sigma = fitFunc->GetParameter(2);
250 //____________________________________________________________________
251 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
254 AliWarning("Not initialized yet. Call Init() to remedy");
258 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
259 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
261 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
265 Float_t mpv = fitFunc->GetParameter(1);
268 //____________________________________________________________________
269 Float_t AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta) {
272 AliWarning("Not initialized yet. Call Init() to remedy");
276 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
277 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
278 if(!fitFunc) return 0;
279 Float_t twoMIPweight = fitFunc->GetParameter(3);
283 if(twoMIPweight < 1e-05)
288 //____________________________________________________________________
289 Float_t AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta) {
292 AliWarning("Not initialized yet. Call Init() to remedy");
296 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
297 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
298 if(!fitFunc) return 0;
299 Float_t threeMIPweight = fitFunc->GetParameter(4);
301 if(threeMIPweight < 1e-05)
304 Float_t twoMIPweight = fitFunc->GetParameter(3);
306 if(twoMIPweight < 1e-05)
309 return threeMIPweight;
311 //____________________________________________________________________
312 Int_t AliFMDAnaParameters::GetNetaBins() {
313 return GetBackgroundCorrection(1,'I',0)->GetNbinsX();
316 //____________________________________________________________________
317 Float_t AliFMDAnaParameters::GetEtaMin() {
319 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmin();
321 //____________________________________________________________________
322 Float_t AliFMDAnaParameters::GetEtaMax() {
324 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmax();
327 //____________________________________________________________________
329 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
334 AliWarning("Not initialized yet. Call Init() to remedy");
340 if(vtxbin > fBackground->GetNvtxBins()) {
341 AliWarning(Form("No background object for vertex bin %d", vtxbin));
345 return fBackground->GetBgCorrection(det,ring,vtxbin);
347 //____________________________________________________________________
349 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det,
353 AliWarning("Not initialized yet. Call Init() to remedy");
357 return fBackground->GetDoubleHitCorrection(det,ring);
359 //_____________________________________________________________________
360 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
362 AliWarning("Not initialized yet. Call Init() to remedy");
365 return fEventSelectionEfficiency->GetCorrection(vtxbin);
368 //_____________________________________________________________________
369 TH1F* AliFMDAnaParameters::GetSharingEfficiency(Int_t det, Char_t ring, Int_t vtxbin) {
371 AliWarning("Not initialized yet. Call Init() to remedy");
375 return fSharingEfficiency->GetSharingEff(det,ring,vtxbin);
378 //_____________________________________________________________________
379 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const{
386 AliWarning("Unknown ring - must be I or O!");
390 //_____________________________________________________________________
391 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
398 AliWarning("Unknown ring - must be I or O!");
403 //_____________________________________________________________________
404 void AliFMDAnaParameters::SetCorners(Char_t ring) {
407 fCorner1.Set(4.9895, 15.3560);
408 fCorner2.Set(1.8007, 17.2000);
411 fCorner1.Set(4.2231, 26.6638);
412 fCorner2.Set(1.8357, 27.9500);
416 //_____________________________________________________________________
417 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
419 Int_t nsec = (ring == 'I' ? 20 : 40);
422 basephi = 1.72787594;
423 if(det == 2 && ring == 'I')
424 basephi = 0.15707963;
425 if(det == 2 && ring == 'O')
426 basephi = 0.078539818;
427 if(det == 3 && ring == 'I')
428 basephi = 2.984513044;
429 if(det == 3 && ring == 'O')
430 basephi = 3.06305289;
432 Float_t step = 2*TMath::Pi() / nsec;
435 phi = basephi - sec*step;
437 phi = basephi + sec*step;
440 phi = phi +2*TMath::Pi();
441 if(phi > 2*TMath::Pi() )
442 phi = phi - 2*TMath::Pi();
446 //_____________________________________________________________________
447 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
449 // AliFMDRing fmdring(ring);
451 Float_t rad = GetMaxR(ring)-GetMinR(ring);
452 Float_t nStrips = (ring == 'I' ? 512 : 256);
453 Float_t segment = rad / nStrips;
454 Float_t r = GetMinR(ring) + segment*strip;
456 Int_t hybrid = sec / 2;
459 if(!(hybrid%2)) z = 320.266; else z = 319.766;
461 if(det == 2 && ring == 'I' ) {
462 if(!(hybrid%2)) z = 83.666; else z = 83.166;
464 if(det == 2 && ring == 'O' ) {
465 if(!(hybrid%2)) z = 74.966; else z = 75.466;
467 if(det == 3 && ring == 'I' ) {
468 if(!(hybrid%2)) z = -63.066; else z = -62.566;
470 if(det == 3 && ring == 'O' ) {
471 if(!(hybrid%2)) z = -74.966; else z = -75.466;
474 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
476 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
477 Float_t theta = TMath::ATan2(r,z-zvtx);
478 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
483 //_____________________________________________________________________
485 void AliFMDAnaParameters::GetVertex(AliESDEvent* esd, Double_t* vertexXYZ)
487 const AliESDVertex* vertex = 0;
488 vertex = esd->GetPrimaryVertex();
489 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
490 vertex = esd->GetPrimaryVertexSPD();
491 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
492 vertex = esd->GetPrimaryVertexTPC();
493 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
494 vertex = esd->GetVertex();
495 if (vertex && (vertexXYZ[0] != 0 || vertexXYZ[1] != 0 || vertexXYZ[2] != 0)) {
496 vertex->GetXYZ(vertexXYZ);
497 //std::cout<<vertex->GetName()<<" "<< vertex->GetTitle() <<" "<< vertex->GetZv()<<std::endl;
500 else if (esd->GetESDTZERO()) {
503 vertexXYZ[2] = esd->GetT0zVertex();
512 //____________________________________________________________________
513 Bool_t AliFMDAnaParameters::IsEventTriggered(AliESDEvent *esd) {
514 // check if the event was triggered
515 ULong64_t triggerMask = esd->GetTriggerMask();
517 // definitions from p-p.cfg
518 ULong64_t spdFO = (1 << 14);
519 ULong64_t v0left = (1 << 11);
520 ULong64_t v0right = (1 << 12);
524 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
529 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
534 if (triggerMask & spdFO)
547 //____________________________________________________________________
549 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
551 //AliFMDRing fmdring(ring);
554 Float_t rad = GetMaxR(ring)-GetMinR(ring);
555 Float_t nStrips = (ring == 'I' ? 512 : 256);
556 Float_t segment = rad / nStrips;
558 //TVector2* corner1 = fmdring.GetVertex(2);
559 // TVector2* corner2 = fmdring.GetVertex(3);
563 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
564 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
565 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
566 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
567 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
568 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
569 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
570 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
571 Float_t radius = GetMinR(ring) + strip*segment;
573 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
575 Float_t arclength = GetBaseStripLength(ring,strip);
578 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
579 Float_t y = slope*x + constant;
580 Float_t theta = TMath::ATan2(x,y);
582 if(x < fCorner1.X() && y > fCorner1.Y()) {
583 arclength = radius*theta; //One sector since theta is by definition half-hybrid
593 //____________________________________________________________________
595 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
597 // AliFMDRing fmdring(ring);
599 Float_t rad = GetMaxR(ring)-GetMinR(ring);
600 Float_t nStrips = (ring == 'I' ? 512 : 256);
601 Float_t nSec = (ring == 'I' ? 20 : 40);
602 Float_t segment = rad / nStrips;
603 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
604 Float_t radius = GetMinR(ring) + strip*segment;
605 Float_t basearclength = 0.5*basearc * radius; // One sector
607 return basearclength;
609 //____________________________________________________________________