32 #include "Math/VectorUtil.h"
44 LogInfo(
"GoodSeedProducer")<<
"Electron PreIdentification started ";
49 iConfig.
getParameter< vector < InputTag > >(
"TkColList");
104 LogDebug(
"GoodSeedProducer")<<
"Seeds for GSF will be produced ";
107 produces<ElectronSeedCollection>(
preidgsf_);
110 LogDebug(
"GoodSeedProducer")<<
"Seeds for CKF will be produced ";
111 produces<TrajectorySeedCollection>(
preidckf_);
116 LogDebug(
"GoodSeedProducer")<<
"PreId debugging information will be produced ";
153 <<
" in run "<<iEvent.
id().
run();
176 vector<PFCluster> basClus;
177 vector<PFCluster>::const_iterator iklus;
178 for (iklus=theECPfClustCollection.
product()->begin();
179 iklus!=theECPfClustCollection.
product()->end();
195 for (iklus=thePSPfClustCollection.
product()->begin();
196 iklus!=thePSPfClustCollection.
product()->end();
200 if ((*iklus).layer()==-11)
ps1Clus.push_back(*iklus);
201 if ((*iklus).layer()==-12)
ps2Clus.push_back(*iklus);
215 vector<Trajectory> Tj=*(tjCollection.
product());
218 LogDebug(
"GoodSeedProducer")<<
"Number of tracks in collection "
224 for(
unsigned int i=0;
i<Tk.size();
i++){
229 bool GoodPreId=
false;
239 float PTOB=Tj[
i].lastMeasurement().updatedState().globalMomentum().mag();
240 float chikfred=Tk[
i].normalizedChi2();
241 int nhitpi=Tj[
i].foundHits();
248 float pfmass= 0.0005;
249 float pfoutenergy=
sqrt((pfmass*pfmass)+Tk[
i].outerMomentum().Mag2());
251 Tk[
i].outerMomentum().
y(),
252 Tk[
i].outerMomentum().
z(),
255 Tk[
i].outerPosition().
y(),
256 Tk[
i].outerPosition().
z(),
277 theOutParticle.
vertex().y(),
278 theOutParticle.
vertex().z());
279 bool isBelowPS=(fabs(theOutParticle.
vertex().eta())>1.65) ?
true :
false;
281 unsigned clusCounter=0;
283 for(vector<PFCluster>::const_iterator aClus = basClus.begin();
284 aClus != basClus.end(); aClus++,++clusCounter) {
286 double ecalShowerDepth
287 = PFCluster::getDepthCorrection(aClus->energy(),
294 float etarec=meanShower.eta();
295 float phirec=meanShower.phi();
296 float tmp_ep=aClus->energy()/PTOB;
297 float tmp_phi=fabs(aClus->position().phi()-phirec);
299 float tmp_dr=
sqrt(
pow(tmp_phi,2)+
300 pow((aClus->position().eta()-etarec),2));
304 toteta=aClus->position().eta()-etarec;
308 feta= aClus->position().eta();
309 clusterRef =
PFClusterRef(theECPfClustCollection,clusCounter);
310 meanShowerSaved = meanShower;
322 float chieta=(toteta!=1000)? toteta/ecaletares : toteta;
323 float chiphi=(totphi!=1000)? totphi/ecalphires : totphi;
324 float chichi=
sqrt(chieta*chieta + chiphi*chiphi);
328 float chi2cut=
thr[ibin+0];
329 float ep_cutmin=
thr[ibin+1];
330 bool GoodMatching= ((chichi<chi2cut) &&(EP>ep_cutmin) && (nhitpi>10));
331 bool EcalMatching=GoodMatching;
333 if (Tk[
i].
pt()>
maxPt_) GoodMatching=
true;
334 if (Tk[
i].
pt()<
minPt_) GoodMatching=
false;
338 bool GoodPSMatching=
false;
344 float p1e=
thrPS[iptbin];
345 float p2e=
thrPS[iptbin+1];
346 float p1c=
thrPS[iptbin+2];
347 float p2c=
thrPS[iptbin+3];
353 GoodMatching = (GoodMatching && GoodPSMatching);
356 math::XYZPoint myPoint(ElecTrkEcalPos.X(),ElecTrkEcalPos.Y(),ElecTrkEcalPos.Z());
364 ElecTrkEcalPos,*theECPfClustCollection,*theHCPfClustCollection))
370 int hit1max=int(
thr[ibin+2]);
371 float chiredmin=
thr[ibin+3];
372 bool GoodKFFiltering =
373 ((chikfred>chiredmin) || (nhitpi<hit1max));
377 bool GoodTkId=
false;
379 if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
388 for (
int ih=hits.size()-1; ih>=0; ih--) tmp.push_back(hits[ih]);
389 vector<Trajectory> FitTjs=(
fitter_.
product())->fit(Seed,tmp,Tj[
i].lastMeasurement().updatedState());
392 if(FitTjs[0].isValid()){
394 if(SmooTjs.size()>0){
395 if(SmooTjs[0].isValid()){
399 float pt_out=SmooTjs[0].firstMeasurement().
400 updatedState().globalMomentum().perp();
401 float pt_in=SmooTjs[0].lastMeasurement().
402 updatedState().globalMomentum().perp();
403 dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
405 chiRatio=SmooTjs[0].chiSquared()/Tj[
i].chiSquared();
421 float BDTcut=
thr[ibin+4];
422 if ( Ytmva>BDTcut) GoodTkId=
true;
423 myPreId.
setMVA(GoodTkId,Ytmva);
428 float chiratiocut=
thr[ibin+5];
429 float gschicut=
thr[ibin+6];
430 float gsptmin=
thr[ibin+7];
437 GoodPreId= (GoodTkId || GoodMatching);
442 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
443 "GeV/c, eta= "<<Tk[
i].eta() <<
444 ") preidentified for agreement between track and ECAL cluster";
445 if(GoodPreId &&(!GoodMatching))
446 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
447 "GeV/c, eta= "<<Tk[
i].eta() <<
448 ") preidentified only for track properties";
457 output_preid->push_back(NewSeed);
460 output_nopre->push_back(Seed);
466 refMap_[trackRef] = output_preidinfo->size();
467 output_preidinfo->push_back(myPreId);
513 reader =
new TMVA::Reader(
"!Color:Silent");
531 ifstream ifs(parFile.
fullPath().c_str());
532 for (
int iy=0;iy<72;iy++) ifs >>
thr[iy];
536 ifstream ifsPS(parPSFile.
fullPath().c_str());
537 for (
int iy=0;iy<12;iy++) ifsPS >>
thrPS[iy];
553 else {
if (pt<12) ip=1;
563 if (fabs(eta)<1.2) ie=0;
564 else{
if (fabs(eta)<1.68) ie=1;
568 else {
if (pt<12) ip=1;
572 LogDebug(
"GoodSeedProducer")<<
"Track pt ="<<pt<<
" eta="<<eta<<
" bin="<<iep;
583 if (OutParticle.getSuccess()!=0){
592 vector<PFCluster>::const_iterator ips;
594 float ax=((*ips).position().x()-v1.x())/0.114;
595 float ay=((*ips).position().y()-v1.y())/2.43;
596 float pschi=
sqrt(ax*ax+ay*ay);
599 enPScl1=(*ips).energy();
606 OutParticle.propagateToPreshowerLayer2(
false);
607 if (OutParticle.getSuccess()!=0){
616 float ax=((*ips).position().x()-v2.x())/1.88;
617 float ay=((*ips).position().y()-v2.y())/0.1449;
618 float pschi=
sqrt(ax*ax+ay*ay);
621 enPScl2=(*ips).energy();
643 double myHCALenergy3x3=0.;
644 double myStripClusterE=0.;
649 if (fabs(myElecTrkEcalPos.z())<1. && myElecTrkEcalPos.x()<1. && myElecTrkEcalPos.y()<1. )
return false;
653 PFClusterCollection::const_iterator hc=hcalColl.begin();
654 PFClusterCollection::const_iterator hcend=hcalColl.end();
655 for (;hc!=hcend;++hc){
657 double en = hc->energy();
658 double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,clusPos);
660 myHCALenergy3x3 += en;
667 PFClusterCollection::const_iterator ec=ecalColl.begin();
668 PFClusterCollection::const_iterator ecend=ecalColl.end();
669 for (;ec!=ecend;++ec){
671 double en = ec->energy();
674 double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,clusPos);
675 double deltaEta =
abs(myElecTrkEcalPos.eta()-clusPos.eta());
676 double deltaPhiOverQ = deltaPhi/
charge;
678 myStripClusterE += en;
682 double EoP=myStripClusterE/
P;
683 double HoP=myHCALenergy3x3/
P;
693 std::vector<reco::PreIdRef>
values;
695 unsigned ntracks=tracks->size();
696 for(
unsigned itrack=0;itrack<ntracks;++itrack)
699 std::map<reco::TrackRef,unsigned>::const_iterator itcheck=
refMap_.find(theTrackRef);
708 values.push_back(preIdRef);
712 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.
double deltaPhi(float phi1, float phi2)
virtual void beginRun(edm::Run &run, const edm::EventSetup &)
float eP
VARIABLES NEEDED FOR TMVA.
edm::InputTag pfCLusTagPSLabel_
void insert(const H &h, I begin, I end)
Global3DPoint GlobalPoint
std::vector< Track > TrackCollection
collection of Tracks
static PFResolutionMap * resMapPhiECAL_
int getSuccess() const
Has propagation been performed and was barrel or endcap reached ?
edm::InputTag pfCLusTagHCLabel_
static 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
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)
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.
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
TMVA::Reader * reader
READER FOR TMVA.
bool disablePreId_
switch to disable the pre-id
virtual void produce(edm::Event &, const edm::EventSetup &)
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.
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)
void PSforTMVA(math::XYZTLorentzVector mom, math::XYZTLorentzVector pos)
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