]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/ThermalFits/AliParticleYield.h
Fix
[u/mrichter/AliRoot.git] / PWGLF / ThermalFits / AliParticleYield.h
CommitLineData
2f86df33 1#ifndef _ALIPARTICLEYIELD_H_
2#define _ALIPARTICLEYIELD_H_
3
4// AliParticleYield
5// This class implements a container for particle yields results, to
6// be used e.g. in thermal model fits, with utility methods to
7// read/write to ASCII files or root trees
8ac70929 8// Author: Michele Floris, michele.floris@cern.ch
2f86df33 9
10#include "TObject.h"
11#include "TString.h"
589e4fb0 12#include "TCut.h"
2f86df33 13
14class TClonesArray;
15class TTree;
2f86df33 16class AliParticleYield : public TObject
17{
18public:
19
20 enum AliPYCSystem_t {kCSpp = 0,
21 kCSpPb = 1,
22 kCSPbPb = 2 } ;
23
24 static const char * kSystemString[];
25
26 enum AliPYStatusCode_t {
27 kSCPublished = 0,
28 kSCPreliminary = 1,
29 kSCFinalNotPublished = 2,
30 kSCMayChange = 3,
31 };
32
33 static const char * kStatusString[];
34
35 enum AliPYMeasurementType_t { // this is a bit mask: more than one bit can be one (be careful not to set mutually exclusive ones).
f10825a3 36 // Type of measurements
2f86df33 37 kTypeLinearInterpolation = 0x1,
f10825a3 38 kTypeParticleRatio = 0x2, // If true, this is a ratio of 2 particles where the propagation of uncertainty was properly taken into account.
39 kTypeAverageAndRefit = 0x4, // this means that the measurement has been obtained summing several spectra in smaller centality bins (weihgted by the width of the centrality bin) and refitting them
40 kTypeExtrPionRatio = 0x8, // Extrapolated from a different centrality bin, assumin the ratio to pions is constant
41 kTypeExtrFit = 0x20, // Extrapolated fitting the centrality dependence vs npart
a573732b 42
2f86df33 43 // Type of errors
44 kTypeOnlyTotError = 0x10, // If on, only the total error is returned as "GetSystError". GetStatError should be set to 0;
8ac70929 45
46 // Additional flags
47 kTypeAveragePartAntiPart = 0x100, // Can only be set if isSum = 1. It indicates that it is an averrage rather than a sum TODO: add separate bits for different averages (e.g. quadratic)?
48
2f86df33 49 };
50
51 AliParticleYield();
52 AliParticleYield(Int_t pdg, Int_t system, Float_t sqrts, Float_t value, Float_t stat, Float_t syst, Float_t norm, Float_t ymin, Float_t ymax, Int_t status, Int_t type, TString centr, Int_t isSum = 0, TString tag = "ALICE");
3e8c4dd8 53 AliParticleYield(Int_t pdg, Int_t system, Float_t sqrts, Float_t value, Float_t stat, Float_t syst, Float_t normPos, Float_t normNeg, Float_t ymin, Float_t ymax, Int_t status, Int_t type, TString centr, Int_t isSum = 0, TString tag = "ALICE");
2f86df33 54 virtual ~AliParticleYield();
55 AliParticleYield(const AliParticleYield& part);
56
57 // IO
58 static TClonesArray * ReadFromASCIIFile(const char * fileName, const char * separators = " \t");
59 static TTree * ReadFromASCIIFileAsTree(const char * fileName, const char * separators = " \t");
60 static void SaveAsASCIIFile(TClonesArray * arr, const char * filename, const char * separator = " ", Int_t colWidth = 7);
5a633e19 61 static void WriteThermusFile(TClonesArray * arr, const char * filename, Int_t colWidth = 10);
589e4fb0 62 static TClonesArray * GetEntriesMatchingSelection(TTree * tree, TCut selection);
63 static TTree * GetTreeFromArray(TClonesArray * arr) ;
2f86df33 64
65 // Misc helpers
66 Bool_t CheckTypeConsistency() const;
16163c99 67 Bool_t CheckForDuplicates(TClonesArray * arr) ;
68 virtual void Print (Option_t * opt = "") const;
2f86df33 69 static Float_t GetError(TString error, Float_t yield) ;
5a633e19 70 static const char * FormatCol(const char * text, Int_t width, const char * sep =" ") ;
2f86df33 71 static Double_t RoundToSignificantFigures(double num, int n) ;
90132fab 72 static AliParticleYield * FindParticle(TClonesArray * arr, Int_t pdg, Int_t system, Float_t sqrts, TString centrality = "", Int_t isSum = -1, Int_t status = -1, Int_t pdg2 = 0);
73 static AliParticleYield * FindRatio (TClonesArray * arr, Int_t pdg, Int_t pdg2, Int_t system, Float_t sqrts, TString centrality="", Int_t isSum = -1, Int_t status = -1) { return FindParticle(arr, pdg, system, sqrts, centrality, isSum, status, pdg2); }
16163c99 74 Bool_t operator==(const AliParticleYield& rhs);
75 Bool_t IsTheSameMeasurement(AliParticleYield &rhs);
90132fab 76 static AliParticleYield * Divide(AliParticleYield * part1, AliParticleYield * part2, Double_t correlatedError = 0, Option_t * opt="");
77 static AliParticleYield * Add (AliParticleYield * part1, AliParticleYield * part2, Double_t correlatedError = 0, Option_t * opt="");
78 void Scale(Float_t scale) ;
2f86df33 79
80 // Getters
81 TString GetCentr() const{ return fCentr ;}
82 Int_t GetCollisionSystem() const{ return fCollisionSystem ;}
83 Int_t GetIsSum() const{ return fIsSum ;}
84 Int_t GetPdgCode() const{ return fPdgCode ;}
85 Int_t GetPdgCode2() const{ return fPdgCode2; }
86 Float_t GetSqrtS() const{ return fSqrtS ;}
87 Float_t GetYield() const{ return fYield ;}
3e8c4dd8 88 Float_t GetNormError() const;
89 Float_t GetNormErrorNeg() const{ return fNormErrorNeg; }
90 Float_t GetNormErrorPos() const{ return fNormErrorPos; }
91
2f86df33 92 TString GetPartName() const{ return fPartName ;}
93 Float_t GetStatError() const{ return fStatError ;}
94 Int_t GetStatus() const{ return fStatus ;}
95 Float_t GetSystError() const{ return fSystError ;}
96 Float_t GetYMax() const{ return fYMax ;}
97 Float_t GetYMin() const{ return fYMin ;}
98 UInt_t GetMeasurementType() const{ return fMeasurementType ;}
99 TString GetTag() const{ return fTag; }
100
101 const char * GetLatexName(Int_t pdg = 0) const;
102 Float_t GetTotalError(Bool_t includeNormalization = kFALSE) const;
103
87381af7 104 Bool_t IsTypeMeasured() const{ CheckTypeConsistency(); return (!(fMeasurementType & kTypeLinearInterpolation) && !(fMeasurementType & kTypeExtrPionRatio));}
2f86df33 105 Bool_t IsTypeRatio() const{ CheckTypeConsistency(); return (fMeasurementType & kTypeParticleRatio);}
87381af7 106 Bool_t IsTypeExtrapolatedWithPionRatio() const { CheckTypeConsistency(); return (fMeasurementType & kTypeExtrPionRatio);}
2f86df33 107 Bool_t IsTypeLinearInterp() const{ CheckTypeConsistency(); return fMeasurementType & kTypeLinearInterpolation;}
108 Bool_t IsTypeOnlyTotErr() const{ CheckTypeConsistency(); return fMeasurementType & kTypeOnlyTotError; }
101d9a81 109 Bool_t IsTypeAverage() const{CheckTypeConsistency(); return fMeasurementType & kTypeAveragePartAntiPart;}
2f86df33 110
111 static Int_t GetSignificantDigits() { return fSignificantDigits; }
112
113 // Setters
114 void SetCentr (TString var ) { fCentr = var ;}
115 void SetCollisionSystem (AliPYCSystem_t var ) { fCollisionSystem = var ;}
116 void SetIsSum (Int_t var ) { fIsSum = var ;}
117 void SetPdgCode (Int_t var ) { fPdgCode = var ; SetPartName(var);}
118 void SetPdgCode2 (Int_t var ) { fPdgCode2 = var; }
119 void SetSqrtS (Float_t var ) { fSqrtS = var ;}
120 void SetYield (Float_t var ) { fYield = var ;}
3e8c4dd8 121 void SetNormError (Float_t var ) { fNormErrorPos = var ; fNormErrorNeg=0;};
122 void SetNormErrorNeg (Float_t var ) { fNormErrorNeg = var;}
123 void SetNormErrorPos (Float_t var ) { fNormErrorPos = var;}
2f86df33 124 void SetPartName (TString var ) { fPartName = var; SetPdgCode(var); }
125 void SetStatError (Float_t var ) { fStatError = var ;}
126 void SetStatus (AliPYStatusCode_t var ) { fStatus = var ;}
127 void SetSystError (Float_t var ) { fSystError = var ;}
128 void SetYMax (Float_t var ) { fYMax = var ;}
129 void SetYMin (Float_t var ) { fYMin = var ;}
130 void SetMeasurementType (UInt_t var ) { fMeasurementType = var ;}
131 void SetTag (TString var ) { fTag = var;}
132 //This 2 additional setters will ensure consistency between the pdg code and the name of the particle
133 void SetPartName(Int_t pdgCode);
134 void SetPdgCode (TString partName);
135
136 void SetTypeBits(UInt_t mask) { fMeasurementType |= mask; } // This switches on the bits passed. Does not affect the others! If you want to set the Whole mask, use SetMeasurementType
137
138 static void SetSignificantDigits (Int_t var) { fSignificantDigits = var;}
90132fab 139
2f86df33 140
141
142
143private:
144
90132fab 145 static Bool_t Compare2Floats(Float_t a, Float_t b) ;
146 static Double_t SumErrors(AliParticleYield * part1, AliParticleYield * part2, Int_t error, Option_t * opt) ;
87381af7 147 void CombineMetadata(AliParticleYield *part1, AliParticleYield*part2, const char * pdgSep) ;
90132fab 148
16163c99 149
2f86df33 150 Int_t fPdgCode; // PdgCode
151 Int_t fPdgCode2; // The PdgCode of the second particle, only needed in case of a ratio
152 TString fPartName; // Particle name (redundant, we also have PDG code)
153 Int_t fCollisionSystem; // Collision System, see the AliPYCSystem_t enum for possible values
154 Float_t fSqrtS; // center of mass energy, in GeV
155 Float_t fYield; // The yield
156 Float_t fStatError; // StatError
157 Float_t fSystError; // SystError
3e8c4dd8 158 Float_t fNormErrorPos; // Normalization error, if the error is simmetric, this is used as the symmetric error. Otherwise it is just the positive one
159 Float_t fNormErrorNeg; // Normalization error (negative)
2f86df33 160 Float_t fYMin; // min rapidity cut
161 Float_t fYMax; // max rapidity cut
162 Int_t fStatus; // Status code, to determine the quality of the measurement, see AliPYStatusCode_t for possible values
163
3e8c4dd8 164
165
2f86df33 166 UInt_t fMeasurementType; // Measurement Type, e.g. actually measured, interpolated from 2 centrality bins or only total error given, etc. THIS IS A BIT MASK see AliPYMeasurementType_t for possible values and the IsType* Methods for easy access. Be carefull not to set mutually exclusive values
167
168 TString fCentr; // Centrality. The format is estimator 3-digits id, bin low-edge 2 digits, bin hi-edge 2 digits , e.g. V0A0005
169 Int_t fIsSum; // A flag which indicates if the yield is for a single charge or for the sum. 0 = single charge, 1 = particle + antiparticle
170 TString fTag; // Generic text tag (to be used e.g. for the name of the experiment)
171
172
173 static Int_t fSignificantDigits; // Significant Digits to be used in values and errors
16163c99 174 static Float_t fEpsilon; // Used for float conparisons
2f86df33 175
87381af7 176 ClassDef(AliParticleYield,2)
2f86df33 177};
178
179
180#endif /* _ALIPARTICLEYIELD_H_ */