1 #ifndef PAIRANALYSISHISTOS_H
2 #define PAIRANALYSISHISTOS_H
18 #ifdef HAVE_UINT8_T_HEADER_FILE
19 #include <_types/_uint16_t.h>
20 #include <_types/_uint32_t.h>
21 #include <_types/_uint64_t.h>
22 #include <_types/_uint8_t.h>
34 #include <THashList.h>
36 #include <THnSparse.h>
58 const Double_t* xmin = 0,
59 const Double_t* xmax = 0,
60 Int_t chunksize = 1024 * 16)
61 : THnSparseF(name, title, dim, nbins, xmin, xmax, chunksize)
70 if (!obj->TestBit(kNotDeleted)) {
break; }
91 class PairAnalysisHistos :
public TNamed {
94 PairAnalysisHistos(
const char* name,
const char* title);
95 virtual ~PairAnalysisHistos();
98 kNoAutoFill = 1000000000,
103 enum Eprecision { kFloat = 0, kDouble };
106 void SetPrecision(Eprecision precision) { fPrecision = precision; }
107 TBits* GetUsedVars()
const {
return fUsedVars; }
108 void SetReservedWords(
const char* words);
109 void AddClass(
const char* histClass);
110 TString UserHistogram(
const char* histClass, TObject* hist);
111 static void AdaptNameTitle(TH1* hist,
const char* histClass);
112 static void AdaptNameTitle(THnBase* hist,
const char* histClass);
113 static void StoreVariables(TObject* obj, UInt_t valType[20]);
114 static void StoreVariables(TH1* obj, UInt_t valType[20]);
115 static void StoreVariables(THnBase* obj, UInt_t valType[20]);
117 void UserHistogram(
const char* histClass,
121 UInt_t valTypeW = kNoWeights);
122 void AddSparse(
const char* histClass,
126 UInt_t valTypeW = kNoWeights);
127 void AddSparse(
const char* histClass,
131 UInt_t valTypeW = kNoWeights);
134 template<
typename valX,
139 TString UserObject(
const char* histClass,
142 const TVectorD*
const binsX,
144 const TVectorD*
const binsY,
146 const TVectorD*
const binsZ,
153 template<
typename valX,
typename valW>
154 TString AddHistogram(
const char* histClass,
155 const TVectorD*
const binsX,
158 return UserObject(histClass,
172 template<
typename valX>
173 TString AddHistogram(
const char* histClass,
174 const TVectorD*
const binsX,
176 return AddHistogram(histClass, binsX, valTypeX, (UInt_t) kNoWeights);
179 template<
typename valX,
typename valP,
typename valW>
180 TString AddProfile(
const char* histClass,
181 const TVectorD*
const binsX,
186 return UserObject(histClass,
200 template<
typename valX,
typename valP>
201 TString AddProfile(
const char* histClass,
202 const TVectorD*
const binsX,
207 histClass, binsX, valTypeX, valTypeP, option, (UInt_t) kNoWeights);
211 template<
typename valX,
typename valY,
typename valW>
212 TString AddHistogram(
const char* histClass,
213 const TVectorD*
const binsX,
215 const TVectorD*
const binsY,
218 return UserObject(histClass,
232 template<
typename valX,
typename valY>
233 TString AddHistogram(
const char* histClass,
234 const TVectorD*
const binsX,
236 const TVectorD*
const binsY,
239 histClass, binsX, valTypeX, binsY, valTypeY, (UInt_t) kNoWeights);
242 template<
typename valX,
typename valY,
typename valP,
typename valW>
243 TString AddProfile(
const char* histClass,
244 const TVectorD*
const binsX,
246 const TVectorD*
const binsY,
251 return UserObject(histClass,
265 template<
typename valX,
typename valY,
typename valP>
266 TString AddProfile(
const char* histClass,
267 const TVectorD*
const binsX,
269 const TVectorD*
const binsY,
273 return AddProfile(histClass,
280 (UInt_t) kNoWeights);
284 template<
typename valX,
typename valY,
typename valZ,
typename valW>
285 TString AddHistogram(
const char* histClass,
286 const TVectorD*
const binsX,
288 const TVectorD*
const binsY,
290 const TVectorD*
const binsZ,
293 return UserObject(histClass,
307 template<
typename valX,
typename valY,
typename valZ>
308 TString AddHistogram(
const char* histClass,
309 const TVectorD*
const binsX,
311 const TVectorD*
const binsY,
313 const TVectorD*
const binsZ,
315 return AddHistogram(histClass,
322 (UInt_t) kNoWeights);
326 template<
typename valX,
331 TString AddProfile(
const char* histClass,
332 const TVectorD*
const binsX,
334 const TVectorD*
const binsY,
336 const TVectorD*
const binsZ,
341 return UserObject(histClass,
355 template<
typename valX,
typename valY,
typename valZ,
typename valP>
356 TString AddProfile(
const char* histClass,
357 const TVectorD*
const binsX,
359 const TVectorD*
const binsY,
361 const TVectorD*
const binsZ,
365 return AddProfile(histClass,
374 (UInt_t) kNoWeights);
379 void FillClass(TString histClass,
const Double_t* values);
380 static void FillValues(TObject* obj,
const Double_t* values);
381 static void FillValues(TH1* obj,
const Double_t* values);
382 static void FillValues(THnBase* obj,
const Double_t* values);
385 void ReadFromFile(
const char* file =
"histos.root",
386 const char*
task =
"",
387 const char* config =
"");
388 void DumpToFile(
const char* file =
"histos.root");
389 void SetList(TList*
const list) { fList = list; }
390 TList* GetList()
const {
return fList; }
391 Bool_t SetCutClass(
const char* cutClass);
392 Bool_t HasHistClass(TString histClass)
const {
393 return fHistoList.FindObject(histClass.Data());
395 void SetHistogramList(THashList& list, Bool_t setOwner = kTRUE);
396 void ResetHistogramList() { fHistoList.Clear(); }
397 const THashList* GetHistogramList()
const {
return &fHistoList; }
399 TObject* GetHist(
const char* histClass,
const char* name)
const;
400 TH1* GetHistogram(
const char* histClass,
const char* name)
const;
402 GetHist(
const char* cutClass,
const char* histClass,
const char* name)
const;
403 TH1* GetHistogram(
const char* cutClass,
404 const char* histClass,
405 const char* name)
const;
410 virtual void Print(
const Option_t* option =
"")
const;
411 virtual void Draw(
const Option_t* option =
"");
412 virtual TObjArray* DrawSame(TString histName,
413 TString option =
"leg can",
414 TString histClassDenom =
"",
415 THashList* listDenom = 0x0);
416 virtual TObjArray* DrawTaskSame(TString histName,
417 TString opt =
"leg can",
418 TString histClassDenom =
"",
419 TString taskDenom =
"");
423 THashList fHistoList;
428 TFormula*
GetFormula(
const char* name,
const char* formula);
429 TH1* GetTHist(
const char* histClass,
432 const TVectorD*
const binsX,
433 const TVectorD*
const binsY,
434 const TVectorD*
const binsZ);
435 TH1* GetTProf(
const char* histClass,
438 const TVectorD*
const binsX,
439 const TVectorD*
const binsY,
440 const TVectorD*
const binsZ,
441 TString option =
"i");
443 void FillVarArray(TObject* obj, UInt_t* valType);
450 TString* fReservedWords;
451 void UserHistogramReservedWords(
const char* histClass,
const TObject* hist);
452 void FillClass(THashTable* classTable, Int_t nValues, Double_t* values);
454 void PrintPDF(Option_t* opt);
455 void PrintStructure()
const;
457 Bool_t IsHistogramOk(
const char* classTable,
const char* name);
458 Eprecision fPrecision;
460 PairAnalysisHistos(
const PairAnalysisHistos& hist);
461 PairAnalysisHistos& operator=(
const PairAnalysisHistos& hist);
463 ClassDef(PairAnalysisHistos, 3)
466 template<
typename valX,
471 TString PairAnalysisHistos::UserObject(
const char* histClass,
474 const TVectorD*
const binsX,
476 const TVectorD*
const binsY,
478 const TVectorD*
const binsZ,
489 if (
typeid(valTypeP) ==
typeid(UInt_t) && (uintptr_t) valTypeP == kNoProfile)
490 hist = GetTHist(histClass, name, title, binsX, binsY, binsZ);
492 hist = GetTProf(histClass, name, title, binsX, binsY, binsZ, option);
500 UInt_t valType[20] = {0};
504 hist->GetListOfFunctions()->Add(
GetFormula(
"xFormula", func));
506 valType[0] = func.Atoi();
511 hist->GetListOfFunctions()->Add(
GetFormula(
"yFormula", func));
513 valType[1] = func.Atoi();
518 hist->GetListOfFunctions()->Add(
GetFormula(
"zFormula", func));
520 valType[2] = func.Atoi();
525 hist->GetListOfFunctions()->Add(
GetFormula(
"pFormula", func));
527 valType[3] = func.Atoi();
534 hist->GetListOfFunctions()->Add(
GetFormula(
"wFormula", func));
535 else if (func2.Atoi() != kNoWeights) {
536 hist->SetUniqueID(func.Atoi());
537 fUsedVars->SetBitNumber(func.Atoi(), kTRUE);
541 StoreVariables(hist, valType);
542 for (Int_t
i = 0;
i < 4;
i++)
543 fUsedVars->SetBitNumber(valType[
i], kTRUE);
546 AdaptNameTitle(hist, histClass);
549 TString key = hist->GetName();
562 Bool_t isReserved = fReservedWords->Contains(histClass);
563 if (func2.Atoi() && func2.Atoi() == kNoAutoFill)
564 hist->SetUniqueID(func2.Atoi());
566 UserHistogramReservedWords(histClass, hist);
568 UserHistogram(histClass, hist);