1#ifndef PAIRANALYSISHISTOS_H
2#define PAIRANALYSISHISTOS_H
45 const Double_t* xmax = 0,
Int_t chunksize = 1024 * 16)
46 : THnSparseF(name, title, dim, nbins, xmin, xmax, chunksize)
58 if (!obj->TestBit(kNotDeleted)) {
break; }
80 class PairAnalysisHistos :
public TNamed {
83 PairAnalysisHistos(
const char* name,
const char* title);
84 virtual ~PairAnalysisHistos();
88 kNoAutoFill = 1000000000,
100 void SetPrecision(Eprecision precision) { fPrecision = precision; }
101 TBits* GetUsedVars()
const {
return fUsedVars; }
102 void SetReservedWords(
const char* words);
103 void AddClass(
const char* histClass);
104 TString UserHistogram(
const char* histClass, TObject* hist);
105 static void AdaptNameTitle(TH1* hist,
const char* histClass);
106 static void AdaptNameTitle(THnBase* hist,
const char* histClass);
107 static void StoreVariables(TObject* obj, UInt_t valType[20]);
108 static void StoreVariables(TH1* obj, UInt_t valType[20]);
109 static void StoreVariables(THnBase* obj, UInt_t valType[20]);
111 void UserHistogram(
const char* histClass,
Int_t ndim, TObjArray* limits, UInt_t* vars,
112 UInt_t valTypeW =
static_cast<UInt_t
>(Eoption::kNoWeights));
113 void AddSparse(
const char* histClass,
Int_t ndim, TObjArray* limits, UInt_t* vars,
114 UInt_t valTypeW =
static_cast<UInt_t
>(Eoption::kNoWeights));
115 void AddSparse(
const char* histClass,
Int_t ndim, TObjArray* limits, TFormula** vars,
116 UInt_t valTypeW =
static_cast<UInt_t
>(Eoption::kNoWeights));
119 template<
typename valX,
typename valY,
typename valZ,
typename valP,
typename valW>
120 TString UserObject(
const char* histClass,
const char* name,
const char* title,
const TVectorD*
const binsX,
121 valX valTypeX,
const TVectorD*
const binsY, valY valTypeY,
const TVectorD*
const binsZ,
122 valZ valTypeZ, valP valTypeP, valW valTypeW, TString option);
125 template<
typename valX,
typename valW>
126 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX, valW valTypeW)
128 return UserObject(histClass,
"",
"", binsX, valTypeX, 0x0,
static_cast<UInt_t
>(Eoption::kNo), 0x0,
129 static_cast<UInt_t
>(Eoption::kNo),
static_cast<UInt_t
>(Eoption::kNoProfile), valTypeW,
"");
132 template<
typename valX>
133 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX)
135 return AddHistogram(histClass, binsX, valTypeX,
static_cast<UInt_t
>(Eoption::kNoWeights));
138 template<
typename valX,
typename valP,
typename valW>
139 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX, valP valTypeP, TString option,
142 return UserObject(histClass,
"",
"", binsX, valTypeX, 0x0, valTypeP, 0x0,
static_cast<UInt_t
>(Eoption::kNo),
143 valTypeP, valTypeW, option);
146 template<
typename valX,
typename valP>
147 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX, valP valTypeP, TString option)
149 return AddProfile(histClass, binsX, valTypeX, valTypeP, option,
static_cast<UInt_t
>(Eoption::kNoWeights));
153 template<
typename valX,
typename valY,
typename valW>
154 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
155 valY valTypeY, valW valTypeW)
157 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, 0x0,
static_cast<UInt_t
>(Eoption::kNo),
158 static_cast<UInt_t
>(Eoption::kNoProfile), valTypeW,
"");
161 template<
typename valX,
typename valY>
162 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
165 return AddHistogram(histClass, binsX, valTypeX, binsY, valTypeY,
static_cast<UInt_t
>(Eoption::kNoWeights));
168 template<
typename valX,
typename valY,
typename valP,
typename valW>
169 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
170 valY valTypeY, valP valTypeP, TString option, valW valTypeW)
172 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, 0x0, valTypeP, valTypeP, valTypeW, option);
175 template<
typename valX,
typename valY,
typename valP>
176 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
177 valY valTypeY, valP valTypeP, TString option)
179 return AddProfile(histClass, binsX, valTypeX, binsY, valTypeY, valTypeP, option,
180 static_cast<UInt_t
>(Eoption::kNoWeights));
184 template<
typename valX,
typename valY,
typename valZ,
typename valW>
185 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
186 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valW valTypeW)
188 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ,
189 static_cast<UInt_t
>(Eoption::kNoProfile), valTypeW,
"");
192 template<
typename valX,
typename valY,
typename valZ>
193 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
194 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ)
196 return AddHistogram(histClass, binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ,
197 static_cast<UInt_t
>(Eoption::kNoWeights));
201 template<
typename valX,
typename valY,
typename valZ,
typename valP,
typename valW>
202 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
203 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valP valTypeP, TString option,
206 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ, valTypeP, valTypeW, option);
209 template<
typename valX,
typename valY,
typename valZ,
typename valP>
210 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
211 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valP valTypeP, TString option)
213 return AddProfile(histClass, binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ, valTypeP, option,
214 static_cast<UInt_t
>(Eoption::kNoWeights));
219 void FillClass(TString histClass,
const Double_t* values);
220 static void FillValues(TObject* obj,
const Double_t* values);
221 static void FillValues(TH1* obj,
const Double_t* values);
222 static void FillValues(THnBase* obj,
const Double_t* values);
225 void ReadFromFile(
const char* file =
"histos.root",
const char*
task =
"",
const char* config =
"");
226 void DumpToFile(
const char* file =
"histos.root");
227 void SetList(TList*
const list) { fList = list; }
228 TList* GetList()
const {
return fList; }
229 Bool_t SetCutClass(
const char* cutClass);
230 Bool_t HasHistClass(TString histClass)
const {
return fHistoList.FindObject(histClass.Data()); }
231 void SetHistogramList(THashList& list,
Bool_t setOwner = kTRUE);
232 void ResetHistogramList() { fHistoList.Clear(); }
233 const THashList* GetHistogramList()
const {
return &fHistoList; }
235 TObject* GetHist(
const char* histClass,
const char* name)
const;
236 TH1* GetHistogram(
const char* histClass,
const char* name)
const;
237 TObject* GetHist(
const char* cutClass,
const char* histClass,
const char* name)
const;
238 TH1* GetHistogram(
const char* cutClass,
const char* histClass,
const char* name)
const;
241 PairAnalysisMetaData* GetMetaData()
const {
return fMetaData; }
243 virtual void Print(
const Option_t* option =
"")
const;
244 virtual void Draw(
const Option_t* option =
"");
245 virtual TObjArray* DrawSame(TString histName, TString option =
"leg can", TString histClassDenom =
"",
246 THashList* listDenom = 0x0);
247 virtual TObjArray* DrawTaskSame(TString histName, TString opt =
"leg can", TString histClassDenom =
"",
248 TString taskDenom =
"");
252 THashList fHistoList;
257 TFormula*
GetFormula(
const char* name,
const char* formula);
258 TH1* GetTHist(
const char* histClass,
const char* name,
const char* title,
const TVectorD*
const binsX,
259 const TVectorD*
const binsY,
const TVectorD*
const binsZ);
260 TH1* GetTProf(
const char* histClass,
const char* name,
const char* title,
const TVectorD*
const binsX,
261 const TVectorD*
const binsY,
const TVectorD*
const binsZ, TString option =
"i");
263 void FillVarArray(TObject* obj, UInt_t* valType);
265 PairAnalysisMetaData* fMetaData;
270 TString* fReservedWords;
271 void UserHistogramReservedWords(
const char* histClass,
const TObject* hist);
272 void FillClass(THashTable* classTable,
Int_t nValues, Double_t* values);
274 void PrintPDF(Option_t* opt);
275 void PrintStructure()
const;
277 Bool_t IsHistogramOk(
const char* classTable,
const char* name);
278 Eprecision fPrecision;
280 PairAnalysisHistos(
const PairAnalysisHistos& hist);
281 PairAnalysisHistos& operator=(
const PairAnalysisHistos& hist);
283 ClassDef(PairAnalysisHistos, 3)
286template<
typename valX,
typename valY,
typename valZ,
typename valP,
typename valW>
287TString PairAnalysisHistos::UserObject(
const char* histClass,
const char* name,
const char* title,
288 const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
289 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valP valTypeP,
290 valW valTypeW, TString option)
298 if (
typeid(valTypeP) ==
typeid(UInt_t) && (uintptr_t) valTypeP ==
static_cast<UInt_t
>(Eoption::kNoProfile))
299 hist = GetTHist(histClass, name, title, binsX, binsY, binsZ);
301 hist = GetTProf(histClass, name, title, binsX, binsY, binsZ, option);
309 UInt_t valType[20] = {0};
311 func.Form(
"%d", valTypeX);
312 if (!func.Atoi()) std::cout << func << std::endl;
314 valType[0] = func.Atoi();
317 func.Form(
"%d", valTypeY);
318 if (!func.Atoi()) std::cout << func << std::endl;
320 valType[1] = func.Atoi();
323 func.Form(
"%d", valTypeZ);
324 if (!func.Atoi()) std::cout << func << std::endl;
326 valType[2] = func.Atoi();
329 func.Form(
"%d", valTypeP);
330 if (!func.Atoi()) std::cout << func << std::endl;
332 valType[3] = func.Atoi();
335 func2.Form(
"%d", valTypeX);
337 func.Form(
"%d", valTypeW);
338 if (!func.Atoi()) std::cout << func << std::endl;
339 else if (func2.Atoi() !=
static_cast<UInt_t
>(Eoption::kNoWeights)) {
340 hist->SetUniqueID(func.Atoi());
341 fUsedVars->SetBitNumber(func.Atoi(), kTRUE);
345 StoreVariables(hist, valType);
346 for (
Int_t i = 0; i < 4; i++)
347 fUsedVars->SetBitNumber(valType[i], kTRUE);
350 AdaptNameTitle(hist, histClass);
353 TString key = hist->GetName();
366 Bool_t isReserved = fReservedWords->Contains(histClass);
367 if (func2.Atoi() && func2.Atoi() ==
static_cast<UInt_t
>(Eoption::kNoAutoFill)) hist->SetUniqueID(func2.Atoi());
368 if (isReserved) UserHistogramReservedWords(histClass, hist);
370 UserHistogram(histClass, hist);
ClassImp(CbmConverterManager)
TList * GetListOfFunctions() const
PairAnalysisHn(const PairAnalysisHn &hist)
PairAnalysisHn(const char *name, const char *title, Int_t dim, const Int_t *nbins, const Double_t *xmin=0, const Double_t *xmax=0, Int_t chunksize=1024 *16)
PairAnalysisHn & operator=(const PairAnalysisHn &hist)
TFormula * GetFormula(const char *name, const char *formula)
@ Print
Run starttime in nanosecond.
T ReadFromFile(fs::path path)