36 using namespace reco ;
56 updateEnergyError = cfg.
getParameter<
bool>(
"updateEnergyError");
58 correctionsType = cfg.
getParameter<
int>(
"correctionsType");
59 applyLinearityCorrection = cfg.
getParameter<
bool>(
"applyLinearityCorrection");
60 combinationType = cfg.
getParameter<
int>(
"combinationType");
62 synchronization = cfg.
getParameter<
bool>(
"synchronization");
69 if ( isMC && ( dataset !=
"Summer11" && dataset !=
"Fall11"
70 && dataset!=
"Summer12" && dataset !=
"Summer12_DR53X_HCP2012"
71 && dataset !=
"Summer12_LegacyPaper" ) )
73 throw cms::Exception(
"CalibratedgsfElectronProducer|ConfigError") <<
"Unknown MC dataset";
75 if ( !isMC && ( dataset !=
"Prompt" && dataset !=
"ReReco"
76 && dataset !=
"Jan16ReReco" && dataset !=
"ICHEP2012"
77 && dataset !=
"Moriond2013" && dataset !=
"22Jan2013ReReco" ) )
79 throw cms::Exception(
"CalibratedgsfElectronProducer|ConfigError") <<
"Unknown Data dataset";
83 if(combinationType!=3 && applyLinearityCorrection)
85 std::cout <<
"[CalibratedElectronProducer] "
86 <<
"Warning: you chose combinationType!=3 and applyLinearityCorrection=True. Linearity corrections are only applied on top of combination 3." << std::endl;
89 std::cout <<
"[CalibratedGsfElectronProducer] Correcting scale for dataset " << dataset << std::endl;
93 switch (correctionsType)
100 std::cout <<
"You choose regression 1 scale corrections" << std::endl;
106 std::cout <<
"You choose regression 2 scale corrections." << std::endl;
111 <<
"You choose standard non-regression ecal energy scale corrections. They are not implemented yet.";
115 <<
"Unknown correctionsType !!!" ;
124 applyLinearityCorrection,
134 std::cout<<
"[CalibratedGsfElectronProducer] "
135 <<
"ElectronEnergyCalibrator object is created" << std::endl;
139 myEpCombinationTool->init
149 std::cout <<
"[CalibratedGsfElectronProducer] "
150 <<
"Combination tools are created and initialized" << std::endl;
153 produces<edm::ValueMap<double> >(nameNewEnergyReg_);
154 produces<edm::ValueMap<double> >(nameNewEnergyErrorReg_);
155 produces<GsfElectronCollection> (newElectronName_);
156 geomInitialized_ =
false;
164 if (!geomInitialized_)
168 ecalTopology_ = & (*theCaloTopology);
172 caloGeometry_ = & (*theCaloGeometry);
173 geomInitialized_ =
true;
178 event.getByToken(inputElectronsToken_,oldElectronsH) ;
183 event.getByToken( recHitCollectionEBToken_, pEBRecHits );
184 event.getByToken( recHitCollectionEEToken_, pEERecHits );
188 event.getByToken(energyRegToken_,valMapEnergyH);
190 event.getByToken(energyErrorRegToken_,valMapEnergyErrorH);
202 unsigned nElectrons = oldElectronsH->size();
203 for(
unsigned iele = 0; iele < nElectrons; ++iele )
205 electrons->push_back((*oldElectronsH)[iele]);
208 std::vector<double> regressionValues;
209 std::vector<double> regressionErrorValues;
210 regressionValues.reserve(nElectrons);
211 regressionErrorValues.reserve(nElectrons);
213 if ( correctionsType != 0 )
215 for (
unsigned iele = 0; iele < nElectrons ; ++iele)
219 double regressionEnergy = (*valMapEnergyH)[elecRef];
220 double regressionEnergyError = (*valMapEnergyErrorH)[elecRef];
222 regressionValues.push_back(regressionEnergy);
223 regressionErrorValues.push_back(regressionEnergyError);
229 recHits = pEBRecHits.
product();
230 }
else recHits = pEERecHits.
product();
235 int run =
event.run();
237 float r9 = mySCHelper.
r9();
242 double combinedMomentum = ele.
p();
249 double error = 999. ;
250 double momentum = (combinedMomentum<15. ? 15. : combinedMomentum);
253 float parEB[3] = { 5.24e-02, 2.01e-01, 1.00e-02};
254 error = momentum *
sqrt(
pow(parEB[0]/
sqrt(momentum),2) +
pow(parEB[1]/momentum,2) +
pow(parEB[2],2) );
256 else if ( ele.
isEE() )
258 float parEE[3] = { 1.46e-01, 9.21e-01, 1.94e-03} ;
259 error = momentum *
sqrt(
pow(parEE[0]/
sqrt(momentum),2) +
pow(parEE[1]/momentum,2) +
pow(parEE[2],2) );
261 combinedMomentumError =
error;
276 correctedEcalEnergyError,
280 regressionEnergyError,
282 combinedMomentumError,
291 if ( ele.
core()->ecalDrivenSeed() || correctionsType==2 || combinationType==3 )
293 theEnCorrector->calibrate(mySimpleElectron, event.
streamID());
297 switch ( combinationType )
302 std::cout <<
"[CalibratedGsfElectronProducer] "
303 <<
"You choose not to combine." << std::endl;
309 std::cout <<
"[CalibratedGsfElectronProducer] "
310 <<
"You choose corrected regression energy for standard combination" << std::endl;
312 myCombinator->setCombinationMode(1);
313 myCombinator->combine(mySimpleElectron);
318 std::cout <<
"[CalibratedGsfElectronProducer] "
319 <<
"You choose uncorrected regression energy for standard combination" << std::endl;
321 myCombinator->setCombinationMode(2);
322 myCombinator->combine(mySimpleElectron);
327 std::cout <<
"[CalibratedGsfElectronProducer] "
328 <<
"You choose regression combination." << std::endl;
331 theEnCorrector->correctLinearity(mySimpleElectron);
335 <<
"Unknown combination Type !!!" ;
341 ( oldMomentum.x()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
342 oldMomentum.y()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
343 oldMomentum.z()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
344 mySimpleElectron.getCombinedMomentum() ) ;
349 mySimpleElectron.getTrackerMomentumError(),
350 mySimpleElectron.getCombinedMomentumError()
355 std::cout <<
"[CalibratedGsfElectronProducer] Combined momentum after saving "
356 << ele.
p4().t() << std::endl;
364 std::cout <<
"[CalibratedGsfElectronProducer] "
365 <<
"You choose not to correct. Uncorrected Regression Energy is taken." << std::endl;
371 energyFiller.
insert(gsfNewElectronHandle,regressionValues.begin(),regressionValues.end());
373 energyErrorFiller.
insert(gsfNewElectronHandle,regressionErrorValues.begin(),regressionErrorValues.end());
374 energyErrorFiller.
fill();
376 event.put(regrNewEnergyMap,nameNewEnergyReg_);
377 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
#define DEFINE_FWK_MODULE(type)
tuple applyExtraHighEnergyProtection
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
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
T const * product() const
Classification classification() const
virtual GsfElectronCoreRef core() const
float correctedEcalEnergyError() const
StreamID streamID() 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