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");
68 if ( isMC && ( dataset !=
"Summer11" && dataset !=
"Fall11"
69 && dataset!=
"Summer12" && dataset !=
"Summer12_DR53X_HCP2012"
70 && dataset !=
"Summer12_LegacyPaper" ) )
72 throw cms::Exception(
"CalibratedgsfElectronProducer|ConfigError") <<
"Unknown MC dataset";
74 if ( !isMC && ( dataset !=
"Prompt" && dataset !=
"ReReco"
75 && dataset !=
"Jan16ReReco" && dataset !=
"ICHEP2012"
76 && dataset !=
"Moriond2013" && dataset !=
"22Jan2013ReReco" ) )
78 throw cms::Exception(
"CalibratedgsfElectronProducer|ConfigError") <<
"Unknown Data dataset";
82 if(combinationType!=3 && applyLinearityCorrection)
84 std::cout <<
"[CalibratedElectronProducer] "
85 <<
"Warning: you chose combinationType!=3 and applyLinearityCorrection=True. Linearity corrections are only applied on top of combination 3." << std::endl;
88 std::cout <<
"[CalibratedGsfElectronProducer] Correcting scale for dataset " << dataset << std::endl;
92 switch (correctionsType)
99 std::cout <<
"You choose regression 1 scale corrections" << std::endl;
105 std::cout <<
"You choose regression 2 scale corrections." << std::endl;
110 <<
"You choose standard non-regression ecal energy scale corrections. They are not implemented yet.";
114 <<
"Unknown correctionsType !!!" ;
123 applyLinearityCorrection,
133 std::cout<<
"[CalibratedGsfElectronProducer] "
134 <<
"ElectronEnergyCalibrator object is created" << std::endl;
138 myEpCombinationTool->init
148 std::cout <<
"[CalibratedGsfElectronProducer] "
149 <<
"Combination tools are created and initialized" << std::endl;
152 produces<edm::ValueMap<double> >(nameNewEnergyReg_);
153 produces<edm::ValueMap<double> >(nameNewEnergyErrorReg_);
154 produces<GsfElectronCollection> (newElectronName_);
155 geomInitialized_ =
false;
163 if (!geomInitialized_)
167 ecalTopology_ = & (*theCaloTopology);
171 caloGeometry_ = & (*theCaloGeometry);
172 geomInitialized_ =
true;
177 event.getByToken(inputElectronsToken_,oldElectronsH) ;
182 event.getByToken( recHitCollectionEBToken_, pEBRecHits );
183 event.getByToken( recHitCollectionEEToken_, pEERecHits );
187 event.getByToken(energyRegToken_,valMapEnergyH);
189 event.getByToken(energyErrorRegToken_,valMapEnergyErrorH);
201 unsigned nElectrons = oldElectronsH->size();
202 for(
unsigned iele = 0; iele < nElectrons; ++iele )
204 electrons->push_back((*oldElectronsH)[iele]);
207 std::vector<double> regressionValues;
208 std::vector<double> regressionErrorValues;
209 regressionValues.reserve(nElectrons);
210 regressionErrorValues.reserve(nElectrons);
212 if ( correctionsType != 0 )
214 for (
unsigned iele = 0; iele < nElectrons ; ++iele)
218 double regressionEnergy = (*valMapEnergyH)[elecRef];
219 double regressionEnergyError = (*valMapEnergyErrorH)[elecRef];
221 regressionValues.push_back(regressionEnergy);
222 regressionErrorValues.push_back(regressionEnergyError);
228 recHits = pEBRecHits.
product();
229 }
else recHits = pEERecHits.
product();
234 int run =
event.run();
236 float r9 = mySCHelper.
r9();
241 double combinedMomentum = ele.
p();
248 double error = 999. ;
249 double momentum = (combinedMomentum<15. ? 15. : combinedMomentum);
252 float parEB[3] = { 5.24e-02, 2.01e-01, 1.00e-02};
253 error = momentum *
sqrt(
pow(parEB[0]/
sqrt(momentum),2) +
pow(parEB[1]/momentum,2) +
pow(parEB[2],2) );
255 else if ( ele.
isEE() )
257 float parEE[3] = { 1.46e-01, 9.21e-01, 1.94e-03} ;
258 error = momentum *
sqrt(
pow(parEE[0]/
sqrt(momentum),2) +
pow(parEE[1]/momentum,2) +
pow(parEE[2],2) );
260 combinedMomentumError =
error;
275 correctedEcalEnergyError,
279 regressionEnergyError,
281 combinedMomentumError,
290 if ( ele.
core()->ecalDrivenSeed() || correctionsType==2 || combinationType==3 )
292 theEnCorrector->calibrate(mySimpleElectron, event.
streamID());
296 switch ( combinationType )
301 std::cout <<
"[CalibratedGsfElectronProducer] "
302 <<
"You choose not to combine." << std::endl;
308 std::cout <<
"[CalibratedGsfElectronProducer] "
309 <<
"You choose corrected regression energy for standard combination" << std::endl;
311 myCombinator->setCombinationMode(1);
312 myCombinator->combine(mySimpleElectron);
317 std::cout <<
"[CalibratedGsfElectronProducer] "
318 <<
"You choose uncorrected regression energy for standard combination" << std::endl;
320 myCombinator->setCombinationMode(2);
321 myCombinator->combine(mySimpleElectron);
326 std::cout <<
"[CalibratedGsfElectronProducer] "
327 <<
"You choose regression combination." << std::endl;
329 myEpCombinationTool->combine(mySimpleElectron);
330 theEnCorrector->correctLinearity(mySimpleElectron);
334 <<
"Unknown combination Type !!!" ;
340 ( oldMomentum.x()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
341 oldMomentum.y()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
342 oldMomentum.z()*mySimpleElectron.getCombinedMomentum()/oldMomentum.t(),
343 mySimpleElectron.getCombinedMomentum() ) ;
348 mySimpleElectron.getTrackerMomentumError(),
349 mySimpleElectron.getCombinedMomentumError()
354 std::cout <<
"[CalibratedGsfElectronProducer] Combined momentum after saving "
355 << ele.
p4().t() << std::endl;
363 std::cout <<
"[CalibratedGsfElectronProducer] "
364 <<
"You choose not to correct. Uncorrected Regression Energy is taken." << std::endl;
370 energyFiller.
insert(gsfNewElectronHandle,regressionValues.begin(),regressionValues.end());
372 energyErrorFiller.
insert(gsfNewElectronHandle,regressionErrorValues.begin(),regressionErrorValues.end());
373 energyErrorFiller.
fill();
375 event.put(regrNewEnergyMap,nameNewEnergyReg_);
376 event.put(regrNewEnergyErrorMap,nameNewEnergyErrorReg_);
T getParameter(std::string const &) const
float trackMomentumError() const
const LorentzVector & p4(P4Kind kind) const
P4Kind candidateP4Kind() const
virtual double p() const GCC11_FINAL
magnitude of momentum vector
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
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