CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ConvBremPFTrackFinder Class Reference

#include <ConvBremPFTrackFinder.h>

Public Member Functions

 ConvBremPFTrackFinder (const TransientTrackBuilder &builder, double mvaBremConvCutBarrelLowPt, double mvaBremConvCutBarrelHighPt, double mvaBremConvCutEndcapsLowPt, double mvaBremConvCutEndcapsHighPt, std::string mvaWeightFileConvBremBarrelLowPt, std::string mvaWeightFileConvBremBarrelHighPt, std::string mvaWeightFileConvBremEndcapsLowPt, std::string mvaWeightFileConvBremEndcapsHighPt)
 
bool foundConvBremPFRecTrack (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, bool useNuclear, bool useConversions, bool useV0, const reco::PFClusterCollection &theEClus, const reco::GsfPFRecTrack &gsfpfrectk)
 
const std::vector
< reco::PFRecTrackRef > & 
getConvBremPFRecTracks ()
 
 ~ConvBremPFTrackFinder ()
 

Private Member Functions

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, bool useNuclear, bool useConversions, bool useV0, const reco::PFClusterCollection &theEClus, const reco::GsfPFRecTrack &gsfpfrectk)
 

Private Attributes

TransientTrackBuilder builder_
 
float detaBremKF
 
float Epout
 
bool found_
 
double mvaBremConvCutBarrelHighPt_
 
double mvaBremConvCutBarrelLowPt_
 
double mvaBremConvCutEndcapsHighPt_
 
double mvaBremConvCutEndcapsLowPt_
 
std::string mvaWeightFileConvBremBarrelHighPt_
 
std::string mvaWeightFileConvBremBarrelLowPt_
 
std::string mvaWeightFileConvBremEndcapsHighPt_
 
std::string mvaWeightFileConvBremEndcapsLowPt_
 
float nHITS1
 
PFEnergyCalibrationpfcalib_
 
std::vector< reco::PFRecTrackRefpfRecTrRef_vec_
 
float ptRatioGsfKF
 
float secPin
 
float secPout
 
float secR
 
float sTIP
 
TMVA::Reader * tmvaReaderBarrelHighPt_
 
TMVA::Reader * tmvaReaderBarrelLowPt_
 
TMVA::Reader * tmvaReaderEndcapsHighPt_
 
TMVA::Reader * tmvaReaderEndcapsLowPt_
 

Detailed Description

Definition at line 30 of file ConvBremPFTrackFinder.h.

Constructor & Destructor Documentation

ConvBremPFTrackFinder::ConvBremPFTrackFinder ( const TransientTrackBuilder builder,
double  mvaBremConvCutBarrelLowPt,
double  mvaBremConvCutBarrelHighPt,
double  mvaBremConvCutEndcapsLowPt,
double  mvaBremConvCutEndcapsHighPt,
std::string  mvaWeightFileConvBremBarrelLowPt,
std::string  mvaWeightFileConvBremBarrelHighPt,
std::string  mvaWeightFileConvBremEndcapsLowPt,
std::string  mvaWeightFileConvBremEndcapsHighPt 
)

Definition at line 22 of file ConvBremPFTrackFinder.cc.

References detaBremKF, Epout, nHITS1, pfcalib_, ptRatioGsfKF, secR, sTIP, tmvaReaderBarrelHighPt_, tmvaReaderBarrelLowPt_, tmvaReaderEndcapsHighPt_, and tmvaReaderEndcapsLowPt_.

31  :
32  builder_(builder),
33  mvaBremConvCutBarrelLowPt_(mvaBremConvCutBarrelLowPt),
34  mvaBremConvCutBarrelHighPt_(mvaBremConvCutBarrelHighPt),
35  mvaBremConvCutEndcapsLowPt_(mvaBremConvCutEndcapsLowPt),
36  mvaBremConvCutEndcapsHighPt_(mvaBremConvCutEndcapsHighPt),
37  mvaWeightFileConvBremBarrelLowPt_(mvaWeightFileConvBremBarrelLowPt),
38  mvaWeightFileConvBremBarrelHighPt_(mvaWeightFileConvBremBarrelHighPt),
39  mvaWeightFileConvBremEndcapsLowPt_(mvaWeightFileConvBremEndcapsLowPt),
40  mvaWeightFileConvBremEndcapsHighPt_(mvaWeightFileConvBremEndcapsHighPt)
41 
42 {
43 
44  tmvaReaderBarrelLowPt_ = new TMVA::Reader("!Color:Silent");
45  tmvaReaderBarrelLowPt_->AddVariable("kftrack_secR",&secR);
46  tmvaReaderBarrelLowPt_->AddVariable("kftrack_sTIP",&sTIP);
47  tmvaReaderBarrelLowPt_->AddVariable("kftrack_nHITS1",&nHITS1);
48  tmvaReaderBarrelLowPt_->AddVariable("kftrack_Epout",&Epout);
49  tmvaReaderBarrelLowPt_->AddVariable("kftrack_detaBremKF",&detaBremKF);
50  tmvaReaderBarrelLowPt_->AddVariable("kftrack_ptRatioGsfKF",&ptRatioGsfKF);
51  tmvaReaderBarrelLowPt_->BookMVA("BDT", mvaWeightFileConvBremBarrelLowPt.c_str());
52 
53  tmvaReaderBarrelHighPt_ = new TMVA::Reader("!Color:Silent");
54  tmvaReaderBarrelHighPt_->AddVariable("kftrack_secR",&secR);
55  tmvaReaderBarrelHighPt_->AddVariable("kftrack_sTIP",&sTIP);
56  tmvaReaderBarrelHighPt_->AddVariable("kftrack_nHITS1",&nHITS1);
57  tmvaReaderBarrelHighPt_->AddVariable("kftrack_Epout",&Epout);
58  tmvaReaderBarrelHighPt_->AddVariable("kftrack_detaBremKF",&detaBremKF);
59  tmvaReaderBarrelHighPt_->AddVariable("kftrack_ptRatioGsfKF",&ptRatioGsfKF);
60  tmvaReaderBarrelHighPt_->BookMVA("BDT", mvaWeightFileConvBremBarrelHighPt.c_str());
61 
62  tmvaReaderEndcapsLowPt_ = new TMVA::Reader("!Color:Silent");
63  tmvaReaderEndcapsLowPt_->AddVariable("kftrack_secR",&secR);
64  tmvaReaderEndcapsLowPt_->AddVariable("kftrack_sTIP",&sTIP);
65  tmvaReaderEndcapsLowPt_->AddVariable("kftrack_nHITS1",&nHITS1);
66  tmvaReaderEndcapsLowPt_->AddVariable("kftrack_Epout",&Epout);
67  tmvaReaderEndcapsLowPt_->AddVariable("kftrack_detaBremKF",&detaBremKF);
68  tmvaReaderEndcapsLowPt_->AddVariable("kftrack_ptRatioGsfKF",&ptRatioGsfKF);
69  tmvaReaderEndcapsLowPt_->BookMVA("BDT", mvaWeightFileConvBremEndcapsLowPt.c_str());
70 
71  tmvaReaderEndcapsHighPt_ = new TMVA::Reader("!Color:Silent");
72  tmvaReaderEndcapsHighPt_->AddVariable("kftrack_secR",&secR);
73  tmvaReaderEndcapsHighPt_->AddVariable("kftrack_sTIP",&sTIP);
74  tmvaReaderEndcapsHighPt_->AddVariable("kftrack_nHITS1",&nHITS1);
75  tmvaReaderEndcapsHighPt_->AddVariable("kftrack_Epout",&Epout);
76  tmvaReaderEndcapsHighPt_->AddVariable("kftrack_detaBremKF",&detaBremKF);
77  tmvaReaderEndcapsHighPt_->AddVariable("kftrack_ptRatioGsfKF",&ptRatioGsfKF);
78  tmvaReaderEndcapsHighPt_->BookMVA("BDT", mvaWeightFileConvBremEndcapsHighPt.c_str());
79 
80 
82 
83 }
TMVA::Reader * tmvaReaderEndcapsHighPt_
std::string mvaWeightFileConvBremEndcapsHighPt_
PFEnergyCalibration * pfcalib_
TransientTrackBuilder builder_
TMVA::Reader * tmvaReaderBarrelHighPt_
TMVA::Reader * tmvaReaderEndcapsLowPt_
std::string mvaWeightFileConvBremEndcapsLowPt_
std::string mvaWeightFileConvBremBarrelHighPt_
TMVA::Reader * tmvaReaderBarrelLowPt_
std::string mvaWeightFileConvBremBarrelLowPt_
ConvBremPFTrackFinder::~ConvBremPFTrackFinder ( )

Member Function Documentation

bool ConvBremPFTrackFinder::foundConvBremPFRecTrack ( 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,
bool  useNuclear,
bool  useConversions,
bool  useV0,
const reco::PFClusterCollection theEClus,
const reco::GsfPFRecTrack gsfpfrectk 
)
inline

Definition at line 45 of file ConvBremPFTrackFinder.h.

References found_, and runConvBremFinder().

Referenced by PFElecTkProducer::produce().

55  {
56  found_ = false;
57  runConvBremFinder(thePfRecTrackCol,primaryVertex,
58  pfNuclears,pfConversions,
59  pfV0,useNuclear,
60  useConversions,useV0,
61  theEClus,gsfpfrectk);
62  return found_;};
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, bool useNuclear, bool useConversions, bool useV0, const reco::PFClusterCollection &theEClus, const reco::GsfPFRecTrack &gsfpfrectk)
const std::vector<reco::PFRecTrackRef>& ConvBremPFTrackFinder::getConvBremPFRecTracks ( )
inline

Definition at line 65 of file ConvBremPFTrackFinder.h.

References pfRecTrRef_vec_.

Referenced by PFElecTkProducer::produce().

65 {return pfRecTrRef_vec_;};
std::vector< reco::PFRecTrackRef > pfRecTrRef_vec_
void ConvBremPFTrackFinder::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,
bool  useNuclear,
bool  useConversions,
bool  useV0,
const reco::PFClusterCollection theEClus,
const reco::GsfPFRecTrack gsfpfrectk 
)
private

Definition at line 87 of file ConvBremPFTrackFinder.cc.

References TrackingRecHit::all, TransientTrackBuilder::build(), builder_, reco::PFCluster::calculatePositionREP(), reco::PFTrack::calculatePositionREP(), gather_cfg::cout, debug, detaBremKF, alignCSCRings::e, reco::PFTrajectoryPoint::ECALEntrance, reco::PFTrajectoryPoint::ECALShowerMax, PFEnergyCalibration::energyEm(), Epout, eta(), reco::PFTrack::extrapolatedPoint(), found_, reco::GsfPFRecTrack::gsfTrackRef(), i, edm::Ref< C, T, F >::isNonnull(), reco::PFTrajectoryPoint::isValid(), reco::GsfPFRecTrack::kfPFRecTrackRef(), reco::PFTrajectoryPoint::momentum(), mvaBremConvCutBarrelHighPt_, mvaBremConvCutBarrelLowPt_, mvaBremConvCutEndcapsHighPt_, mvaBremConvCutEndcapsLowPt_, nHITS1, notFound, AlCaHLTBitMon_ParallelJobs::p, pfcalib_, reco::GsfPFRecTrack::PFRecBrem(), pfRecTrRef_vec_, phi, Pi, edm::Handle< T >::product(), ptRatioGsfKF, secPin, secPout, secR, IPTools::signedTransverseImpactParameter(), findQualityFiles::size, mathSSE::sqrt(), sTIP, LinkByRecHit::testTrackAndClusterByRecHit(), tmvaReaderBarrelHighPt_, tmvaReaderBarrelLowPt_, tmvaReaderEndcapsHighPt_, tmvaReaderEndcapsLowPt_, and TwoPi.

Referenced by foundConvBremPFRecTrack().

97 {
98 
99 
100  found_ = false;
101  bool debug = false;
102  bool debugRef = false;
103 
104  if(debug)
105  cout << "runConvBremFinder:: Entering " << endl;
106 
107 
108 
109  reco::GsfTrackRef refGsf = gsfpfrectk.gsfTrackRef();
110  reco::PFRecTrackRef pfTrackRef = gsfpfrectk.kfPFRecTrackRef();
111  vector<PFBrem> primPFBrem = gsfpfrectk.PFRecBrem();
112 
113 
114  const PFRecTrackCollection& PfRTkColl = *(thePfRecTrackCol.product());
115  reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
116  reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
117  //PFEnergyCalibration pfcalib_;
118 
119 
120 
121 
122  vector<PFRecTrackRef> AllPFRecTracks;
123  AllPFRecTracks.clear();
124  unsigned int ipft = 0;
125 
126 
127  for(;pft!=pftend;++pft,ipft++){
128  // do not consider the kf track already associated to the seed
129  if(pfTrackRef.isNonnull())
130  if(pfTrackRef->trackRef() == pft->trackRef()) continue;
131 
132  PFRecTrackRef pfRecTrRef(thePfRecTrackCol,ipft);
133  TrackRef trackRef = pfRecTrRef->trackRef();
134  reco::TrackBaseRef selTrackBaseRef(trackRef);
135 
136  if(debug)
137  cout << "runConvBremFinder:: pushing_back High Purity " << pft->trackRef()->pt()
138  << " eta,phi " << pft->trackRef()->eta() << ", " << pft->trackRef()->phi()
139  << " Memory Address Ref " << &*trackRef << " Memory Address BaseRef " << &*selTrackBaseRef << endl;
140  AllPFRecTracks.push_back(pfRecTrRef);
141  }
142 
143 
144  if(useConversions) {
145  const PFConversionCollection& PfConvColl = *(pfConversions.product());
146  for(unsigned i=0;i<PfConvColl.size(); i++) {
147  reco::PFConversionRef convRef(pfConversions,i);
148 
149  unsigned int trackSize=(convRef->pfTracks()).size();
150  if ( convRef->pfTracks().size() < 2) continue;
151  for(unsigned iTk=0;iTk<trackSize; iTk++) {
152  PFRecTrackRef compPFTkRef = convRef->pfTracks()[iTk];
153  reco::TrackBaseRef newTrackBaseRef(compPFTkRef->trackRef());
154  // do not consider the kf track already associated to the seed
155  if(pfTrackRef.isNonnull()) {
156  reco::TrackBaseRef primaryTrackBaseRef(pfTrackRef->trackRef());
157  if(primaryTrackBaseRef == newTrackBaseRef) continue;
158  }
159  bool notFound = true;
160  for(unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
161  reco::TrackBaseRef selTrackBaseRef(AllPFRecTracks[iPF]->trackRef());
162 
163  if(debugRef)
164  cout << "## Track 1 HP pt " << AllPFRecTracks[iPF]->trackRef()->pt() << " eta, phi " << AllPFRecTracks[iPF]->trackRef()->eta() << ", " << AllPFRecTracks[iPF]->trackRef()->phi()
165  << " Memory Address Ref " << &(*AllPFRecTracks[iPF]->trackRef()) << " Memory Address BaseRef " << &*selTrackBaseRef << endl;
166  if(debugRef)
167  cout << "** Track 2 CONV pt " << compPFTkRef->trackRef()->pt() << " eta, phi " << compPFTkRef->trackRef()->eta() << ", " << compPFTkRef->trackRef()->phi()
168  << " Memory Address Ref " << &*compPFTkRef->trackRef() << " Memory Address BaseRef " << &*newTrackBaseRef << endl;
169  //if(selTrackBaseRef == newTrackBaseRef || AllPFRecTracks[iPF]->trackRef()== compPFTkRef->trackRef()) {
170  if(AllPFRecTracks[iPF]->trackRef()== compPFTkRef->trackRef()) {
171  if(debugRef)
172  cout << " SAME BREM REF " << endl;
173  notFound = false;
174  }
175  }
176  if(notFound) {
177  if(debug)
178  cout << "runConvBremFinder:: pushing_back Conversions " << compPFTkRef->trackRef()->pt()
179  << " eta,phi " << compPFTkRef->trackRef()->eta() << " phi " << compPFTkRef->trackRef()->phi() <<endl;
180  AllPFRecTracks.push_back(compPFTkRef);
181  }
182  }
183  }
184  }
185 
186  if(useNuclear) {
187  const PFDisplacedTrackerVertexCollection& PfNuclColl = *(pfNuclears.product());
188  for(unsigned i=0;i<PfNuclColl.size(); i++) {
189  const reco::PFDisplacedTrackerVertexRef dispacedVertexRef(pfNuclears, i );
190  unsigned int trackSize= dispacedVertexRef->pfRecTracks().size();
191  for(unsigned iTk=0;iTk < trackSize; iTk++) {
192  reco::PFRecTrackRef newPFRecTrackRef = dispacedVertexRef->pfRecTracks()[iTk];
193  reco::TrackBaseRef newTrackBaseRef(newPFRecTrackRef->trackRef());
194  // do not consider the kf track already associated to the seed
195  if(pfTrackRef.isNonnull()) {
196  reco::TrackBaseRef primaryTrackBaseRef(pfTrackRef->trackRef());
197  if(primaryTrackBaseRef == newTrackBaseRef) continue;
198  }
199  bool notFound = true;
200  for(unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
201  reco::TrackBaseRef selTrackBaseRef(AllPFRecTracks[iPF]->trackRef());
202  if(selTrackBaseRef == newTrackBaseRef) notFound = false;
203  }
204  if(notFound) {
205  if(debug)
206  cout << "runConvBremFinder:: pushing_back displaced Vertex pt " << newPFRecTrackRef->trackRef()->pt()
207  << " eta,phi " << newPFRecTrackRef->trackRef()->eta() << ", " << newPFRecTrackRef->trackRef()->phi() << endl;
208  AllPFRecTracks.push_back(newPFRecTrackRef);
209  }
210  }
211  }
212  }
213 
214  if(useV0) {
215  const PFV0Collection& PfV0Coll = *(pfV0.product());
216  for(unsigned i=0;i<PfV0Coll.size(); i++) {
217  reco::PFV0Ref v0Ref( pfV0, i );
218  unsigned int trackSize=(v0Ref->pfTracks()).size();
219  for(unsigned iTk=0;iTk<trackSize; iTk++) {
220  reco::PFRecTrackRef newPFRecTrackRef = (v0Ref->pfTracks())[iTk];
221  reco::TrackBaseRef newTrackBaseRef(newPFRecTrackRef->trackRef());
222  // do not consider the kf track already associated to the seed
223  if(pfTrackRef.isNonnull()) {
224  reco::TrackBaseRef primaryTrackBaseRef(pfTrackRef->trackRef());
225  if(primaryTrackBaseRef == newTrackBaseRef) continue;
226  }
227  bool notFound = true;
228  for(unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
229  reco::TrackBaseRef selTrackBaseRef(AllPFRecTracks[iPF]->trackRef());
230  if(selTrackBaseRef == newTrackBaseRef) notFound = false;
231  }
232  if(notFound) {
233  if(debug)
234  cout << "runConvBremFinder:: pushing_back V0 " << newPFRecTrackRef->trackRef()->pt()
235  << " eta,phi " << newPFRecTrackRef->trackRef()->eta() << ", " << newPFRecTrackRef->trackRef()->phi() << endl;
236  AllPFRecTracks.push_back(newPFRecTrackRef);
237  }
238  }
239  }
240  }
241 
242 
243 
244  pfRecTrRef_vec_.clear();
245 
246 
247  for(unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
248 
249 
250  double dphi= fabs(AllPFRecTracks[iPF]->trackRef()->phi()-refGsf->phi());
251  if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
252  double deta=fabs(AllPFRecTracks[iPF]->trackRef()->eta()-refGsf->eta());
253 
254  // limiting the phase space (just for saving cpu-time)
255  if( fabs(dphi)> 1.0 || fabs(deta) > 0.4) continue;
256 
257 
258  double minDEtaBremKF = 1000.;
259  double minDPhiBremKF = 1000.;
260  double minDRBremKF = 1000.;
261  double minDEtaBremKFPos = 1000.;
262  double minDPhiBremKFPos = 1000.;
263  double minDRBremKFPos = 1000.;
264  reco:: TrackRef trkRef = AllPFRecTracks[iPF]->trackRef();
265 
266  double secEta = trkRef->innerMomentum().eta();
267  double secPhi = trkRef->innerMomentum().phi();
268 
269  for(unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
270  if(primPFBrem[ipbrem].indTrajPoint() == 99) continue;
271  const reco::PFTrajectoryPoint& atPrimECAL
272  = primPFBrem[ipbrem].extrapolatedPoint( reco::PFTrajectoryPoint::ECALEntrance );
273  if( ! atPrimECAL.isValid() ) continue;
274  double bremEta = atPrimECAL.momentum().Eta();
275  double bremPhi = atPrimECAL.momentum().Phi();
276 
277 
278  double deta = fabs(bremEta - secEta);
279  double dphi = fabs(bremPhi - secPhi);
280  if (dphi>TMath::Pi()) dphi-= TMath::TwoPi();
281  double DR = sqrt(deta*deta + dphi*dphi);
282 
283 
284  double detaPos = fabs(bremEta - trkRef->innerPosition().eta());
285  double dphiPos = fabs(bremPhi - trkRef->innerPosition().phi());
286  if (dphiPos>TMath::Pi()) dphiPos-= TMath::TwoPi();
287  double DRPos = sqrt(detaPos*detaPos + dphiPos*dphiPos);
288 
289 
290 
291  // find the closest track tangent
292  if(DR < minDRBremKF) {
293 
294  minDRBremKF = DR;
295  minDEtaBremKF = deta;
296  minDPhiBremKF = fabs(dphi);
297  }
298 
299  if(DRPos < minDRBremKFPos) {
300  minDRBremKFPos = DR;
301  minDEtaBremKFPos = detaPos;
302  minDPhiBremKFPos = fabs(dphiPos);
303  }
304 
305  }
306 
307  //gsfR
308  float gsfR = sqrt(refGsf->innerPosition().x()*refGsf->innerPosition().x() +
309  refGsf->innerPosition().y()*refGsf->innerPosition().y() );
310 
311 
312  // secR
313  secR = sqrt(trkRef->innerPosition().x()*trkRef->innerPosition().x() +
314  trkRef->innerPosition().y()*trkRef->innerPosition().y() );
315 
316 
317  // apply loose selection (to be parallel) between the secondary track and brem-tangents.
318  // Moreover if the secR is internal with respect to the GSF track by two pixel layers discard it.
319  if( (minDPhiBremKF < 0.1 || minDPhiBremKFPos < 0.1) &&
320  (minDEtaBremKF < 0.02 || minDEtaBremKFPos < 0.02)&&
321  secR > (gsfR-8)) {
322 
323 
324  if(debug)
325  cout << "runConvBremFinder:: OK Find track and BREM close "
326  << " MinDphi " << minDPhiBremKF << " MinDeta " << minDEtaBremKF << endl;
327 
328 
329  float MinDist = 100000.;
330  float EE_calib = 0.;
331  PFRecTrack pfrectrack = *AllPFRecTracks[iPF];
332  pfrectrack.calculatePositionREP();
333  // Find and ECAL associated cluster
334  for (PFClusterCollection::const_iterator clus = theEClus.begin();
335  clus != theEClus.end();
336  clus++ ) {
337  // Removed unusd variable, left this in case it has side effects
338  clus->position();
339  double dist = -1.;
340  PFCluster clust = *clus;
341  clust.calculatePositionREP();
343  LinkByRecHit::testTrackAndClusterByRecHit(pfrectrack , clust ) : -1.;
344 
345  if(dist > 0.) {
346  bool applyCrackCorrections = false;
347  vector<double> ps1Ene(0);
348  vector<double> ps2Ene(0);
349  double ps1,ps2;
350  ps1=ps2=0.;
351  if(dist < MinDist) {
352  MinDist = dist;
353  EE_calib = pfcalib_->energyEm(*clus,ps1Ene,ps2Ene,ps1,ps2,applyCrackCorrections);
354  }
355  }
356  }
357  if(MinDist > 0. && MinDist < 100000.) {
358 
359  // compute all the input variables for conv brem selection
360 
361  secPout = sqrt(trkRef->outerMomentum().x()*trkRef->outerMomentum().x() +
362  trkRef->outerMomentum().y()*trkRef->outerMomentum().y() +
363  trkRef->outerMomentum().z()*trkRef->outerMomentum().z());
364 
365  secPin = sqrt(trkRef->innerMomentum().x()*trkRef->innerMomentum().x() +
366  trkRef->innerMomentum().y()*trkRef->innerMomentum().y() +
367  trkRef->innerMomentum().z()*trkRef->innerMomentum().z());
368 
369 
370  // maybe put innter momentum pt?
371  ptRatioGsfKF = trkRef->pt()/(refGsf->ptMode());
372 
373  Vertex dummy;
374  const Vertex *pv = &dummy;
376  if (primaryVertex->size() != 0) {
377  pv = &*primaryVertex->begin();
378  // we always use the first vertex (at the moment)
379  pvRef = edm::Ref<VertexCollection>(primaryVertex, 0);
380  } else { // create a dummy PV
382  e(0, 0) = 0.0015 * 0.0015;
383  e(1, 1) = 0.0015 * 0.0015;
384  e(2, 2) = 15. * 15.;
385  Vertex::Point p(0, 0, 0);
386  dummy = Vertex(p, e, 0, 0, 0);
387  }
388 
389 
390  // direction of the Gsf track
391  GlobalVector direction(refGsf->innerMomentum().x(),
392  refGsf->innerMomentum().y(),
393  refGsf->innerMomentum().z());
394 
395  TransientTrack transientTrack = builder_.build(*trkRef);
396  sTIP = IPTools::signedTransverseImpactParameter(transientTrack, direction, *pv).second.significance();
397 
398 
399  Epout = EE_calib/secPout;
400 
401  // eta distance brem-secondary kf track
402  detaBremKF = minDEtaBremKF;
403 
404  // Number of commont hits
405  trackingRecHit_iterator nhit=refGsf->recHitsBegin();
406  trackingRecHit_iterator nhit_end=refGsf->recHitsEnd();
407  unsigned int tmp_sh = 0;
408  //uint ish=0;
409  int kfhitcounter=0;
410  for (;nhit!=nhit_end;++nhit){
411  if ((*nhit)->isValid()){
412  trackingRecHit_iterator ihit=trkRef->recHitsBegin();
413  trackingRecHit_iterator ihit_end=trkRef->recHitsEnd();
414  kfhitcounter=0;
415  for (;ihit!=ihit_end;++ihit){
416  if ((*ihit)->isValid()) {
417  // method 1
418  if((*nhit)->sharesInput(&*(*ihit),TrackingRecHit::all)) tmp_sh++;
419  kfhitcounter++;
420  // method 2 to switch in case of problem with rechit collections
421  // if(((*ihit)->geographicalId()==(*nhit)->geographicalId())&&
422  // (((*nhit)->localPosition()-(*ihit)->localPosition()).mag()<0.01)) ish++;
423 
424 
425  }
426  }
427  }
428  }
429 
430  nHITS1 = tmp_sh;
431 
432 
433 
434 
435  TString weightfilepath ="";
436  double mvaValue = -10;
437  double cutvalue = -10;
438  if(refGsf->pt()<20 && fabs(refGsf->eta())<1.479 ){
439  mvaValue = tmvaReaderBarrelLowPt_->EvaluateMVA("BDT");
440  cutvalue = mvaBremConvCutBarrelLowPt_;
441  }
442  if(refGsf->pt()>20 && fabs(refGsf->eta())<1.479 ){
443  mvaValue = tmvaReaderBarrelHighPt_->EvaluateMVA("BDT");
444  cutvalue = mvaBremConvCutBarrelHighPt_;
445  }
446  if(refGsf->pt()<20 && fabs(refGsf->eta())>1.479 ){
447  mvaValue = tmvaReaderEndcapsLowPt_->EvaluateMVA("BDT");
448  cutvalue = mvaBremConvCutEndcapsLowPt_;
449  }
450  if(refGsf->pt()>20 && fabs(refGsf->eta())>1.479 ){
451  mvaValue = tmvaReaderEndcapsHighPt_->EvaluateMVA("BDT");
452  cutvalue = mvaBremConvCutEndcapsHighPt_;
453  }
454 
455 
456 
457 
458  if(debug) cout << "Gsf track Pt, Eta " << refGsf->pt() << " " << refGsf->eta()<< endl;
459  if(debug) cout << "Cutvalue " << cutvalue << endl;
460 
461 
462  if( (kfhitcounter-nHITS1) <=3 && nHITS1>3) mvaValue = 2; // this means duplicates tracks, very likely not physical
463 
464 
465  if(debug)
466  cout << " The input variables for conv brem tracks identification " << endl
467  << " secR " << secR << " gsfR " << gsfR << endl
468  << " N shared hits " << nHITS1 << endl
469  << " sTIP " << sTIP << endl
470  << " detaBremKF " << detaBremKF << endl
471  << " E/pout " << Epout << endl
472  << " ptRatioKFGsf " << ptRatioGsfKF << endl
473  << " ***** MVA ***** " << mvaValue << endl;
474 
475  if(mvaValue > cutvalue) {
476  found_ = true;
477  pfRecTrRef_vec_.push_back(AllPFRecTracks[iPF]);
478 
479  }
480  } // end MinDIST
481  } // end selection kf - brem tangents
482  } // loop on the kf tracks
483 
484 
485 
486 
487 
488 
489 }
const double TwoPi
const double Pi
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
int i
Definition: DBlmapReader.cc:9
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:43
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
reco::TransientTrack build(const reco::Track *p) const
const std::vector< reco::PFBrem > & PFRecBrem() const
Definition: GsfPFRecTrack.h:51
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
std::vector< PFConversion > PFConversionCollection
collection of PFConversion objects
T eta() const
TMVA::Reader * tmvaReaderEndcapsHighPt_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
PFEnergyCalibration * pfcalib_
void calculatePositionREP()
computes posrep_ once and for all
Definition: PFCluster.h:78
const reco::GsfTrackRef & gsfTrackRef() const
Definition: GsfPFRecTrack.h:39
T sqrt(T t)
Definition: SSEVec.h:48
TransientTrackBuilder builder_
TMVA::Reader * tmvaReaderBarrelHighPt_
std::vector< reco::PFRecTrackRef > pfRecTrRef_vec_
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
std::vector< PFV0 > PFV0Collection
collection of PFV0 objects
Definition: PFV0Fwd.h:9
TMVA::Reader * tmvaReaderEndcapsLowPt_
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
#define debug
Definition: HDRShower.cc:19
bool isValid() const
is this point valid ?
const edm::Ref< std::vector< PFRecTrack > > & kfPFRecTrackRef() const
Definition: GsfPFRecTrack.h:43
void calculatePositionREP()
Definition: PFTrack.cc:68
static const GlobalPoint notFound(0, 0, 0)
T const * product() const
Definition: Handle.h:81
tuple cout
Definition: gather_cfg.py:121
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
TMVA::Reader * tmvaReaderBarrelLowPt_
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
Definition: LinkByRecHit.cc:10
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
Definition: PFRecTrackFwd.h:9
tuple size
Write out results.
std::vector< PFDisplacedTrackerVertex > PFDisplacedTrackerVertexCollection
collection of DisplacedTrackerVertexs
double energyEm(const reco::PFCluster &clusterEcal, std::vector< double > &EclustersPS1, std::vector< double > &EclustersPS2, bool crackCorrection=true)
Definition: DDAxes.h:10

Member Data Documentation

TransientTrackBuilder ConvBremPFTrackFinder::builder_
private

Definition at line 82 of file ConvBremPFTrackFinder.h.

Referenced by runConvBremFinder().

float ConvBremPFTrackFinder::detaBremKF
private

Definition at line 91 of file ConvBremPFTrackFinder.h.

Referenced by ConvBremPFTrackFinder(), and runConvBremFinder().

float ConvBremPFTrackFinder::Epout
private

Definition at line 91 of file ConvBremPFTrackFinder.h.

Referenced by ConvBremPFTrackFinder(), and runConvBremFinder().

bool ConvBremPFTrackFinder::found_
private

Definition at line 81 of file ConvBremPFTrackFinder.h.

Referenced by foundConvBremPFRecTrack(), and runConvBremFinder().

double ConvBremPFTrackFinder::mvaBremConvCutBarrelHighPt_
private

Definition at line 83 of file ConvBremPFTrackFinder.h.

Referenced by runConvBremFinder().

double ConvBremPFTrackFinder::mvaBremConvCutBarrelLowPt_
private

Definition at line 83 of file ConvBremPFTrackFinder.h.

Referenced by runConvBremFinder().

double ConvBremPFTrackFinder::mvaBremConvCutEndcapsHighPt_
private

Definition at line 83 of file ConvBremPFTrackFinder.h.

Referenced by runConvBremFinder().

double ConvBremPFTrackFinder::mvaBremConvCutEndcapsLowPt_
private

Definition at line 83 of file ConvBremPFTrackFinder.h.

Referenced by runConvBremFinder().

std::string ConvBremPFTrackFinder::mvaWeightFileConvBremBarrelHighPt_
private

Definition at line 84 of file ConvBremPFTrackFinder.h.

std::string ConvBremPFTrackFinder::mvaWeightFileConvBremBarrelLowPt_
private

Definition at line 84 of file ConvBremPFTrackFinder.h.

std::string ConvBremPFTrackFinder::mvaWeightFileConvBremEndcapsHighPt_
private

Definition at line 84 of file ConvBremPFTrackFinder.h.

std::string ConvBremPFTrackFinder::mvaWeightFileConvBremEndcapsLowPt_
private

Definition at line 84 of file ConvBremPFTrackFinder.h.

float ConvBremPFTrackFinder::nHITS1
private

Definition at line 93 of file ConvBremPFTrackFinder.h.

Referenced by ConvBremPFTrackFinder(), and runConvBremFinder().

PFEnergyCalibration* ConvBremPFTrackFinder::pfcalib_
private
std::vector<reco::PFRecTrackRef> ConvBremPFTrackFinder::pfRecTrRef_vec_
private

Definition at line 90 of file ConvBremPFTrackFinder.h.

Referenced by getConvBremPFRecTracks(), and runConvBremFinder().

float ConvBremPFTrackFinder::ptRatioGsfKF
private

Definition at line 91 of file ConvBremPFTrackFinder.h.

Referenced by ConvBremPFTrackFinder(), and runConvBremFinder().

float ConvBremPFTrackFinder::secPin
private

Definition at line 91 of file ConvBremPFTrackFinder.h.

Referenced by runConvBremFinder().

float ConvBremPFTrackFinder::secPout
private

Definition at line 91 of file ConvBremPFTrackFinder.h.

Referenced by runConvBremFinder().

float ConvBremPFTrackFinder::secR
private

Definition at line 91 of file ConvBremPFTrackFinder.h.

Referenced by ConvBremPFTrackFinder(), and runConvBremFinder().

float ConvBremPFTrackFinder::sTIP
private

Definition at line 91 of file ConvBremPFTrackFinder.h.

Referenced by ConvBremPFTrackFinder(), and runConvBremFinder().

TMVA::Reader* ConvBremPFTrackFinder::tmvaReaderBarrelHighPt_
private
TMVA::Reader* ConvBremPFTrackFinder::tmvaReaderBarrelLowPt_
private
TMVA::Reader* ConvBremPFTrackFinder::tmvaReaderEndcapsHighPt_
private
TMVA::Reader* ConvBremPFTrackFinder::tmvaReaderEndcapsLowPt_
private