17 #include "TMVA/MethodBDT.h"
24 double mvaBremConvCutBarrelLowPt,
25 double mvaBremConvCutBarrelHighPt,
26 double mvaBremConvCutEndcapsLowPt,
27 double mvaBremConvCutEndcapsHighPt):
29 mvaBremConvCutBarrelLowPt_(mvaBremConvCutBarrelLowPt),
30 mvaBremConvCutBarrelHighPt_(mvaBremConvCutBarrelHighPt),
31 mvaBremConvCutEndcapsLowPt_(mvaBremConvCutEndcapsLowPt),
32 mvaBremConvCutEndcapsHighPt_(mvaBremConvCutEndcapsHighPt)
53 bool debugRef =
false;
56 cout <<
"runConvBremFinder:: Entering " << endl;
62 vector<PFBrem> primPFBrem = gsfpfrectk.
PFRecBrem();
66 reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
67 reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
73 vector<PFRecTrackRef> AllPFRecTracks;
74 AllPFRecTracks.clear();
75 unsigned int ipft = 0;
78 for(;pft!=pftend;++pft,ipft++){
81 if(pfTrackRef->trackRef() == pft->trackRef())
continue;
84 TrackRef trackRef = pfRecTrRef->trackRef();
88 cout <<
"runConvBremFinder:: pushing_back High Purity " << pft->trackRef()->pt()
89 <<
" eta,phi " << pft->trackRef()->eta() <<
", " << pft->trackRef()->phi()
90 <<
" Memory Address Ref " << &*trackRef <<
" Memory Address BaseRef " << &*selTrackBaseRef << endl;
91 AllPFRecTracks.push_back(pfRecTrRef);
97 for(
unsigned i=0;
i<PfConvColl.size();
i++) {
100 unsigned int trackSize=(convRef->pfTracks()).
size();
101 if ( convRef->pfTracks().size() < 2)
continue;
102 for(
unsigned iTk=0;iTk<trackSize; iTk++) {
108 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
111 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
115 cout <<
"## Track 1 HP pt " << AllPFRecTracks[iPF]->trackRef()->pt() <<
" eta, phi " << AllPFRecTracks[iPF]->trackRef()->eta() <<
", " << AllPFRecTracks[iPF]->trackRef()->phi()
116 <<
" Memory Address Ref " << &(*AllPFRecTracks[iPF]->trackRef()) <<
" Memory Address BaseRef " << &*selTrackBaseRef << endl;
118 cout <<
"** Track 2 CONV pt " << compPFTkRef->trackRef()->pt() <<
" eta, phi " << compPFTkRef->trackRef()->eta() <<
", " << compPFTkRef->trackRef()->phi()
119 <<
" Memory Address Ref " << &*compPFTkRef->trackRef() <<
" Memory Address BaseRef " << &*newTrackBaseRef << endl;
121 if(AllPFRecTracks[iPF]->trackRef()== compPFTkRef->trackRef()) {
123 cout <<
" SAME BREM REF " << endl;
129 cout <<
"runConvBremFinder:: pushing_back Conversions " << compPFTkRef->trackRef()->pt()
130 <<
" eta,phi " << compPFTkRef->trackRef()->eta() <<
" phi " << compPFTkRef->trackRef()->phi() <<endl;
131 AllPFRecTracks.push_back(compPFTkRef);
139 for(
unsigned i=0;
i<PfNuclColl.size();
i++) {
141 unsigned int trackSize= dispacedVertexRef->pfRecTracks().size();
142 for(
unsigned iTk=0;iTk < trackSize; iTk++) {
148 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
151 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
153 if(selTrackBaseRef == newTrackBaseRef) notFound =
false;
157 cout <<
"runConvBremFinder:: pushing_back displaced Vertex pt " << newPFRecTrackRef->trackRef()->pt()
158 <<
" eta,phi " << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi() << endl;
159 AllPFRecTracks.push_back(newPFRecTrackRef);
167 for(
unsigned i=0;
i<PfV0Coll.size();
i++) {
169 unsigned int trackSize=(v0Ref->pfTracks()).
size();
170 for(
unsigned iTk=0;iTk<trackSize; iTk++) {
176 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
179 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
181 if(selTrackBaseRef == newTrackBaseRef) notFound =
false;
185 cout <<
"runConvBremFinder:: pushing_back V0 " << newPFRecTrackRef->trackRef()->pt()
186 <<
" eta,phi " << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi() << endl;
187 AllPFRecTracks.push_back(newPFRecTrackRef);
198 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
201 double dphi= fabs(AllPFRecTracks[iPF]->trackRef()->
phi()-refGsf->phi());
203 double deta=fabs(AllPFRecTracks[iPF]->trackRef()->
eta()-refGsf->eta());
206 if( fabs(dphi)> 1.0 || fabs(deta) > 0.4)
continue;
209 double minDEtaBremKF = 1000.;
210 double minDPhiBremKF = 1000.;
211 double minDRBremKF = 1000.;
212 double minDEtaBremKFPos = 1000.;
213 double minDPhiBremKFPos = 1000.;
214 double minDRBremKFPos = 1000.;
217 double secEta = trkRef->innerMomentum().eta();
218 double secPhi = trkRef->innerMomentum().phi();
220 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
221 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
224 if( ! atPrimECAL.
isValid() )
continue;
225 double bremEta = atPrimECAL.
momentum().Eta();
226 double bremPhi = atPrimECAL.
momentum().Phi();
229 double deta = fabs(bremEta - secEta);
230 double dphi = fabs(bremPhi - secPhi);
232 double DR =
sqrt(deta*deta + dphi*dphi);
235 double detaPos = fabs(bremEta - trkRef->innerPosition().eta());
236 double dphiPos = fabs(bremPhi - trkRef->innerPosition().phi());
238 double DRPos =
sqrt(detaPos*detaPos + dphiPos*dphiPos);
243 if(DR < minDRBremKF) {
246 minDEtaBremKF = deta;
247 minDPhiBremKF = fabs(dphi);
250 if(DRPos < minDRBremKFPos) {
252 minDEtaBremKFPos = detaPos;
253 minDPhiBremKFPos = fabs(dphiPos);
259 float gsfR =
sqrt(refGsf->innerPosition().x()*refGsf->innerPosition().x() +
260 refGsf->innerPosition().y()*refGsf->innerPosition().y() );
264 secR =
sqrt(trkRef->innerPosition().x()*trkRef->innerPosition().x() +
265 trkRef->innerPosition().y()*trkRef->innerPosition().y() );
270 if( (minDPhiBremKF < 0.1 || minDPhiBremKFPos < 0.1) &&
271 (minDEtaBremKF < 0.02 || minDEtaBremKFPos < 0.02)&&
276 cout <<
"runConvBremFinder:: OK Find track and BREM close "
277 <<
" MinDphi " << minDPhiBremKF <<
" MinDeta " << minDEtaBremKF << endl;
280 float MinDist = 100000.;
285 for (PFClusterCollection::const_iterator clus = theEClus.begin();
286 clus != theEClus.end();
298 vector<double> ps1Ene(0);
299 vector<double> ps2Ene(0);
304 EE_calib = cache->
pfcalib_->energyEm(*clus,ps1Ene,ps2Ene,ps1,ps2,applyCrackCorrections);
308 if(MinDist > 0. && MinDist < 100000.) {
312 secPout =
sqrt(trkRef->outerMomentum().x()*trkRef->outerMomentum().x() +
313 trkRef->outerMomentum().y()*trkRef->outerMomentum().y() +
314 trkRef->outerMomentum().z()*trkRef->outerMomentum().z());
316 secPin =
sqrt(trkRef->innerMomentum().x()*trkRef->innerMomentum().x() +
317 trkRef->innerMomentum().y()*trkRef->innerMomentum().y() +
318 trkRef->innerMomentum().z()*trkRef->innerMomentum().z());
327 if (primaryVertex->size() != 0) {
328 pv = &*primaryVertex->begin();
333 e(0, 0) = 0.0015 * 0.0015;
334 e(1, 1) = 0.0015 * 0.0015;
337 dummy =
Vertex(p, e, 0, 0, 0);
343 refGsf->innerMomentum().y(),
344 refGsf->innerMomentum().z());
358 unsigned int tmp_sh = 0;
361 for (;nhit!=nhit_end;++nhit){
362 if ((*nhit)->isValid()){
366 for (;ihit!=ihit_end;++ihit){
367 if ((*ihit)->isValid()) {
383 TString weightfilepath =
"";
384 double mvaValue = -10;
385 double cutvalue = -10;
388 if(refGsf->pt()<20 && fabs(refGsf->eta())<1.479 ){
392 if(refGsf->pt()>20 && fabs(refGsf->eta())<1.479 ){
396 if(refGsf->pt()<20 && fabs(refGsf->eta())>1.479 ){
400 if(refGsf->pt()>20 && fabs(refGsf->eta())>1.479 ){
408 if(debug)
cout <<
"Gsf track Pt, Eta " << refGsf->pt() <<
" " << refGsf->eta()<< endl;
409 if(debug)
cout <<
"Cutvalue " << cutvalue << endl;
412 if( (kfhitcounter-
nHITS1) <=3 &&
nHITS1>3) mvaValue = 2;
416 cout <<
" The input variables for conv brem tracks identification " << endl
417 <<
" secR " << secR <<
" gsfR " << gsfR << endl
418 <<
" N shared hits " <<
nHITS1 << endl
419 <<
" sTIP " <<
sTIP << endl
421 <<
" E/pout " <<
Epout << endl
422 <<
" ptRatioKFGsf " << ptRatioGsfKF << endl
423 <<
" ***** MVA ***** " << mvaValue << endl;
425 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
tuple applyCrackCorrections
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
tuple size
Write out results.
std::vector< PFDisplacedTrackerVertex > PFDisplacedTrackerVertexCollection
collection of DisplacedTrackerVertexs
double mvaBremConvCutBarrelLowPt_
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
std::unique_ptr< const GBRForest > gbrBarrelHighPt_