Skip to content

Commit b6bdff6

Browse files
author
Yuanjun Mei
committed
Change and fix according to code check
1 parent e39d44f commit b6bdff6

1 file changed

Lines changed: 38 additions & 20 deletions

File tree

PWGCF/MultiparticleCorrelations/Tasks/multiparticleCorrelationsMei.cxx

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,32 @@
1919
#include "Common/DataModel/TrackSelectionTables.h" // needed for aod::TracksDCA table
2020

2121
#include <CCDB/BasicCCDBManager.h>
22+
#include <CommonConstants/MathConstants.h>
2223
#include <Framework/AnalysisDataModel.h>
24+
#include <Framework/AnalysisHelpers.h>
2325
#include <Framework/AnalysisTask.h>
24-
#include <Framework/DataTypes.h>
26+
#include <Framework/Configurable.h>
27+
#include <Framework/InitContext.h>
28+
#include <Framework/OutputObjHeader.h>
2529
#include <Framework/runDataProcessing.h>
2630

31+
#include <TCollection.h>
32+
#include <TColor.h>
33+
#include <TFile.h>
2734
#include <TGrid.h>
28-
#include <TH1D.h>
35+
#include <TH1.h>
36+
#include <TH2.h>
37+
#include <TIterator.h>
38+
#include <TList.h>
39+
#include <TObject.h>
40+
#include <TString.h>
41+
#include <TStyle.h>
2942
#include <TSystem.h>
3043

44+
#include <Rtypes.h>
45+
46+
#include <cstddef>
47+
#include <cstdint>
3148
#include <string>
3249
#include <vector>
3350

@@ -202,7 +219,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
202219
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
203220
}
204221
if (0 == list->GetEntries()) {
205-
return NULL;
222+
return nullptr;
206223
}
207224

208225
// The object is in the current base list:
@@ -212,14 +229,15 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
212229
}
213230

214231
// Otherwise, search for the object recursively in the nested lists:
215-
TObject* objectIter; // iterator object in the loop below
232+
TObject* objectIter = nullptr; // iterator object in the loop below
216233
TIter next(list);
217234
while ((objectIter = next())) // double round braces are to silence the warnings
218235
{
219-
if (TString(objectIter->ClassName()).EqualTo("TList")) {
220-
objectFinal = getObjectFromList(reinterpret_cast<TList*>(objectIter), objectName);
221-
if (objectFinal)
236+
if (auto* subList = dynamic_cast<TList*>(objectIter)) {
237+
objectFinal = getObjectFromList(subList, objectName);
238+
if (objectFinal) {
222239
return objectFinal;
240+
}
223241
}
224242
} // while(objectIter = next())
225243

@@ -229,9 +247,9 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
229247
TH1D* getHistogramWithWeights(const char* filePath, const char* runNumber)
230248
{
231249
// *) Return value:
232-
TH1D* hist = NULL;
233-
TList* baseList = NULL; // base top-level list in the TFile, e.g. named "ccdb_object"
234-
TList* listWithRuns = NULL; // nested list with run-wise TList's holding run-specific weights
250+
TH1D* hist = nullptr;
251+
TList* baseList = nullptr; // base top-level list in the TFile, e.g. named "ccdb_object"
252+
TList* listWithRuns = nullptr; // nested list with run-wise TList's holding run-specific weights
235253

236254
// *) Determine from filePath if the file is on a local machine, or in home dir AliEn, or in CCDB:
237255
// Algorithm: If filePath begins with "/alice/cern.ch/" then it's in the home dir AliEn;
@@ -240,7 +258,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
240258
bool bFileIsInAliEn = false;
241259
bool bFileIsInCCDB = false;
242260

243-
std::string path(cfFileWithWeights);
261+
std::string path(filePath);
244262

245263
if (path.starts_with("/alice/cern.ch/")) {
246264
bFileIsInAliEn = true;
@@ -266,11 +284,11 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
266284

267285
// Finally, from the top-level TList, get the desired nested TList => the technical problem here is that it can be nested at any level,
268286
// for that there is a helper utility function getObjectFromList(...) , see its implementation further below
269-
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumber));
287+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumber));
270288
if (!listWithRuns) {
271289
TString runNumberWithLeadingZeroes = "000";
272290
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
273-
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
291+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
274292
if (!listWithRuns) {
275293
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
276294
}
@@ -288,11 +306,11 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
288306
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
289307
}
290308

291-
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumber));
309+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumber));
292310
if (!listWithRuns) {
293311
TString runNumberWithLeadingZeroes = "000";
294312
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
295-
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
313+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
296314
if (!listWithRuns) {
297315
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
298316
}
@@ -321,11 +339,11 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
321339
LOGF(fatal, "\033[1;31m%s at line %d\033[0m", __FUNCTION__, __LINE__);
322340
}
323341

324-
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumber));
342+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumber));
325343
if (!listWithRuns) {
326344
TString runNumberWithLeadingZeroes = "000";
327345
runNumberWithLeadingZeroes += runNumber; // another try, with "000" prepended to run number
328-
listWithRuns = reinterpret_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
346+
listWithRuns = dynamic_cast<TList*>(getObjectFromList(baseList, runNumberWithLeadingZeroes.Data()));
329347
if (!listWithRuns) {
330348
// baseList->ls();
331349
// LOGF(fatal, "\033[1;31m%s at line %d : this crash can happen if in the output file there is no list with weights for the current run number = %s\033[0m", __FUNCTION__, __LINE__, tc.fRunNumber.Data());
@@ -346,9 +364,9 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
346364
if (!hist) {
347365
LOGF(fatal, "%s: histogram 'hist1' not found in run list", __FUNCTION__);
348366
}
349-
hist->SetDirectory(0);
367+
hist->SetDirectory(nullptr);
350368
auto histClone = dynamic_cast<TH1D*>(hist->Clone());
351-
histClone->SetDirectory(0);
369+
histClone->SetDirectory(nullptr);
352370

353371
delete baseList; // release back the memory
354372

@@ -621,7 +639,7 @@ struct MultiparticleCorrelationsMei // this name is used in lower-case format to
621639
tc.fDryRun = cfDryRun;
622640

623641
// *) Book base list:
624-
TList* temp = new TList();
642+
auto* temp = new TList();
625643
temp->SetOwner(true);
626644
fBaseList.setObject(temp);
627645

0 commit comments

Comments
 (0)