38 using namespace reco ;
51 nameNewEnergyReg_ = cfg.
getParameter<std::string>(
"nameNewEnergyReg");
52 nameNewEnergyErrorReg_ = cfg.
getParameter<std::string>(
"nameNewEnergyErrorReg");
53 newElectronName_ = cfg.
getParameter<std::string>(
"outputGsfElectronCollectionLabel");
58 updateEnergyError = cfg.
getParameter<
bool>(
"updateEnergyError");
60 correctionsType = cfg.
getParameter<
int>(
"correctionsType");
61 applyLinearityCorrection = cfg.
getParameter<
bool>(
"applyLinearityCorrection");
62 combinationType = cfg.
getParameter<
int>(
"combinationType");
64 synchronization = cfg.
getParameter<
bool>(
"synchronization");
65 combinationRegressionInputPath = cfg.
getParameter<std::string>(
"combinationRegressionInputPath");
66 scaleCorrectionsInputPath = cfg.
getParameter<std::string>(
"scaleCorrectionsInputPath");
67 linCorrectionsInputPath = cfg.
getParameter<std::string>(
"linearityCorrectionsInputPath");
70 if ( isMC && ( dataset !=
"Summer11" && dataset !=
"Fall11"
71 && dataset!=
"Summer12" && dataset !=
"Summer12_DR53X_HCP2012"
72 && dataset !=
"Summer12_LegacyPaper" ) )
74 throw cms::Exception(
"CalibratedgsfElectronProducer|ConfigError") <<
"Unknown MC dataset";
76 if ( !isMC && ( dataset !=
"Prompt" && dataset !=
"ReReco"
77 && dataset !=
"Jan16ReReco" && dataset !=
"ICHEP2012"
78 && dataset !=
"Moriond2013" && dataset !=
"22Jan2013ReReco" ) )
80 throw cms::Exception(
"CalibratedgsfElectronProducer|ConfigError") <<
"Unknown Data dataset";
84 if(combinationType!=3 && applyLinearityCorrection)
86 std::cout <<
"[CalibratedElectronProducer] "
87 <<
"Warning: you chose combinationType!=3 and applyLinearityCorrection=True. Linearity corrections are only applied on top of combination 3." << std::endl;
90 std::cout <<
"[CalibratedGsfElectronProducer] Correcting scale for dataset " << dataset << std::endl;
93 std::string pathToDataCorr;
94 switch (correctionsType)
101 std::cout <<
"You choose regression 1 scale corrections" << std::endl;
107 std::cout <<
"You choose regression 2 scale corrections." << std::endl;
112 <<
"You choose standard non-regression ecal energy scale corrections. They are not implemented yet.";
116 <<
"Unknown correctionsType !!!" ;
125 applyLinearityCorrection,
135 std::cout<<
"[CalibratedGsfElectronProducer] "
136 <<
"ElectronEnergyCalibrator object is created" << std::endl;
140 myEpCombinationTool->init
142 edm::FileInPath(combinationRegressionInputPath.c_str()).fullPath().c_str(),
150 std::cout <<
"[CalibratedGsfElectronProducer] "
151 <<
"Combination tools are created and initialized" << std::endl;
154 produces<edm::ValueMap<double> >(nameNewEnergyReg_);
155 produces<edm::ValueMap<double> >(nameNewEnergyErrorReg_);
156 produces<GsfElectronCollection> (newElectronName_);
157 geomInitialized_ =
false;
165 if (!geomInitialized_)
169 ecalTopology_ = & (*theCaloTopology);
173 caloGeometry_ = & (*theCaloGeometry);
174 geomInitialized_ =
true;
179 event.getByLabel(inputElectrons_,oldElectronsH) ;
184 event.getByLabel( recHitCollectionEB_, pEBRecHits );
185 event.getByLabel( recHitCollectionEE_, pEERecHits );
189 event.getByLabel(nameEnergyReg_,valMapEnergyH);
191 event.getByLabel(nameEnergyErrorReg_,valMapEnergyErrorH);
203 unsigned nElectrons = oldElectronsH->size();
204 for(
unsigned iele = 0; iele < nElectrons; ++iele )
206 electrons->push_back((*oldElectronsH)[iele]);
209 std::vector<double> regressionValues;
210 std::vector<double> regressionErrorValues;
211 regressionValues.reserve(nElectrons);
212 regressionErrorValues.reserve(nElectrons);
214 if ( correctionsType != 0 )
216 for (
unsigned iele = 0; iele < nElectrons ; ++iele)
220 double regressionEnergy = (*valMapEnergyH)[elecRef];
221 double regressionEnergyError = (*valMapEnergyErrorH)[elecRef];
223 regressionValues.push_back(regressionEnergy);
224 regressionErrorValues.push_back(regressionEnergyError);
230 recHits = pEBRecHits.
product();
231 }
else recHits = pEERecHits.
product();
236 int run =
event.run();
238 float r9 = mySCHelper.
r9();
243 double combinedMomentum = ele.
p();
250 double error = 999. ;
251 double momentum = (combinedMomentum<15. ? 15. : combinedMomentum);
254 float parEB[3] = { 5.24e-02, 2.01e-01, 1.00e-02};
255 error = momentum *
sqrt(
pow(parEB[0]/
sqrt(momentum),2) +
pow(parEB[1]/momentum,2) +
pow(parEB[2],2) );
257 else if ( ele.
isEE() )
259 float parEE[3] = { 1.46e-01, 9.21e-01, 1.94e-03} ;
260 error = momentum *
sqrt(
pow(parEE[0]/
sqrt(momentum),2) +
pow(parEE[1]/momentum,2) +
pow(parEE[2],2) );
262 combinedMomentumError =
error;
277 correctedEcalEnergyError,
281 regressionEnergyError,
283 combinedMomentumError,
292 if ( ele.
core()->ecalDrivenSeed() || correctionsType==2 || combinationType==3 )
294 theEnCorrector->calibrate(mySimpleElectron);
298 switch ( combinationType )
303 std::cout <<
"[CalibratedGsfElectronProducer] "
304 <<
"You choose not to combine." << std::endl;
310 std::cout <<
"[CalibratedGsfElectronProducer] "
311 <<
"You choose corrected regression energy for standard combination" << std::endl;
313 myCombinator->setCombinationMode(1);
314 myCombinator->combine(mySimpleElectron);
319 std::cout <<
"[CalibratedGsfElectronProducer] "
320 <<
"You choose uncorrected regression energy for standard combination" << std::endl;
322 myCombinator->setCombinationMode(2);
323 myCombinator->combine(mySimpleElectron);
328 std::cout <<
"[CalibratedGsfElectronProducer] "
329 <<
"You choose regression combination." << std::endl;
331 myEpCombinationTool->combine(mySimpleElectron);
332 theEnCorrector->correctLinearity(mySimpleElectron);
336 <<
"Unknown combination Type !!!" ;
342 ( oldMomentum.x()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
343 oldMomentum.y()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
344 oldMomentum.z()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
345 mySimpleElectron.getCombinedMomentum() ) ;
350 mySimpleElectron.getTrackerMomentumError(),
351 mySimpleElectron.getCombinedMomentumError()
356 std::cout <<
"[CalibratedGsfElectronProducer] Combined momentum after saving "
357 << ele.
p4().t() << std::endl;
365 std::cout <<
"[CalibratedGsfElectronProducer] "
366 <<
"You choose not to correct. Uncorrected Regression Energy is taken." << std::endl;
372 energyFiller.
insert(gsfNewElectronHandle,regressionValues.begin(),regressionValues.end());
374 energyErrorFiller.
insert(gsfNewElectronHandle,regressionErrorValues.begin(),regressionErrorValues.end());
375 energyErrorFiller.
fill();
377 event.put(regrNewEnergyMap,nameNewEnergyReg_);
378 event.put(regrNewEnergyErrorMap,nameNewEnergyErrorReg_);
T getParameter(std::string const &) const
virtual double p() const
magnitude of momentum vector
float trackMomentumError() const
const LorentzVector & p4(P4Kind kind) const
P4Kind candidateP4Kind() const
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
math::XYZVectorF trackMomentumAtVtx() const
void insert(const H &h, I begin, I end)
float p4Error(P4Kind kind) const
DEFINE_FWK_MODULE(HiMixingModule)
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
virtual ~CalibratedElectronProducer()
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
float correctedEcalEnergy() const
Classification classification() const
T const * product() const
virtual GsfElectronCoreRef core() const
float correctedEcalEnergyError() const
bool trackerDrivenSeed() const
CalibratedElectronProducer(const edm::ParameterSet &)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Power< A, B >::type pow(const A &a, const B &b)
bool ecalDrivenSeed() const