MCReweight Class Reference

#include <MCReweight.h>

List of all members.

Public Member Functions

 ~MCReweight ()
void AddWeightCalculator (WeightCalculator *)
void ClearWeightCalculators ()
void ResetAllReweightConfigs ()
int NumWeightCalcAdded ()
void SetStandardConfig (Registry *stdconfig)
RegistryGetStandardConfig ()
double ComputeWeight (Registry *event, Registry *rwtconfig=0)
double ComputeWeight (MCEventInfo *event, NuParent *parent=0, Registry *rwtconfig=0)
void PrintReweightConfig (ostream &)

Static Public Member Functions

static MCReweightInstance ()

Protected Member Functions

 MCReweight ()

Private Attributes

std::vector< WeightCalculator * > fWeightCalculators
Registry fStandardConfig

Static Private Attributes

static MCReweightfgInstance = 0

Friends

struct Cleaner

Classes

struct  Cleaner


Detailed Description

Definition at line 9 of file MCReweight.h.


Constructor & Destructor Documentation

MCReweight::MCReweight (  )  [protected]

Definition at line 12 of file MCReweight.cxx.

References fWeightCalculators.

Referenced by Instance().

00013 {
00014   fWeightCalculators.clear();    
00015 }

MCReweight::~MCReweight (  ) 

Definition at line 18 of file MCReweight.cxx.

References Msg::kInfo, and MSG.

00019 {
00020   MSG("MCReweight",Msg::kInfo) << "Closing down MCReweight object" 
00021                                << endl;
00022 }


Member Function Documentation

void MCReweight::AddWeightCalculator ( WeightCalculator  ) 

Definition at line 72 of file MCReweight.cxx.

References fStandardConfig, fWeightCalculators, WeightCalculator::GetName(), Msg::kError, MSG, and WeightCalculator::SetStandardConfig().

Referenced by add_neugen_weight_calculator(), NuZBeamReweight::AddNeugenWeightCalculator(), SKZPWeightCalculator::Config(), NuSystematic::NeugenXSecShift(), and MiniPlotMaker::SetSystematic().

00072                                                         {
00073 
00074   std::vector<WeightCalculator*>::iterator beg = fWeightCalculators.begin();
00075   std::vector<WeightCalculator*>::iterator end = fWeightCalculators.end();
00076   while(beg!=end){
00077     if((*beg)->GetName()==wc->GetName()){
00078       MSG("MCReweight", Msg::kError) 
00079         << "Attempting to add " << wc->GetName() << " more than once! " 
00080         << "This is not a good idea, so not doing it."
00081         << endl;
00082       return;
00083     }
00084     beg++;
00085   }
00086   wc->SetStandardConfig(&fStandardConfig);
00087   fWeightCalculators.push_back(wc);
00088   
00089 }

void MCReweight::ClearWeightCalculators (  ) 

Definition at line 92 of file MCReweight.cxx.

References fWeightCalculators.

00092                                        {
00093   
00094   fWeightCalculators.clear();
00095   
00096 }

double MCReweight::ComputeWeight ( MCEventInfo event,
NuParent parent = 0,
Registry rwtconfig = 0 
)

Definition at line 57 of file MCReweight.cxx.

References fWeightCalculators.

00058                                                      {
00059   
00060   std::vector<WeightCalculator*>::iterator beg = fWeightCalculators.begin();
00061   std::vector<WeightCalculator*>::iterator end = fWeightCalculators.end();
00062   double totalWeight = 1;
00063   while(beg!=end) {
00064     (*beg)->SetReweightConfig(rwtconfig);
00065     totalWeight *= (*beg)->GetWeight(event,parent);
00066     beg++;
00067   }
00068   return totalWeight;
00069 }

double MCReweight::ComputeWeight ( Registry event,
Registry rwtconfig = 0 
)

Definition at line 43 of file MCReweight.cxx.

References fWeightCalculators.

Referenced by NueXsecWeightAna::Analyze(), NuZBeamReweight::CalcGeneratorReweight(), MadAnalysis::Do2DFitNearFar(), NueSystematic::DoNeugenCalc(), NCEventInfo::FindNeugenWeight(), SKZPWeightCalculator::GetDetWeight(), MiniPlotMaker::GetReweight(), PANAnalysis::MakeReweightTree(), NuSystematic::NeugenXSecShift(), and NueReweight::Reco().

00043                                                                     {
00044   
00045   std::vector<WeightCalculator*>::iterator beg = fWeightCalculators.begin();
00046   std::vector<WeightCalculator*>::iterator end = fWeightCalculators.end();
00047   double totalWeight = 1;
00048   while(beg!=end) {
00049     (*beg)->SetReweightConfig(rwtconfig);
00050     totalWeight *= (*beg)->GetWeight(event);
00051     beg++;
00052   }
00053   return totalWeight;
00054 }

Registry* MCReweight::GetStandardConfig (  )  [inline]

Definition at line 44 of file MCReweight.h.

References fStandardConfig.

00044 {return &fStandardConfig;}

MCReweight & MCReweight::Instance (  )  [static]

Definition at line 25 of file MCReweight.cxx.

References fgInstance, Msg::kError, MCReweight(), MSG, and MCReweight::Cleaner::UseMe().

Referenced by add_neugen_weight_calculator(), NuZBeamReweight::AddNeugenWeightCalculator(), NuZBeamReweight::CalcGeneratorReweight(), MadAnalysis::Do2DFitNearFar(), NueSystematic::DoNeugenCalc(), NCEventInfo::FindNeugenWeight(), PANAnalysis::MakeReweightTree(), NuSystematic::NeugenXSecShift(), NueModule::NueModule(), MiniPlotMaker::SetSystematic(), and SKZPWeightCalculator::SKZPWeightCalculator().

00026 {
00027   static Cleaner cleaner;
00028   
00029   //all copied from Calibrator package...
00030   if (!fgInstance) {
00031     cleaner.UseMe();           // dummy call to quiet compiler warnings
00032     fgInstance = new MCReweight();
00033     if(!fgInstance){
00034       MSG("MCReweight", Msg::kError)
00035         << "No MCReweight Instance - fatal." << endl;
00036       assert(fgInstance); // Kill job is there is no instance
00037     }    
00038   }
00039   return *fgInstance;
00040 }

int MCReweight::NumWeightCalcAdded (  )  [inline]

Definition at line 41 of file MCReweight.h.

References fWeightCalculators.

00041 {return fWeightCalculators.size();}

void MCReweight::PrintReweightConfig ( ostream &   ) 

Definition at line 121 of file MCReweight.cxx.

References fWeightCalculators.

00121                                                      {
00122   std::vector<WeightCalculator*>::iterator beg = fWeightCalculators.begin();
00123   std::vector<WeightCalculator*>::iterator end = fWeightCalculators.end();
00124   while(beg!=end){
00125     (*beg)->PrintReweightConfig(stream);
00126     beg++;
00127   }
00128 }

void MCReweight::ResetAllReweightConfigs (  ) 

Definition at line 99 of file MCReweight.cxx.

References fWeightCalculators.

Referenced by NCEventInfo::FindNeugenWeight(), and NuSystematic::NeugenXSecShift().

00099                                          {
00100   std::vector<WeightCalculator*>::iterator beg = fWeightCalculators.begin();
00101   std::vector<WeightCalculator*>::iterator end = fWeightCalculators.end();
00102   while(beg!=end){
00103     (*beg)->ReweightConfigReset();
00104     beg++;
00105   }
00106 }

void MCReweight::SetStandardConfig ( Registry stdconfig  ) 

Definition at line 109 of file MCReweight.cxx.

References fStandardConfig, and fWeightCalculators.

00109                                                    {
00110   if(!config) return;
00111   fStandardConfig = *config;
00112   std::vector<WeightCalculator*>::iterator beg = fWeightCalculators.begin();
00113   std::vector<WeightCalculator*>::iterator end = fWeightCalculators.end();
00114   while(beg!=end){
00115     (*beg)->SetStandardConfig(&fStandardConfig);
00116     beg++;
00117   } 
00118 }


Friends And Related Function Documentation

friend struct Cleaner [friend]

Definition at line 27 of file MCReweight.h.


Member Data Documentation

MCReweight * MCReweight::fgInstance = 0 [static, private]

Definition at line 28 of file MCReweight.h.

Referenced by Instance(), and MCReweight::Cleaner::~Cleaner().

Registry MCReweight::fStandardConfig [private]

Definition at line 15 of file MCReweight.h.

Referenced by AddWeightCalculator(), GetStandardConfig(), and SetStandardConfig().

std::vector<WeightCalculator*> MCReweight::fWeightCalculators [private]

Definition at line 14 of file MCReweight.h.

Referenced by AddWeightCalculator(), ClearWeightCalculators(), ComputeWeight(), MCReweight(), NumWeightCalcAdded(), PrintReweightConfig(), ResetAllReweightConfigs(), and SetStandardConfig().


The documentation for this class was generated from the following files:
Generated on Thu Apr 10 23:02:56 2014 for loon by  doxygen 1.4.7