Skip to content

Commit

Permalink
Added run-dependent energy scale corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
musella committed Jul 5, 2011
1 parent 0aebd11 commit 8a0f0e9
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 22 deletions.
2 changes: 1 addition & 1 deletion BaseSmearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BaseSmearer
operator const std::string & () const { return this->name(); };

// ! return smeared photon informations
virtual bool smearPhoton( PhotonReducedInfo & pho, float & weight, float syst_shift=0. ) const = 0;
virtual bool smearPhoton( PhotonReducedInfo & pho, float & weight, int run, float syst_shift=0. ) const = 0;

/// virtual bool smearDiPhoton( TLorentzVector & 4p, const TVector3 & selVtx, const TVector3 & trueVtx);
};
Expand Down
2 changes: 1 addition & 1 deletion EfficiencySmearer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::string EfficiencySmearer::photonCategory(PhotonReducedInfo & aPho) const
return myCategory;
}

bool EfficiencySmearer::smearPhoton(PhotonReducedInfo & aPho, float & weight, float syst_shift) const
bool EfficiencySmearer::smearPhoton(PhotonReducedInfo & aPho, float & weight, int run, float syst_shift) const
{
std::string category=photonCategory(aPho);

Expand Down
2 changes: 1 addition & 1 deletion EfficiencySmearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EfficiencySmearer : public BaseSmearer

virtual const std::string & name() const { return name_; };

virtual bool smearPhoton( PhotonReducedInfo & pho, float & weight, float syst_shift=0. ) const;
virtual bool smearPhoton( PhotonReducedInfo & pho, float & weight, int run, float syst_shift=0. ) const;

void name(const std::string & x) { name_ = x; };

Expand Down
61 changes: 46 additions & 15 deletions EnergySmearer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ EnergySmearer::EnergySmearer(const energySmearingParameters& par) : myParameters
name_="EnergySmearer_"+ par.categoryType + "_" + par.parameterSetName;
//Checking consistency of input parameters
std::cerr << myParameters_.categoryType << " " << myParameters_.n_categories << std::endl;
assert( myParameters_.n_categories == myParameters_.scale_offset.size() );
assert( myParameters_.n_categories == myParameters_.scale_offset_error.size() );
assert( myParameters_.n_categories == myParameters_.smearing_sigma.size() );
assert( myParameters_.n_categories == myParameters_.smearing_sigma_error.size() );
assert( ( myParameters_.categoryType == "EBEE" && myParameters_.n_categories == 2) ||
( myParameters_.categoryType == "2CatR9_EBEE" && myParameters_.n_categories == 4) );
assert( ( myParameters_.categoryType == "EBEE" && myParameters_.n_categories == 2 ) ||
( myParameters_.categoryType == "2CatR9_EBEE" && myParameters_.n_categories == 4 ) ||
( myParameters_.categoryType == "2CatR9_EBEE_ByRun" && myParameters_.n_categories == 4 )
);
if( myParameters_.byRun ) {
for(energySmearingParameters::eScaleVectorIt it=myParameters_.scale_offset_byrun.begin(); it!=myParameters_.scale_offset_byrun.end();
++it ) {
assert( myParameters_.n_categories == it->scale_offset.size() );
assert( myParameters_.n_categories == it->scale_offset_error.size() );
}
} else {
assert( myParameters_.n_categories == myParameters_.scale_offset.size() );
assert( myParameters_.n_categories == myParameters_.scale_offset_error.size() );
}
}

EnergySmearer::~EnergySmearer()
Expand All @@ -25,7 +35,7 @@ EnergySmearer::~EnergySmearer()
std::string EnergySmearer::photonCategory(PhotonReducedInfo & aPho) const
{
std::string myCategory="";
if (myParameters_.categoryType=="2CatR9_EBEE")
if (myParameters_.categoryType=="2CatR9_EBEE" )
{
if (aPho.iDet()==1)
myCategory+="EB";
Expand All @@ -51,7 +61,27 @@ std::string EnergySmearer::photonCategory(PhotonReducedInfo & aPho) const
return myCategory;
}

bool EnergySmearer::smearPhoton(PhotonReducedInfo & aPho, float & weight, float syst_shift) const

float EnergySmearer::getScaleOffset(int run, const std::string & category) const
{
const std::map<std::string, float> * scale_offset = &(myParameters_.scale_offset);

if( myParameters_.byRun ) {
scale_offset = &(find(myParameters_.scale_offset_byrun.begin(),myParameters_.scale_offset_byrun.end(),run)->scale_offset) ;
}
energySmearingParameters::parameterMapConstIt it=scale_offset->find(category);

if ( it == scale_offset->end())
{
std::cout << "Category was not found in the configuration. Giving Up" << std::endl;
return false;
}

return 1. + it->second;

}

bool EnergySmearer::smearPhoton(PhotonReducedInfo & aPho, float & weight, int run, float syst_shift) const
{
std::string category=photonCategory(aPho);

Expand All @@ -61,15 +91,16 @@ bool EnergySmearer::smearPhoton(PhotonReducedInfo & aPho, float & weight, float
return false;
}

energySmearingParameters::parameterMapConstIt it=myParameters_.scale_offset.find(category);

if ( it == myParameters_.scale_offset.end())
{
std::cout << "Category was not found in the configuration. Giving Up" << std::endl;
return false;
}

float scale_offset = 1. + it->second;
/// energySmearingParameters::parameterMapConstIt it=myParameters_.scale_offset.find(category);
///
/// if ( it == myParameters_.scale_offset.end())
/// {
/// std::cout << "Category was not found in the configuration. Giving Up" << std::endl;
/// return false;
/// }
///
/// float scale_offset = 1. + it->second;
float scale_offset = getScaleOffset(run, category);
float smearing_sigma = myParameters_.smearing_sigma.find(category)->second;

/////////////////////// smearing or re-scaling photon energy ///////////////////////////////////////////
Expand Down
29 changes: 25 additions & 4 deletions EnergySmearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
class PhotonReducedInfo;
class TRandom3;

// ------------------------------------------------------------------------------------
class EnergyScaleOffset {
public:
EnergyScaleOffset(int first, int last) : firstrun(first), lastrun(last) {};
bool operator == (int run) const { return run>=firstrun && ( lastrun<0 || run<=lastrun); };

int firstrun, lastrun;

std::map<std::string,float> scale_offset;
std::map<std::string,float> scale_offset_error;

};

// ------------------------------------------------------------------------------------
class EnergySmearer : public BaseSmearer
{
Expand All @@ -18,9 +31,14 @@ class EnergySmearer : public BaseSmearer
struct energySmearingParameters
{
int n_categories;
bool byRun;
std::string categoryType;
std::string parameterSetName;

typedef std::vector<EnergyScaleOffset> eScaleVector;
typedef std::vector<EnergyScaleOffset>::iterator eScaleVectorIt;
typedef std::vector<EnergyScaleOffset>::const_iterator eScaleVectorConstIt;

typedef std::map<std::string,float> parameterMap;
typedef std::map<std::string,float>::iterator parameterMapIt;
typedef std::map<std::string,float>::const_iterator parameterMapConstIt;
Expand All @@ -33,17 +51,20 @@ class EnergySmearer : public BaseSmearer

std::map<std::string,float> smearing_sigma;
std::map<std::string,float> smearing_sigma_error;


eScaleVector scale_offset_byrun;

std::string efficiency_file;
};

EnergySmearer(const energySmearingParameters& par) ;
EnergySmearer(const energySmearingParameters& par);
virtual ~EnergySmearer();

virtual const std::string & name() const { return name_; };

virtual bool smearPhoton(PhotonReducedInfo &, float & weight, float syst_shift) const;

virtual bool smearPhoton(PhotonReducedInfo &, float & weight, int run, float syst_shift) const;
float getScaleOffset(int run, const std::string & category) const;

void name(const std::string & x) { name_ = x; };

void scaleOrSmear(bool x) { scaleOrSmear_=x; };
Expand Down
2 changes: 2 additions & 0 deletions PhotonAnalysis_scripts/energy_scale_offsets.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Format first_run last_run EBHighR9 EBLowR9 EEHighR9 EELowR9
0 -1 0.49e-2 -0.11e-2 -0.57e-2 0.39e-2
4 changes: 4 additions & 0 deletions PhotonAnalysis_scripts/statanalysis.dat
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ efficiencyFile=/afs/cern.ch/user/m/musella/public/higgs/sig_reweighing_v9.root
Numbers from Riccardo: "slide 1" of https://hypernews.cern.ch/HyperNews/CMS/get/higgs2g/252/1.html
scale variations defined as: (deltaM_data - deltaM_MC) / M_Z => scale factor >0 means energy should increased to MC
->
->
scale_offset_EBHighR9=0.49e-2
scale_offset_EBLowR9=-0.11e-2
scale_offset_EEHighR9=-0.57e-2
scale_offset_EELowR9=0.39e-2
->
scale_offset_file=energy_scale_offsets.dat
scale_offset_error_EBHighR9=0.07e-2
scale_offset_error_EBLowR9=0.05e-2
scale_offset_error_EEHighR9=0.24e-2
scale_offset_error_EELowR9=0.19e-2

smearing_sigma_EBHighR9=0.89e-2
smearing_sigma_EBLowR9=1.99e-2
smearing_sigma_EEHighR9=4.09e-2
Expand Down

0 comments on commit 8a0f0e9

Please sign in to comment.