36 #include "Math/VectorUtil.h" 44 LogInfo(
"GoodSeedProducer") <<
"Electron PreIdentification started ";
47 std::vector<edm::InputTag>
tags = iConfig.
getParameter<vector<InputTag>>(
"TkColList");
48 for (
unsigned int i = 0;
i < tags.size(); ++
i) {
94 producePreId_ =
false;
97 LogDebug(
"GoodSeedProducer") <<
"Seeds for GSF will be produced ";
100 produces<ElectronSeedCollection>(
preidgsf_);
102 if (produceCkfseed_) {
103 LogDebug(
"GoodSeedProducer") <<
"Seeds for CKF will be produced ";
104 produces<TrajectorySeedCollection>(
preidckf_);
108 LogDebug(
"GoodSeedProducer") <<
"PreId debugging information will be produced ";
131 LogDebug(
"GoodSeedProducer") <<
"START event: " << iEvent.
id().
event() <<
" in run " << iEvent.
id().
run();
133 auto output_preid = std::make_unique<ElectronSeedCollection>();
134 auto output_nopre = std::make_unique<TrajectorySeedCollection>();
135 auto output_preidinfo = std::make_unique<PreIdCollection>();
136 auto preIdMap_p = std::make_unique<edm::ValueMap<reco::PreIdRef>>();
166 vector<PFCluster const*> basClus;
167 for (
auto const& klus : *theECPfClustCollection.
product()) {
169 basClus.push_back(&klus);
187 LogDebug(
"GoodSeedProducer") <<
"Number of tracks in collection " 188 <<
"tracksContainers_[" << istr <<
"] to be analyzed " << Tk.size();
191 for (
unsigned int i = 0;
i < Tk.size(); ++
i) {
196 bool GoodPreId =
false;
200 auto tketa = tkmom.eta();
202 auto const& Seed = (*trackRef->seedRef());
205 int ibin = ipteta * 9;
210 float nchi = Tk[
i].normalizedChi2();
212 int nhitpi = Tk[
i].found();
219 auto pfmass = 0.0005;
220 auto pfoutenergy =
sqrt((pfmass * pfmass) + Tk[
i].outerMomentum().Mag2());
223 Tk[
i].outerMomentum().
x(), Tk[
i].outerMomentum().
y(), Tk[
i].outerMomentum().
z(), pfoutenergy);
231 float toteta = 1000.f;
232 float totphi = 1000.f;
240 if (theOutParticle.getSuccess() != 0) {
241 ElecTrkEcalPos =
GlobalPoint(theOutParticle.particle().vertex().x(),
242 theOutParticle.particle().vertex().y(),
243 theOutParticle.particle().vertex().z());
246 bool isBelowPS = (ElecTrkEcalPos.
z() * ElecTrkEcalPos.
z()) > (psLim * psLim) * ElecTrkEcalPos.
perp2();
249 unsigned clusCounter = 0;
251 for (
auto aClus : basClus) {
252 float tmp_ep =
float(aClus->correctedEnergy()) * oPTOB;
258 double ecalShowerDepth = PFCluster::getDepthCorrection(aClus->correctedEnergy(), isBelowPS,
false);
259 auto mom = theOutParticle.particle().momentum().Vect();
260 auto meanShower = ElecTrkEcalPos +
GlobalVector(mom.x(), mom.y(), mom.z()).
unit() * ecalShowerDepth;
262 float etarec = meanShower.
eta();
263 float phirec = meanShower.phi();
265 float tmp_phi =
std::abs(aClus->positionREP().phi() - phirec);
274 if (aClus->correctedEnergy() > max_ee) {
275 toteta = aClus->positionREP().eta() - etarec;
278 EE = aClus->correctedEnergy();
279 feta = aClus->positionREP().eta();
280 clusterRef =
PFClusterRef(theECPfClustCollection, clusCounter);
281 meanShowerSaved = meanShower;
288 float trk_ecalDeta_ = fabs(toteta);
289 float trk_ecalDphi_ = fabs(totphi);
296 float chieta = (toteta != 1000.f) ? toteta / ecaletares : toteta;
297 float chiphi = (totphi != 1000.f) ? totphi / ecalphires : totphi;
298 float chichi =
sqrt(chieta * chieta + chiphi * chiphi);
301 float eta_cut =
thr[ibin + 0];
302 float phi_cut =
thr[ibin + 1];
303 float ep_cutmin =
thr[ibin + 2];
305 ((trk_ecalDeta_ < eta_cut) && (trk_ecalDphi_ < phi_cut) && (EP > ep_cutmin) && (nhitpi > 10));
307 bool EcalMatching = GoodMatching;
312 GoodMatching =
false;
314 math::XYZPoint myPoint(ElecTrkEcalPos.
x(), ElecTrkEcalPos.
y(), ElecTrkEcalPos.
z());
316 clusterRef, myPoint, meanShowerSaved,
std::abs(toteta),
std::abs(totphi), chieta, chiphi, chichi, EP);
321 int hit1max =
int(
thr[ibin + 3]);
322 float chiredmin =
thr[ibin + 4];
323 bool GoodKFFiltering = ((nchi > chiredmin) | (nhitpi < hit1max));
327 bool GoodTkId =
false;
329 if ((!GoodMatching) && (GoodKFFiltering) && (GoodRange)) {
340 tmp.push_back(
hit->cloneSH());
341 auto const& theTrack = Tk[
i];
342 GlobalVector gv(theTrack.innerMomentum().x(), theTrack.innerMomentum().y(), theTrack.innerMomentum().z());
343 GlobalPoint gp(theTrack.innerPosition().x(), theTrack.innerPosition().y(), theTrack.innerPosition().z());
348 if (FitTjs.isValid()) {
355 dpt = (pt_in > 0) ? fabs(pt_out - pt_in) / pt_in : 0.;
369 float Ytmva = globalCache()->gbr[ipteta]->GetClassifier(vars);
371 float BDTcut =
thr[ibin + 5];
374 myPreId.
setMVA(GoodTkId, Ytmva);
377 float chiratiocut =
thr[ibin + 6];
378 float gschicut =
thr[ibin + 7];
379 float gsptmin =
thr[ibin + 8];
385 GoodPreId = GoodTkId | GoodMatching;
391 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
392 <<
") preidentified for agreement between track and ECAL cluster";
393 if (GoodPreId && (!GoodMatching))
394 LogDebug(
"GoodSeedProducer") <<
"Track (pt= " << Tk[
i].pt() <<
"GeV/c, eta= " << Tk[
i].eta()
395 <<
") preidentified only for track properties";
404 output_preid->push_back(NewSeed);
407 output_nopre->push_back(Seed);
412 refMap_[trackRef] = output_preidinfo->size();
413 output_preidinfo->push_back(myPreId);
454 for (UInt_t
j = 0;
j < gbr.size(); ++
j) {
479 ifstream ifs(parFile.
fullPath().c_str());
480 for (
int iy = 0; iy < 81; ++iy)
490 if (fabs(eta) < 1.479)
503 int iep = ie * 3 + ip;
504 LogDebug(
"GoodSeedProducer") <<
"Track pt =" << pt <<
" eta=" << eta <<
" bin=" << iep;
511 std::vector<reco::PreIdRef>
values;
513 unsigned ntracks = tracks->size();
514 for (
unsigned itrack = 0; itrack < ntracks; ++itrack) {
516 std::map<reco::TrackRef, unsigned>::const_iterator itcheck =
refMap_.find(theTrackRef);
517 if (itcheck ==
refMap_.end()) {
522 values.push_back(preIdRef);
526 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)
std::vector< edm::EDGetTokenT< reco::TrackCollection > > tracksContainers_
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
std::map< reco::TrackRef, unsigned > refMap_
Map used to create the TrackRef, PreIdRef value map.
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
void setECALMatching(bool accepted, unsigned n=0)
GlobalVector globalMomentum() const
bool producePreId_
Produce the pre-id debugging collection.
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
std::string fullPath() const
std::string trackerRecHitBuilderName_
std::string smootherName_
TrajectoryStateOnSurface const & updatedState() const
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
Basic3DVector unit() const