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 TH1F* AliFMDAnaParameters::GetSharingEfficiencyTrVtx(Int_t det, Char_t ring, Int_t vtxbin) {
381 AliWarning("Not initialized yet. Call Init() to remedy");
385 return fSharingEfficiency->GetSharingEffTrVtx(det,ring,vtxbin);
388 //_____________________________________________________________________
389 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const{
396 AliWarning("Unknown ring - must be I or O!");
400 //_____________________________________________________________________
401 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
408 AliWarning("Unknown ring - must be I or O!");
413 //_____________________________________________________________________
414 void AliFMDAnaParameters::SetCorners(Char_t ring) {
417 fCorner1.Set(4.9895, 15.3560);
418 fCorner2.Set(1.8007, 17.2000);
421 fCorner1.Set(4.2231, 26.6638);
422 fCorner2.Set(1.8357, 27.9500);
426 //_____________________________________________________________________
427 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
429 Int_t nsec = (ring == 'I' ? 20 : 40);
432 basephi = 1.72787594;
433 if(det == 2 && ring == 'I')
434 basephi = 0.15707963;
435 if(det == 2 && ring == 'O')
436 basephi = 0.078539818;
437 if(det == 3 && ring == 'I')
438 basephi = 2.984513044;
439 if(det == 3 && ring == 'O')
440 basephi = 3.06305289;
442 Float_t step = 2*TMath::Pi() / nsec;
445 phi = basephi - sec*step;
447 phi = basephi + sec*step;
450 phi = phi +2*TMath::Pi();
451 if(phi > 2*TMath::Pi() )
452 phi = phi - 2*TMath::Pi();
456 //_____________________________________________________________________
457 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
459 // AliFMDRing fmdring(ring);
461 Float_t rad = GetMaxR(ring)-GetMinR(ring);
462 Float_t nStrips = (ring == 'I' ? 512 : 256);
463 Float_t segment = rad / nStrips;
464 Float_t r = GetMinR(ring) + segment*strip;
466 Int_t hybrid = sec / 2;
469 if(!(hybrid%2)) z = 320.266; else z = 319.766;
471 if(det == 2 && ring == 'I' ) {
472 if(!(hybrid%2)) z = 83.666; else z = 83.166;
474 if(det == 2 && ring == 'O' ) {
475 if(!(hybrid%2)) z = 74.966; else z = 75.466;
477 if(det == 3 && ring == 'I' ) {
478 if(!(hybrid%2)) z = -63.066; else z = -62.566;
480 if(det == 3 && ring == 'O' ) {
481 if(!(hybrid%2)) z = -74.966; else z = -75.466;
484 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
486 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
487 Float_t theta = TMath::ATan2(r,z-zvtx);
488 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
493 //_____________________________________________________________________
495 void AliFMDAnaParameters::GetVertex(AliESDEvent* esd, Double_t* vertexXYZ)
497 const AliESDVertex* vertex = 0;
498 vertex = esd->GetPrimaryVertex();
499 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
500 vertex = esd->GetPrimaryVertexSPD();
501 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
502 vertex = esd->GetPrimaryVertexTPC();
503 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
504 vertex = esd->GetVertex();
505 if (vertex && (vertexXYZ[0] != 0 || vertexXYZ[1] != 0 || vertexXYZ[2] != 0)) {
506 vertex->GetXYZ(vertexXYZ);
507 //std::cout<<vertex->GetName()<<" "<< vertex->GetTitle() <<" "<< vertex->GetZv()<<std::endl;
510 else if (esd->GetESDTZERO()) {
513 vertexXYZ[2] = esd->GetT0zVertex();
522 //____________________________________________________________________
523 Bool_t AliFMDAnaParameters::IsEventTriggered(AliESDEvent *esd) {
524 // check if the event was triggered
525 ULong64_t triggerMask = esd->GetTriggerMask();
527 // definitions from p-p.cfg
528 ULong64_t spdFO = (1 << 14);
529 ULong64_t v0left = (1 << 11);
530 ULong64_t v0right = (1 << 12);
534 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
539 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
544 if (triggerMask & spdFO)
557 //____________________________________________________________________
559 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
561 //AliFMDRing fmdring(ring);
564 Float_t rad = GetMaxR(ring)-GetMinR(ring);
565 Float_t nStrips = (ring == 'I' ? 512 : 256);
566 Float_t segment = rad / nStrips;
568 //TVector2* corner1 = fmdring.GetVertex(2);
569 // TVector2* corner2 = fmdring.GetVertex(3);
573 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
574 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
575 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
576 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
577 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
578 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
579 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
580 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
581 Float_t radius = GetMinR(ring) + strip*segment;
583 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
585 Float_t arclength = GetBaseStripLength(ring,strip);
588 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
589 Float_t y = slope*x + constant;
590 Float_t theta = TMath::ATan2(x,y);
592 if(x < fCorner1.X() && y > fCorner1.Y()) {
593 arclength = radius*theta; //One sector since theta is by definition half-hybrid
603 //____________________________________________________________________
605 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
607 // AliFMDRing fmdring(ring);
609 Float_t rad = GetMaxR(ring)-GetMinR(ring);
610 Float_t nStrips = (ring == 'I' ? 512 : 256);
611 Float_t nSec = (ring == 'I' ? 20 : 40);
612 Float_t segment = rad / nStrips;
613 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
614 Float_t radius = GetMinR(ring) + strip*segment;
615 Float_t basearclength = 0.5*basearc * radius; // One sector
617 return basearclength;
619 //____________________________________________________________________