22 using namespace reco ;
30 inputCollectionType_ = cfg.
getParameter<uint32_t>(
"inputCollectionType");
33 energyRegressionType_ = cfg.
getParameter<uint32_t>(
"energyRegressionType");
34 regressionInputFile_ = cfg.
getParameter<std::string>(
"regressionInputFile");
37 nameEnergyReg_ = cfg.
getParameter<std::string>(
"nameEnergyReg");
38 nameEnergyErrorReg_ = cfg.
getParameter<std::string>(
"nameEnergyErrorReg");
40 useReducedRecHits_ = cfg.
getParameter<
bool>(
"useRecHitCollections");
41 produceValueMaps_ = cfg.
getParameter<
bool>(
"produceValueMaps");
44 if(inputCollectionType_ == 0 && !useReducedRecHits_) {
45 throw cms::Exception(
"InconsistentParameters") <<
" *** Inconsistent configuration : if you read GsfElectrons, you should set useRecHitCollections to true and provide the correcte values to recHitCollectionEB and recHitCollectionEE (most probably reducedEcalRecHitsEB and reducedEcalRecHitsEE )" << std::endl;
48 if(inputCollectionType_ == 0 && !produceValueMaps_) {
49 std::cout <<
" You are running on GsfElectrons and the producer is not configured to produce ValueMaps with the results. In that case, it does not nothing !! " << std::endl;
52 if (inputCollectionType_ == 0) {
54 }
else if (inputCollectionType_ == 1) {
55 produces<ElectronCollection>();
57 throw cms::Exception(
"InconsistentParameters") <<
" inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) " << std::endl;
69 regressionEvaluator_->initialize(regressionInputFile_.c_str(),
type);
71 if(produceValueMaps_) {
72 produces<edm::ValueMap<double> >(nameEnergyReg_);
73 produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
81 geomInitialized_ =
false;
83 std::cout <<
" Finished initialization " << std::endl;
89 delete regressionEvaluator_;
96 assert(regressionEvaluator_->isInitialized());
97 if (!geomInitialized_) {
100 ecalTopology_ = & (*theCaloTopology);
104 caloGeometry_ = & (*theCaloGeometry);
105 geomInitialized_ =
true;
113 event.getByLabel(verticesInputTag_,hVertexProduct);
118 for (reco::VertexCollection::const_iterator inV = inVertices.begin();
119 inV != inVertices.end(); ++inV) {
123 && inV->position().Rho() <= 2.0
124 && fabs(inV->z()) <= 24.0
135 event.getByLabel(rhoInputTag_, hRhoKt6PFJets);
136 rho = (*hRhoKt6PFJets);
144 if (useReducedRecHits_) {
145 event.getByLabel( recHitCollectionEB_, pEBRecHits );
146 event.getByLabel( recHitCollectionEE_, pEERecHits );
151 if ( inputCollectionType_ == 0 ) {
152 event.getByLabel ( inputElectrons_,gsfCollectionH ) ;
153 nElectrons_ = gsfCollectionH->size();
155 if ( inputCollectionType_ == 1 ) {
156 event.getByLabel ( inputElectrons_,patCollectionH ) ;
157 nElectrons_ = patCollectionH->size();
172 std::vector<double> energyValues;
173 std::vector<double> energyErrorValues;
174 energyValues.reserve(nElectrons_);
175 energyErrorValues.reserve(nElectrons_);
178 for(
unsigned iele=0; iele < nElectrons_ ; ++iele) {
180 const GsfElectron * ele = ( inputCollectionType_ == 0 ) ? &(*gsfCollectionH)[iele] : &(*patCollectionH)[iele] ;
182 std::cout <<
"***********************************************************************\n";
183 std::cout <<
"Run Lumi Event: " <<
event.id().run() <<
" " <<
event.luminosityBlock() <<
" " <<
event.id().event() <<
"\n";
184 std::cout <<
"Pat Electron : " << ele->
pt() <<
" " << ele->
eta() <<
" " << ele->
phi() <<
"\n";
190 if (useReducedRecHits_) {
192 recHits = pEBRecHits.
product();
194 recHits = pEERecHits.
product();
196 recHits = (*patCollectionH)[iele].recHits();
200 if ( inputCollectionType_ == 0 ) {
202 }
else if ( inputCollectionType_ == 1) {
203 mySCHelper =
new SuperClusterHelper( &(*patCollectionH)[iele], recHits,ecalTopology_,caloGeometry_);
207 Double_t FinalMomentum = 0;
208 Double_t FinalMomentumError = 0;
209 Double_t RegressionMomentum = 0;
210 Double_t RegressionMomentumError = 0;
212 if (energyRegressionType_ == 1) {
214 RegressionMomentum = regressionEvaluator_->regressionValueNoTrkVar( mySCHelper->
rawEnergy(),
249 RegressionMomentumError = regressionEvaluator_->regressionUncertaintyNoTrkVar(
287 if(inputCollectionType_ == 1) {
290 energyValues.push_back(RegressionMomentum);
291 energyErrorValues.push_back(RegressionMomentumError);
294 }
else if (energyRegressionType_ == 2) {
295 RegressionMomentum = regressionEvaluator_->regressionValueWithSubClusters(
363 RegressionMomentumError = regressionEvaluator_->regressionUncertaintyWithSubClusters(
433 if(inputCollectionType_ == 1) {
436 energyValues.push_back(RegressionMomentum);
437 energyErrorValues.push_back(RegressionMomentumError);
442 else if (energyRegressionType_ == 3) {
443 RegressionMomentum = regressionEvaluator_->regressionValueWithTrkVar(ele->
p(),
484 RegressionMomentumError = regressionEvaluator_->regressionUncertaintyWithTrkVar(
526 FinalMomentum = RegressionMomentum;
527 FinalMomentumError = RegressionMomentumError;
530 ( oldMomentum.x()*FinalMomentum/oldMomentum.t(),
531 oldMomentum.y()*FinalMomentum/oldMomentum.t(),
532 oldMomentum.z()*FinalMomentum/oldMomentum.t(),
538 energyValues.push_back(RegressionMomentum);
539 energyErrorValues.push_back(RegressionMomentumError);
541 cout <<
"Error: RegressionType = " << energyRegressionType_ <<
" is not supported.\n";
544 if(inputCollectionType_ == 1) {
545 patElectrons->push_back(*myPatElectron);
547 if (myPatElectron)
delete myPatElectron;
548 if (mySCHelper)
delete mySCHelper;
552 if(inputCollectionType_ == 1) {
553 event.put(patElectrons) ;
557 if (produceValueMaps_) {
559 if ( inputCollectionType_ ==0 ) {
560 energyFiller.
insert( gsfCollectionH, energyValues.begin(), energyValues.end() );
561 energyErrorFiller.
insert( gsfCollectionH, energyErrorValues.begin(), energyErrorValues.end() );
562 }
else if ( inputCollectionType_ ==1 ) {
563 energyFiller.
insert( patCollectionH, energyValues.begin(), energyValues.end() );
564 energyErrorFiller.
insert( patCollectionH, energyErrorValues.begin(), energyErrorValues.end() );
568 energyErrorFiller.
fill();
569 event.put(regrEnergyMap,nameEnergyReg_);
570 event.put(regrEnergyErrorMap,nameEnergyErrorReg_);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void correctEcalEnergy(float newEnergy, float newEnergyError)
virtual double p() const
magnitude of momentum vector
RegressionEnergyPatElectronProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
float trackMomentumError() const
float eESClusters() const
const LorentzVector & p4(P4Kind kind) const
float eSuperClusterOverP() const
float esClusterEnergy(unsigned i) const
float sigmaIetaIeta() const
float subClusterE3x3(unsigned i) const
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
math::XYZVectorF trackMomentumAtVtx() const
void insert(const H &h, I begin, I end)
virtual ~RegressionEnergyPatElectronProducer()
std::vector< Vertex > VertexCollection
collection of Vertex objects
DEFINE_FWK_MODULE(HiMixingModule)
float eSubClusters() const
virtual double eta() const
momentum pseudorapidity
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
float esClusterEta(unsigned i) const
float subClusterEnergy(unsigned i) const
float preshowerEnergyOverRaw() const
virtual int charge() const
electric charge
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
std::vector< Electron > ElectronCollection
collectin of Electron objects
float preshowerEnergy() const
float hadronicOverEm() const
float subClusterEmax(unsigned i) const
ElectronEnergyRegressionType
float esClusterPhi(unsigned i) const
float subClusterPhi(unsigned i) const
virtual double pt() const
transverse momentum
Analysis-level electron class.
T const * product() const
float nPreshowerClusters() const
float clustersSize() const
float subClusterEta(unsigned i) const
virtual double phi() const
momentum azimuthal angle
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setEcalRegressionEnergy(double val, double err)
set regression1
bool ecalDrivenSeed() const