forked from AliceO2Group/O2Physics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PWGCF] flow-runbyrun: add a class to hold the list of weight (AliceO…
- Loading branch information
1 parent
54a9f6f
commit 7cd2cda
Showing
5 changed files
with
153 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
/// \file GFWWeightsList.cxx | ||
/// \author Zhiyong Lu ([email protected]) | ||
/// \since Dec/25/2024 | ||
/// \brief one object to hold a list of GFWWeights objects, | ||
|
||
#include <utility> | ||
#include <cstdio> | ||
#include "GFWWeightsList.h" | ||
|
||
GFWWeightsList::GFWWeightsList() : TNamed("", ""), list(0) | ||
{ | ||
runNumerMap.clear(); | ||
} | ||
|
||
GFWWeightsList::GFWWeightsList(const char* name) : TNamed(name, name), list(0) | ||
{ | ||
runNumerMap.clear(); | ||
} | ||
|
||
GFWWeightsList::~GFWWeightsList() | ||
{ | ||
delete list; | ||
runNumerMap.clear(); | ||
} | ||
|
||
void GFWWeightsList::init(const char* listName) | ||
{ | ||
list = new TObjArray(); | ||
list->SetName(listName); | ||
list->SetOwner(kTRUE); | ||
} | ||
|
||
void GFWWeightsList::addGFWWeightsByName(const char* weightName, int nPtBins, double* ptBins, bool addData, bool addMC) | ||
{ | ||
if (!list) { | ||
init("weightList"); | ||
} | ||
GFWWeights* weight = new GFWWeights(weightName); | ||
weight->SetPtBins(nPtBins, ptBins); | ||
weight->Init(addData, addMC); | ||
list->Add(weight); | ||
} | ||
|
||
GFWWeights* GFWWeightsList::getGFWWeightsByName(const char* weightName) | ||
{ | ||
if (!list) { | ||
printf("Error: weight list is not initialized\n"); | ||
return nullptr; | ||
} | ||
return reinterpret_cast<GFWWeights*>(list->FindObject(weightName)); | ||
} | ||
|
||
void GFWWeightsList::addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, bool addData, bool addMC) | ||
{ | ||
if (!list) { | ||
init("weightList"); | ||
} | ||
GFWWeights* weight = new GFWWeights(Form("weight_%d", runNumber)); | ||
weight->SetPtBins(nPtBins, ptBins); | ||
weight->Init(addData, addMC); | ||
list->Add(weight); | ||
runNumerMap.insert(std::make_pair(runNumber, weight)); | ||
} | ||
|
||
GFWWeights* GFWWeightsList::getGFWWeightsByRun(int runNumber) | ||
{ | ||
if (!list) { | ||
printf("Error: weight list is not initialized\n"); | ||
return nullptr; | ||
} | ||
if (!runNumerMap.contains(runNumber)) { | ||
printf("Error: weight for run %d is not found\n", runNumber); | ||
return nullptr; | ||
} | ||
return runNumerMap.at(runNumber); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
/// \file GFWWeightsList.h | ||
/// \author Zhiyong Lu ([email protected]) | ||
/// \since Dec/25/2024 | ||
/// \brief one object to hold a list of GFWWeights objects, | ||
|
||
#ifndef PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTSLIST_H_ | ||
#define PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTSLIST_H_ | ||
#include <map> | ||
#include "TObjArray.h" | ||
#include "GFWWeights.h" | ||
|
||
class GFWWeightsList : public TNamed | ||
{ | ||
public: | ||
GFWWeightsList(); | ||
explicit GFWWeightsList(const char* name); | ||
~GFWWeightsList(); | ||
void init(const char* listName); | ||
void addGFWWeightsByName(const char* weightName, int nPtBins, double* ptBins, bool addData = kTRUE, bool addMC = kTRUE); | ||
GFWWeights* getGFWWeightsByName(const char* weightName); | ||
void addGFWWeightsByRun(int runNumber, int nPtBins, double* ptBins, bool addData = kTRUE, bool addMC = kTRUE); | ||
GFWWeights* getGFWWeightsByRun(int runNumber); | ||
TObjArray* getList() const { return list; } | ||
|
||
private: | ||
TObjArray* list; | ||
std::map<int, GFWWeights*> runNumerMap; | ||
|
||
ClassDef(GFWWeightsList, 1); | ||
}; | ||
|
||
#endif // PWGCF_GENERICFRAMEWORK_CORE_GFWWEIGHTSLIST_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters