7 #include <AliAnalysisManager.h>
10 #include <AliInputEventHandler.h>
11 #include <AliAODInputHandler.h>
12 #include <AliAODHandler.h>
13 #include <AliAODEvent.h>
14 #include <AliESDEvent.h>
15 #include <AliAnalysisTaskSE.h>
16 #include <AliPhysicsSelection.h>
17 #include <AliTriggerAnalysis.h>
18 #include <AliMultiplicity.h>
19 #include "AliMultEstimator.h"
20 #include "AliMultVariable.h"
21 #include "AliMultInput.h"
22 #include "AliMultSelection.h"
23 #include "AliMultSelectionCuts.h"
24 #include <TParameter.h>
28 #include <TFitResult.h>
33 #define FIT_OPTIONS "RNS"
38 #ifdef ALIROOT_SVN_REVISION
40 #elif defined(ALIROOT_REVISION)
42 if (ret != 0)
return ret;
45 TString rev(ALIROOT_REVISION, 8);
46 for (
ULong_t i = 0; i < 8; i++) {
49 case '0': p = 0;
break;
50 case '1': p = 1;
break;
51 case '2': p = 2;
break;
52 case '3': p = 3;
break;
53 case '4': p = 4;
break;
54 case '5': p = 5;
break;
55 case '6': p = 6;
break;
56 case '7': p = 7;
break;
57 case '8': p = 8;
break;
58 case '9': p = 9;
break;
59 case 'a':
case 'A': p = 10;
break;
60 case 'b':
case 'B': p = 11;
break;
61 case 'c':
case 'C': p = 12;
break;
62 case 'd':
case 'D': p = 13;
break;
63 case 'e':
case 'E': p = 14;
break;
64 case 'f':
case 'F': p = 15;
break;
66 ret |= (p << (32-4*(i+1)));
77 #if !defined(ALIROOT_SVN_BRANCH) && !defined(ALIROOT_BRANCH)
81 if (ret != 0)
return ret;
84 #ifdef ALIROOT_SVN_BRANCH
85 str = ALIROOT_SVN_BRANCH;
87 #elif defined(ALIROOT_BRANCH)
91 if (str.IsNull())
return 0xFFFFFFFF;
92 if (str[0] ==
'v') str.Remove(0,1);
93 if (str.EqualTo(top))
return ret = 0xFFFFFFFF;
96 TObjString* pMajor = tokens->GetEntries()>0 ?
97 (
static_cast<TObjString*
>(tokens->At(0))) : 0;
98 TObjString* pMinor = tokens->GetEntries()>1 ?
99 (
static_cast<TObjString*
>(tokens->At(1))) : 0;
100 TObjString* pRelea = tokens->GetEntries() > 2 ?
101 static_cast<TObjString*
>(tokens->At(2)) : 0;
102 TObjString* pAn = tokens->GetEntries() > 3 ?
103 static_cast<TObjString*
>(tokens->At(3)) : 0;
105 if (pMajor) sMajor = pMajor->String().Strip(TString::kLeading,
'0');
106 if (pMinor) sMinor = pMinor->String().Strip(TString::kLeading,
'0');
107 if (pRelea) sRelea = pRelea->String().Strip(TString::kLeading,
'0');
109 ret = (((sMajor.Atoi() & 0xFF) << 12) |
110 ((sMinor.Atoi() & 0xFF) << 8) |
111 ((sRelea.Atoi() & 0xFF) << 4) |
177 const Double_t pMass = 9.38271999999999995e-01;
178 const Double_t nMass = 9.39564999999999984e-01;
180 Double_t beamM = z * pMass + (a - z) * nMass;
181 Double_t beamP = TMath::Sqrt(beamE * beamE - beamM * beamM);
182 Double_t beamY = .5* TMath::Log((beamE+beamP) / (beamE-beamP));
197 return TMath::Sqrt(
Float_t(z1*z2)/a1/a2) * beam;
210 if (z2 == z1 && a2 == a1)
return 0;
211 return .5 * TMath::Log(
Float_t(z1*a2)/z2/a1);
217 if (TMath::Abs(energy - 900.) < 10)
return 900;
218 if (TMath::Abs(energy - 2400.) < 10)
return 2400;
219 if (TMath::Abs(energy - 2760.) < 20)
return 2760;
220 if (TMath::Abs(energy - 4400.) < 10)
return 4400;
221 if (TMath::Abs(energy - 5000.) < 10)
return 5000;
222 if (TMath::Abs(energy - 5022.) < 10)
return 5023;
223 if (TMath::Abs(energy - 5125.) < 30)
return 5100;
224 if (TMath::Abs(energy - 5500.) < 40)
return 5500;
225 if (TMath::Abs(energy - 7000.) < 10)
return 7000;
226 if (TMath::Abs(energy - 8000.) < 10)
return 8000;
227 if (TMath::Abs(energy - 10000.) < 10)
return 10000;
228 if (TMath::Abs(energy - 13000.) < 10)
return 13000;
229 if (TMath::Abs(energy - 14000.) < 10)
return 14000;
258 if (ret > 1)
return ret;
262 ret = CheckSNN(beam);
279 return Form(
"%04dGeV", cms);
294 if (TMath::Abs(v - 5.) < 1 )
return +5;
295 if (TMath::Abs(v + 5.) < 1 )
return -5;
296 if (TMath::Abs(v) < 1)
return 0;
312 return Form(
"%01dkG", f);
318 if (!task) ::Fatal(
"GetAODEvent",
"Null task given, cannot do that");
324 ret =
dynamic_cast<AliAODEvent*
>(task->InputEvent());
325 if (!ret) ::Warning(
"GetAODEvent",
"No AOD event found");
333 if (dynamic_cast<AliAODInputHandler*>(am->GetInputEventHandler())) {
337 if (dynamic_cast<AliAODHandler*>(am->GetOutputEventHandler())) {
342 ::Warning(
"CheckForAOD",
343 "Neither and input nor output AOD handler is specified");
353 ::Warning(
"CheckForTask",
"Task %s not found in manager", clsOrName);
356 ::Info(
"CheckForTask",
"Found task %s", clsOrName);
359 TClass* dep = gROOT->GetClass(clsOrName);
361 ::Warning(
"CheckForTask",
"Unknown class %s for needed task", clsOrName);
364 TIter next(am->GetTasks());
366 while ((o = next())) {
367 if (o->IsA()->InheritsFrom(dep)) {
368 ::Info(
"CheckForTask",
"Found task of class %s: %s",
369 clsOrName, o->GetName());
373 ::Warning(
"CheckForTask",
"No task of class %s was found", clsOrName);
381 ret->SetMergeMode(
'f');
382 ret->SetUniqueID(value);
389 ret->SetMergeMode(
'f');
390 ret->SetUniqueID(value);
397 ret->SetMergeMode(
'f');
398 ret->SetUniqueID(value);
407 ret->SetMergeMode(
'f');
415 ret->SetMergeMode(
'f');
416 ret->SetUniqueID(value);
425 if (p->TestBit(BIT(19)))
428 value = o->GetUniqueID();
435 if (p->TestBit(BIT(19)))
438 value = o->GetUniqueID();
445 if (p->TestBit(BIT(19)))
448 value = o->GetUniqueID();
455 if (p->TestBit(BIT(19)))
458 UInt_t i = o->GetUniqueID();
468 if (p->TestBit(BIT(19)))
471 value = o->GetUniqueID();
480 const Double_t minR[] = { 4.5213, 15.4 };
481 const Double_t maxR[] = { 17.2, 28.0 };
482 const Int_t nStr[] = { 512, 256 };
484 Int_t q = (ring ==
'I' || ring ==
'i') ? 0 : 1;
487 Double_t r = minR[q] + segment*strip;
495 Int_t hybrid = sec / 2;
496 Int_t q = (ring ==
'I' || ring ==
'i') ? 0 : 1;
497 Int_t r = q == 0 ? 1 : 0;
499 { 83.666, 74.966+.5 },
500 { -63.066+.5, -74.966 } };
502 ::Warning(
"GetSectorZ",
"Unknown sub-detector FMD%d%c", det, ring);
508 case 1:
if ((hybrid % 2) == 1) z -= .5;
break;
509 case 2:
if ((hybrid % 2) == r) z -= .5;
break;
510 case 3:
if ((hybrid % 2) == q) z -= .5;
break;
519 UShort_t nSec = (ring ==
'I' || ring ==
'i') ? 20 : 40;
520 Double_t base = float(sec+.5) / nSec * TMath::TwoPi();
522 case 1: base += TMath::Pi()/2;
break;
524 case 3: base = TMath::Pi() - base;
break;
526 ::Warning(
"GetSectorPhi",
"Unknown detector %d", d);
529 if (base < 0) base += TMath::TwoPi();
530 if (base > TMath::TwoPi()) base -= TMath::TwoPi();
547 Double_t theta = TMath::ATan2(r,z-zvtx);
548 Double_t eta = -1*TMath::Log(TMath::Tan(0.5*theta));
568 Double_t iX = ip.X();
if (iX > 100) iX = 0;
569 Double_t iY = ip.Y();
if (iY > 100) iY = 0;
573 pos.SetXYZ(dX, dY, dZ);
583 if (!
GetXYZ(det, ring, sec, strip, ip, pos)) {
584 ::Warning(
"GetEtaPhi",
"Invalid position for FMD%d%c[%2d,%3d]=(%f,%f,%f)",
585 det, ring, sec, strip, pos.X(), pos.Y(), pos.Z());
590 Double_t r = TMath::Sqrt(TMath::Power(pos.X(),2)+
591 TMath::Power(pos.Y(),2));
592 Double_t theta = TMath::ATan2(r, pos.Z());
593 Double_t tant = TMath::Tan(theta/2);
594 if (TMath::Abs(theta) < 1e-9) {
595 ::Warning(
"GetEtaPhi",
"tan(theta/2)=%f very small", tant);
600 phi = TMath::ATan2(pos.Y(), pos.X());
601 eta = -TMath::Log(tant);
602 if (phi < 0) phi += TMath::TwoPi();
603 if (phi > TMath::TwoPi()) phi -= TMath::TwoPi();
619 Double_t rv = TMath::Sqrt(TMath::Power(dx,2) + TMath::Power(dy,2));
620 Double_t the = 2*TMath::ATan(TMath::Exp(-eta));
622 if (TMath::Abs(tth) < 1e-9) {
623 ::Warning(
"GetEtaPhiFromStrip",
624 "eta=%f -> theta=%f tan(theta)=%f invalid (no change)",
632 eta = -TMath::Log(TMath::Tan(TMath::ATan2(rv,z)/2));
633 phi = TMath::ATan2(dy,dx);
634 if (phi < 0) phi += TMath::TwoPi();
649 if (yvtx > 999 || xvtx > 999)
return phi;
653 Double_t amp = TMath::Sqrt(xvtx*xvtx+yvtx*yvtx) / r;
654 Double_t pha = (TMath::Abs(yvtx) < 1e-12 ? 0 : TMath::ATan2(xvtx, yvtx));
655 Double_t cha = amp * TMath::Cos(phi+pha);
657 if (phi < 0) phi += TMath::TwoPi();
658 if (phi > TMath::TwoPi()) phi -= TMath::TwoPi();
667 TAxis* a =
new TAxis(bins.GetSize()-1,bins.GetArray());
682 if (nCenter % 2 == 1)
686 const Int_t nSat = 10;
687 const Int_t nBins = 2*nSat + nCenter;
688 const Int_t mBin = nBins / 2;
689 Double_t dCenter = 2*mCenter / nCenter;
692 for (
Int_t i = 1; i <= nCenter/2; i++) {
699 for (
Int_t i = 1; i <= nSat; i++) {
701 Int_t o = nCenter/2+i;
716 for (
Int_t i = 0; i <= nBins; i++) bins[i] = TMath::Power(10, i * dO+minOrder);
723 Int_t ind = gROOT->GetDirLevel();
726 std::cout << std::setfill(
' ') << std::setw(ind) <<
" " << std::flush;
728 TString t = TString::Format(
"%s %s", o.GetName(), o.ClassName());
729 const Int_t maxN = 75;
730 std::cout <<
"--- " << t <<
" " << std::setfill(
'-')
731 << std::setw(maxN-ind-5-t.Length()) <<
"-" << std::endl;
737 Int_t ind = gROOT->GetDirLevel();
740 std::cout << std::setfill(
' ') << std::setw(ind) <<
" " << std::flush;
743 const Int_t maxN = 29;
744 Int_t width = maxN - ind;
746 if (n.Length() > width-1) {
752 std::cout << std::setfill(
' ') << std::left << std::setw(width)
753 << n << std::right << std::flush;
764 static char buf[512];
765 vsnprintf(buf, 511, value, ap);
769 std::cout << buf << std::endl;
781 if (qual < 0xFFF)
return cent;
792 TObject* o =
event.FindListObject(
"MultSelection");
795 ::Warning(
"AliForwardUtil::GetCentralityMult",
796 "No MultSelection object found in event");
799 AliMultSelection* sel =
static_cast<AliMultSelection*
>(o);
800 if (!sel->GetEstimatorList() ||
801 sel->GetEstimatorList()->GetEntries() <= 0){
803 ::Warning(
"AliForwardUtil::GetCentralityMult",
804 "No list of estimators, falling back to compat");
809 AliMultEstimator* est = sel->GetEstimator(method);
813 ::Warning(
"AliForwardUtil::GetCentralityMult",
814 "Unknown estimator: %s", method.Data());
815 sel->GetEstimatorList()->Print();
827 Float_t cent = est->GetPercentile();
828 qual = sel->GetEvSelCode();
829 if (qual == AliMultSelectionCuts::kNoCalib) cent = -1;
831 ::Info(
"AliForwardUtil::GetCentralityMult",
832 "Got centrality %5.1f%% (%d)",
844 if (event.IsA()->InheritsFrom(AliESDEvent::Class()))
847 if (event.IsA()->InheritsFrom(AliAODEvent::Class()))
861 ::Warning(
"AliForwardUtil::GetCentralityCompat",
862 "No centrality object found in ESD");
865 Float_t cent = centObj->GetCentralityPercentileUnchecked(method);
866 qual = centObj->GetQuality();
868 ::Info(
"AliForwardUtil::GetCentralityCompat<ESD>",
869 "Got centrality %5.1f%% (%d)", cent, qual);
871 qual = AliMultSelectionCuts::kRejVzCut;
873 qual = AliMultSelectionCuts::kRejTrackletsVsClusters;
875 qual = AliMultSelectionCuts::kRejConsistencySPDandTrackVertices;
877 qual = AliMultSelectionCuts::kRejTrackletsVsClusters;
886 AliAODHeader* hdr =
dynamic_cast<AliAODHeader*
>(
event.GetHeader());
889 ::Warning(
"AliForwardUtil::GetCentralityCompat",
"Not a standard AOD");
892 AliCentrality* cP = hdr->GetCentralityP();
895 ::Warning(
"AliForwardUtil::GetCentralityCompat",
896 "No centrality found in AOD");
899 Float_t cent = cP->GetCentralityPercentile(method);
900 qual = cP->GetQuality();
901 if (qual & 0x1) qual = AliMultSelectionCuts::kRejVzCut;
902 if (qual & 0x2) qual = AliMultSelectionCuts::kRejTrackletsVsClusters;
903 if (qual & 0x4) qual = AliMultSelectionCuts::kRejConsistencySPDandTrackVertices;
904 if (qual & 0x8) qual = AliMultSelectionCuts::kRejTrackletsVsClusters;
907 ::Info(
"AliForwardUtil::GetCentralityCompat<AOD>",
908 "Got centrality %5.1f%% (%d)", cent, qual);
923 if (fFMD1i)
delete fFMD1i;
924 if (fFMD2i)
delete fFMD2i;
925 if (fFMD2o)
delete fFMD2o;
926 if (fFMD3i)
delete fFMD3i;
927 if (fFMD3o)
delete fFMD3o;
933 TObject::Delete(opt);
951 Int_t ns = (r ==
'I' || r ==
'i') ? 20 : 40;
953 if (etaAxis.GetXbins() && etaAxis.GetXbins()->GetArray())
954 hist =
new TH2D(Form(
"FMD%d%c_cache", d, r),
955 Form(
"FMD%d%c cache", d, r),
956 etaAxis.GetNbins(), etaAxis.GetXbins()->GetArray(),
957 ns, 0, TMath::TwoPi());
959 hist =
new TH2D(Form(
"FMD%d%c_cache", d, r),
960 Form(
"FMD%d%c cache", d, r),
961 etaAxis.GetNbins(), etaAxis.GetXmin(),
962 etaAxis.GetXmax(), ns, 0, TMath::TwoPi());
963 hist->SetXTitle(
"#eta");
964 hist->SetYTitle(
"#phi [radians]");
965 hist->SetZTitle(
"d^{2}N_{ch}/d#etad#phi");
967 hist->SetDirectory(0);
975 TAxis* xAxis = hist->GetXaxis();
976 if (etaAxis.GetXbins() && etaAxis.GetXbins()->GetArray())
977 xAxis->Set(etaAxis.GetNbins(), etaAxis.GetXbins()->GetArray());
979 xAxis->Set(etaAxis.GetNbins(), etaAxis.GetXmin(), etaAxis.GetXmax());
994 fFMD1i =
Make(1,
'I', etaAxis);
995 fFMD2i =
Make(2,
'I', etaAxis);
996 fFMD2o =
Make(2,
'O', etaAxis);
997 fFMD3i =
Make(3,
'I', etaAxis);
998 fFMD3o =
Make(3,
'O', etaAxis);
1010 if (!fFMD1i) fFMD1i =
Make(1,
'i', etaAxis);
else RebinEta(fFMD1i, etaAxis);
1011 if (!fFMD2i) fFMD2i =
Make(2,
'i', etaAxis);
else RebinEta(fFMD2i, etaAxis);
1012 if (!fFMD2o) fFMD2o =
Make(2,
'o', etaAxis);
else RebinEta(fFMD2o, etaAxis);
1013 if (!fFMD3i) fFMD3i =
Make(3,
'i', etaAxis);
else RebinEta(fFMD3i, etaAxis);
1014 if (!fFMD3o) fFMD3o =
Make(3,
'o', etaAxis);
else RebinEta(fFMD3o, etaAxis);
1027 if (fFMD1i) { fFMD1i->Reset(option); fFMD1i->ResetBit(
kSkipRing); }
1028 if (fFMD2i) { fFMD2i->Reset(option); fFMD2i->ResetBit(
kSkipRing); }
1029 if (fFMD2o) { fFMD2o->Reset(option); fFMD2o->ResetBit(
kSkipRing); }
1030 if (fFMD3i) { fFMD3i->Reset(option); fFMD3i->ResetBit(
kSkipRing); }
1031 if (fFMD3o) { fFMD3o->Reset(option); fFMD3o->ResetBit(
kSkipRing); }
1049 case 1:
return fFMD1i;
1050 case 2:
return (r ==
'I' || r ==
'i' ? fFMD2i : fFMD2o);
1051 case 3:
return (r ==
'I' || r ==
'i' ? fFMD3i : fFMD3o);
1071 list->SetName(fName.Data());
1107 return static_cast<TH1*
>(d->FindObject(name));
1116 if (lvl < msgLvl)
return;
1118 va_start(ap, format);
1126 if (fMsg.IsNull())
return;
1134 if (lvl < msgLvl)
return;
1137 va_start(ap, format);
1138 Format(msg, format, ap);
1147 static char buf[512];
1148 Int_t n = gROOT->GetDirLevel() + 2;
1149 for (
Int_t i = 0; i < n; i++) buf[i] =
' ';
1150 vsnprintf(&(buf[n]), 511-n, format, ap);
1158 msg[0] = (in > 0 ?
'>' : in < 0 ?
'<' :
'=');
1159 AliLog::Message(AliLog::kInfo, msg, 0, 0,
"PWGLF/forward", 0, 0);
1160 if (in > 0) gROOT->IncreaseDirLevel();
1161 else if (in < 0) gROOT->DecreaseDirLevel();
1165 : save(gErrorIgnoreLevel)
1167 gErrorIgnoreLevel = lvl;
1168 AliLog::SetModuleDebugLevel(
"ROOT", lvl);
1169 AliLog::SetGlobalDebugLevel(lvl);
1174 gErrorIgnoreLevel = save;
1175 AliLog::SetModuleDebugLevel(
"ROOT", save);
1176 AliLog::SetGlobalDebugLevel(save);
return jsonbuilder str().c_str()
static Short_t ParseMagneticField(Float_t field)
void Clear(Option_t *option="")
static TAxis * MakeFullIpZAxis(Int_t nCenter=20)
static const char * CenterOfMassEnergyString(UShort_t cms)
static void Message(Int_t lvl, Int_t msgLvl, const char *format,...)
static Double_t GetPhiFromStrip(Char_t ring, UShort_t strip, Double_t phi, Double_t xvtx, Double_t yvtx)
static UShort_t ParseCenterOfMassEnergy(UShort_t sys, Float_t cms)
void ReInit(const TAxis &etaAxis)
TString format
file names tag, basically the trigger and calorimeter combination
static Bool_t GetEtaPhi(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, const TVector3 &ip, Double_t &eta, Double_t &phi)
static Double_t GetSectorZ(UShort_t det, Char_t ring, UShort_t sec)
TList * list
TDirectory file where lists per trigger are stored in train ouput.
static void Format(TString &out, const char *format, va_list ap)
static Bool_t GetXYZ(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, const TVector3 &ip, TVector3 &pos)
static Bool_t GetEtaPhiFromStrip(Char_t r, UShort_t strip, Double_t &eta, Double_t &phi, Double_t ipX, Double_t ipY)
static AliAODEvent * GetAODEvent(AliAnalysisTaskSE *task)
#define ALIROOT_SVN_REVISION
static void PrintName(const char *name)
static const char * MagneticFieldString(Short_t field)
static TH2D * Make(UShort_t d, Char_t r, const TAxis &etaAxis)
static Double_t GetSectorPhi(UShort_t det, Char_t ring, UShort_t sec)
SuppressGuard(Int_t lvl=2000)
static Float_t GetCentralityCompat(const AliVEvent &event, const TString &method, Int_t &qual, Bool_t verbose)
Various utilities used in PWGLF/FORWARD.
static Double_t GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Double_t zvtx)
static void Output(int in, TString &msg)
static void GetParameter(TObject *o, UShort_t &value)
static void PrintTask(const TObject &o)
TH2D * Get(UShort_t d, Char_t r) const
static TObject * MakeParameter(const char *name, UShort_t value)
TH1 * Make(UShort_t d, Char_t r)
static Float_t BeamRapidity(Float_t beam, UShort_t z, UShort_t a)
static UShort_t ParseCollisionSystem(const char *sys)
TH1 * GetOutputHist(const TList *d, const char *name) const
static Double_t GetStripR(Char_t ring, UShort_t strip)
static UShort_t CheckForAOD()
static Float_t GetCentrality(const AliVEvent &event, const TString &method, Int_t &qual, Bool_t verbose=false)
void Init(const TAxis &etaAxis)
static ULong_t AliROOTBranch()
static void MakeLogScale(Int_t nBins, Int_t minOrder, Int_t maxOrder, TArrayD &bins)
static void PrintField(const char *name, const char *value,...)
TList * DefineOutputList(TList *d) const
void Delete(Option_t *opt="")
static Float_t CenterOfMassEnergy(Float_t beam, UShort_t z1, UShort_t a1, Short_t z2=-1, Short_t a2=-1)
static Float_t CenterOfMassRapidity(UShort_t z1, UShort_t a1, Short_t z2=-1, Short_t a2=-1)
static const char * CollisionSystemString(UShort_t sys)
static Bool_t CheckForTask(const char *clsOrName, Bool_t cls=true)
DebugGuard(Int_t lvl, Int_t msgLvl, const char *format,...)
static ULong_t AliROOTRevision()
static Float_t GetCentralityMult(const AliVEvent &event, const TString &method, Int_t &qual, Bool_t verbose=false)
static void RebinEta(TH2D *hist, const TAxis &etaAxis)
TList * GetOutputList(const TList *d) const