32 #include "Math/VectorUtil.h"
45 LogInfo(
"GoodSeedProducer")<<
"Electron PreIdentification started ";
50 iConfig.
getParameter< vector < InputTag > >(
"TkColList");
105 LogDebug(
"GoodSeedProducer")<<
"Seeds for GSF will be produced ";
108 produces<ElectronSeedCollection>(
preidgsf_);
111 LogDebug(
"GoodSeedProducer")<<
"Seeds for CKF will be produced ";
112 produces<TrajectorySeedCollection>(
preidckf_);
117 LogDebug(
"GoodSeedProducer")<<
"PreId debugging information will be produced ";
159 <<
" in run "<<iEvent.
id().
run();
182 vector<PFCluster> basClus;
183 vector<PFCluster>::const_iterator iklus;
184 for (iklus=theECPfClustCollection.
product()->begin();
185 iklus!=theECPfClustCollection.
product()->end();
201 for (iklus=thePSPfClustCollection.
product()->begin();
202 iklus!=thePSPfClustCollection.
product()->end();
206 if ((*iklus).layer()==-11)
ps1Clus.push_back(*iklus);
207 if ((*iklus).layer()==-12)
ps2Clus.push_back(*iklus);
221 vector<Trajectory> Tj=*(tjCollection.
product());
224 LogDebug(
"GoodSeedProducer")<<
"Number of tracks in collection "
230 for(
unsigned int i=0;
i<Tk.size();
i++){
235 bool GoodPreId=
false;
245 float PTOB=Tj[
i].lastMeasurement().updatedState().globalMomentum().mag();
246 float chikfred=Tk[
i].normalizedChi2();
247 int nhitpi=Tj[
i].foundHits();
254 float pfmass= 0.0005;
255 float pfoutenergy=
sqrt((pfmass*pfmass)+Tk[
i].outerMomentum().Mag2());
257 Tk[
i].outerMomentum().
y(),
258 Tk[
i].outerMomentum().
z(),
261 Tk[
i].outerPosition().
y(),
262 Tk[
i].outerPosition().
z(),
283 theOutParticle.
vertex().y(),
284 theOutParticle.
vertex().z());
285 bool isBelowPS=(fabs(theOutParticle.
vertex().eta())>1.65) ?
true :
false;
287 unsigned clusCounter=0;
289 for(vector<PFCluster>::const_iterator aClus = basClus.begin();
290 aClus != basClus.end(); aClus++,++clusCounter) {
292 double ecalShowerDepth
293 = PFCluster::getDepthCorrection(aClus->energy(),
300 float etarec=meanShower.eta();
301 float phirec=meanShower.phi();
302 float tmp_ep=aClus->energy()/PTOB;
303 float tmp_phi=fabs(aClus->position().phi()-phirec);
305 float tmp_dr=
sqrt(
pow(tmp_phi,2)+
306 pow((aClus->position().eta()-etarec),2));
310 toteta=aClus->position().eta()-etarec;
314 feta= aClus->position().eta();
315 clusterRef =
PFClusterRef(theECPfClustCollection,clusCounter);
316 meanShowerSaved = meanShower;
328 float chieta=(toteta!=1000)? toteta/ecaletares : toteta;
329 float chiphi=(totphi!=1000)? totphi/ecalphires : totphi;
330 float chichi=
sqrt(chieta*chieta + chiphi*chiphi);
334 float chi2cut=
thr[ibin+0];
335 float ep_cutmin=
thr[ibin+1];
336 bool GoodMatching= ((chichi<chi2cut) &&(EP>ep_cutmin) && (nhitpi>10));
337 bool EcalMatching=GoodMatching;
339 if (Tk[
i].
pt()>
maxPt_) GoodMatching=
true;
340 if (Tk[
i].
pt()<
minPt_) GoodMatching=
false;
344 bool GoodPSMatching=
false;
350 float p1e=
thrPS[iptbin];
351 float p2e=
thrPS[iptbin+1];
352 float p1c=
thrPS[iptbin+2];
353 float p2c=
thrPS[iptbin+3];
359 GoodMatching = (GoodMatching && GoodPSMatching);
362 math::XYZPoint myPoint(ElecTrkEcalPos.X(),ElecTrkEcalPos.Y(),ElecTrkEcalPos.Z());
370 ElecTrkEcalPos,*theECPfClustCollection,*theHCPfClustCollection))
376 int hit1max=int(
thr[ibin+2]);
377 float chiredmin=
thr[ibin+3];
378 bool GoodKFFiltering =
379 ((chikfred>chiredmin) || (nhitpi<hit1max));
383 bool GoodTkId=
false;
385 if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
394 for (
int ih=hits.size()-1; ih>=0; ih--) tmp.push_back(hits[ih]);
395 vector<Trajectory> FitTjs=(
fitter_.
product())->fit(Seed,tmp,Tj[
i].lastMeasurement().updatedState());
398 if(FitTjs[0].isValid()){
400 if(SmooTjs.size()>0){
401 if(SmooTjs[0].isValid()){
405 float pt_out=SmooTjs[0].firstMeasurement().
406 updatedState().globalMomentum().perp();
407 float pt_in=SmooTjs[0].lastMeasurement().
408 updatedState().globalMomentum().perp();
409 dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
411 chiRatio=SmooTjs[0].chiSquared()/Tj[
i].chiSquared();
427 float BDTcut=
thr[ibin+4];
428 if ( Ytmva>BDTcut) GoodTkId=
true;
429 myPreId.
setMVA(GoodTkId,Ytmva);
434 float chiratiocut=
thr[ibin+5];
435 float gschicut=
thr[ibin+6];
436 float gsptmin=
thr[ibin+7];
443 GoodPreId= (GoodTkId || GoodMatching);
448 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
449 "GeV/c, eta= "<<Tk[
i].eta() <<
450 ") preidentified for agreement between track and ECAL cluster";
451 if(GoodPreId &&(!GoodMatching))
452 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
453 "GeV/c, eta= "<<Tk[
i].eta() <<
454 ") preidentified only for track properties";
463 output_preid->push_back(NewSeed);
466 output_nopre->push_back(Seed);
472 refMap_[trackRef] = output_preidinfo->size();
473 output_preidinfo->push_back(myPreId);
522 reader =
new TMVA::Reader(
"!Color:Silent");
540 ifstream ifs(parFile.
fullPath().c_str());
541 for (
int iy=0;iy<72;iy++) ifs >>
thr[iy];
545 ifstream ifsPS(parPSFile.
fullPath().c_str());
546 for (
int iy=0;iy<12;iy++) ifsPS >>
thrPS[iy];
568 else {
if (pt<12) ip=1;
578 if (fabs(eta)<1.2) ie=0;
579 else{
if (fabs(eta)<1.68) ie=1;
583 else {
if (pt<12) ip=1;
587 LogDebug(
"GoodSeedProducer")<<
"Track pt ="<<pt<<
" eta="<<eta<<
" bin="<<iep;
598 if (OutParticle.getSuccess()!=0){
607 vector<PFCluster>::const_iterator ips;
609 float ax=((*ips).position().x()-v1.x())/0.114;
610 float ay=((*ips).position().y()-v1.y())/2.43;
611 float pschi=
sqrt(ax*ax+ay*ay);
614 enPScl1=(*ips).energy();
621 OutParticle.propagateToPreshowerLayer2(
false);
622 if (OutParticle.getSuccess()!=0){
631 float ax=((*ips).position().x()-v2.x())/1.88;
632 float ay=((*ips).position().y()-v2.y())/0.1449;
633 float pschi=
sqrt(ax*ax+ay*ay);
636 enPScl2=(*ips).energy();
658 double myHCALenergy3x3=0.;
659 double myStripClusterE=0.;
664 if (fabs(myElecTrkEcalPos.z())<1. && myElecTrkEcalPos.x()<1. && myElecTrkEcalPos.y()<1. )
return false;
668 PFClusterCollection::const_iterator hc=hcalColl.begin();
669 PFClusterCollection::const_iterator hcend=hcalColl.end();
670 for (;hc!=hcend;++hc){
672 double en = hc->energy();
673 double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,clusPos);
675 myHCALenergy3x3 += en;
682 PFClusterCollection::const_iterator ec=ecalColl.begin();
683 PFClusterCollection::const_iterator ecend=ecalColl.end();
684 for (;ec!=ecend;++ec){
686 double en = ec->energy();
689 double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,clusPos);
690 double deltaEta =
abs(myElecTrkEcalPos.eta()-clusPos.eta());
691 double deltaPhiOverQ = deltaPhi/
charge;
693 myStripClusterE += en;
697 double EoP=myStripClusterE/
P;
698 double HoP=myHCALenergy3x3/
P;
708 std::vector<reco::PreIdRef>
values;
710 unsigned ntracks=tracks->size();
711 for(
unsigned itrack=0;itrack<ntracks;++itrack)
714 std::map<reco::TrackRef,unsigned>::const_iterator itcheck=
refMap_.find(theTrackRef);
723 values.push_back(preIdRef);
727 filler.
insert(tracks,values.begin(),values.end());
int nHitsInSeed_
Number of hits in the seed;.
edm::ESHandle< TrajectoryFitter > fitter_
Fitter.
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
bool propagateToPreshowerLayer1(bool first=true)
std::string preidckf_
Name of the Seed(Ckf) Collection.
std::vector< reco::PFCluster > ps1Clus
Vector of clusters of the PreShower.
float eP
VARIABLES NEEDED FOR TMVA.
edm::InputTag pfCLusTagPSLabel_
void insert(const H &h, I begin, I end)
Global3DPoint GlobalPoint
void PSforTMVA(const math::XYZTLorentzVector &mom, const math::XYZTLorentzVector &pos)
std::vector< Track > TrackCollection
collection of Tracks
PFResolutionMap * resMapEtaECAL_
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
edm::InputTag pfCLusTagHCLabel_
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
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
bool IsIsolated(float charge, float P, math::XYZPointF, const reco::PFClusterCollection &ecalColl, const reco::PFClusterCollection &hcalColl)
bool applyIsolation_
ISOLATION REQUEST AS DONE IN THE TAU GROUP.
void setCtfTrack(const CtfTrackRef &)
Set additional info.
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
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.
const XYZTLorentzVector & momentum() const
the momentum fourvector
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)
TypeLabelItem const & produces()
declare what type of product will make and with which optional label
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
TMVA::Reader * reader
READER FOR TMVA.
bool disablePreId_
switch to disable the pre-id
virtual void beginRun(const edm::Run &run, const edm::EventSetup &) override
reco::TrackBase::TrackQuality trackQuality_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double clusThreshold_
Cut on the energy of the clusters.
bool propagateToEcalEntrance(bool first=true)
double deltaR(double eta1, double eta2, double phi1, double phi2)
const XYZTLorentzVector & vertex() const
the vertex fourvector
PFTrackTransformer * pfTransformer_
PFTrackTransformer.
virtual void endRun(const edm::Run &run, const edm::EventSetup &) override
bool produceCkfseed_
Produce the Seed for Ckf tracks?
bool useTmva_
USE OF TMVA.
XYZPointD XYZPoint
point in space with cartesian internal representation
static const float outerRadius(PFGeometry::Layers_t layer)
return outer radius of a given layer
T const * product() const
static const float innerRadius(PFGeometry::Layers_t layer)
return inner radius of a given layer
std::vector< reco::PFCluster > ps2Clus
T const * product() const
std::vector< edm::InputTag > tracksContainers_
std::vector< std::vector< double > > tmp
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
bool usePreshower_
Use of Preshower clusters.
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::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
std::string smootherName_
void setESMatching(bool accepted, unsigned n=0)
std::string fullPath() const
edm::InputTag pfCLusTagECLabel_
Resolution Map (resolution as a function of eta and E)
std::string preidgsf_
Name of the Seed(Gsf) Collection.
double minEp_
Min and MAx allowed values forEoverP.
edm::ESHandle< TrajectorySmoother > smoother_
Smoother.
Power< A, B >::type pow(const A &a, const B &b)
double PtThresholdSavePredId_
Threshold to save Pre Idinfo.
void setFinalDecision(bool accepted, unsigned n=0)
math::XYZTLorentzVector XYZTLorentzVector