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 //____________________________________________________________________
50 AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
52 //____________________________________________________________________
55 AliFMDAnaParameters::Instance()
57 // Get static instance
58 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
62 //____________________________________________________________________
63 AliFMDAnaParameters::AliFMDAnaParameters() :
66 fEnergyDistribution(0),
67 fEventSelectionEfficiency(0),
68 fCorner1(4.2231, 26.6638),
69 fCorner2(1.8357, 27.9500),
70 fEnergyPath("$ALICE_ROOT/FMD/Correction/EnergyDistribution"),
71 fBackgroundPath("$ALICE_ROOT/FMD/Correction/Background"),
72 fEventSelectionEffPath("$ALICE_ROOT/FMD/Correction/EventSelectionEfficiency"),
73 fProcessPrimary(kFALSE),
82 //fVerticies.Add(new TVector2(4.2231, 26.6638));
83 // fVerticies.Add(new TVector2(1.8357, 27.9500));
84 // Default constructor
86 //____________________________________________________________________
87 char* AliFMDAnaParameters::GetPath(const char* species) {
91 if(species == fgkBackgroundID)
92 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
93 fBackgroundPath.Data(),
101 if(species == fgkEnergyDistributionID)
102 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
104 fgkEnergyDistributionID,
111 if(species == fgkEventSelectionEffID)
112 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
113 fEventSelectionEffPath.Data(),
114 fgkEventSelectionEffID,
124 //____________________________________________________________________
125 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
127 // Initialize the parameters manager. We need to get stuff from the
129 if (forceReInit) fIsInit = kFALSE;
131 if (what & kBackgroundCorrection) InitBackground();
132 if (what & kEnergyDistributions) InitEnergyDists();
133 if (what & kEventSelectionEfficiency) InitEventSelectionEff();
137 //____________________________________________________________________
139 void AliFMDAnaParameters::InitBackground() {
141 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
143 TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
147 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(fin->Get(fgkBackgroundID));
148 if (!fBackground) AliFatal("Invalid background object from CDB");
152 //____________________________________________________________________
154 void AliFMDAnaParameters::InitEnergyDists() {
156 TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
157 //AliCDBEntry* edist = GetEntry(fgkEnergyDists);
160 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(fin->Get(fgkEnergyDistributionID));
162 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
166 //____________________________________________________________________
168 void AliFMDAnaParameters::InitEventSelectionEff() {
170 //AliCDBEntry* background = GetEntry(fgkBackgroundCorrection);
171 TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
175 fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
176 if (!fEventSelectionEfficiency) AliFatal("Invalid background object from CDB");
179 //____________________________________________________________________
180 Float_t AliFMDAnaParameters::GetVtxCutZ() {
183 AliWarning("Not initialized yet. Call Init() to remedy");
187 return fBackground->GetVtxCutZ();
190 //____________________________________________________________________
191 Int_t AliFMDAnaParameters::GetNvtxBins() {
194 AliWarning("Not initialized yet. Call Init() to remedy");
198 return fBackground->GetNvtxBins();
200 //____________________________________________________________________
201 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
203 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
205 //____________________________________________________________________
206 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
209 AliWarning("Not initialized yet. Call Init() to remedy");
213 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
214 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
216 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
219 Float_t sigma = fitFunc->GetParameter(2);
224 //____________________________________________________________________
225 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
228 AliWarning("Not initialized yet. Call Init() to remedy");
232 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
233 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
235 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
239 Float_t mpv = fitFunc->GetParameter(1);
242 //____________________________________________________________________
243 Float_t AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta) {
246 AliWarning("Not initialized yet. Call Init() to remedy");
250 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
251 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
252 if(!fitFunc) return 0;
253 Float_t twoMIPweight = fitFunc->GetParameter(3);
257 if(twoMIPweight < 1e-05)
262 //____________________________________________________________________
263 Float_t AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta) {
266 AliWarning("Not initialized yet. Call Init() to remedy");
270 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
271 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
272 if(!fitFunc) return 0;
273 Float_t threeMIPweight = fitFunc->GetParameter(4);
275 if(threeMIPweight < 1e-05)
278 Float_t twoMIPweight = fitFunc->GetParameter(3);
280 if(twoMIPweight < 1e-05)
283 return threeMIPweight;
285 //____________________________________________________________________
286 Int_t AliFMDAnaParameters::GetNetaBins() {
287 return GetBackgroundCorrection(1,'I',0)->GetNbinsX();
290 //____________________________________________________________________
291 Float_t AliFMDAnaParameters::GetEtaMin() {
293 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmin();
295 //____________________________________________________________________
296 Float_t AliFMDAnaParameters::GetEtaMax() {
298 return GetBackgroundCorrection(1,'I',0)->GetXaxis()->GetXmax();
301 //____________________________________________________________________
303 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
308 AliWarning("Not initialized yet. Call Init() to remedy");
314 if(vtxbin > fBackground->GetNvtxBins()) {
315 AliWarning(Form("No background object for vertex bin %d", vtxbin));
319 return fBackground->GetBgCorrection(det,ring,vtxbin);
321 //____________________________________________________________________
323 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det,
327 AliWarning("Not initialized yet. Call Init() to remedy");
331 return fBackground->GetDoubleHitCorrection(det,ring);
333 //_____________________________________________________________________
334 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
336 AliWarning("Not initialized yet. Call Init() to remedy");
339 return fEventSelectionEfficiency->GetCorrection(vtxbin);
342 //_____________________________________________________________________
343 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const{
350 AliWarning("Unknown ring - must be I or O!");
354 //_____________________________________________________________________
355 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
362 AliWarning("Unknown ring - must be I or O!");
367 //_____________________________________________________________________
368 void AliFMDAnaParameters::SetCorners(Char_t ring) {
371 fCorner1.Set(4.9895, 15.3560);
372 fCorner2.Set(1.8007, 17.2000);
375 fCorner1.Set(4.2231, 26.6638);
376 fCorner2.Set(1.8357, 27.9500);
380 //_____________________________________________________________________
381 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
383 Int_t nsec = (ring == 'I' ? 20 : 40);
386 basephi = 1.72787594;
387 if(det == 2 && ring == 'I')
388 basephi = 0.15707963;
389 if(det == 2 && ring == 'O')
390 basephi = 0.078539818;
391 if(det == 3 && ring == 'I')
392 basephi = 2.984513044;
393 if(det == 3 && ring == 'O')
394 basephi = 3.06305289;
396 Float_t step = 2*TMath::Pi() / nsec;
399 phi = basephi - sec*step;
401 phi = basephi + sec*step;
404 phi = phi +2*TMath::Pi();
405 if(phi > 2*TMath::Pi() )
406 phi = phi - 2*TMath::Pi();
410 //_____________________________________________________________________
411 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
413 // AliFMDRing fmdring(ring);
415 Float_t rad = GetMaxR(ring)-GetMinR(ring);
416 Float_t nStrips = (ring == 'I' ? 512 : 256);
417 Float_t segment = rad / nStrips;
418 Float_t r = GetMinR(ring) + segment*strip;
420 Int_t hybrid = sec / 2;
423 if(!(hybrid%2)) z = 320.266; else z = 319.766;
425 if(det == 2 && ring == 'I' ) {
426 if(!(hybrid%2)) z = 83.666; else z = 83.166;
428 if(det == 2 && ring == 'O' ) {
429 if(!(hybrid%2)) z = 74.966; else z = 75.466;
431 if(det == 3 && ring == 'I' ) {
432 if(!(hybrid%2)) z = -63.066; else z = -62.566;
434 if(det == 3 && ring == 'O' ) {
435 if(!(hybrid%2)) z = -74.966; else z = -75.466;
438 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
440 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
441 Float_t theta = TMath::ATan2(r,z-zvtx);
442 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
447 //_____________________________________________________________________
449 void AliFMDAnaParameters::GetVertex(AliESDEvent* esd, Double_t* vertexXYZ)
451 const AliESDVertex* vertex = 0;
452 vertex = esd->GetPrimaryVertex();
453 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
454 vertex = esd->GetPrimaryVertexSPD();
455 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
456 vertex = esd->GetPrimaryVertexTPC();
457 if(!vertex || (vertexXYZ[0] == 0 && vertexXYZ[1] == 0 && vertexXYZ[2] == 0))
458 vertex = esd->GetVertex();
459 if (vertex && (vertexXYZ[0] != 0 || vertexXYZ[1] != 0 || vertexXYZ[2] != 0)) {
460 vertex->GetXYZ(vertexXYZ);
461 //std::cout<<vertex->GetName()<<" "<< vertex->GetTitle() <<" "<< vertex->GetZv()<<std::endl;
464 else if (esd->GetESDTZERO()) {
467 vertexXYZ[2] = esd->GetT0zVertex();
476 //____________________________________________________________________
477 Bool_t AliFMDAnaParameters::IsEventTriggered(AliESDEvent *esd) {
478 // check if the event was triggered
479 ULong64_t triggerMask = esd->GetTriggerMask();
481 // definitions from p-p.cfg
482 ULong64_t spdFO = (1 << 14);
483 ULong64_t v0left = (1 << 11);
484 ULong64_t v0right = (1 << 12);
488 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
493 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
498 if (triggerMask & spdFO)
511 //____________________________________________________________________
513 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
515 //AliFMDRing fmdring(ring);
518 Float_t rad = GetMaxR(ring)-GetMinR(ring);
519 Float_t nStrips = (ring == 'I' ? 512 : 256);
520 Float_t segment = rad / nStrips;
522 //TVector2* corner1 = fmdring.GetVertex(2);
523 // TVector2* corner2 = fmdring.GetVertex(3);
527 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
528 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
529 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
530 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
531 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
532 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
533 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
534 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
535 Float_t radius = GetMinR(ring) + strip*segment;
537 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
539 Float_t arclength = GetBaseStripLength(ring,strip);
542 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
543 Float_t y = slope*x + constant;
544 Float_t theta = TMath::ATan2(x,y);
546 if(x < fCorner1.X() && y > fCorner1.Y()) {
547 arclength = radius*theta; //One sector since theta is by definition half-hybrid
557 //____________________________________________________________________
559 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
561 // AliFMDRing fmdring(ring);
563 Float_t rad = GetMaxR(ring)-GetMinR(ring);
564 Float_t nStrips = (ring == 'I' ? 512 : 256);
565 Float_t nSec = (ring == 'I' ? 20 : 40);
566 Float_t segment = rad / nStrips;
567 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
568 Float_t radius = GetMinR(ring) + strip*segment;
569 Float_t basearclength = 0.5*basearc * radius; // One sector
571 return basearclength;
573 //____________________________________________________________________