19 using namespace reco ;
28 inputCollectionType_ = cfg.
getParameter<uint32_t>(
"inputCollectionType");
31 energyRegressionType_ = cfg.
getParameter<uint32_t>(
"energyRegressionType");
38 useReducedRecHits_ = cfg.
getParameter<
bool>(
"useRecHitCollections");
39 produceValueMaps_ = cfg.
getParameter<
bool>(
"produceValueMaps");
42 if(inputCollectionType_ == 0 && !useReducedRecHits_) {
43 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;
46 if(inputCollectionType_ == 0 && !produceValueMaps_) {
47 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;
50 if (inputCollectionType_ == 0) {
52 }
else if (inputCollectionType_ == 1) {
53 produces<ElectronCollection>();
55 throw cms::Exception(
"InconsistentParameters") <<
" inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) " << std::endl;
67 regressionEvaluator_->initialize(regressionInputFile_.c_str(),
type);
69 if(produceValueMaps_) {
70 produces<edm::ValueMap<double> >(nameEnergyReg_);
71 produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
79 geomInitialized_ =
false;
81 std::cout <<
" Finished initialization " << std::endl;
87 delete regressionEvaluator_;
94 assert(regressionEvaluator_->isInitialized());
95 if (!geomInitialized_) {
98 ecalTopology_ = & (*theCaloTopology);
102 caloGeometry_ = & (*theCaloGeometry);
103 geomInitialized_ =
true;
111 event.getByToken(verticesInputToken_,hVertexProduct);
116 for (reco::VertexCollection::const_iterator inV = inVertices.begin();
117 inV != inVertices.end(); ++inV) {
121 && inV->position().Rho() <= 2.0
122 && fabs(inV->z()) <= 24.0
133 event.getByToken(rhoInputToken_, hRhoKt6PFJets);
134 rho = (*hRhoKt6PFJets);
142 if (useReducedRecHits_) {
143 event.getByToken( recHitCollectionEBToken_, pEBRecHits );
144 event.getByToken( recHitCollectionEEToken_, pEERecHits );
149 if ( inputCollectionType_ == 0 ) {
150 event.getByToken ( inputGsfElectronsToken_,gsfCollectionH ) ;
151 nElectrons_ = gsfCollectionH->size();
153 if ( inputCollectionType_ == 1 ) {
154 event.getByToken ( inputPatElectronsToken_,patCollectionH ) ;
155 nElectrons_ = patCollectionH->size();
170 std::vector<double> energyValues;
171 std::vector<double> energyErrorValues;
172 energyValues.reserve(nElectrons_);
173 energyErrorValues.reserve(nElectrons_);
176 for(
unsigned iele=0; iele < nElectrons_ ; ++iele) {
178 const GsfElectron * ele = ( inputCollectionType_ == 0 ) ? &(*gsfCollectionH)[iele] : &(*patCollectionH)[iele] ;
180 std::cout <<
"***********************************************************************\n";
181 std::cout <<
"Run Lumi Event: " <<
event.id().run() <<
" " <<
event.luminosityBlock() <<
" " <<
event.id().event() <<
"\n";
182 std::cout <<
"Pat Electron : " << ele->
pt() <<
" " << ele->
eta() <<
" " << ele->
phi() <<
"\n";
188 if (useReducedRecHits_) {
190 recHits = pEBRecHits.
product();
192 recHits = pEERecHits.
product();
194 recHits = (*patCollectionH)[iele].recHits();
198 if ( inputCollectionType_ == 0 ) {
200 }
else if ( inputCollectionType_ == 1) {
201 mySCHelper =
new SuperClusterHelper( &(*patCollectionH)[iele], recHits,ecalTopology_,caloGeometry_);
205 Double_t FinalMomentum = 0;
206 Double_t FinalMomentumError = 0;
207 Double_t RegressionMomentum = 0;
208 Double_t RegressionMomentumError = 0;
210 if (energyRegressionType_ == 1) {
212 RegressionMomentum = regressionEvaluator_->regressionValueNoTrkVar( mySCHelper->
rawEnergy(),
247 RegressionMomentumError = regressionEvaluator_->regressionUncertaintyNoTrkVar(
285 if(inputCollectionType_ == 1) {
288 energyValues.push_back(RegressionMomentum);
289 energyErrorValues.push_back(RegressionMomentumError);
292 }
else if (energyRegressionType_ == 2) {
293 RegressionMomentum = regressionEvaluator_->regressionValueWithSubClusters(
361 RegressionMomentumError = regressionEvaluator_->regressionUncertaintyWithSubClusters(
431 if(inputCollectionType_ == 1) {
434 energyValues.push_back(RegressionMomentum);
435 energyErrorValues.push_back(RegressionMomentumError);
440 else if (energyRegressionType_ == 3) {
441 RegressionMomentum = regressionEvaluator_->regressionValueWithTrkVar(ele->
p(),
482 RegressionMomentumError = regressionEvaluator_->regressionUncertaintyWithTrkVar(
524 FinalMomentum = RegressionMomentum;
525 FinalMomentumError = RegressionMomentumError;
528 ( oldMomentum.x()*FinalMomentum/oldMomentum.t(),
529 oldMomentum.y()*FinalMomentum/oldMomentum.t(),
530 oldMomentum.z()*FinalMomentum/oldMomentum.t(),
536 energyValues.push_back(RegressionMomentum);
537 energyErrorValues.push_back(RegressionMomentumError);
539 cout <<
"Error: RegressionType = " << energyRegressionType_ <<
" is not supported.\n";
542 if(inputCollectionType_ == 1) {
543 patElectrons->push_back(*myPatElectron);
545 if (myPatElectron)
delete myPatElectron;
546 if (mySCHelper)
delete mySCHelper;
550 if(inputCollectionType_ == 1) {
551 event.put(patElectrons) ;
555 if (produceValueMaps_) {
557 if ( inputCollectionType_ ==0 ) {
558 energyFiller.
insert( gsfCollectionH, energyValues.begin(), energyValues.end() );
559 energyErrorFiller.
insert( gsfCollectionH, energyErrorValues.begin(), energyErrorValues.end() );
560 }
else if ( inputCollectionType_ ==1 ) {
561 energyFiller.
insert( patCollectionH, energyValues.begin(), energyValues.end() );
562 energyErrorFiller.
insert( patCollectionH, energyErrorValues.begin(), energyErrorValues.end() );
566 energyErrorFiller.
fill();
567 event.put(regrEnergyMap,nameEnergyReg_);
568 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
#define DEFINE_FWK_MODULE(type)
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
float eSubClusters() const
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
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
T const * product() const
Analysis-level electron class.
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