16 #include "TMVA/MethodBDT.h" 23 double mvaBremConvCutBarrelLowPt,
24 double mvaBremConvCutBarrelHighPt,
25 double mvaBremConvCutEndcapsLowPt,
26 double mvaBremConvCutEndcapsHighPt):
28 mvaBremConvCutBarrelLowPt_(mvaBremConvCutBarrelLowPt),
29 mvaBremConvCutBarrelHighPt_(mvaBremConvCutBarrelHighPt),
30 mvaBremConvCutEndcapsLowPt_(mvaBremConvCutEndcapsLowPt),
31 mvaBremConvCutEndcapsHighPt_(mvaBremConvCutEndcapsHighPt)
52 bool debugRef =
false;
55 cout <<
"runConvBremFinder:: Entering " << endl;
61 vector<PFBrem> primPFBrem = gsfpfrectk.
PFRecBrem();
65 reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
66 reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
72 vector<PFRecTrackRef> AllPFRecTracks;
73 AllPFRecTracks.clear();
74 unsigned int ipft = 0;
77 for(;pft!=pftend;++pft,ipft++){
80 if(pfTrackRef->trackRef() == pft->trackRef())
continue;
83 TrackRef trackRef = pfRecTrRef->trackRef();
87 cout <<
"runConvBremFinder:: pushing_back High Purity " << pft->trackRef()->pt()
88 <<
" eta,phi " << pft->trackRef()->eta() <<
", " << pft->trackRef()->phi()
89 <<
" Memory Address Ref " << &*trackRef <<
" Memory Address BaseRef " << &*selTrackBaseRef << endl;
90 AllPFRecTracks.push_back(pfRecTrRef);
96 for(
unsigned i=0;
i<PfConvColl.size();
i++) {
99 unsigned int trackSize=(convRef->pfTracks()).
size();
100 if ( convRef->pfTracks().size() < 2)
continue;
101 for(
unsigned iTk=0;iTk<trackSize; iTk++) {
107 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
110 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
114 cout <<
"## Track 1 HP pt " << AllPFRecTracks[iPF]->trackRef()->pt() <<
" eta, phi " << AllPFRecTracks[iPF]->trackRef()->eta() <<
", " << AllPFRecTracks[iPF]->trackRef()->phi()
115 <<
" Memory Address Ref " << &(*AllPFRecTracks[iPF]->trackRef()) <<
" Memory Address BaseRef " << &*selTrackBaseRef << endl;
117 cout <<
"** Track 2 CONV pt " << compPFTkRef->trackRef()->pt() <<
" eta, phi " << compPFTkRef->trackRef()->eta() <<
", " << compPFTkRef->trackRef()->phi()
118 <<
" Memory Address Ref " << &*compPFTkRef->trackRef() <<
" Memory Address BaseRef " << &*newTrackBaseRef << endl;
120 if(AllPFRecTracks[iPF]->trackRef()== compPFTkRef->trackRef()) {
122 cout <<
" SAME BREM REF " << endl;
128 cout <<
"runConvBremFinder:: pushing_back Conversions " << compPFTkRef->trackRef()->pt()
129 <<
" eta,phi " << compPFTkRef->trackRef()->eta() <<
" phi " << compPFTkRef->trackRef()->phi() <<endl;
130 AllPFRecTracks.push_back(compPFTkRef);
138 for(
unsigned i=0;
i<PfNuclColl.size();
i++) {
140 unsigned int trackSize= dispacedVertexRef->pfRecTracks().size();
141 for(
unsigned iTk=0;iTk < trackSize; iTk++) {
147 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
150 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
152 if(selTrackBaseRef == newTrackBaseRef) notFound =
false;
156 cout <<
"runConvBremFinder:: pushing_back displaced Vertex pt " << newPFRecTrackRef->trackRef()->pt()
157 <<
" eta,phi " << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi() << endl;
158 AllPFRecTracks.push_back(newPFRecTrackRef);
166 for(
unsigned i=0;
i<PfV0Coll.size();
i++) {
168 unsigned int trackSize=(v0Ref->pfTracks()).
size();
169 for(
unsigned iTk=0;iTk<trackSize; iTk++) {
175 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
178 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
180 if(selTrackBaseRef == newTrackBaseRef) notFound =
false;
184 cout <<
"runConvBremFinder:: pushing_back V0 " << newPFRecTrackRef->trackRef()->pt()
185 <<
" eta,phi " << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi() << endl;
186 AllPFRecTracks.push_back(newPFRecTrackRef);
197 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
200 double dphi= fabs(AllPFRecTracks[iPF]->trackRef()->
phi()-refGsf->phi());
202 double deta=fabs(AllPFRecTracks[iPF]->trackRef()->
eta()-refGsf->eta());
205 if( fabs(dphi)> 1.0 || fabs(deta) > 0.4)
continue;
208 double minDEtaBremKF = 1000.;
209 double minDPhiBremKF = 1000.;
210 double minDRBremKF = 1000.;
211 double minDEtaBremKFPos = 1000.;
212 double minDPhiBremKFPos = 1000.;
213 double minDRBremKFPos = 1000.;
216 double secEta = trkRef->innerMomentum().eta();
217 double secPhi = trkRef->innerMomentum().phi();
219 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
220 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
223 if( ! atPrimECAL.
isValid() )
continue;
224 double bremEta = atPrimECAL.
momentum().Eta();
225 double bremPhi = atPrimECAL.
momentum().Phi();
228 double deta = fabs(bremEta - secEta);
229 double dphi = fabs(bremPhi - secPhi);
231 double DR =
sqrt(deta*deta + dphi*dphi);
234 double detaPos = fabs(bremEta - trkRef->innerPosition().eta());
235 double dphiPos = fabs(bremPhi - trkRef->innerPosition().phi());
237 double DRPos =
sqrt(detaPos*detaPos + dphiPos*dphiPos);
242 if(DR < minDRBremKF) {
245 minDEtaBremKF = deta;
246 minDPhiBremKF = fabs(dphi);
249 if(DRPos < minDRBremKFPos) {
251 minDEtaBremKFPos = detaPos;
252 minDPhiBremKFPos = fabs(dphiPos);
258 float gsfR =
sqrt(refGsf->innerPosition().x()*refGsf->innerPosition().x() +
259 refGsf->innerPosition().y()*refGsf->innerPosition().y() );
263 secR =
sqrt(trkRef->innerPosition().x()*trkRef->innerPosition().x() +
264 trkRef->innerPosition().y()*trkRef->innerPosition().y() );
269 if( (minDPhiBremKF < 0.1 || minDPhiBremKFPos < 0.1) &&
270 (minDEtaBremKF < 0.02 || minDEtaBremKFPos < 0.02)&&
275 cout <<
"runConvBremFinder:: OK Find track and BREM close " 276 <<
" MinDphi " << minDPhiBremKF <<
" MinDeta " << minDEtaBremKF << endl;
279 float MinDist = 100000.;
284 for (PFClusterCollection::const_iterator clus = theEClus.begin();
285 clus != theEClus.end();
297 vector<double> ps1Ene(0);
298 vector<double> ps2Ene(0);
303 EE_calib = cache->
pfcalib_->energyEm(*clus,ps1Ene,ps2Ene,ps1,ps2,applyCrackCorrections);
307 if(MinDist > 0. && MinDist < 100000.) {
311 secPout =
sqrt(trkRef->outerMomentum().x()*trkRef->outerMomentum().x() +
312 trkRef->outerMomentum().y()*trkRef->outerMomentum().y() +
313 trkRef->outerMomentum().z()*trkRef->outerMomentum().z());
315 secPin =
sqrt(trkRef->innerMomentum().x()*trkRef->innerMomentum().x() +
316 trkRef->innerMomentum().y()*trkRef->innerMomentum().y() +
317 trkRef->innerMomentum().z()*trkRef->innerMomentum().z());
326 if (!primaryVertex->empty()) {
327 pv = &*primaryVertex->begin();
332 e(0, 0) = 0.0015 * 0.0015;
333 e(1, 1) = 0.0015 * 0.0015;
336 dummy =
Vertex(p, e, 0, 0, 0);
342 refGsf->innerMomentum().y(),
343 refGsf->innerMomentum().z());
355 unsigned int tmpSh = 0;
358 for(
auto const& nhit : refGsf->recHits())
if (nhit->isValid()) {
360 for(
auto const& ihit : trkRef->recHits())
if (ihit->isValid()) {
372 TString weightfilepath =
"";
373 double mvaValue = -10;
374 double cutvalue = -10;
377 if(refGsf->pt()<20 && fabs(refGsf->eta())<1.479 ){
381 if(refGsf->pt()>20 && fabs(refGsf->eta())<1.479 ){
385 if(refGsf->pt()<20 && fabs(refGsf->eta())>1.479 ){
389 if(refGsf->pt()>20 && fabs(refGsf->eta())>1.479 ){
397 if(debug)
cout <<
"Gsf track Pt, Eta " << refGsf->pt() <<
" " << refGsf->eta()<< endl;
398 if(debug)
cout <<
"Cutvalue " << cutvalue << endl;
401 if( (kfhitcounter-
nHITS1) <=3 &&
nHITS1>3) mvaValue = 2;
405 cout <<
" The input variables for conv brem tracks identification " << endl
406 <<
" secR " << secR <<
" gsfR " << gsfR << endl
407 <<
" N shared hits " <<
nHITS1 << endl
408 <<
" sTIP " <<
sTIP << endl
410 <<
" E/pout " <<
Epout << endl
411 <<
" ptRatioKFGsf " << ptRatioGsfKF << endl
412 <<
" ***** MVA ***** " << mvaValue << endl;
414 if(mvaValue > cutvalue) {
reconstructed track used as an input to particle flow
std::unique_ptr< const GBRForest > gbrEndcapsHighPt_
bool isNonnull() const
Checks for non-null.
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
std::unique_ptr< const GBRForest > gbrEndcapsLowPt_
std::unique_ptr< const GBRForest > gbrBarrelLowPt_
reco::TransientTrack build(const reco::Track *p) const
const std::vector< reco::PFBrem > & PFRecBrem() const
math::Error< dimension >::type Error
covariance error matrix (3x3)
std::vector< PFConversion > PFConversionCollection
collection of PFConversion objects
void runConvBremFinder(const edm::Handle< reco::PFRecTrackCollection > &thePfRecTrackCol, const edm::Handle< reco::VertexCollection > &primaryVertex, const edm::Handle< reco::PFDisplacedTrackerVertexCollection > &pfNuclears, const edm::Handle< reco::PFConversionCollection > &pfConversions, const edm::Handle< reco::PFV0Collection > &pfV0, const convbremhelpers::HeavyObjectCache *cache, bool useNuclear, bool useConversions, bool useV0, const reco::PFClusterCollection &theEClus, const reco::GsfPFRecTrack &gsfpfrectk)
double mvaBremConvCutEndcapsLowPt_
void calculatePositionREP()
computes posrep_ once and for all
const reco::GsfTrackRef & gsfTrackRef() const
TransientTrackBuilder builder_
double mvaBremConvCutBarrelHighPt_
std::vector< reco::PFRecTrackRef > pfRecTrRef_vec_
double mvaBremConvCutEndcapsHighPt_
math::XYZPoint Point
point in the space
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
std::vector< PFV0 > PFV0Collection
collection of PFV0 objects
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
bool isValid() const
is this point valid ?
const edm::Ref< std::vector< PFRecTrack > > & kfPFRecTrackRef() const
T const * product() const
void calculatePositionREP()
static const GlobalPoint notFound(0, 0, 0)
ConvBremPFTrackFinder(const TransientTrackBuilder &builder, double mvaBremConvCutBarrelLowPt, double mvaBremConvCutBarrelHighPt, double mvaBremConvCutEndcapsLowPt, double mvaBremConvCutEndcapsHighPt)
std::unique_ptr< const PFEnergyCalibration > pfcalib_
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
std::vector< PFDisplacedTrackerVertex > PFDisplacedTrackerVertexCollection
collection of DisplacedTrackerVertexs
double mvaBremConvCutBarrelLowPt_
std::unique_ptr< const GBRForest > gbrBarrelHighPt_