1#ifndef PAIRANALYSISHISTOS_H
2#define PAIRANALYSISHISTOS_H
46 inline PairAnalysisHn(
const char* name,
const char* title, Int_t dim,
const Int_t* nbins,
const Double_t* xmin = 0,
47 const Double_t* xmax = 0, Int_t chunksize = 1024 * 16)
48 : THnSparseF(name, title, dim, nbins, xmin, xmax, chunksize)
60 if (!obj->TestBit(kNotDeleted)) {
break; }
82 class PairAnalysisHistos :
public TNamed {
85 PairAnalysisHistos(
const char* name,
const char* title);
86 virtual ~PairAnalysisHistos();
90 kNoAutoFill = 1000000000,
102 void SetPrecision(Eprecision precision) { fPrecision = precision; }
103 TBits* GetUsedVars()
const {
return fUsedVars; }
104 void SetReservedWords(
const char* words);
105 void AddClass(
const char* histClass);
106 TString UserHistogram(
const char* histClass, TObject* hist);
107 static void AdaptNameTitle(TH1* hist,
const char* histClass);
108 static void AdaptNameTitle(THnBase* hist,
const char* histClass);
109 static void StoreVariables(TObject* obj, UInt_t valType[20]);
110 static void StoreVariables(TH1* obj, UInt_t valType[20]);
111 static void StoreVariables(THnBase* obj, UInt_t valType[20]);
113 void UserHistogram(
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, UInt_t* vars,
116 UInt_t valTypeW =
static_cast<UInt_t
>(Eoption::kNoWeights));
117 void AddSparse(
const char* histClass, Int_t ndim, TObjArray* limits, TFormula** vars,
118 UInt_t valTypeW =
static_cast<UInt_t
>(Eoption::kNoWeights));
121 template<
typename valX,
typename valY,
typename valZ,
typename valP,
typename valW>
122 TString UserObject(
const char* histClass,
const char* name,
const char* title,
const TVectorD*
const binsX,
123 valX valTypeX,
const TVectorD*
const binsY, valY valTypeY,
const TVectorD*
const binsZ,
124 valZ valTypeZ, valP valTypeP, valW valTypeW, TString option);
127 template<
typename valX,
typename valW>
128 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX, valW valTypeW)
130 return UserObject(histClass,
"",
"", binsX, valTypeX, 0x0,
static_cast<UInt_t
>(Eoption::kNo), 0x0,
131 static_cast<UInt_t
>(Eoption::kNo),
static_cast<UInt_t
>(Eoption::kNoProfile), valTypeW,
"");
134 template<
typename valX>
135 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX)
137 return AddHistogram(histClass, binsX, valTypeX,
static_cast<UInt_t
>(Eoption::kNoWeights));
140 template<
typename valX,
typename valP,
typename valW>
141 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX, valP valTypeP, TString option,
144 return UserObject(histClass,
"",
"", binsX, valTypeX, 0x0, valTypeP, 0x0,
static_cast<UInt_t
>(Eoption::kNo),
145 valTypeP, valTypeW, option);
148 template<
typename valX,
typename valP>
149 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX, valP valTypeP, TString option)
151 return AddProfile(histClass, binsX, valTypeX, valTypeP, option,
static_cast<UInt_t
>(Eoption::kNoWeights));
155 template<
typename valX,
typename valY,
typename valW>
156 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
157 valY valTypeY, valW valTypeW)
159 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, 0x0,
static_cast<UInt_t
>(Eoption::kNo),
160 static_cast<UInt_t
>(Eoption::kNoProfile), valTypeW,
"");
163 template<
typename valX,
typename valY>
164 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
167 return AddHistogram(histClass, binsX, valTypeX, binsY, valTypeY,
static_cast<UInt_t
>(Eoption::kNoWeights));
170 template<
typename valX,
typename valY,
typename valP,
typename valW>
171 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
172 valY valTypeY, valP valTypeP, TString option, valW valTypeW)
174 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, 0x0, valTypeP, valTypeP, valTypeW, option);
177 template<
typename valX,
typename valY,
typename valP>
178 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
179 valY valTypeY, valP valTypeP, TString option)
181 return AddProfile(histClass, binsX, valTypeX, binsY, valTypeY, valTypeP, option,
182 static_cast<UInt_t
>(Eoption::kNoWeights));
186 template<
typename valX,
typename valY,
typename valZ,
typename valW>
187 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
188 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valW valTypeW)
190 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ,
191 static_cast<UInt_t
>(Eoption::kNoProfile), valTypeW,
"");
194 template<
typename valX,
typename valY,
typename valZ>
195 TString AddHistogram(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
196 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ)
198 return AddHistogram(histClass, binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ,
199 static_cast<UInt_t
>(Eoption::kNoWeights));
203 template<
typename valX,
typename valY,
typename valZ,
typename valP,
typename valW>
204 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
205 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valP valTypeP, TString option,
208 return UserObject(histClass,
"",
"", binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ, valTypeP, valTypeW, option);
211 template<
typename valX,
typename valY,
typename valZ,
typename valP>
212 TString AddProfile(
const char* histClass,
const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
213 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valP valTypeP, TString option)
215 return AddProfile(histClass, binsX, valTypeX, binsY, valTypeY, binsZ, valTypeZ, valTypeP, option,
216 static_cast<UInt_t
>(Eoption::kNoWeights));
221 void FillClass(TString histClass,
const Double_t* values);
222 static void FillValues(TObject* obj,
const Double_t* values);
223 static void FillValues(TH1* obj,
const Double_t* values);
224 static void FillValues(THnBase* obj,
const Double_t* values);
227 void ReadFromFile(
const char* file =
"histos.root",
const char* task =
"",
const char* config =
"");
228 void DumpToFile(
const char* file =
"histos.root");
229 void SetList(TList*
const list) { fList = list; }
230 TList* GetList()
const {
return fList; }
231 Bool_t SetCutClass(
const char* cutClass);
232 Bool_t HasHistClass(TString histClass)
const {
return fHistoList.FindObject(histClass.Data()); }
233 void SetHistogramList(THashList& list, Bool_t setOwner = kTRUE);
234 void ResetHistogramList() { fHistoList.Clear(); }
235 const THashList* GetHistogramList()
const {
return &fHistoList; }
237 TObject* GetHist(
const char* histClass,
const char* name)
const;
238 TH1* GetHistogram(
const char* histClass,
const char* name)
const;
239 TObject* GetHist(
const char* cutClass,
const char* histClass,
const char* name)
const;
240 TH1* GetHistogram(
const char* cutClass,
const char* histClass,
const char* name)
const;
245 virtual void Print(
const Option_t* option =
"")
const;
246 virtual void Draw(
const Option_t* option =
"");
247 virtual TObjArray* DrawSame(TString histName, TString option =
"leg can", TString histClassDenom =
"",
248 THashList* listDenom = 0x0);
249 virtual TObjArray* DrawTaskSame(TString histName, TString opt =
"leg can", TString histClassDenom =
"",
250 TString taskDenom =
"");
254 THashList fHistoList;
259 TFormula*
GetFormula(
const char* name,
const char* formula);
260 TH1* GetTHist(
const char* histClass,
const char* name,
const char* title,
const TVectorD*
const binsX,
261 const TVectorD*
const binsY,
const TVectorD*
const binsZ);
262 TH1* GetTProf(
const char* histClass,
const char* name,
const char* title,
const TVectorD*
const binsX,
263 const TVectorD*
const binsY,
const TVectorD*
const binsZ, TString option =
"i");
265 void FillVarArray(TObject* obj, UInt_t* valType);
272 TString* fReservedWords;
273 void UserHistogramReservedWords(
const char* histClass,
const TObject* hist);
274 void FillClass(THashTable* classTable, Int_t nValues, Double_t* values);
276 void PrintPDF(Option_t* opt);
277 void PrintStructure()
const;
279 Bool_t IsHistogramOk(
const char* classTable,
const char* name);
280 Eprecision fPrecision;
282 PairAnalysisHistos(
const PairAnalysisHistos& hist);
283 PairAnalysisHistos& operator=(
const PairAnalysisHistos& hist);
285 ClassDef(PairAnalysisHistos, 3)
288template<
typename valX,
typename valY,
typename valZ,
typename valP,
typename valW>
289TString PairAnalysisHistos::UserObject(
const char* histClass,
const char* name,
const char* title,
290 const TVectorD*
const binsX, valX valTypeX,
const TVectorD*
const binsY,
291 valY valTypeY,
const TVectorD*
const binsZ, valZ valTypeZ, valP valTypeP,
292 valW valTypeW, TString option)
300 if (
typeid(valTypeP) ==
typeid(UInt_t) && (uintptr_t) valTypeP ==
static_cast<UInt_t
>(Eoption::kNoProfile))
301 hist = GetTHist(histClass, name, title, binsX, binsY, binsZ);
303 hist = GetTProf(histClass, name, title, binsX, binsY, binsZ, option);
311 UInt_t valType[20] = {0};
313 func.Form(
"%d", valTypeX);
314 if (!func.Atoi()) std::cout << func << std::endl;
316 valType[0] = func.Atoi();
319 func.Form(
"%d", valTypeY);
320 if (!func.Atoi()) std::cout << func << std::endl;
322 valType[1] = func.Atoi();
325 func.Form(
"%d", valTypeZ);
326 if (!func.Atoi()) std::cout << func << std::endl;
328 valType[2] = func.Atoi();
331 func.Form(
"%d", valTypeP);
332 if (!func.Atoi()) std::cout << func << std::endl;
334 valType[3] = func.Atoi();
337 func2.Form(
"%d", valTypeX);
339 func.Form(
"%d", valTypeW);
340 if (!func.Atoi()) std::cout << func << std::endl;
341 else if (func2.Atoi() !=
static_cast<UInt_t
>(Eoption::kNoWeights)) {
342 hist->SetUniqueID(func.Atoi());
343 fUsedVars->SetBitNumber(func.Atoi(), kTRUE);
347 StoreVariables(hist, valType);
348 for (Int_t i = 0; i < 4; i++)
349 fUsedVars->SetBitNumber(valType[i], kTRUE);
352 AdaptNameTitle(hist, histClass);
355 TString key = hist->GetName();
368 Bool_t isReserved = fReservedWords->Contains(histClass);
369 if (func2.Atoi() && func2.Atoi() ==
static_cast<UInt_t
>(Eoption::kNoAutoFill)) hist->SetUniqueID(func2.Atoi());
370 if (isReserved) UserHistogramReservedWords(histClass, hist);
372 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)
T ReadFromFile(fs::path path)