73 TFile * file_prefiringmaps_;
76 file_prefiringmaps_ =
new TFile(mapsfilepath.fullPath().c_str(),
"read" );
77 if(file_prefiringmaps_ ==
nullptr && !skipwarnings_)
78 std::cout <<
"File with maps not found. All prefiring weights set to 0. " <<std::endl;
80 TString mapphotonfullname=
"L1prefiring_photonptvseta_"+
dataera_;
81 if(!file_prefiringmaps_->Get(mapphotonfullname)&& !
skipwarnings_)
82 std::cout <<
"Photon map not found. All photons prefiring weights set to 0. " <<std::endl;
86 if(!file_prefiringmaps_->Get(mapjetfullname)&& !
skipwarnings_)
87 std::cout <<
"Jet map not found. All jets prefiring weights set to 0. "<< std::endl ;
88 h_prefmap_jet =(TH2F*) file_prefiringmaps_->Get(mapjetfullname);
89 file_prefiringmaps_->Close();
90 delete file_prefiringmaps_;
91 produces<double>(
"nonPrefiringProb" ).setBranchAlias(
"nonPrefiringProb");
92 produces<double>(
"nonPrefiringProbUp" ).setBranchAlias(
"nonPrefiringProbUp");
93 produces<double>(
"nonPrefiringProbDown" ).setBranchAlias(
"nonPrefiringProbDown");
118 double nonPrefiringProba[3]={1.,1.,1.};
121 for (
const auto &
photon : *thePhotons ) {
122 double pt_gam=
photon.pt();
123 double eta_gam=
photon.eta();
124 if( pt_gam < 20.)
continue;
125 if( fabs(eta_gam) <2.)
continue;
126 if( fabs(eta_gam) >3.)
continue;
128 nonPrefiringProba[fluct] *= (1.-prefiringprob_gam);
132 for (
const auto &
jet: *theJets ) {
134 double pt_jet=
jet.pt();
135 double eta_jet=
jet.eta();
136 double phi_jet=
jet.phi();
137 if( pt_jet < 20.)
continue;
138 if( fabs(eta_jet) <2.)
continue;
139 if( fabs(eta_jet) >3.)
continue;
142 double nonprefiringprobfromoverlappingphotons =1.;
143 for (
const auto &
photon : *thePhotons ) {
144 double pt_gam=
photon.pt();
145 double eta_gam=
photon.eta();
146 double phi_gam=
photon.phi();
147 if( pt_gam < 20.)
continue;
148 if( fabs(eta_gam) <2.)
continue;
149 if( fabs(eta_gam) >3.)
continue;
153 nonprefiringprobfromoverlappingphotons *= (1.-prefiringprob_gam) ;
157 pt_jet *= (
jet.neutralEmEnergyFraction()+
jet.chargedEmEnergyFraction());
160 if(nonprefiringprobfromoverlappingphotons ==1.){
161 nonPrefiringProba[fluct] *= nonprefiringprobfromoverlappingjet ;
164 else if(nonprefiringprobfromoverlappingphotons > nonprefiringprobfromoverlappingjet ) {
165 if(nonprefiringprobfromoverlappingphotons !=0.) {
166 nonPrefiringProba[fluct] *= nonprefiringprobfromoverlappingjet / nonprefiringprobfromoverlappingphotons;
169 nonPrefiringProba[fluct] = 0.;
176 auto nonPrefiringProb =std::make_unique <double> ( nonPrefiringProba[0]);
177 auto nonPrefiringProbUp =std::make_unique <double> ( nonPrefiringProba[1]);
178 auto nonPrefiringProbDown =std::make_unique <double> ( nonPrefiringProba[2]);
179 iEvent.
put(
std::move(nonPrefiringProb),
"nonPrefiringProb" );
180 iEvent.
put(
std::move(nonPrefiringProbUp),
"nonPrefiringProbUp" );
181 iEvent.
put(
std::move(nonPrefiringProbDown),
"nonPrefiringProbDown" );
188 if(h_prefmap==
nullptr&& !
skipwarnings_)
std::cout <<
"Prefiring map not found, setting prefiring rate to 0 " <<std::endl;
189 if(h_prefmap==
nullptr )
return 0.;
191 int nbinsy = h_prefmap->GetNbinsY();
192 double maxy= h_prefmap->GetYaxis()->GetBinLowEdge(nbinsy+1);
193 if(pt>=maxy) pt = maxy-0.01;
194 int thebin= h_prefmap->FindBin(eta,pt);
196 double prefrate = h_prefmap->GetBinContent(thebin);
198 double statuncty = h_prefmap->GetBinError(thebin) ;
217 desc.
add<
bool>(
"UseJetEMPt",
false);
218 desc.
add<
double>(
"PrefiringRateSystematicUncty",0.2);
219 desc.
add<
bool>(
"SkipWarnings",
true);
220 descriptions.
add(
"l1ECALPrefiringWeightProducer", desc);
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
~L1ECALPrefiringWeightProducer() override
double getPrefiringRate(double eta, double pt, TH2F *h_prefmap, fluctuations fluctuation) const
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
ParameterDescriptionBase * add(U const &iLabel, T const &value)
L1ECALPrefiringWeightProducer(const edm::ParameterSet &)
edm::EDGetTokenT< std::vector< pat::Photon > > photons_token_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< std::vector< pat::Jet > > jets_token_
double prefiringRateSystUnc_
Power< A, B >::type pow(const A &a, const B &b)