47 using namespace asg::TestxAODPhotonAlg;
66 std::unique_ptr< TFile >
ifile( TFile::Open(
fileName,
"READ" ) );
78 Long64_t
entries =
event.getEntries();
80 const Long64_t
e = atoll(
argv[ 2 ] );
91 photonSF_ID.msg().setLevel( mylevel );
92 photonSF_Iso.msg().setLevel( mylevel );
93 photonSF_Trig.msg().setLevel( mylevel );
97 ANA_CHECK(photonSF_ID.setProperty(
"ForceDataType",1));
100 ANA_CHECK(photonSF_Iso.setProperty(
"IsoKey",
"Loose"));
101 ANA_CHECK(photonSF_Iso.setProperty(
"ForceDataType",1));
104 ANA_CHECK(photonSF_Trig.setProperty(
"IsoKey",
"Loose"));
105 ANA_CHECK(photonSF_Trig.setProperty(
"TriggerKey",
"DI_PH_2015_2016_g25_loose_2017_2018_g50_loose_L1EM20VH"));
106 ANA_CHECK(photonSF_Trig.setProperty(
"ForceDataType",1));
109 ANA_CHECK(photonSF_ID.setProperty(
"UseRandomRunNumber",
false));
110 ANA_CHECK(photonSF_ID.setProperty(
"DefaultRandomRunNumber",428648));
111 ANA_CHECK(photonSF_Iso.setProperty(
"UseRandomRunNumber",
false));
112 ANA_CHECK(photonSF_Iso.setProperty(
"DefaultRandomRunNumber",428648));
113 ANA_CHECK(photonSF_Trig.setProperty(
"UseRandomRunNumber",
false));
114 ANA_CHECK(photonSF_Trig.setProperty(
"DefaultRandomRunNumber",349534));
116 if(!photonSF_ID.initialize()){
117 std::cout <<
"Failed to initialize the tool, check for errors"<<std::endl;
120 if(!photonSF_Iso.initialize()){
121 std::cout <<
"Failed to initialize the tool, check for errors"<<std::endl;
124 if(!photonSF_Trig.initialize()){
125 std::cout <<
"Failed to initialize the tool, check for errors"<<std::endl;
130 std::vector<CP::SystematicSet> sysList;
134 std::cout <<
"List of recommended systematics from the registry:"<<std::endl;
135 for (
auto sysListItr = recommendedSystematics.
begin(); sysListItr != recommendedSystematics.
end(); ++sysListItr){
136 std::cout <<(*sysListItr).name()<<std::endl;
143 std::cout <<
"restructure all recommended systematic variations for the SF tool"<<std::endl;
144 std::vector<CP::SystematicSet> syst_PhotonID, syst_PhotonIso, syst_PhotonTrig;
147 syst_PhotonID.emplace_back();
148 syst_PhotonID.back().insert(SystematicsVariation);
152 syst_PhotonIso.emplace_back();
153 syst_PhotonIso.back().insert(SystematicsVariation);
157 syst_PhotonTrig.emplace_back();
158 syst_PhotonTrig.back().insert(SystematicsVariation);
161 for (
const auto& sSystematicSet: syst_PhotonID){
162 Info(
APP_NAME,
"PhotonEfficiencyCorrectionTool ID instance has next systematic variation %s ",sSystematicSet.name().c_str());
164 for (
const auto& sSystematicSet: syst_PhotonIso){
165 Info(
APP_NAME,
"PhotonEfficiencyCorrectionTool Iso instance has next systematic variation %s ",sSystematicSet.name().c_str());
167 for (
const auto& sSystematicSet: syst_PhotonTrig){
168 Info(
APP_NAME,
"PhotonEfficiencyCorrectionTool Iso instance has next systematic variation %s ",sSystematicSet.name().c_str());
171 double efficiencyScaleFactor=0, efficiencyScaleFactorError=0;
173 std::cout <<
"loop on " <<
entries <<
" entries"<<std::endl;
177 event.getEntry(
entry );
194 for( ; ph_itr != ph_end; ++ph_itr, ++
i ) {
198 if(ph->
pt()<10000.0)
continue;
204 if( std::abs(cluster->
etaBE(2))>2.37)
continue;
209 ANA_CHECK(photonSF_ID.applySystematicVariation(syst_PhotonID.at(0)));
210 ANA_CHECK(photonSF_Iso.applySystematicVariation(syst_PhotonIso.at(0)));
213 ANA_CHECK(photonSF_ID.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
214 ANA_CHECK(photonSF_ID.getEfficiencyScaleFactorError(*ph,efficiencyScaleFactorError));
215 ANA_CHECK(photonSF_Trig.applySystematicVariation(syst_PhotonTrig.at(0)));
217 Info(
APP_NAME,
"===>>> Result ID: ScaleFactor %f, TotalUncertainty %f ",efficiencyScaleFactor,efficiencyScaleFactorError);
220 ANA_CHECK(photonSF_Iso.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
221 ANA_CHECK(photonSF_Iso.getEfficiencyScaleFactorError(*ph,efficiencyScaleFactorError));
223 Info(
APP_NAME,
"===>>> Result Iso: ScaleFactor %f, TotalUncertainty %f ",efficiencyScaleFactor,efficiencyScaleFactorError);
226 ANA_CHECK(photonSF_Trig.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
227 ANA_CHECK(photonSF_Trig.getEfficiencyScaleFactorError(*ph,efficiencyScaleFactorError));
229 Info(
APP_NAME,
"===>>> Result Trigger: ScaleFactor %f, TotalUncertainty %f ",efficiencyScaleFactor,efficiencyScaleFactorError);
232 ANA_CHECK(photonSF_ID.applyEfficiencyScaleFactor(*ph));
233 Info(
"applyEfficiencyScaleFactor()",
"===>>> new decoration: \"SF\"=%f", sfAcc(*ph));
234 ANA_CHECK(photonSF_Iso.applyEfficiencyScaleFactor(*ph));
235 Info(
"applyEfficiencyScaleFactor()",
"===>>> new decoration: \"SF\"=%f", sfAcc(*ph));
236 ANA_CHECK(photonSF_Trig.applyEfficiencyScaleFactor(*ph));
237 Info(
"applyEfficiencyScaleFactor()",
"===>>> new decoration: \"SF\"=%f", sfAcc(*ph));
240 for (
const auto& sSystematicSet: syst_PhotonID){
241 ANA_CHECK(photonSF_ID.applySystematicVariation(sSystematicSet));
242 ANA_CHECK(photonSF_ID.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
243 Info(
APP_NAME,
"===>>> apply %s: ScaleFactor = %f",photonSF_ID.appliedSystematics().name().c_str(),efficiencyScaleFactor);
245 for (
const auto& sSystematicSet: syst_PhotonIso){
246 ANA_CHECK(photonSF_Iso.applySystematicVariation(sSystematicSet));
247 ANA_CHECK(photonSF_Iso.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
248 Info(
APP_NAME,
"===>>> apply %s: ScaleFactor = %f",photonSF_Iso.appliedSystematics().name().c_str(),efficiencyScaleFactor);
250 for (
const auto& sSystematicSet: syst_PhotonTrig){
251 ANA_CHECK(photonSF_Trig.applySystematicVariation(sSystematicSet));
252 ANA_CHECK(photonSF_Trig.getEfficiencyScaleFactor(*ph,efficiencyScaleFactor));
253 Info(
APP_NAME,
"===>>> apply %s: ScaleFactor = %f",photonSF_Trig.appliedSystematics().name().c_str(),efficiencyScaleFactor);