46 bool debugRef =
false;
49 cout <<
"runConvBremFinder:: Entering " << endl;
53 vector<PFBrem> primPFBrem = gsfpfrectk.
PFRecBrem();
56 reco::PFRecTrackCollection::const_iterator pft = PfRTkColl.begin();
57 reco::PFRecTrackCollection::const_iterator pftend = PfRTkColl.end();
59 vector<PFRecTrackRef> AllPFRecTracks;
60 AllPFRecTracks.clear();
61 unsigned int ipft = 0;
63 for (; pft != pftend; ++pft, ipft++) {
66 if (pfTrackRef->trackRef() == pft->trackRef())
70 TrackRef trackRef = pfRecTrRef->trackRef();
74 cout <<
"runConvBremFinder:: pushing_back High Purity " << pft->trackRef()->pt() <<
" eta,phi "
75 << pft->trackRef()->eta() <<
", " << pft->trackRef()->phi() <<
" Memory Address Ref " << &*trackRef
76 <<
" Memory Address BaseRef " << &*selTrackBaseRef << endl;
77 AllPFRecTracks.push_back(pfRecTrRef);
82 for (
unsigned i = 0;
i < PfConvColl.size();
i++) {
85 unsigned int trackSize = (convRef->pfTracks()).
size();
86 if (convRef->pfTracks().size() < 2)
88 for (
unsigned iTk = 0; iTk < trackSize; iTk++) {
94 if (primaryTrackBaseRef == newTrackBaseRef)
98 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
102 cout <<
"## Track 1 HP pt " << AllPFRecTracks[iPF]->trackRef()->pt() <<
" eta, phi "
103 << AllPFRecTracks[iPF]->trackRef()->eta() <<
", " << AllPFRecTracks[iPF]->trackRef()->phi()
104 <<
" Memory Address Ref " << &(*AllPFRecTracks[iPF]->trackRef()) <<
" Memory Address BaseRef "
105 << &*selTrackBaseRef << endl;
107 cout <<
"** Track 2 CONV pt " << compPFTkRef->trackRef()->pt() <<
" eta, phi "
108 << compPFTkRef->trackRef()->eta() <<
", " << compPFTkRef->trackRef()->phi() <<
" Memory Address Ref "
109 << &*compPFTkRef->trackRef() <<
" Memory Address BaseRef " << &*newTrackBaseRef << endl;
111 if (AllPFRecTracks[iPF]->trackRef() == compPFTkRef->trackRef()) {
113 cout <<
" SAME BREM REF " << endl;
119 cout <<
"runConvBremFinder:: pushing_back Conversions " << compPFTkRef->trackRef()->pt() <<
" eta,phi "
120 << compPFTkRef->trackRef()->eta() <<
" phi " << compPFTkRef->trackRef()->phi() << endl;
121 AllPFRecTracks.push_back(compPFTkRef);
129 for (
unsigned i = 0;
i < PfNuclColl.size();
i++) {
131 unsigned int trackSize = dispacedVertexRef->pfRecTracks().size();
132 for (
unsigned iTk = 0; iTk < trackSize; iTk++) {
138 if (primaryTrackBaseRef == newTrackBaseRef)
142 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
144 if (selTrackBaseRef == newTrackBaseRef)
149 cout <<
"runConvBremFinder:: pushing_back displaced Vertex pt " << newPFRecTrackRef->trackRef()->pt()
150 <<
" eta,phi " << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi()
152 AllPFRecTracks.push_back(newPFRecTrackRef);
160 for (
unsigned i = 0;
i < PfV0Coll.size();
i++) {
162 unsigned int trackSize = (v0Ref->pfTracks()).
size();
163 for (
unsigned iTk = 0; iTk < trackSize; iTk++) {
169 if (primaryTrackBaseRef == newTrackBaseRef)
173 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
175 if (selTrackBaseRef == newTrackBaseRef)
180 cout <<
"runConvBremFinder:: pushing_back V0 " << newPFRecTrackRef->trackRef()->pt() <<
" eta,phi "
181 << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi() << endl;
182 AllPFRecTracks.push_back(newPFRecTrackRef);
190 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
191 double dphi = fabs(AllPFRecTracks[iPF]->trackRef()->
phi() - refGsf->phi());
194 double deta = fabs(AllPFRecTracks[iPF]->trackRef()->
eta() - refGsf->eta());
197 if (fabs(dphi) > 1.0 || fabs(deta) > 0.4)
200 double minDEtaBremKF = 1000.;
201 double minDPhiBremKF = 1000.;
202 double minDRBremKF = 1000.;
203 double minDEtaBremKFPos = 1000.;
204 double minDPhiBremKFPos = 1000.;
205 double minDRBremKFPos = 1000.;
208 double secEta = trkRef->innerMomentum().eta();
209 double secPhi = trkRef->innerMomentum().phi();
211 for (
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
212 if (primPFBrem[ipbrem].indTrajPoint() == 99)
218 double bremEta = atPrimECAL.
momentum().Eta();
219 double bremPhi = atPrimECAL.
momentum().Phi();
221 double deta = fabs(bremEta - secEta);
222 double dphi = fabs(bremPhi - secPhi);
225 double DR =
sqrt(deta * deta + dphi * dphi);
227 double detaPos = fabs(bremEta - trkRef->innerPosition().eta());
228 double dphiPos = fabs(bremPhi - trkRef->innerPosition().phi());
231 double DRPos =
sqrt(detaPos * detaPos + dphiPos * dphiPos);
234 if (DR < minDRBremKF) {
236 minDEtaBremKF = deta;
237 minDPhiBremKF = fabs(dphi);
240 if (DRPos < minDRBremKFPos) {
242 minDEtaBremKFPos = detaPos;
243 minDPhiBremKFPos = fabs(dphiPos);
248 float gsfR =
sqrt(refGsf->innerPosition().x() * refGsf->innerPosition().x() +
249 refGsf->innerPosition().y() * refGsf->innerPosition().y());
252 secR =
sqrt(trkRef->innerPosition().x() * trkRef->innerPosition().x() +
253 trkRef->innerPosition().y() * trkRef->innerPosition().y());
257 if ((minDPhiBremKF < 0.1 || minDPhiBremKFPos < 0.1) && (minDEtaBremKF < 0.02 || minDEtaBremKFPos < 0.02) &&
260 cout <<
"runConvBremFinder:: OK Find track and BREM close "
261 <<
" MinDphi " << minDPhiBremKF <<
" MinDeta " << minDEtaBremKF << endl;
263 float MinDist = 100000.;
267 for (PFClusterCollection::const_iterator clus = theEClus.begin(); clus != theEClus.end(); clus++) {
277 if (dist > 0. && dist < MinDist) {
279 EE_calib =
cache->pfcalib_->energyEm(*clus, 0.0, 0.0,
false);
282 if (MinDist > 0. && MinDist < 100000.) {
285 secPout =
sqrt(trkRef->outerMomentum().x() * trkRef->outerMomentum().x() +
286 trkRef->outerMomentum().y() * trkRef->outerMomentum().y() +
287 trkRef->outerMomentum().z() * trkRef->outerMomentum().z());
289 secPin =
sqrt(trkRef->innerMomentum().x() * trkRef->innerMomentum().x() +
290 trkRef->innerMomentum().y() * trkRef->innerMomentum().y() +
291 trkRef->innerMomentum().z() * trkRef->innerMomentum().z());
305 e(0, 0) = 0.0015 * 0.0015;
306 e(1, 1) = 0.0015 * 0.0015;
313 GlobalVector direction(refGsf->innerMomentum().x(), refGsf->innerMomentum().y(), refGsf->innerMomentum().z());
324 unsigned int tmpSh = 0;
326 int kfhitcounter = 0;
327 for (
auto const& nhit : refGsf->recHits())
328 if (nhit->isValid()) {
330 for (
auto const& ihit : trkRef->recHits())
331 if (ihit->isValid()) {
344 TString weightfilepath =
"";
345 double mvaValue = -10;
346 double cutvalue = -10;
349 if (refGsf->pt() < 20 && fabs(refGsf->eta()) < 1.479) {
350 mvaValue =
cache->gbrBarrelLowPt_->GetClassifier(
vars);
353 if (refGsf->pt() > 20 && fabs(refGsf->eta()) < 1.479) {
354 mvaValue =
cache->gbrBarrelHighPt_->GetClassifier(
vars);
357 if (refGsf->pt() < 20 && fabs(refGsf->eta()) > 1.479) {
358 mvaValue =
cache->gbrEndcapsLowPt_->GetClassifier(
vars);
361 if (refGsf->pt() > 20 && fabs(refGsf->eta()) > 1.479) {
362 mvaValue =
cache->gbrEndcapsHighPt_->GetClassifier(
vars);
367 cout <<
"Gsf track Pt, Eta " << refGsf->pt() <<
" " << refGsf->eta() << endl;
369 cout <<
"Cutvalue " << cutvalue << endl;
375 cout <<
" The input variables for conv brem tracks identification " << endl
376 <<
" secR " <<
secR <<
" gsfR " << gsfR << endl
377 <<
" N shared hits " <<
nHITS1 << endl
378 <<
" sTIP " <<
sTIP << endl
380 <<
" E/pout " <<
Epout << endl
382 <<
" ***** MVA ***** " << mvaValue << endl;
384 if (mvaValue > cutvalue) {