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();
60 vector<PFRecTrackRef> AllPFRecTracks;
61 AllPFRecTracks.clear();
62 unsigned int ipft = 0;
64 for (; pft != pftend; ++pft, ipft++) {
67 if (pfTrackRef->trackRef() == pft->trackRef())
71 TrackRef trackRef = pfRecTrRef->trackRef();
75 cout <<
"runConvBremFinder:: pushing_back High Purity " << pft->trackRef()->pt() <<
" eta,phi "
76 << pft->trackRef()->eta() <<
", " << pft->trackRef()->phi() <<
" Memory Address Ref " << &*trackRef
77 <<
" Memory Address BaseRef " << &*selTrackBaseRef << endl;
78 AllPFRecTracks.push_back(pfRecTrRef);
83 for (
unsigned i = 0;
i < PfConvColl.size();
i++) {
86 unsigned int trackSize = (convRef->pfTracks()).
size();
87 if (convRef->pfTracks().size() < 2)
89 for (
unsigned iTk = 0; iTk < trackSize; iTk++) {
95 if (primaryTrackBaseRef == newTrackBaseRef)
99 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
103 cout <<
"## Track 1 HP pt " << AllPFRecTracks[iPF]->trackRef()->pt() <<
" eta, phi "
104 << AllPFRecTracks[iPF]->trackRef()->eta() <<
", " << AllPFRecTracks[iPF]->trackRef()->phi()
105 <<
" Memory Address Ref " << &(*AllPFRecTracks[iPF]->trackRef()) <<
" Memory Address BaseRef "
106 << &*selTrackBaseRef << endl;
108 cout <<
"** Track 2 CONV pt " << compPFTkRef->trackRef()->pt() <<
" eta, phi "
109 << compPFTkRef->trackRef()->eta() <<
", " << compPFTkRef->trackRef()->phi() <<
" Memory Address Ref "
110 << &*compPFTkRef->trackRef() <<
" Memory Address BaseRef " << &*newTrackBaseRef << endl;
112 if (AllPFRecTracks[iPF]->trackRef() == compPFTkRef->trackRef()) {
114 cout <<
" SAME BREM REF " << endl;
120 cout <<
"runConvBremFinder:: pushing_back Conversions " << compPFTkRef->trackRef()->pt() <<
" eta,phi "
121 << compPFTkRef->trackRef()->eta() <<
" phi " << compPFTkRef->trackRef()->phi() << endl;
122 AllPFRecTracks.push_back(compPFTkRef);
130 for (
unsigned i = 0;
i < PfNuclColl.size();
i++) {
132 unsigned int trackSize = dispacedVertexRef->pfRecTracks().size();
133 for (
unsigned iTk = 0; iTk < trackSize; iTk++) {
139 if (primaryTrackBaseRef == newTrackBaseRef)
143 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
145 if (selTrackBaseRef == newTrackBaseRef)
150 cout <<
"runConvBremFinder:: pushing_back displaced Vertex pt " << newPFRecTrackRef->trackRef()->pt()
151 <<
" eta,phi " << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi()
153 AllPFRecTracks.push_back(newPFRecTrackRef);
161 for (
unsigned i = 0;
i < PfV0Coll.size();
i++) {
163 unsigned int trackSize = (v0Ref->pfTracks()).
size();
164 for (
unsigned iTk = 0; iTk < trackSize; iTk++) {
170 if (primaryTrackBaseRef == newTrackBaseRef)
174 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
176 if (selTrackBaseRef == newTrackBaseRef)
181 cout <<
"runConvBremFinder:: pushing_back V0 " << newPFRecTrackRef->trackRef()->pt() <<
" eta,phi "
182 << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi() << endl;
183 AllPFRecTracks.push_back(newPFRecTrackRef);
191 for (
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
192 double dphi = fabs(AllPFRecTracks[iPF]->trackRef()->
phi() - refGsf->phi());
195 double deta = fabs(AllPFRecTracks[iPF]->trackRef()->
eta() - refGsf->eta());
198 if (fabs(dphi) > 1.0 || fabs(deta) > 0.4)
201 double minDEtaBremKF = 1000.;
202 double minDPhiBremKF = 1000.;
203 double minDRBremKF = 1000.;
204 double minDEtaBremKFPos = 1000.;
205 double minDPhiBremKFPos = 1000.;
206 double minDRBremKFPos = 1000.;
209 double secEta = trkRef->innerMomentum().eta();
210 double secPhi = trkRef->innerMomentum().phi();
212 for (
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
213 if (primPFBrem[ipbrem].indTrajPoint() == 99)
219 double bremEta = atPrimECAL.
momentum().Eta();
220 double bremPhi = atPrimECAL.
momentum().Phi();
222 double deta = fabs(bremEta - secEta);
223 double dphi = fabs(bremPhi - secPhi);
226 double DR =
sqrt(deta * deta + dphi * dphi);
228 double detaPos = fabs(bremEta - trkRef->innerPosition().eta());
229 double dphiPos = fabs(bremPhi - trkRef->innerPosition().phi());
232 double DRPos =
sqrt(detaPos * detaPos + dphiPos * dphiPos);
235 if (DR < minDRBremKF) {
237 minDEtaBremKF = deta;
238 minDPhiBremKF = fabs(dphi);
241 if (DRPos < minDRBremKFPos) {
243 minDEtaBremKFPos = detaPos;
244 minDPhiBremKFPos = fabs(dphiPos);
249 float gsfR =
sqrt(refGsf->innerPosition().x() * refGsf->innerPosition().x() +
250 refGsf->innerPosition().y() * refGsf->innerPosition().y());
253 secR =
sqrt(trkRef->innerPosition().x() * trkRef->innerPosition().x() +
254 trkRef->innerPosition().y() * trkRef->innerPosition().y());
258 if ((minDPhiBremKF < 0.1 || minDPhiBremKFPos < 0.1) && (minDEtaBremKF < 0.02 || minDEtaBremKFPos < 0.02) &&
261 cout <<
"runConvBremFinder:: OK Find track and BREM close "
262 <<
" MinDphi " << minDPhiBremKF <<
" MinDeta " << minDEtaBremKF << endl;
264 float MinDist = 100000.;
269 for (PFClusterCollection::const_iterator clus = theEClus.begin(); clus != theEClus.end(); clus++) {
279 if (dist > 0. && dist < MinDist) {
281 EE_calib =
cache->pfcalib_->energyEm(*clus, 0.0, 0.0,
false);
284 if (MinDist > 0. && MinDist < 100000.) {
287 secPout =
sqrt(trkRef->outerMomentum().x() * trkRef->outerMomentum().x() +
288 trkRef->outerMomentum().y() * trkRef->outerMomentum().y() +
289 trkRef->outerMomentum().z() * trkRef->outerMomentum().z());
291 secPin =
sqrt(trkRef->innerMomentum().x() * trkRef->innerMomentum().x() +
292 trkRef->innerMomentum().y() * trkRef->innerMomentum().y() +
293 trkRef->innerMomentum().z() * trkRef->innerMomentum().z());
307 e(0, 0) = 0.0015 * 0.0015;
308 e(1, 1) = 0.0015 * 0.0015;
315 GlobalVector direction(refGsf->innerMomentum().x(), refGsf->innerMomentum().y(), refGsf->innerMomentum().z());
326 unsigned int tmpSh = 0;
328 int kfhitcounter = 0;
329 for (
auto const& nhit : refGsf->recHits())
330 if (nhit->isValid()) {
332 for (
auto const& ihit : trkRef->recHits())
333 if (ihit->isValid()) {
346 TString weightfilepath =
"";
347 double mvaValue = -10;
348 double cutvalue = -10;
351 if (refGsf->pt() < 20 && fabs(refGsf->eta()) < 1.479) {
352 mvaValue =
cache->gbrBarrelLowPt_->GetClassifier(
vars);
355 if (refGsf->pt() > 20 && fabs(refGsf->eta()) < 1.479) {
356 mvaValue =
cache->gbrBarrelHighPt_->GetClassifier(
vars);
359 if (refGsf->pt() < 20 && fabs(refGsf->eta()) > 1.479) {
360 mvaValue =
cache->gbrEndcapsLowPt_->GetClassifier(
vars);
363 if (refGsf->pt() > 20 && fabs(refGsf->eta()) > 1.479) {
364 mvaValue =
cache->gbrEndcapsHighPt_->GetClassifier(
vars);
369 cout <<
"Gsf track Pt, Eta " << refGsf->pt() <<
" " << refGsf->eta() << endl;
371 cout <<
"Cutvalue " << cutvalue << endl;
377 cout <<
" The input variables for conv brem tracks identification " << endl
378 <<
" secR " <<
secR <<
" gsfR " << gsfR << endl
379 <<
" N shared hits " <<
nHITS1 << endl
380 <<
" sTIP " <<
sTIP << endl
382 <<
" E/pout " <<
Epout << endl
384 <<
" ***** MVA ***** " << mvaValue << endl;
386 if (mvaValue > cutvalue) {