23 double mvaBremConvCutBarrelLowPt,
24 double mvaBremConvCutBarrelHighPt,
25 double mvaBremConvCutEndcapsLowPt,
26 double mvaBremConvCutEndcapsHighPt,
27 string mvaWeightFileConvBremBarrelLowPt,
28 string mvaWeightFileConvBremBarrelHighPt,
29 string mvaWeightFileConvBremEndcapsLowPt,
30 string mvaWeightFileConvBremEndcapsHighPt
33 mvaBremConvCutBarrelLowPt_(mvaBremConvCutBarrelLowPt),
34 mvaBremConvCutBarrelHighPt_(mvaBremConvCutBarrelHighPt),
35 mvaBremConvCutEndcapsLowPt_(mvaBremConvCutEndcapsLowPt),
36 mvaBremConvCutEndcapsHighPt_(mvaBremConvCutEndcapsHighPt),
37 mvaWeightFileConvBremBarrelLowPt_(mvaWeightFileConvBremBarrelLowPt),
38 mvaWeightFileConvBremBarrelHighPt_(mvaWeightFileConvBremBarrelHighPt),
39 mvaWeightFileConvBremEndcapsLowPt_(mvaWeightFileConvBremEndcapsLowPt),
40 mvaWeightFileConvBremEndcapsHighPt_(mvaWeightFileConvBremEndcapsHighPt)
102 bool debugRef =
false;
105 cout <<
"runConvBremFinder:: Entering " << endl;
111 vector<PFBrem> primPFBrem = gsfpfrectk.
PFRecBrem();
115 reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
116 reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
122 vector<PFRecTrackRef> AllPFRecTracks;
123 AllPFRecTracks.clear();
124 unsigned int ipft = 0;
127 for(;pft!=pftend;++pft,ipft++){
130 if(pfTrackRef->trackRef() == pft->trackRef())
continue;
133 TrackRef trackRef = pfRecTrRef->trackRef();
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);
146 for(
unsigned i=0;
i<PfConvColl.size();
i++) {
149 unsigned int trackSize=(convRef->pfTracks()).
size();
150 if ( convRef->pfTracks().size() < 2)
continue;
151 for(
unsigned iTk=0;iTk<trackSize; iTk++) {
157 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
160 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
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;
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;
170 if(AllPFRecTracks[iPF]->trackRef()== compPFTkRef->trackRef()) {
172 cout <<
" SAME BREM REF " << endl;
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);
188 for(
unsigned i=0;
i<PfNuclColl.size();
i++) {
190 unsigned int trackSize= dispacedVertexRef->pfRecTracks().size();
191 for(
unsigned iTk=0;iTk < trackSize; iTk++) {
197 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
200 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
202 if(selTrackBaseRef == newTrackBaseRef) notFound =
false;
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);
216 for(
unsigned i=0;
i<PfV0Coll.size();
i++) {
218 unsigned int trackSize=(v0Ref->pfTracks()).
size();
219 for(
unsigned iTk=0;iTk<trackSize; iTk++) {
225 if(primaryTrackBaseRef == newTrackBaseRef)
continue;
228 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
230 if(selTrackBaseRef == newTrackBaseRef) notFound =
false;
234 cout <<
"runConvBremFinder:: pushing_back V0 " << newPFRecTrackRef->trackRef()->pt()
235 <<
" eta,phi " << newPFRecTrackRef->trackRef()->eta() <<
", " << newPFRecTrackRef->trackRef()->phi() << endl;
236 AllPFRecTracks.push_back(newPFRecTrackRef);
247 for(
unsigned iPF = 0; iPF < AllPFRecTracks.size(); iPF++) {
250 double dphi= fabs(AllPFRecTracks[iPF]->trackRef()->
phi()-refGsf->phi());
252 double deta=fabs(AllPFRecTracks[iPF]->trackRef()->
eta()-refGsf->eta());
255 if( fabs(dphi)> 1.0 || fabs(deta) > 0.4)
continue;
258 double minDEtaBremKF = 1000.;
259 double minDPhiBremKF = 1000.;
260 double minDRBremKF = 1000.;
261 double minDEtaBremKFPos = 1000.;
262 double minDPhiBremKFPos = 1000.;
263 double minDRBremKFPos = 1000.;
266 double secEta = trkRef->innerMomentum().eta();
267 double secPhi = trkRef->innerMomentum().phi();
269 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
270 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
273 if( ! atPrimECAL.
isValid() )
continue;
274 double bremEta = atPrimECAL.
momentum().Eta();
275 double bremPhi = atPrimECAL.
momentum().Phi();
278 double deta = fabs(bremEta - secEta);
279 double dphi = fabs(bremPhi - secPhi);
281 double DR =
sqrt(deta*deta + dphi*dphi);
284 double detaPos = fabs(bremEta - trkRef->innerPosition().eta());
285 double dphiPos = fabs(bremPhi - trkRef->innerPosition().phi());
287 double DRPos =
sqrt(detaPos*detaPos + dphiPos*dphiPos);
292 if(DR < minDRBremKF) {
295 minDEtaBremKF = deta;
296 minDPhiBremKF = fabs(dphi);
299 if(DRPos < minDRBremKFPos) {
301 minDEtaBremKFPos = detaPos;
302 minDPhiBremKFPos = fabs(dphiPos);
308 float gsfR =
sqrt(refGsf->innerPosition().x()*refGsf->innerPosition().x() +
309 refGsf->innerPosition().y()*refGsf->innerPosition().y() );
313 secR =
sqrt(trkRef->innerPosition().x()*trkRef->innerPosition().x() +
314 trkRef->innerPosition().y()*trkRef->innerPosition().y() );
319 if( (minDPhiBremKF < 0.1 || minDPhiBremKFPos < 0.1) &&
320 (minDEtaBremKF < 0.02 || minDEtaBremKFPos < 0.02)&&
325 cout <<
"runConvBremFinder:: OK Find track and BREM close "
326 <<
" MinDphi " << minDPhiBremKF <<
" MinDeta " << minDEtaBremKF << endl;
329 float MinDist = 100000.;
334 for (PFClusterCollection::const_iterator clus = theEClus.begin();
335 clus != theEClus.end();
346 bool applyCrackCorrections =
false;
347 vector<double> ps1Ene(0);
348 vector<double> ps2Ene(0);
353 EE_calib =
pfcalib_->
energyEm(*clus,ps1Ene,ps2Ene,ps1,ps2,applyCrackCorrections);
357 if(MinDist > 0. && MinDist < 100000.) {
361 secPout =
sqrt(trkRef->outerMomentum().x()*trkRef->outerMomentum().x() +
362 trkRef->outerMomentum().y()*trkRef->outerMomentum().y() +
363 trkRef->outerMomentum().z()*trkRef->outerMomentum().z());
365 secPin =
sqrt(trkRef->innerMomentum().x()*trkRef->innerMomentum().x() +
366 trkRef->innerMomentum().y()*trkRef->innerMomentum().y() +
367 trkRef->innerMomentum().z()*trkRef->innerMomentum().z());
376 if (primaryVertex->size() != 0) {
377 pv = &*primaryVertex->begin();
382 e(0, 0) = 0.0015 * 0.0015;
383 e(1, 1) = 0.0015 * 0.0015;
386 dummy =
Vertex(p, e, 0, 0, 0);
392 refGsf->innerMomentum().y(),
393 refGsf->innerMomentum().z());
407 unsigned int tmp_sh = 0;
410 for (;nhit!=nhit_end;++nhit){
411 if ((*nhit)->isValid()){
415 for (;ihit!=ihit_end;++ihit){
416 if ((*ihit)->isValid()) {
435 TString weightfilepath =
"";
436 double mvaValue = -10;
437 double cutvalue = -10;
438 if(refGsf->pt()<20 && fabs(refGsf->eta())<1.479 ){
442 if(refGsf->pt()>20 && fabs(refGsf->eta())<1.479 ){
446 if(refGsf->pt()<20 && fabs(refGsf->eta())>1.479 ){
450 if(refGsf->pt()>20 && fabs(refGsf->eta())>1.479 ){
458 if(debug)
cout <<
"Gsf track Pt, Eta " << refGsf->pt() <<
" " << refGsf->eta()<< endl;
459 if(debug)
cout <<
"Cutvalue " << cutvalue << endl;
462 if( (kfhitcounter-
nHITS1) <=3 &&
nHITS1>3) mvaValue = 2;
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
471 <<
" E/pout " <<
Epout << endl
472 <<
" ptRatioKFGsf " << ptRatioGsfKF << endl
473 <<
" ***** MVA ***** " << mvaValue << endl;
475 if(mvaValue > cutvalue) {
reconstructed track used as an input to particle flow
bool isNonnull() const
Checks for non-null.
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
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
TMVA::Reader * tmvaReaderEndcapsHighPt_
ConvBremPFTrackFinder(const TransientTrackBuilder &builder, double mvaBremConvCutBarrelLowPt, double mvaBremConvCutBarrelHighPt, double mvaBremConvCutEndcapsLowPt, double mvaBremConvCutEndcapsHighPt, std::string mvaWeightFileConvBremBarrelLowPt, std::string mvaWeightFileConvBremBarrelHighPt, std::string mvaWeightFileConvBremEndcapsLowPt, std::string mvaWeightFileConvBremEndcapsHighPt)
PFEnergyCalibration * pfcalib_
double mvaBremConvCutEndcapsLowPt_
void calculatePositionREP()
computes posrep_ once and for all
const reco::GsfTrackRef & gsfTrackRef() const
TransientTrackBuilder builder_
double mvaBremConvCutBarrelHighPt_
TMVA::Reader * tmvaReaderBarrelHighPt_
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
TMVA::Reader * tmvaReaderEndcapsLowPt_
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)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
TMVA::Reader * tmvaReaderBarrelLowPt_
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)
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
double energyEm(const reco::PFCluster &clusterEcal, std::vector< double > &EclustersPS1, std::vector< double > &EclustersPS2, bool crackCorrection=true)