36 #include "Math/VectorUtil.h" 48 LogInfo(
"GoodSeedProducer")<<
"Electron PreIdentification started ";
51 std::vector<edm::InputTag> tags = iConfig.
getParameter< vector < InputTag > >(
"TkColList");
52 for(
unsigned int i=0;
i<tags.size();++
i) {
103 LogDebug(
"GoodSeedProducer")<<
"Seeds for GSF will be produced ";
106 produces<ElectronSeedCollection>(
preidgsf_);
109 LogDebug(
"GoodSeedProducer")<<
"Seeds for CKF will be produced ";
110 produces<TrajectorySeedCollection>(
preidckf_);
114 LogDebug(
"GoodSeedProducer")<<
"PreId debugging information will be produced ";
143 <<
" in run "<<iEvent.
id().
run();
145 auto output_preid = std::make_unique<ElectronSeedCollection>();
146 auto output_nopre = std::make_unique<TrajectorySeedCollection>();
147 auto output_preidinfo = std::make_unique<PreIdCollection>();
148 auto preIdMap_p = std::make_unique<edm::ValueMap<reco::PreIdRef>>();
180 vector<PFCluster const *> basClus;
181 for (
auto const & klus : *theECPfClustCollection.
product() ) {
182 if(klus.correctedEnergy()>
clusThreshold_) basClus.push_back(&klus);
201 LogDebug(
"GoodSeedProducer")<<
"Number of tracks in collection " 202 <<
"tracksContainers_[" << istr <<
"] to be analyzed " 206 for(
unsigned int i=0;
i<Tk.size();++
i){
211 bool GoodPreId=
false;
215 auto tketa= tkmom.eta();
217 auto const & Seed=(*trackRef->seedRef());
225 float nchi=Tk[
i].normalizedChi2();
227 int nhitpi=Tk[
i].found();
235 auto pfoutenergy=
sqrt((pfmass*pfmass)+Tk[
i].outerMomentum().Mag2());
238 Tk[
i].outerMomentum().
y(),
239 Tk[
i].outerMomentum().
z(),
242 Tk[
i].outerPosition().
y(),
243 Tk[
i].outerPosition().
z(),
262 if(theOutParticle.getSuccess()!=0){
263 ElecTrkEcalPos=
GlobalPoint(theOutParticle.particle().vertex().x(),
264 theOutParticle.particle().vertex().y(),
265 theOutParticle.particle().vertex().z()
269 bool isBelowPS= (ElecTrkEcalPos.
z()*ElecTrkEcalPos.
z()) > (psLim*psLim)*ElecTrkEcalPos.
perp2();
272 unsigned clusCounter=0;
274 for(
auto aClus : basClus) {
276 float tmp_ep=
float(aClus->correctedEnergy())*oPTOB;
277 if ((tmp_ep<
minEp_)|(tmp_ep>
maxEp_)) { ++clusCounter;
continue;}
279 double ecalShowerDepth
280 = PFCluster::getDepthCorrection(aClus->correctedEnergy(),
283 auto mom = theOutParticle.particle().momentum().Vect();
284 auto meanShower = ElecTrkEcalPos +
287 float etarec=meanShower.eta();
288 float phirec=meanShower.phi();
291 float tmp_phi=
std::abs(aClus->positionREP().phi()-phirec);
295 std::pow(aClus->positionREP().eta()-etarec,2.f));
300 if(aClus->correctedEnergy() > max_ee){
302 toteta=aClus->positionREP().eta()-etarec;
305 EE=aClus->correctedEnergy();
306 feta= aClus->positionREP().eta();
307 clusterRef =
PFClusterRef(theECPfClustCollection,clusCounter);
308 meanShowerSaved = meanShower;
316 float trk_ecalDeta_ = fabs(toteta);
317 float trk_ecalDphi_ = fabs(totphi);
326 float chieta=(toteta!=1000.f)? toteta/ecaletares : toteta;
327 float chiphi=(totphi!=1000.f)? totphi/ecalphires : totphi;
328 float chichi=
sqrt(chieta*chieta + chiphi*chiphi);
331 float eta_cut =
thr[ibin+0];
332 float phi_cut =
thr[ibin+1];
333 float ep_cutmin=
thr[ibin+2];
334 bool GoodMatching= ((trk_ecalDeta_<eta_cut) && (trk_ecalDphi_<phi_cut) && (EP>ep_cutmin) && (nhitpi>10));
336 bool EcalMatching=GoodMatching;
338 if (tkpt>
maxPt_) GoodMatching=
true;
339 if (tkpt<
minPt_) GoodMatching=
false;
343 math::XYZPoint myPoint(ElecTrkEcalPos.
x(),ElecTrkEcalPos.
y(),ElecTrkEcalPos.
z());
352 int hit1max=
int(
thr[ibin+3]);
353 float chiredmin=
thr[ibin+4];
354 bool GoodKFFiltering =
355 ((nchi>chiredmin) | (nhitpi<hit1max));
360 bool GoodTkId=
false;
362 if((!GoodMatching) &&(GoodKFFiltering) &&(GoodRange)){
372 for(
auto const&
hit : Tk[
i].recHits()) tmp.push_back(
hit->cloneSH());
373 auto const & theTrack = Tk[
i];
374 GlobalVector gv(theTrack.innerMomentum().x(),theTrack.innerMomentum().y(),theTrack.innerMomentum().z());
375 GlobalPoint gp(theTrack.innerPosition().x(),theTrack.innerPosition().y(),theTrack.innerPosition().z());
380 if(FitTjs.isValid()){
390 dpt=(pt_in>0) ? fabs(pt_out-pt_in)/pt_in : 0.;
407 float Ytmva = globalCache()->gbr[ipteta]->GetClassifier( vars );
409 float BDTcut=
thr[ibin+5];
410 if ( Ytmva>BDTcut) GoodTkId=
true;
411 myPreId.
setMVA(GoodTkId,Ytmva);
415 float chiratiocut=
thr[ibin+6];
416 float gschicut=
thr[ibin+7];
417 float gsptmin=
thr[ibin+8];
424 GoodPreId= GoodTkId | GoodMatching;
430 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
431 "GeV/c, eta= "<<Tk[
i].eta() <<
432 ") preidentified for agreement between track and ECAL cluster";
433 if(GoodPreId &&(!GoodMatching))
434 LogDebug(
"GoodSeedProducer")<<
"Track (pt= "<<Tk[
i].pt()<<
435 "GeV/c, eta= "<<Tk[
i].eta() <<
436 ") preidentified only for track properties";
446 output_preid->push_back(NewSeed);
449 output_nopre->push_back(Seed);
455 refMap_[trackRef] = output_preidinfo->size();
456 output_preidinfo->push_back(myPreId);
499 for(UInt_t j = 0; j < gbr.size(); ++j){
527 ifstream ifs(parFile.
fullPath().c_str());
528 for (
int iy=0;iy<81;++iy) ifs >>
thr[iy];
535 if (fabs(eta)<0.8) ie=0;
536 else{
if (fabs(eta)<1.479) ie=1;
540 else {
if (pt<12) ip=1;
544 LogDebug(
"GoodSeedProducer")<<
"Track pt ="<<pt<<
" eta="<<eta<<
" bin="<<iep;
552 std::vector<reco::PreIdRef>
values;
554 unsigned ntracks=tracks->size();
555 for(
unsigned itrack=0;itrack<ntracks;++itrack)
558 std::map<reco::TrackRef,unsigned>::const_iterator itcheck=
refMap_.find(theTrackRef);
567 values.push_back(preIdRef);
571 filler.
insert(tracks,values.begin(),values.end());
int nHitsInSeed_
Number of hits in the seed;.
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
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::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::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
GoodSeedProducer(const edm::ParameterSet &, const goodseedhelpers::HeavyObjectCache *)
void setCtfTrack(const CtfTrackRef &)
Set additional info.
virtual TrajectorySmoother * clone() const =0
void setTrack(reco::TrackRef trackref)
virtual std::unique_ptr< TrajectoryFitter > clone() const =0
int getBin(float, float)
Find the bin in pt and eta.
std::unique_ptr< TrajectoryFitter > fitter_
Fitter.
#define DEFINE_FWK_MODULE(type)
void setMVA(bool accepted, float mva, unsigned n=0)
double EcalStripSumE_deltaEta_
double EcalStripSumE_deltaPhiOverQ_minValue_
double EcalStripSumE_deltaPhiOverQ_maxValue_
void setTrackFiltering(bool accepted, unsigned n=0)
void produce(edm::Event &, const edm::EventSetup &) override
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
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
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.
bool disablePreId_
switch to disable the pre-id
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
void beginRun(const edm::Run &run, const edm::EventSetup &) override
reco::TrackBase::TrackQuality trackQuality_
double clusThreshold_
Cut on the energy of the clusters.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
bool propagateToEcalEntrance(bool first=true)
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
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
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.
std::string fullPath() const
std::string trackerRecHitBuilderName_
std::string smootherName_
edm::EDGetTokenT< reco::PFClusterCollection > pfCLusTagHCLabel_
Resolution Map (resolution as a function of eta and E)
std::string preidgsf_
Name of the Seed(Gsf) Collection.
T const * product() const
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