00001
00002 #ifndef PILEUPREWEIGHTING_PILEUPREWEIGHTINGTOOL_H
00003 #define PILEUPREWEIGHTING_PILEUPREWEIGHTINGTOOL_H
00004
00005
00006 #include "AsgTools/AsgTool.h"
00007
00008 #include "AsgAnalysisInterfaces/IPileupReweightingTool.h"
00009
00010
00011
00012 #include "PileupReweighting/TPileupReweighting.h"
00013
00014 #include "AsgTools/ToolHandle.h"
00015 #include "PATInterfaces/IWeightTool.h"
00016
00017 #include "TrigDecisionInterface/ITrigDecisionTool.h"
00018
00019 namespace CP {
00020
00025
00026 class PileupReweightingTool :
00027 public asg::AsgTool, protected virtual CP::TPileupReweighting,public virtual IPileupReweightingTool {
00028
00030 ASG_TOOL_CLASS( PileupReweightingTool, CP::IPileupReweightingTool )
00031
00032 public:
00033 using CP::TPileupReweighting::operator new;
00034 using CP::TPileupReweighting::Merge;
00035 using CP::TPileupReweighting::operator delete;
00036 using CP::TPileupReweighting::operator delete[];
00037
00038
00040 virtual UInt_t GetRandomLumiBlockNumber(UInt_t runNumber) { return m_activeTool->GetRandomLumiBlockNumber(runNumber); }
00042 virtual Double_t GetIntegratedLumi(UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumi(start, end); }
00044 virtual Double_t GetIntegratedLumi(const TString& trigger) { return m_activeTool->GetIntegratedLumi(trigger); }
00046 virtual Double_t GetIntegratedLumi(Int_t periodNumber, UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumi(periodNumber, start, end); }
00048 virtual Double_t GetIntegratedLumiFraction(Int_t periodNumber, UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumiFraction(periodNumber, start, end); }
00050 virtual Double_t GetIntegratedLumiFraction(Int_t periodNumber, Double_t mu, UInt_t start, UInt_t end) { return m_activeTool->GetIntegratedLumiFraction(periodNumber, mu, start, end); }
00052 virtual Int_t AddPeriod(Int_t periodNumber, UInt_t start, UInt_t end) { return m_activeTool->AddPeriod(periodNumber, start, end); }
00053 virtual Int_t SetBinning(Int_t nbinsx, Double_t* xbins, Int_t nbinsy=0, Double_t* ybins=0) { return m_activeTool->SetBinning(nbinsx, xbins, nbinsy, ybins); }
00054 virtual Int_t SetUniformBinning(Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy=0, Double_t ylow=0, Double_t yup=0) { return m_activeTool->SetUniformBinning(nbinsx, xlow, xup, nbinsy, ylow, yup); }
00055 virtual Int_t SetBinning(TH1* hist) { return m_activeTool->SetBinning(hist); }
00057 virtual Double_t GetSumOfEventWeights(Int_t channel) { return m_activeTool->GetSumOfEventWeights(channel); }
00058 virtual Double_t GetNumberOfEvents(Int_t channel) { return m_activeTool->GetNumberOfEvents(channel) ; }
00059
00060
00062 PileupReweightingTool( const std::string& name );
00063
00065 virtual StatusCode initialize();
00066
00068 virtual StatusCode finalize();
00069
00074 virtual StatusCode apply ( const xAOD::EventInfo& eventInfo, bool mu_dependent );
00075
00077 virtual float getCombinedWeight( const xAOD::EventInfo& eventInfo );
00078
00080 virtual float getCombinedWeight( const xAOD::EventInfo& eventInfo,Double_t x, Double_t y );
00081
00082 virtual float getCombinedWeight( const xAOD::EventInfo& eventInfo , const TString& trigger, bool mu_dependent );
00083
00085 virtual ULong64_t getPRWHash( const xAOD::EventInfo& eventInfo );
00086
00088 virtual float getCorrectedAverageInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor );
00090 virtual float getCorrectedActualInteractionsPerCrossing( const xAOD::EventInfo& eventInfo, bool includeDataScaleFactor );
00091
00093 virtual double getLumiBlockIntegratedLumi(const xAOD::EventInfo& eventInfo);
00094
00096 virtual float getUnrepresentedDataWeight( const xAOD::EventInfo& eventInfo );
00097
00099 virtual float getDataWeight( const xAOD::EventInfo& eventInfo, const TString& trigger, bool mu_dependent );
00100
00102 virtual int getRandomRunNumber( const xAOD::EventInfo& eventInfo , bool mu_dependent );
00103
00105 virtual int fill( const xAOD::EventInfo& eventInfo );
00106
00108 virtual int fill( const xAOD::EventInfo& eventInfo, Double_t x, Double_t y);
00109
00111 virtual CP::TPileupReweighting* expert() { return m_activeTool; }
00112
00113
00114
00116 bool isAffectedBySystematic( const CP::SystematicVariation& systematic ) const;
00117 CP::SystematicSet affectingSystematics() const;
00118 CP::SystematicSet recommendedSystematics() const;
00119 CP::SystematicCode applySystematicVariation( const CP::SystematicSet& systConfig );
00120
00121 #ifndef XAOD_STANDALONE
00122 void updateHandler(Property& );
00123 #endif
00124
00125 protected:
00126 virtual bool runLbnOK(Int_t runNbr, Int_t lbn);
00127 virtual bool passTriggerBeforePrescale(const TString& trigger) const;
00128
00129 private:
00130 std::string m_configStream;
00131 bool m_inConfigMode;
00132 CP::TPileupReweighting *m_upTool, *m_downTool;
00133
00134 double m_upVariation; double m_downVariation;
00135 CP::SystematicVariation m_systUp, m_systDown;
00136 CP::TPileupReweighting* m_activeTool;
00137
00138 std::vector<std::string> m_prwFiles;
00139 std::vector<std::string> m_lumicalcFiles;
00140
00141 std::string m_prefix;
00142
00143 int m_defaultChannel;
00144 std::string m_usePeriodConfig;
00145 std::map<int, bool> m_doneConfigs;
00146
00147 bool m_noWeightsMode;
00148
00149 ToolHandle<IWeightTool> m_weightTool;
00150 ToolHandle<IGoodRunsListSelectionTool> m_grlTool;
00151 ToolHandle<Trig::ITrigDecisionTool> m_tdt;
00152
00153
00154
00155 public:
00156 static Version_t Class_Version() { return 0; }
00157
00158 };
00159
00160 }
00161
00162 #endif //