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"
42 //====================================================================
43 ClassImp(AliFMDAnaParameters)
45 ; // This is here to keep Emacs for indenting the next line
48 //const char* AliFMDAnaParameters::fgkBackgroundCorrection = "FMD/Correction/Background";
49 //const char* AliFMDAnaParameters::fgkEnergyDists = "FMD/Correction/EnergyDistribution";
50 const char* AliFMDAnaParameters::fgkBackgroundID = "background";
51 const char* AliFMDAnaParameters::fgkEnergyDistributionID = "energydistributions";
52 const char* AliFMDAnaParameters::fgkEventSelectionEffID = "eventselectionefficiency";
53 const char* AliFMDAnaParameters::fgkSharingEffID = "sharingefficiency";
54 //____________________________________________________________________
55 AliFMDAnaParameters* AliFMDAnaParameters::fgInstance = 0;
57 //____________________________________________________________________
60 AliFMDAnaParameters::Instance()
62 // Get static instance
63 if (!fgInstance) fgInstance = new AliFMDAnaParameters;
67 //____________________________________________________________________
68 AliFMDAnaParameters::AliFMDAnaParameters() :
71 fEnergyDistribution(0),
72 fEventSelectionEfficiency(0),
73 fSharingEfficiency(0),
74 fCorner1(4.2231, 26.6638),
75 fCorner2(1.8357, 27.9500),
76 fEnergyPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EnergyDistribution"),
77 fBackgroundPath("$ALICE_ROOT/PWG2/FORWARD/corrections/Background"),
78 fEventSelectionEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/EventSelectionEfficiency"),
79 fSharingEffPath("$ALICE_ROOT/PWG2/FORWARD/corrections/SharingEfficiency"),
80 fProcessPrimary(kFALSE),
89 fSPDhighLimit(999999999),
90 fCentralSelection(kFALSE),
91 fSharingObjectPresent(kTRUE),
92 fNumberOfEtaBinsToCut(1),
99 // Default constructor
100 fPhysicsSelection = new AliPhysicsSelection;
101 fPhysicsSelection->SetAnalyzeMC(kTRUE); //For the background correction. This is reset in Init if relevant
103 AliBackgroundSelection* backgroundSelection = new AliBackgroundSelection("bg","bg");
105 fPhysicsSelection->AddBackgroundIdentification(backgroundSelection);
106 //fPhysicsSelection->Initialize(104792);
107 // Do not use this - it is only for IO
111 //____________________________________________________________________
112 char* AliFMDAnaParameters::GetPath(const char* species) {
116 if(species == fgkBackgroundID)
117 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
118 fBackgroundPath.Data(),
126 if(species == fgkEnergyDistributionID)
127 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
129 fgkEnergyDistributionID,
136 if(species == fgkEventSelectionEffID)
137 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
138 fEventSelectionEffPath.Data(),
139 fgkEventSelectionEffID,
146 if(species == fgkSharingEffID)
147 path = Form("%s/%s_%d_%d_%d_%d_%d_%d.root",
148 fSharingEffPath.Data(),
159 //____________________________________________________________________
160 void AliFMDAnaParameters::Init(Bool_t forceReInit, UInt_t what)
162 // Initialize the parameters manager. We need to get stuff from files here.
164 if (forceReInit) fIsInit = kFALSE;
166 if (what & kBackgroundCorrection) InitBackground();
167 if (what & kEnergyDistributions) InitEnergyDists();
168 if (what & kEventSelectionEfficiency) InitEventSelectionEff();
169 if (what & kSharingEfficiency) InitSharingEff();
177 fPhysicsSelection->SetAnalyzeMC(kTRUE);
179 else fPhysicsSelection->SetAnalyzeMC(kFALSE);
183 //____________________________________________________________________
185 void AliFMDAnaParameters::InitBackground() {
186 //Init background correction objects.
188 TFile* fin = TFile::Open(GetPath(fgkBackgroundID));
192 fBackground = dynamic_cast<AliFMDAnaCalibBackgroundCorrection*>(fin->Get(fgkBackgroundID));
193 if (!fBackground) AliFatal("Invalid background object from CDB");
199 //____________________________________________________________________
201 void AliFMDAnaParameters::InitEnergyDists() {
202 //Init energy distributions
203 TFile* fin = TFile::Open(GetPath(fgkEnergyDistributionID));
207 fEnergyDistribution = dynamic_cast<AliFMDAnaCalibEnergyDistribution*>(fin->Get(fgkEnergyDistributionID));
209 if (!fEnergyDistribution) AliFatal("Invalid background object from CDB");
213 //____________________________________________________________________
215 void AliFMDAnaParameters::InitEventSelectionEff() {
216 //Init event selection objects
218 TFile* fin = TFile::Open(GetPath(fgkEventSelectionEffID));
222 fEventSelectionEfficiency = dynamic_cast<AliFMDAnaCalibEventSelectionEfficiency*>(fin->Get(fgkEventSelectionEffID));
223 if (!fEventSelectionEfficiency) AliFatal("Invalid background object from CDB");
227 //____________________________________________________________________
229 void AliFMDAnaParameters::InitSharingEff() {
231 fSharingObjectPresent = kTRUE;
232 TFile* fin = TFile::Open(GetPath(fgkSharingEffID));
235 fSharingObjectPresent = kFALSE;
239 fSharingEfficiency = dynamic_cast<AliFMDAnaCalibSharingEfficiency*>(fin->Get(fgkSharingEffID));
240 if (!fSharingEfficiency) {
241 fSharingObjectPresent = kFALSE;
246 //____________________________________________________________________
247 void AliFMDAnaParameters::FindEtaLimits() {
249 fEtaLowBinLimits.SetBins(4,0,4,2,0,2,GetNvtxBins(),0,GetNvtxBins());
250 fEtaHighBinLimits.SetBins(4,0,4,2,0,2,GetNvtxBins(),0,GetNvtxBins());
251 for(Int_t det=0; det<=3;det++) {
252 Int_t nRings = (det<=1 ? 1 : 2);
253 for (UShort_t ir = 0; ir < nRings; ir++) {
254 Char_t ringChar = (ir == 0 ? 'I' : 'O');
255 for(Int_t v =0; v<GetNvtxBins(); v++) {
256 fEtaLowBinLimits.SetBinContent(det,ir,v,GetFirstEtaBinFromMap(v, det, ringChar));
257 fEtaHighBinLimits.SetBinContent(det,ir,v,GetLastEtaBinFromMap(v, det, ringChar));
258 //std::cout<<det<<" "<<ringChar<<" "<<fEtaLowBinLimits.GetBinContent(det,ir,v)<<" "<<fEtaHighBinLimits.GetBinContent(det,ir,v)<<std::endl;
264 //____________________________________________________________________
266 void AliFMDAnaParameters::PrintStatus() const
268 //Print current status
269 TString energystring;
272 energystring.Form("900 GeV"); break;
274 energystring.Form("7000 GeV"); break;
276 energystring.Form("10000 GeV"); break;
278 energystring.Form("14000 GeV"); break;
280 energystring.Form("invalid energy"); break;
282 TString triggerstring;
285 triggerstring.Form("Minimum bias 1"); break;
287 triggerstring.Form("Minimum bias 2"); break;
289 triggerstring.Form("SPD FAST OR"); break;
291 triggerstring.Form("NO TRIGGER TEST"); break;
293 energystring.Form("invalid trigger"); break;
298 magstring.Form("5 kGaus"); break;
300 magstring.Form("0 kGaus"); break;
302 magstring.Form("invalid mag field"); break;
304 TString collsystemstring;
307 collsystemstring.Form("p+p"); break;
309 collsystemstring.Form("Pb+Pb"); break;
311 collsystemstring.Form("invalid collision system"); break;
317 datastring.Form("Nature"); break;
319 datastring.Form("MC"); break;
321 datastring.Form("Unknown"); break ;
324 std::cout<<"Energy = "<<energystring.Data()<<std::endl;
325 std::cout<<"Trigger = "<<triggerstring.Data()<<std::endl;
326 std::cout<<"Mag Field = "<<magstring.Data()<<std::endl;
327 std::cout<<"Coll System = "<<collsystemstring.Data()<<std::endl;
328 std::cout<<"Data origin = "<<datastring.Data()<<std::endl;
334 //____________________________________________________________________
335 Float_t AliFMDAnaParameters::GetVtxCutZ() {
336 //Get the z vtx cut in analysis
338 AliWarning("Not initialized yet. Call Init() to remedy");
342 return fBackground->GetVtxCutZ();
345 //____________________________________________________________________
346 Int_t AliFMDAnaParameters::GetNvtxBins() {
347 //Get number of vtx bins
349 AliWarning("Not initialized yet. Call Init() to remedy");
353 return fBackground->GetNvtxBins();
355 //____________________________________________________________________
356 TH1F* AliFMDAnaParameters::GetEnergyDistribution(Int_t det, Char_t ring, Float_t eta) {
358 return fEnergyDistribution->GetEnergyDistribution(det, ring, eta);
360 //____________________________________________________________________
361 TH1F* AliFMDAnaParameters::GetEmptyEnergyDistribution(Int_t det, Char_t ring) {
363 return fEnergyDistribution->GetEmptyEnergyDistribution(det, ring);
365 //____________________________________________________________________
366 TH1F* AliFMDAnaParameters::GetRingEnergyDistribution(Int_t det, Char_t ring) {
368 return fEnergyDistribution->GetRingEnergyDistribution(det, ring);
370 //____________________________________________________________________
371 Float_t AliFMDAnaParameters::GetSigma(Int_t det, Char_t ring, Float_t eta) {
372 //Get sigma of Landau fits
374 AliWarning("Not initialized yet. Call Init() to remedy");
378 TH1F* hEnergyDist = GetEnergyDistribution(det,ring, eta);
379 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
381 //AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
384 Float_t sigma = fitFunc->GetParameter(2);
389 //____________________________________________________________________
390 Float_t AliFMDAnaParameters::GetMPV(Int_t det, Char_t ring, Float_t eta) {
391 //Get MPV of landau fits
393 AliWarning("Not initialized yet. Call Init() to remedy");
396 //AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
397 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
398 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
401 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
402 std::cout<<hEnergyDist->GetEntries()<<" "<<GetEtaBin(eta)<<std::endl;
406 Float_t mpv = fitFunc->GetParameter(1);
409 //____________________________________________________________________
410 Float_t AliFMDAnaParameters::GetConstant(Int_t det, Char_t ring, Float_t eta) {
411 //Get constant parameter of Landau fits
413 AliWarning("Not initialized yet. Call Init() to remedy");
417 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
418 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
420 AliWarning(Form("No function for FMD%d%c, eta %f",det,ring,eta));
424 Float_t mpv = fitFunc->GetParameter(0);
427 //____________________________________________________________________
428 Float_t AliFMDAnaParameters::Get2MIPWeight(Int_t det, Char_t ring, Float_t eta) {
429 //Get 2 MIP weights of convoluted Landau fits
431 AliWarning("Not initialized yet. Call Init() to remedy");
435 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
436 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
437 if(!fitFunc) return 0;
438 Float_t twoMIPweight = fitFunc->GetParameter(3);
442 if(twoMIPweight < 1e-05)
447 //____________________________________________________________________
448 Float_t AliFMDAnaParameters::Get3MIPWeight(Int_t det, Char_t ring, Float_t eta) {
449 //Get 3 MIP weights of convoluted Landau fits
451 AliWarning("Not initialized yet. Call Init() to remedy");
455 TH1F* hEnergyDist = GetEnergyDistribution(det,ring,eta);
456 TF1* fitFunc = hEnergyDist->GetFunction("FMDfitFunc");
457 if(!fitFunc) return 0;
458 Float_t threeMIPweight = fitFunc->GetParameter(4);
460 if(threeMIPweight < 1e-05)
463 Float_t twoMIPweight = fitFunc->GetParameter(3);
465 if(twoMIPweight < 1e-05)
468 return threeMIPweight;
470 //____________________________________________________________________
471 Int_t AliFMDAnaParameters::GetNetaBins() {
472 return GetBackgroundCorrection(1,'I',5)->GetNbinsX();
475 //____________________________________________________________________
476 Float_t AliFMDAnaParameters::GetEtaMin() {
478 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmin();
480 //____________________________________________________________________
481 Float_t AliFMDAnaParameters::GetEtaMax() {
483 return GetBackgroundCorrection(1,'I',5)->GetXaxis()->GetXmax();
486 //____________________________________________________________________
487 Int_t AliFMDAnaParameters::GetEtaBin(Float_t eta) {
489 TAxis testaxis(GetNetaBins(),GetEtaMin(),GetEtaMax());
490 Int_t binnumber = testaxis.FindBin(eta) ;
495 //____________________________________________________________________
497 TH2F* AliFMDAnaParameters::GetBackgroundCorrection(Int_t det,
500 //Get background correction histogram
502 AliWarning("Not initialized yet. Call Init() to remedy");
508 if(vtxbin > fBackground->GetNvtxBins()) {
509 AliWarning(Form("No background object for vertex bin %d", vtxbin));
513 return fBackground->GetBgCorrection(det,ring,vtxbin);
515 //____________________________________________________________________
517 TH1F* AliFMDAnaParameters::GetDoubleHitCorrection(Int_t det,
519 //Get correction for several hits in strips for p+p
521 AliWarning("Not initialized yet. Call Init() to remedy");
525 return fBackground->GetDoubleHitCorrection(det,ring);
527 //_____________________________________________________________________
528 TH1F* AliFMDAnaParameters::GetSPDDeadCorrection(Int_t vtxbin) {
530 //Get correction for several hits in strips for p+p
532 AliWarning("Not initialized yet. Call Init() to remedy");
536 return fBackground->GetSPDDeadCorrection(vtxbin);
538 //_____________________________________________________________________
539 Float_t AliFMDAnaParameters::GetEventSelectionEfficiency(Int_t vtxbin) {
540 //Get event selection efficiency object
542 AliWarning("Not initialized yet. Call Init() to remedy");
545 return fEventSelectionEfficiency->GetCorrection(vtxbin);
548 //_____________________________________________________________________
549 Float_t AliFMDAnaParameters::GetVtxSelectionEffFromMC() {
552 AliWarning("Not initialized yet. Call Init() to remedy");
555 return fEventSelectionEfficiency->GetVtxToTriggerRatio();
559 //_____________________________________________________________________
560 TH2F* AliFMDAnaParameters::GetEventSelectionEfficiency(Char_t* trig, Int_t vtxbin, Char_t ring) {
561 //Get event selection efficiency object
563 if(trig != "NSD" && trig != "INEL") {
564 AliWarning("Event selection efficiency only available for INEL and NSD");
568 AliWarning("Not initialized yet. Call Init() to remedy");
571 return fEventSelectionEfficiency->GetCorrection(trig,vtxbin,ring);
574 //_____________________________________________________________________
575 TH1F* AliFMDAnaParameters::GetSharingEfficiency(Int_t det, Char_t ring, Int_t vtxbin) {
576 //Get sharing efficiency object
578 AliWarning("Not initialized yet. Call Init() to remedy");
582 return fSharingEfficiency->GetSharingEff(det,ring,vtxbin);
585 //_____________________________________________________________________
586 TH1F* AliFMDAnaParameters::GetSharingEfficiencyTrVtx(Int_t det, Char_t ring, Int_t vtxbin) {
587 //Get sharing efficiency object TrVtx
589 AliWarning("Not initialized yet. Call Init() to remedy");
593 return fSharingEfficiency->GetSharingEffTrVtx(det,ring,vtxbin);
596 //_____________________________________________________________________
597 Float_t AliFMDAnaParameters::GetMaxR(Char_t ring) const {
605 AliWarning("Unknown ring - must be I or O!");
609 //_____________________________________________________________________
610 Float_t AliFMDAnaParameters::GetMinR(Char_t ring) const{
618 AliWarning("Unknown ring - must be I or O!");
623 //_____________________________________________________________________
624 void AliFMDAnaParameters::SetCorners(Char_t ring) {
625 //Set corners (taken from nominal geometry)
627 fCorner1.Set(4.9895, 15.3560);
628 fCorner2.Set(1.8007, 17.2000);
631 fCorner1.Set(4.2231, 26.6638);
632 fCorner2.Set(1.8357, 27.9500);
636 //_____________________________________________________________________
637 Float_t AliFMDAnaParameters::GetPhiFromSector(UShort_t det, Char_t ring, UShort_t sec) const
639 //Get phi from sector
640 Int_t nsec = (ring == 'I' ? 20 : 40);
643 basephi = 1.72787594;
644 if(det == 2 && ring == 'I')
645 basephi = 0.15707963;
646 if(det == 2 && ring == 'O')
647 basephi = 0.078539818;
648 if(det == 3 && ring == 'I')
649 basephi = 2.984513044;
650 if(det == 3 && ring == 'O')
651 basephi = 3.06305289;
653 Float_t step = 2*TMath::Pi() / nsec;
656 phi = basephi - sec*step;
658 phi = basephi + sec*step;
661 phi = phi +2*TMath::Pi();
662 if(phi > 2*TMath::Pi() )
663 phi = phi - 2*TMath::Pi();
667 //_____________________________________________________________________
668 Float_t AliFMDAnaParameters::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Float_t zvtx) const
670 //Calculate eta from strip with vertex (redundant with AliESDFMD::Eta)
671 Float_t rad = GetMaxR(ring)-GetMinR(ring);
672 Float_t nStrips = (ring == 'I' ? 512 : 256);
673 Float_t segment = rad / nStrips;
674 Float_t r = GetMinR(ring) + segment*strip;
676 Int_t hybrid = sec / 2;
679 if(!(hybrid%2)) z = 320.266; else z = 319.766;
681 if(det == 2 && ring == 'I' ) {
682 if(!(hybrid%2)) z = 83.666; else z = 83.166;
684 if(det == 2 && ring == 'O' ) {
685 if(!(hybrid%2)) z = 74.966; else z = 75.466;
687 if(det == 3 && ring == 'I' ) {
688 if(!(hybrid%2)) z = -63.066; else z = -62.566;
690 if(det == 3 && ring == 'O' ) {
691 if(!(hybrid%2)) z = -74.966; else z = -75.466;
694 //std::cout<<det<<" "<<ring<<" "<<sec<<" "<<hybrid<<" "<<z<<std::endl;
696 // Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2));
697 Float_t theta = TMath::ATan2(r,z-zvtx);
698 Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
703 //_____________________________________________________________________
705 Bool_t AliFMDAnaParameters::GetVertex(const AliESDEvent* esd, Double_t* vertexXYZ)
707 //Get the vertex from the ESD
708 const AliESDVertex* vertex = 0;
709 vertex = esd->GetPrimaryVertexSPD();
712 vertex->GetXYZ(vertexXYZ);
714 //if(vertexXYZ[0] == 0 || vertexXYZ[1] == 0 )
717 if(vertex->GetNContributors() <= 0)
720 if(vertex->GetZRes() > 0.1 )
723 return vertex->GetStatus();
726 //____________________________________________________________________
727 void AliFMDAnaParameters::SetTriggerStatus(const AliESDEvent *esd) {
729 //ULong64_t triggerMask = esd->GetTriggerMask();
731 TString triggers = esd->GetFiredTriggerClasses();
733 //if(triggers.Contains("CINT1B-ABCE-NOPF-ALL") || triggers.Contains("CINT1B-E-NOPF-ALL")) return kTRUE;
734 //else return kFALSE;
735 //if(triggers.Contains("CINT1B-E-NOPF-ALL")) return kFALSE;
737 // if(triggers.Contains("CINT1A-ABCE-NOPF-ALL")) return kFALSE;
738 // if(triggers.Contains("CINT1C-ABCE-NOPF-ALL")) return kFALSE;
740 // definitions from p-p.cfg
741 //ULong64_t spdFO = (1 << 14);
742 // ULong64_t v0left = (1 << 11);
743 // ULong64_t v0right = (1 << 12);
745 AliTriggerAnalysis tAna;
747 //REMOVE WHEN FINISHED PLAYING WITH TRIGGERS!
748 //fPhysicsSelection->IsCollisionCandidate(esd);
751 // fPhysicsSelection->SetAnalyzeMC(kTRUE);
754 fTriggerInel = kFALSE;
755 fTriggerNSD = kFALSE;
756 fTriggerEmpty = kFALSE;
758 if(fPhysicsSelection->IsCollisionCandidate(esd)) {
759 fTriggerInel = kTRUE;
761 if(fTriggerInel && tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1)) {
764 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL")) {
765 fTriggerEmpty = kTRUE;
769 /*switch (fTrigger) {
771 if( fPhysicsSelection->IsCollisionCandidate(esd)) {
772 fTriggerInel = kTRUE;
778 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
783 if (triggerMask & spdFO)
792 if(triggers.Contains("CBEAMB-ABCE-NOPF-ALL"))
797 if(fPhysicsSelection->IsCollisionCandidate(esd) && tAna.IsOfflineTriggerFired(esd,AliTriggerAnalysis::kNSD1))
807 //____________________________________________________________________
808 Bool_t AliFMDAnaParameters::IsEventTriggered(const AliESDEvent *esd, Trigger trig) {
809 //Did we have trig trigger ?
810 Trigger old = fTrigger;
812 Bool_t retval = IsEventTriggered(esd);
818 //____________________________________________________________________
819 Bool_t AliFMDAnaParameters::IsEventTriggered(Trigger trigger) {
820 // check if the event was triggered
822 if (fCentralSelection) return kTRUE;
832 return fTriggerEmpty;
838 AliWarning("Trigger not implemented!!!");
847 //____________________________________________________________________
849 AliFMDAnaParameters::GetStripLength(Char_t ring, UShort_t strip)
851 //Get length of a strip
853 Float_t rad = GetMaxR(ring)-GetMinR(ring);
854 Float_t nStrips = (ring == 'I' ? 512 : 256);
855 Float_t segment = rad / nStrips;
857 //TVector2* corner1 = fmdring.GetVertex(2);
858 // TVector2* corner2 = fmdring.GetVertex(3);
862 std::cout<<GetMaxR(ring)<<" "<<fmdring.GetMaxR()<<std::endl;
863 std::cout<<GetMinR(ring)<<" "<<fmdring.GetMinR()<<std::endl;
864 std::cout<<corner1->X()<<" "<<fCorner1.X()<<std::endl;
865 std::cout<<corner2->X()<<" "<<fCorner2.X()<<std::endl;
866 std::cout<<corner1->Y()<<" "<<fCorner1.Y()<<std::endl;
867 std::cout<<corner2->Y()<<" "<<fCorner2.Y()<<std::endl;*/
868 Float_t slope = (fCorner1.Y() - fCorner2.Y()) / (fCorner1.X() - fCorner2.X());
869 Float_t constant = (fCorner2.Y()*fCorner1.X()-(fCorner2.X()*fCorner1.Y())) / (fCorner1.X() - fCorner2.X());
870 Float_t radius = GetMinR(ring) + strip*segment;
872 Float_t d = TMath::Power(TMath::Abs(radius*slope),2) + TMath::Power(radius,2) - TMath::Power(constant,2);
874 Float_t arclength = GetBaseStripLength(ring,strip);
877 Float_t x = (-1*TMath::Sqrt(d) -slope*constant) / (1+TMath::Power(slope,2));
878 Float_t y = slope*x + constant;
879 Float_t theta = TMath::ATan2(x,y);
881 if(x < fCorner1.X() && y > fCorner1.Y()) {
882 arclength = radius*theta; //One sector since theta is by definition half-hybrid
892 //____________________________________________________________________
894 AliFMDAnaParameters::GetBaseStripLength(Char_t ring, UShort_t strip)
896 //Get length of strip assuming that corners are not cut away
897 Float_t rad = GetMaxR(ring)-GetMinR(ring);
898 Float_t nStrips = (ring == 'I' ? 512 : 256);
899 Float_t nSec = (ring == 'I' ? 20 : 40);
900 Float_t segment = rad / nStrips;
901 Float_t basearc = 2*TMath::Pi() / (0.5*nSec); // One hybrid: 36 degrees inner, 18 outer
902 Float_t radius = GetMinR(ring) + strip*segment;
903 Float_t basearclength = 0.5*basearc * radius; // One sector
905 return basearclength;
907 //____________________________________________________________________
908 Int_t AliFMDAnaParameters::GetFirstEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
910 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
912 if(det == 0) return hBg->GetXaxis()->FindBin(-1.95);
915 Int_t nNonZeroFirst = 0;
917 for(Int_t i=1;i<=hBg->GetNbinsX();i++) {
918 if(nNonZeroFirst == fNumberOfEtaBinsToCut && firstbin==-1) firstbin = i;
920 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
922 Float_t value = hBg->GetBinContent(i,j);
924 if(value > 0.001 && nNonZeroFirst<fNumberOfEtaBinsToCut)
925 {nNonZeroFirst++; break;}
934 //____________________________________________________________________
935 Int_t AliFMDAnaParameters::GetLastEtaBinFromMap(Int_t vtxbin, Int_t det, Char_t ring)
937 TH2F* hBg = GetBackgroundCorrection(det,ring,vtxbin);
939 Int_t nNonZeroLast = 0;
941 if(det == 0) return hBg->GetXaxis()->FindBin(1.95);
943 for(Int_t i=hBg->GetNbinsX();i>0;i--) {
944 if(nNonZeroLast == fNumberOfEtaBinsToCut && lastbin==-1) lastbin = i;
946 for(Int_t j=1;j<=hBg->GetNbinsY();j++) {
948 Float_t value = hBg->GetBinContent(i,j);
950 if(value > 0.001 && nNonZeroLast<fNumberOfEtaBinsToCut)
951 {nNonZeroLast++; break; }
960 //____________________________________________________________________
961 Int_t AliFMDAnaParameters::GetFirstEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
963 Int_t ringNumber = (ring == 'I' ? 0 : 1);
964 return fEtaLowBinLimits.GetBinContent(det,ringNumber,vtxbin);
968 //____________________________________________________________________
969 Int_t AliFMDAnaParameters::GetLastEtaBinToInclude(Int_t vtxbin, Int_t det, Char_t ring)
971 Int_t ringNumber = (ring == 'I' ? 0 : 1);
972 return fEtaHighBinLimits.GetBinContent(det,ringNumber,vtxbin);
975 //____________________________________________________________________