34 #include "Math/VectorUtil.h"
46 LogInfo(
"GoodSeedProducer")<<
"Electron PreIdentification started ";
49 std::vector<edm::InputTag>
tags = iConfig.
getParameter< vector < InputTag > >(
"TkColList");
50 for(
unsigned int i=0;
i<tags.size();++
i) {
101 LogDebug(
"GoodSeedProducer")<<
"Seeds for GSF will be produced ";
104 produces<ElectronSeedCollection>(
preidgsf_);
107 LogDebug(
"GoodSeedProducer")<<
"Seeds for CKF will be produced ";
108 produces<TrajectorySeedCollection>(
preidckf_);
112 LogDebug(
"GoodSeedProducer")<<
"PreId debugging information will be produced ";
138 for (UInt_t
j = 0;
j < 9; ++
j){
155 <<
" in run "<<iEvent.
id().
run();
175 std::string theTrackerRecHitBuilderName(
"WithAngleAndTemplate");
178 std::string theTrackerRecHitBuilderName(
"hltESPTTRHBWithTrackAngle");
195 vector<PFCluster const *> basClus;
196 for (
auto const & klus : *theECPfClustCollection.
product() ) {
197 if(klus.correctedEnergy()>
clusThreshold_) basClus.push_back(&klus);
219 auto const & Tj=*(tjCollection.
product());
221 LogDebug(
"GoodSeedProducer")<<
"Number of tracks in collection "
226 for(
unsigned int i=0;
i<Tk.size();++
i){
231 bool GoodPreId=
false;
236 auto tketa= tkmom.eta();
238 auto const & Seed=(*trackRef->seedRef());
244 float oPTOB=1.f/Tj[
i].lastMeasurement().updatedState().globalMomentum().mag();
246 float nchi=Tk[
i].normalizedChi2();
248 int nhitpi=Tj[
i].foundHits();
256 auto pfoutenergy=
sqrt((pfmass*pfmass)+Tk[
i].outerMomentum().Mag2());
259 Tk[
i].outerMomentum().
y(),
260 Tk[
i].outerMomentum().
z(),
263 Tk[
i].outerPosition().
y(),
264 Tk[
i].outerPosition().
z(),
271 theOutParticle.propagateToEcalEntrance(
false);
284 if(theOutParticle.getSuccess()!=0){
285 ElecTrkEcalPos=
GlobalPoint(theOutParticle.vertex().x(),
286 theOutParticle.vertex().y(),
287 theOutParticle.vertex().z()
291 bool isBelowPS= (ElecTrkEcalPos.
z()*ElecTrkEcalPos.
z()) > (psLim*psLim)*ElecTrkEcalPos.
perp2();
294 unsigned clusCounter=0;
296 for(
auto aClus : basClus) {
298 float tmp_ep=float(aClus->correctedEnergy())*oPTOB;
299 if ((tmp_ep<
minEp_)|(tmp_ep>
maxEp_)) { ++clusCounter;
continue;}
301 double ecalShowerDepth
302 = PFCluster::getDepthCorrection(aClus->correctedEnergy(),
305 auto mom = theOutParticle.momentum().Vect();
306 auto meanShower = ElecTrkEcalPos +
309 float etarec=meanShower.eta();
310 float phirec=meanShower.phi();
313 float tmp_phi=
std::abs(aClus->positionREP().phi()-phirec);
317 std::pow(aClus->positionREP().eta()-etarec,2.f));
322 if(aClus->correctedEnergy() > max_ee){
324 toteta=aClus->positionREP().eta()-etarec;
327 EE=aClus->correctedEnergy();
328 feta= aClus->positionREP().eta();
329 clusterRef =
PFClusterRef(theECPfClustCollection,clusCounter);
330 meanShowerSaved = meanShower;
338 float trk_ecalDeta_ = fabs(toteta);
339 float trk_ecalDphi_ = fabs(totphi);
348 float chieta=(toteta!=1000.f)? toteta/ecaletares : toteta;
349 float chiphi=(totphi!=1000.f)? totphi/ecalphires : totphi;
350 float chichi=
sqrt(chieta*chieta + chiphi*chiphi);
353 float eta_cut =
thr[ibin+0];
354 float phi_cut =
thr[ibin+1];
355 float ep_cutmin=
thr[ibin+2];
356 bool GoodMatching= ((trk_ecalDeta_<eta_cut) && (trk_ecalDphi_<phi_cut) && (EP>ep_cutmin) && (nhitpi>10));
358 bool EcalMatching=GoodMatching;
360 if (tkpt>
maxPt_) GoodMatching=
true;
361 if (tkpt<
minPt_) GoodMatching=
false;
365 math::XYZPoint myPoint(ElecTrkEcalPos.
x(),ElecTrkEcalPos.
y(),ElecTrkEcalPos.
z());
374 int hit1max=int(
thr[ibin+3]);
375 float chiredmin=
thr[ibin+4];
376 bool GoodKFFiltering =
377 ((nchi>chiredmin) | (nhitpi<hit1max));
382 bool GoodTkId=
false;
384 if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
395 for (
int ih=hits.size()-1; ih>=0; ih--) tmp.push_back(hits[ih]);
396 Trajectory && FitTjs=
fitter_->fitOne(Seed,tmp,Tj[
i].lastMeasurement().updatedState());
405 updatedState().globalMomentum().perp();
407 updatedState().globalMomentum().perp();
408 dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
426 float BDTcut=
thr[ibin+5];
427 if ( Ytmva>BDTcut) GoodTkId=
true;
428 myPreId.
setMVA(GoodTkId,Ytmva);
432 float chiratiocut=
thr[ibin+6];
433 float gschicut=
thr[ibin+7];
434 float gsptmin=
thr[ibin+8];
441 GoodPreId= GoodTkId | GoodMatching;
446 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
447 "GeV/c, eta= "<<Tk[
i].eta() <<
448 ") preidentified for agreement between track and ECAL cluster";
449 if(GoodPreId &&(!GoodMatching))
450 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
451 "GeV/c, eta= "<<Tk[
i].eta() <<
452 ") preidentified only for track properties";
460 output_preid->push_back(NewSeed);
463 output_nopre->push_back(Seed);
469 refMap_[trackRef] = output_preidinfo->size();
470 output_preidinfo->push_back(myPreId);
526 for(UInt_t
j = 0;
j < 9; ++
j){
527 reader[
j] =
new TMVA::Reader(
"!Color:Silent");
553 ifstream ifs(parFile.
fullPath().c_str());
554 for (
int iy=0;iy<81;++iy) ifs >>
thr[iy];
571 if (fabs(eta)<0.8) ie=0;
572 else{
if (fabs(eta)<1.479) ie=1;
576 else {
if (pt<12) ip=1;
580 LogDebug(
"GoodSeedProducer")<<
"Track pt ="<<pt<<
" eta="<<eta<<
" bin="<<iep;
588 std::vector<reco::PreIdRef>
values;
590 unsigned ntracks=tracks->size();
591 for(
unsigned itrack=0;itrack<ntracks;++itrack)
594 std::map<reco::TrackRef,unsigned>::const_iterator itcheck=
refMap_.find(theTrackRef);
603 values.push_back(preIdRef);
607 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
float eP
VARIABLES NEEDED FOR TMVA.
std::unique_ptr< TrajectorySmoother > smoother_
Smoother.
void insert(const H &h, I begin, I end)
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
PFResolutionMap * resMapEtaECAL_
double EcalStripSumE_minClusEnergy_
float thr[150]
vector of thresholds for different bins of eta and pt
int FindBin(double eta, double e)
extrapolation requires overloading of this function
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
TMVA::Reader * reader[9]
READER FOR TMVA.
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.
PFResolutionMap * resMapPhiECAL_
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
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
virtual void endRun(const edm::Run &run, const edm::EventSetup &) override
bool produceCkfseed_
Produce the Seed for Ckf tracks?
TrajectoryMeasurement const & firstMeasurement() const
bool useTmva_
USE OF TMVA.
XYZPointD XYZPoint
point in space with cartesian internal representation
T const * product() const
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.
GoodSeedProducer(const edm::ParameterSet &)
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