35 #include "Math/VectorUtil.h"
47 LogInfo(
"GoodSeedProducer")<<
"Electron PreIdentification started ";
50 std::vector<edm::InputTag>
tags = iConfig.
getParameter< vector < InputTag > >(
"TkColList");
51 for(
unsigned int i=0;
i<tags.size();++
i) {
102 LogDebug(
"GoodSeedProducer")<<
"Seeds for GSF will be produced ";
105 produces<ElectronSeedCollection>(
preidgsf_);
108 LogDebug(
"GoodSeedProducer")<<
"Seeds for CKF will be produced ";
109 produces<TrajectorySeedCollection>(
preidckf_);
113 LogDebug(
"GoodSeedProducer")<<
"PreId debugging information will be produced ";
142 <<
" in run "<<iEvent.
id().
run();
175 vector<PFCluster const *> basClus;
176 for (
auto const & klus : *theECPfClustCollection.
product() ) {
177 if(klus.correctedEnergy()>
clusThreshold_) basClus.push_back(&klus);
199 auto const & Tj=*(tjCollection.
product());
201 LogDebug(
"GoodSeedProducer")<<
"Number of tracks in collection "
206 for(
unsigned int i=0;
i<Tk.size();++
i){
211 bool GoodPreId=
false;
216 auto tketa= tkmom.eta();
218 auto const & Seed=(*trackRef->seedRef());
224 float oPTOB=1.f/Tj[
i].lastMeasurement().updatedState().globalMomentum().mag();
226 float nchi=Tk[
i].normalizedChi2();
228 int nhitpi=Tj[
i].foundHits();
236 auto pfoutenergy=
sqrt((pfmass*pfmass)+Tk[
i].outerMomentum().Mag2());
239 Tk[
i].outerMomentum().
y(),
240 Tk[
i].outerMomentum().
z(),
243 Tk[
i].outerPosition().
y(),
244 Tk[
i].outerPosition().
z(),
251 theOutParticle.propagateToEcalEntrance(
false);
264 if(theOutParticle.getSuccess()!=0){
265 ElecTrkEcalPos=
GlobalPoint(theOutParticle.vertex().x(),
266 theOutParticle.vertex().y(),
267 theOutParticle.vertex().z()
271 bool isBelowPS= (ElecTrkEcalPos.
z()*ElecTrkEcalPos.
z()) > (psLim*psLim)*ElecTrkEcalPos.
perp2();
274 unsigned clusCounter=0;
276 for(
auto aClus : basClus) {
278 float tmp_ep=float(aClus->correctedEnergy())*oPTOB;
279 if ((tmp_ep<
minEp_)|(tmp_ep>
maxEp_)) { ++clusCounter;
continue;}
281 double ecalShowerDepth
282 = PFCluster::getDepthCorrection(aClus->correctedEnergy(),
285 auto mom = theOutParticle.momentum().Vect();
286 auto meanShower = ElecTrkEcalPos +
289 float etarec=meanShower.eta();
290 float phirec=meanShower.phi();
293 float tmp_phi=
std::abs(aClus->positionREP().phi()-phirec);
297 std::pow(aClus->positionREP().eta()-etarec,2.f));
302 if(aClus->correctedEnergy() > max_ee){
304 toteta=aClus->positionREP().eta()-etarec;
307 EE=aClus->correctedEnergy();
308 feta= aClus->positionREP().eta();
309 clusterRef =
PFClusterRef(theECPfClustCollection,clusCounter);
310 meanShowerSaved = meanShower;
318 float trk_ecalDeta_ = fabs(toteta);
319 float trk_ecalDphi_ = fabs(totphi);
328 float chieta=(toteta!=1000.f)? toteta/ecaletares : toteta;
329 float chiphi=(totphi!=1000.f)? totphi/ecalphires : totphi;
330 float chichi=
sqrt(chieta*chieta + chiphi*chiphi);
333 float eta_cut =
thr[ibin+0];
334 float phi_cut =
thr[ibin+1];
335 float ep_cutmin=
thr[ibin+2];
336 bool GoodMatching= ((trk_ecalDeta_<eta_cut) && (trk_ecalDphi_<phi_cut) && (EP>ep_cutmin) && (nhitpi>10));
338 bool EcalMatching=GoodMatching;
340 if (tkpt>
maxPt_) GoodMatching=
true;
341 if (tkpt<
minPt_) GoodMatching=
false;
345 math::XYZPoint myPoint(ElecTrkEcalPos.
x(),ElecTrkEcalPos.
y(),ElecTrkEcalPos.
z());
354 int hit1max=int(
thr[ibin+3]);
355 float chiredmin=
thr[ibin+4];
356 bool GoodKFFiltering =
357 ((nchi>chiredmin) | (nhitpi<hit1max));
362 bool GoodTkId=
false;
364 if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
375 for (
int ih=hits.size()-1; ih>=0; ih--) tmp.push_back(hits[ih]);
376 Trajectory && FitTjs=
fitter_->fitOne(Seed,tmp,Tj[
i].lastMeasurement().updatedState());
385 updatedState().globalMomentum().perp();
387 updatedState().globalMomentum().perp();
388 dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
406 float BDTcut=
thr[ibin+5];
407 if ( Ytmva>BDTcut) GoodTkId=
true;
408 myPreId.
setMVA(GoodTkId,Ytmva);
412 float chiratiocut=
thr[ibin+6];
413 float gschicut=
thr[ibin+7];
414 float gsptmin=
thr[ibin+8];
421 GoodPreId= GoodTkId | GoodMatching;
426 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
427 "GeV/c, eta= "<<Tk[
i].eta() <<
428 ") preidentified for agreement between track and ECAL cluster";
429 if(GoodPreId &&(!GoodMatching))
430 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
431 "GeV/c, eta= "<<Tk[
i].eta() <<
432 ") preidentified only for track properties";
440 output_preid->push_back(NewSeed);
443 output_nopre->push_back(Seed);
449 refMap_[trackRef] = output_preidinfo->size();
450 output_preidinfo->push_back(myPreId);
506 for(UInt_t
j = 0;
j < 9; ++
j){
507 reader[
j].reset(
new TMVA::Reader(
"!Color:Silent"));
533 ifstream ifs(parFile.
fullPath().c_str());
534 for (
int iy=0;iy<81;++iy) ifs >>
thr[iy];
541 if (fabs(eta)<0.8) ie=0;
542 else{
if (fabs(eta)<1.479) ie=1;
546 else {
if (pt<12) ip=1;
550 LogDebug(
"GoodSeedProducer")<<
"Track pt ="<<pt<<
" eta="<<eta<<
" bin="<<iep;
558 std::vector<reco::PreIdRef>
values;
560 unsigned ntracks=tracks->size();
561 for(
unsigned itrack=0;itrack<ntracks;++itrack)
564 std::map<reco::TrackRef,unsigned>::const_iterator itcheck=
refMap_.find(theTrackRef);
573 values.push_back(preIdRef);
577 filler.
insert(tracks,values.begin(),values.end());
int nHitsInSeed_
Number of hits in the seed;.
void setCharge(float q)
set the MEASURED charge
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
void setECALMatchingProperties(PFClusterRef clusterRef, const math::XYZPoint &ecalpos, const math::XYZPoint &meanShower, float deta, float dphi, float chieta, float chiphi, float chi2, float eop)
std::vector< reco::PreId > PreIdCollection
std::string preidckf_
Name of the Seed(Ckf) Collection.
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagPSLabel_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::array< std::unique_ptr< TMVA::Reader >, 9 > reader
READER FOR TMVA.
#define DEFINE_FWK_MODULE(type)
float eP
VARIABLES NEEDED FOR TMVA.
std::unique_ptr< TrajectorySmoother > smoother_
Smoother.
void insert(const H &h, I begin, I end)
Global3DPoint GlobalPoint
std::unique_ptr< PFResolutionMap > resMapEtaECAL_
std::vector< Track > TrackCollection
collection of Tracks
double EcalStripSumE_minClusEnergy_
float thr[150]
vector of thresholds for different bins of eta and pt
void setCtfTrack(const CtfTrackRef &)
Set additional info.
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setTrack(reco::TrackRef trackref)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int getBin(float, float)
Find the bin in pt and eta.
std::unique_ptr< TrajectoryFitter > fitter_
Fitter.
void setMVA(bool accepted, float mva, unsigned n=0)
std::string method_
TMVA method.
double EcalStripSumE_deltaEta_
double EcalStripSumE_deltaPhiOverQ_minValue_
std::vector< TrajectorySeed > TrajectorySeedCollection
double EcalStripSumE_deltaPhiOverQ_maxValue_
void setTrackFiltering(bool accepted, unsigned n=0)
virtual void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::Ref< PFClusterCollection > PFClusterRef
persistent reference to PFCluster objects
math::XYZVector B_
B field.
std::string preidname_
Name of the preid Collection (FB)
TrajectoryMeasurement const & lastMeasurement() const
TypeLabelItem const & produces()
declare what type of product will make and with which optional label
Abs< T >::type abs(const T &t)
bool useQuality_
TRACK QUALITY.
void fillPreIdRefValueMap(edm::Handle< reco::TrackCollection > tkhandle, const edm::OrphanHandle< reco::PreIdCollection > &, edm::ValueMap< reco::PreIdRef >::Filler &filler)
double minPt_
Minimum transverse momentum and maximum pseudorapidity.
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
bool disablePreId_
switch to disable the pre-id
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
virtual void beginRun(const edm::Run &run, const edm::EventSetup &) override
reco::TrackBase::TrackQuality trackQuality_
double clusThreshold_
Cut on the energy of the clusters.
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
bool produceCkfseed_
Produce the Seed for Ckf tracks?
TrajectoryMeasurement const & firstMeasurement() const
T const * product() const
bool useTmva_
USE OF TMVA.
std::unique_ptr< PFResolutionMap > resMapPhiECAL_
XYZPointD XYZPoint
point in space with cartesian internal representation
T const * product() const
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
std::vector< std::vector< double > > tmp
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
void setECALMatching(bool accepted, unsigned n=0)
std::map< reco::TrackRef, unsigned > refMap_
Map used to create the TrackRef, PreIdRef value map.
bool producePreId_
Produce the pre-id debugging collection.
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
GoodSeedProducer(const edm::ParameterSet &)
std::string trackerRecHitBuilderName_
std::string smootherName_
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagHCLabel_
std::string fullPath() const
Resolution Map (resolution as a function of eta and E)
std::string preidgsf_
Name of the Seed(Gsf) Collection.
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagECLabel_
double minEp_
Min and MAx allowed values forEoverP.
Power< A, B >::type pow(const A &a, const B &b)
std::vector< edm::EDGetTokenT< std::vector< Trajectory > > > trajContainers_
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
Global3DVector GlobalVector
void setFinalDecision(bool accepted, unsigned n=0)
math::XYZTLorentzVector XYZTLorentzVector