1 #include "EventWeightManager.hxx" 2 #include "MultiThread.hxx" 6 EventWeightManager::EventWeightManager(){
9 _nEventWeightsEnabled = 0;
18 EventWeightManager::~EventWeightManager() {
33 if (!selec->IsEnabled())
continue;
64 if (!selec->IsEnabled())
continue;
65 for (UInt_t ibranch=0;ibranch<selec->
GetNBranches();ibranch++){
80 std::vector<EventWeightBase*> weights;
81 for (UInt_t i=0;i<indices.size();i++)
91 if (index<0 || (UInt_t)index> NMAXEVENTWEIGHTS-1)
return NULL;
136 totalWeight *=
_eventWeights[j]->ComputeWeight(toy, event, ToyBox);
159 weight =
_eventWeights[j]->ComputeWeight(toy, event, ToyBox);
163 totalWeight*= weight;
200 weight =
_eventWeights[j]->ComputeWeight(toy, event, ToyBox, sel);
208 totalWeight*= weight;
233 if (syst->
Type() == EventWeightBase::kWeight){
235 _nEventWeightsEnabled++;
247 if (syst->
Type() == EventWeightBase::kWeight){
248 for (Int_t it = 0; it < _nEventWeightsEnabled;it++){
250 for(
int j = it; j < _nEventWeightsEnabled - 1; ++j){
253 _nEventWeightsEnabled--;
264 for (std::vector<Int_t>::const_iterator it=indices.begin();it!=indices.end();it++){
273 for (std::vector<Int_t>::const_iterator it=indices.begin();it!=indices.end();it++){
282 _nEventWeightsEnabled = 0;
286 _nEventWeightsEnabled++;
297 _nEventWeightsEnabled = 0;
313 std::cout <<
"EventWeightManager::AddEventWeight(). '" << index <<
"' already added !!!" <<std::endl;
337 std::cout <<
"EventWeightManager::ReplaceEventWeight(). '" << index <<
"' does not exist !!!" <<std::endl;
346 std::cout <<
" -------- List of EventWeights ---------------" << std::endl;
348 sprintf(out,
"%3s: %-25s %-15s %-4s",
"#",
"name",
"pdf",
"NPar");
349 std::cout << out <<
"\n" << std::endl;
355 std::cout << out << std::endl;
359 std::cout <<
" --------------------------------------------------" << std::endl;
void SetEnabled(bool ena)
Set the enable bit.
virtual bool IsRelevantSystematic(const AnaEventC &, const ToyBoxB &, SystId_h syst_index, Int_t branch=0) const
Is this systematic relevant for this selection.
Int_t GetEventWeightIndex(const std::string &name)
Get the index of a EventWeight registered with the given name.
void DumpEventWeights()
Dump all eventWeights.
TypeEnum Type() const
Return the type of this systematic.
EventWeightBase * GetEventWeight(const std::string &name) const
Get the EventWeight registered with the given name.
Int_t _eventWeightsEnabled[NMAXEVENTWEIGHTS]
The weight systematics that are enabled.
std::vector< EventWeightBase * > _eventWeights
The systematics that were registered as eventWeights.
UInt_t GetNEnabledSelections()
Returns the number of enabled selections.
void InitializeEvent(SelectionManager &sel, AnaEventC &event)
Fill the SystBox for the enabled EventWeights.
std::vector< EventWeightBase * > _eventWeightsWithNull
The systematics that were registered as eventWeights.
void ReplaceEventWeight(Int_t index, EventWeightBase *sys)
Replace one of the existing EventWeightBase.
void FinalizeEvent(AnaEventC &event)
Delete the SystBox for all EventWeights.
std::vector< SelectionBase * > & GetSelections()
Return the map of selections.
void SetName(const std::string &name)
Set the name of this systematic.
void DisableEventWeights(const std::vector< Int_t > &systs)
Disable the EventWeights registered with the given indices.
Int_t SuccessfulBranch
The branch that is successful for this toy in the selection this ToyBox belongs to.
void EnableAllEventWeights()
Enable all EventWeight eventWeights.
void DisableAllEventWeights()
Disable all eventWeights.
void SetIndex(Int_t index)
Set the index of this systematic.
Weight_h ComputeEventWeight(Int_t index, const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &ToyBox)
Compute EventWeight with a given index. Returns the event normalization weight.
void AddEventWeight(Int_t index, EventWeightBase *sys)
Add a new Event Weight provided its index in the manager and a pointer to it.
UInt_t GetNBranches() const
Return the number of branches.
std::vector< EventWeightBase * > & GetEventWeights()
Get the vector of EventWeights.
void EnableEventWeight(Int_t index)
Enable the EventWeight registered with the given index.
void EnableEventWeights(const std::vector< Int_t > &systs)
Enable the EventWeights registered with the given indices.
Weight_h ComputeEventWeights(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &ToyBox)
Compute all eventWeights. Returns the total event normalization weight.
Int_t GetEnabledIndex() const
Get the Selection index.
bool HasEventWeight(const std::string &name)
Check if an EventWeight with a given name already exists in the manager.
void DisableEventWeight(Int_t index)
Disable the EventWeight registered with the given index.