23 DPtovPtCut_(std::vector<double>(4,static_cast<double>(999.))),
24 NHitCut_(std::vector<unsigned int>(4,static_cast<unsigned>(0))),
25 useIterTracking_(
true),
32 std::vector<unsigned int>& NHitCut,
33 bool useConvBremPFRecTracks,
35 int nuclearInteractionsPurity,
37 std::vector<double>& photonSelectionCuts) {
48 photonSelectionCuts[1], photonSelectionCuts[2],
49 photonSelectionCuts[3], photonSelectionCuts[4],
50 photonSelectionCuts[5], photonSelectionCuts[6],
51 photonSelectionCuts[7]);
58 cout<<
"~PFBlockAlgo - number of remaining elements: "
81 cout<<
" PFBlockAlgo::findBlocks() ----------------------"<<endl;
82 cout<<
" element "<<**ie<<endl;
83 cout<<
" creating new block"<<endl;
89 vector< PFBlockLink > links;
105 vector<PFBlockLink>& links ) {
109 if(
debug_ )
cout<<
"PFBlockAlgo::associate start ----"<<endl;
116 link( *last, *next, linktype, linktest, dist );
127 blocks_->back().addElement( *next );
139 (*next)->index() ) );
148 if(
debug_ )
cout<<
"adding to block element "<<(**next)<<endl;
150 blocks_->back().addElement( *next );
164 if( ie == last || ie == next ) {
170 if( (*ie)->locked() ) {
172 if(
debug_ )
cout<<
"element "<<(**ie)<<
"already used"<<endl;
180 if(
debug_ )
cout<<
"calling associate "<<(**next)<<
" & "<<(**ie)<<endl;
187 cout<<
"**** deleting element "<<endl;
195 cout<<
"**** removing element "<<endl;
199 IE iteratorToNextFreeElement =
elements_.erase( next );
202 if(
debug_ )
cout<<
"PFBlockAlgo::associate stop ----"<<endl;
205 return iteratorToNextFreeElement;
212 const vector<PFBlockLink>& links )
const {
220 for(
unsigned i1=0; i1<els.
size(); i1++ ) {
221 for(
unsigned i2=0; i2<els.
size(); i2++ ) {
224 if( i1==i2 )
continue;
230 = PFBlock::LINKTEST_RECHIT;
235 for(
unsigned il=0; il<links.size(); il++ ) {
236 if( (links[il].element1() == i1 &&
237 links[il].element2() == i2) ||
238 (links[il].element1() == i2 &&
239 links[il].element2() == i1) ) {
241 dist = links[il].dist();
246 linktest = links[il].test();
249 cout <<
"Reading link vector: linktest used="
251 <<
" distance = " << dist
262 link( & els[i1], & els[i2], linktype, linktest, dist);
269 cout <<
"Setting link between elements " << i1 <<
" and " << i2
270 <<
" of dist =" << dist <<
" computed from link test "
295 double& dist)
const {
300 linktest = PFBlock::LINKTEST_RECHIT;
308 if( type1!=PFBlockElement::TRACK && type1!=PFBlockElement::GSF &&
314 if( type1 ==PFBlockElement::TRACK) {
321 ((1<< (type1-1) ) | (1<< (type2-1) ));
323 if(
debug_ )
std::cout <<
" PFBlockAlgo links type1 " << type1 <<
" type2 " << type2 << std::endl;
344 assert( !trackref.
isNull() );
345 assert( !clusterref.
isNull() );
348 linktest = PFBlock::LINKTEST_RECHIT;
357 if(
debug_ )
std::cout <<
" Track pt " << trackref->trackRef()->pt() << std::endl;
360 assert( !trackref.
isNull() );
361 assert( !clusterref.
isNull() );
363 linktest = PFBlock::LINKTEST_RECHIT;
367 std::cout <<
" Here a link has been established"
368 <<
" between a track an Ecal with dist "
369 << dist << std::endl;
371 std::cout <<
" No link found " << std::endl;
382 assert( !trackref.
isNull() );
383 assert( !clusterref.
isNull() );
385 linktest = PFBlock::LINKTEST_RECHIT;
393 assert( !ecalref.
isNull() );
394 assert( !hcalref.
isNull() );
398 linktest = PFBlock::LINKTEST_RECHIT;
407 assert( !psref.
isNull() );
408 assert( !ecalref.
isNull() );
410 linktest = PFBlock::LINKTEST_RECHIT;
417 assert( !ps1ref.
isNull() );
418 assert( !ps2ref.
isNull() );
422 linktest = PFBlock::LINKTEST_RECHIT;
428 cout<<
"TRACKandTRACK"<<endl;
431 std::cout <<
" PFBlockLink::TRACKandTRACK dist " << dist << std::endl;
432 linktest = PFBlock::LINKTEST_RECHIT;
441 assert( !ecal1ref.
isNull() );
442 assert( !ecal2ref.
isNull() );
444 cout <<
" PFBlockLink::ECALandECAL" << endl;
452 assert( !clusterref.
isNull() );
454 const PFRecTrack * myTrack = &(GsfEl->GsftrackPF());
456 linktest = PFBlock::LINKTEST_RECHIT;
460 std::cout <<
" Here a link has been established"
461 <<
" between a GSF track an Ecal with dist "
462 << dist << std::endl;
472 assert( !trackref.
isNull() );
477 assert( !gsfref.
isNull() );
479 if(refkf.isNonnull()) {
482 if (kftrackref == gsftrackref) {
497 vector<PFRecTrackRef> pfrectrack_vec = GsfEl->GsftrackRefPF()->convBremPFRecTrackRef();
498 if(pfrectrack_vec.size() > 0){
499 for(
unsigned int iconv = 0; iconv < pfrectrack_vec.size(); iconv++) {
502 if(kftrackref == (*pfrectrack_vec[iconv]).trackRef()) {
510 if(newTrackBaseRef == elemTrackBaseRef){
529 assert( !gsfref.
isNull() );
530 assert( !bremref.
isNull() );
531 if (gsfref == bremref) {
547 assert( !lowgsfref.
isNull() );
548 assert( !highgsfref.
isNull() );
554 if(lowgsfref->trackId() == highgsfref->trackId()) {
566 assert( !clusterref.
isNull() );
569 const PFRecTrack * myTrack = &(BremEl->trackPF());
578 std::cout <<
"ECALandBREM: dist testTrackAndClusterByRecHit "
579 << dist << std::endl;
580 linktest = PFBlock::LINKTEST_RECHIT;
587 assert( !psref.
isNull() );
589 const PFRecTrack * myTrack = &(GsfEl->GsftrackPF());
592 linktest = PFBlock::LINKTEST_RECHIT;
599 assert( !psref.
isNull() );
601 const PFRecTrack * myTrack = &(BremEl->trackPF());
604 linktest = PFBlock::LINKTEST_RECHIT;
610 assert( !clusterref.
isNull() );
612 const PFRecTrack * myTrack = &(GsfEl->GsftrackPF());
614 linktest = PFBlock::LINKTEST_RECHIT;
620 assert( !clusterref.
isNull() );
622 const PFRecTrack * myTrack = &(BremEl->trackPF());
635 linktest = PFBlock::LINKTEST_RECHIT;
643 assert( !clusterref.
isNull() );
647 assert (!scEl->superClusterRef().isNull());
654 linktest = PFBlock::LINKTEST_RECHIT;
673 switch (ps.
layer()) {
693 if( ! atPS.
isValid() )
return -1.;
695 double trackx = atPS.
position().X();
696 double tracky = atPS.
position().Y();
697 double trackz = atPS.
position().Z();
704 if( trackz*psz < 0.)
return -1.;
709 double dist =
std::sqrt( (psx-trackx)*(psx-trackx)
710 + (psy-tracky)*(psy-tracky));
711 if(
debug_)
cout<<
"testTrackAndPS "<< dist <<
" "<<endl;
713 cout<<
" trackx " << trackx
714 <<
" tracky " << tracky
740 if(
debug_)
cout<<
"testECALAndHCAL "<< dist <<
" "<<endl;
763 if(testindex == -1.)
return dist;
767 const std::vector<reco::PFClusterRef> & thePFClusters(
scpfcRefs_[testindex]);
769 unsigned npf=thePFClusters.size();
770 for(
unsigned i=0;
i<npf;++
i)
772 if(thePFClusters[
i]==ecal2)
775 ecal1->positionREP().Phi(),
776 ecal2->positionREP().Eta(),
777 ecal2->positionREP().Phi() );
806 ecal1->position().phi(),
807 ecal2->positionREP().Eta(),
808 ecal2->positionREP().Phi() );
836 double scale = z2/z1;
837 double x1atPS2 = x1*scale;
838 double y1atPS2 = y1*scale;
841 double dx1dx1 = resPSpitch_*resPSpitch_*scale*scale;
842 double dy1dy1 = resPSlength_*resPSlength_*scale*scale;
844 double dy2dy2 = resPSpitch_*resPSpitch_;
845 double dx2dx2 = resPSlength_*resPSlength_;
850 double dist =
std::sqrt( (x2-x1atPS2)*(x2-x1atPS2)
851 + (y2-y1atPS2)*(y2-y1atPS2));
853 if(
debug_)
cout<<
"testPS1AndPS2 "<<dist<<
" "<<endl;
855 cout<<
" x1atPS2 "<< x1atPS2 <<
" dx1 "<<resPSpitch_*scale
856 <<
" y1atPS2 "<< y1atPS2 <<
" dy1 "<<resPSlength_*scale<< endl
857 <<
" x2 " <<x2 <<
" dx2 "<<resPSlength_
858 <<
" y2 " << y2 <<
" dy2 "<<resPSpitch_<< endl;
884 if( ni1_TO_DISP == ni2_FROM_DISP ) { result = 1.0;
return result; }
887 if( ni1_FROM_DISP == ni2_TO_DISP ) { result = 1.0;
return result; }
890 if( ni1_FROM_DISP == ni2_FROM_DISP ) { result = 1.0;
return result; }
896 if(
debug_ )
std::cout <<
" testLinkByVertex On Conversions " << std::endl;
899 if(
debug_ )
std::cout <<
" PFBlockAlgo.cc testLinkByVertex Cconversion Refs are non null " << std::endl;
902 if(
debug_ )
std::cout <<
" testLinkByVertex Cconversion Refs are equal " << std::endl;
913 if(
debug_ )
std::cout <<
" PFBlockAlgo.cc testLinkByVertex V0 Refs are non null " << std::endl;
916 if(
debug_ )
std::cout <<
" testLinkByVertex V0 Refs are equal " << std::endl;
936 const Mask& trackMask,
937 const Mask& gsftrackMask,
938 const Mask& ecalMask,
939 const Mask& hcalMask,
940 const Mask& hfemMask,
941 const Mask& hfhadMask,
943 const Mask& phMask)
const {
945 if( !trackMask.empty() &&
946 trackMask.size() != tracks.size() ) {
947 string err =
"PFBlockAlgo::setInput: ";
948 err +=
"The size of the track mask is different ";
949 err +=
"from the size of the track vector.";
950 throw std::length_error( err.c_str() );
953 if( !gsftrackMask.empty() &&
954 gsftrackMask.size() != gsftracks.size() ) {
955 string err =
"PFBlockAlgo::setInput: ";
956 err +=
"The size of the gsf track mask is different ";
957 err +=
"from the size of the gsftrack vector.";
958 throw std::length_error( err.c_str() );
961 if( !ecalMask.empty() &&
962 ecalMask.size() != ecals.size() ) {
963 string err =
"PFBlockAlgo::setInput: ";
964 err +=
"The size of the ecal mask is different ";
965 err +=
"from the size of the ecal clusters vector.";
966 throw std::length_error( err.c_str() );
969 if( !hcalMask.empty() &&
970 hcalMask.size() != hcals.size() ) {
971 string err =
"PFBlockAlgo::setInput: ";
972 err +=
"The size of the hcal mask is different ";
973 err +=
"from the size of the hcal clusters vector.";
974 throw std::length_error( err.c_str() );
977 if( !hfemMask.empty() &&
978 hfemMask.size() != hfems.size() ) {
979 string err =
"PFBlockAlgo::setInput: ";
980 err +=
"The size of the hfem mask is different ";
981 err +=
"from the size of the hfem clusters vector.";
982 throw std::length_error( err.c_str() );
985 if( !hfhadMask.empty() &&
986 hfhadMask.size() != hfhads.size() ) {
987 string err =
"PFBlockAlgo::setInput: ";
988 err +=
"The size of the hfhad mask is different ";
989 err +=
"from the size of the hfhad clusters vector.";
990 throw std::length_error( err.c_str() );
993 if( !psMask.empty() &&
994 psMask.size() != pss.size() ) {
995 string err =
"PFBlockAlgo::setInput: ";
996 err +=
"The size of the ps mask is different ";
997 err +=
"from the size of the ps clusters vector.";
998 throw std::length_error( err.c_str() );
1001 if( !phMask.empty() &&
1002 phMask.size() != egphh.size() ) {
1003 string err =
"PFBlockAlgo::setInput: ";
1004 err +=
"The size of the photon mask is different ";
1005 err +=
"from the size of the photon vector.";
1006 throw std::length_error( err.c_str() );
1013 if(! out)
return out;
1015 out<<
"====== Particle Flow Block Algorithm ======= ";
1017 out<<
"number of unassociated elements : "<<a.
elements_.size()<<endl;
1022 out<<
"\t"<<**ie <<endl;
1028 const std::auto_ptr< reco::PFBlockCollection >&
blocks
1031 if(!blocks.get() ) {
1032 out<<
"blocks already transfered"<<endl;
1035 out<<
"number of blocks : "<<blocks->size()<<endl;
1039 ib != blocks->end(); ib++) {
1050 double P = trackref->p();
1051 double Pt = trackref->pt();
1052 double DPt = trackref->ptError();
1053 unsigned int NHit = trackref->hitPattern().trackerLayersWithMeasurement();
1054 unsigned int NLostHit = trackref->hitPattern().trackerLayersWithoutMeasurement();
1055 unsigned int LostHits = trackref->numberOfLostHits();
1056 double sigmaHad =
sqrt(1.20*1.20/P+0.06*0.06) / (1.+LostHits);
1059 unsigned int Algo = 0;
1060 switch (trackref->algo()) {
1061 case TrackBase::ctf:
1062 case TrackBase::iter0:
1063 case TrackBase::iter1:
1066 case TrackBase::iter2:
1069 case TrackBase::iter3:
1072 case TrackBase::iter4:
1075 case TrackBase::iter5:
1084 if ( P < 0.05 )
return false;
1087 if ( Algo > 4 )
return false;
1089 if (
debug_)
cout <<
" PFBlockAlgo: PFrecTrack->Track Pt= "
1090 << Pt <<
" DPt = " << DPt << endl;
1095 if (
debug_)
cout <<
" PFBlockAlgo: skip badly measured track"
1099 <<
", N(hits) = " << NHit <<
" (Lost : " << LostHits <<
"/" << NLostHit <<
")"
1100 <<
", Algo = " << Algo
1132 for(
unsigned j=0;
j<muonh->size();
j++) {
1135 if( muonref->track() == trackref )
return j;
1145 for(
unsigned j=0;
j<muonh->size();
j++) {
1148 if( muonref->track() == trackref )
return j;
1159 typedef std::multimap<double, unsigned>::iterator
IE;
1163 for(
unsigned i1=0; i1 != els.
size(); ++i1 ) {
1164 if( els[i1].
type() == PFBlockElement::TRACK )
continue;
1165 std::multimap<double, unsigned> assocTracks;
1171 for( IE ie = assocTracks.begin(); ie != assocTracks.end(); ++ie) {
1173 unsigned iprim = ie->second;
1176 if( els[iprim].isPrimary()) {
1179 PFBlock::LINKTEST_RECHIT );
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
const std::auto_ptr< reco::PFBlockCollection > & blocks() const
void checkMaskSize(const reco::PFRecTrackCollection &tracks, const reco::GsfPFRecTrackCollection &gsftracks, const reco::PFClusterCollection &ecals, const reco::PFClusterCollection &hcals, const reco::PFClusterCollection &hfems, const reco::PFClusterCollection &hfhads, const reco::PFClusterCollection &pss, const reco::PhotonCollection &egphh, const Mask &trackMask, const Mask &gsftrackMask, const Mask &ecalMask, const Mask &hcalMask, const Mask &hfemMask, const Mask &hfhadMask, const Mask &psMask, const Mask &phMask) const
Abstract base class for a PFBlock element (track, cluster...)
const math::XYZPoint & position() const
cluster centroid position
reconstructed track used as an input to particle flow
float hcalTowerSumEtConeDR04() const
Hcal isolation sum.
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
std::pair< ALIstring, ALIstring > pss
double testECALAndHCAL(const reco::PFCluster &ecal, const reco::PFCluster &hcal) const
bool useIterTracking_
Flag to turn off quality cuts which require iterative tracking (for heavy-ions)
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
GsfPFRecTrackRef GsftrackRefPF() const
double testSuperClusterPFCluster(const reco::SuperClusterRef &sct1, const reco::PFClusterRef &elt2) const
test association between SuperClusters and ECAL
static double testECALAndPSByRecHit(const reco::PFCluster &clusterECAL, const reco::PFCluster &clusterPS, bool debug=false)
const math::XYZPoint & position() const
cartesian position (x, y, z)
int nuclearInteractionsPurity_
void checkDisplacedVertexLinks(reco::PFBlock &block) const
remove extra links between primary track and clusters
float ecalRecHitSumEtConeDR04() const
const edm::OwnVector< reco::PFBlockElement > & elements() const
std::auto_ptr< reco::PFBlockCollection > blocks_
const LinkData & linkData() const
std::vector< double > DPtovPtCut_
DPt/Pt cut for creating atrack element.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
virtual PFDisplacedTrackerVertexRef displacedVertexRef(TrackType trType) const
double testTrackAndPS(const reco::PFRecTrack &track, const reco::PFCluster &ps) const
std::list< reco::PFBlockElement * >::const_iterator IEC
void setLink(unsigned i1, unsigned i2, double dist, LinkData &linkData, LinkTest test=LINKTEST_RECHIT) const
static double computeDist(double eta1, double phi1, double eta2, double phi2)
computes a chisquare
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
void setFromPhoton(bool val)
set provenance
void setHcalIso(float val)
set the had Iso
virtual VertexCompositeCandidateRef V0Ref() const
double testLinkBySuperCluster(const reco::PFClusterRef &elt1, const reco::PFClusterRef &elt2) const
test association by Supercluster between two ECAL
bool isNonnull() const
Checks for non-null.
bool isNull() const
Checks for null.
double testPS1AndPS2(const reco::PFCluster &ps1, const reco::PFCluster &ps2) const
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
void setTrackIso(float val)
set the track Iso
bool useConvBremPFRecTracks_
switch on/off Conversions Brem Recovery with KF Tracks
const REPPoint & positionREP() const
cluster position: rho, eta, phi
int muAssocToTrack(const reco::TrackRef &trackref, const edm::Handle< reco::MuonCollection > &muonh) const
void link(const reco::PFBlockElement *el1, const reco::PFBlockElement *el2, PFBlockLink::Type &linktype, reco::PFBlock::LinkTest &linktest, double &dist) const
check whether 2 elements are linked. Returns distance and linktype
virtual PFClusterRef clusterRef() const
virtual PFRecTrackRef trackRefPF() const
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
std::list< reco::PFBlockElement * >::iterator IE
define these in *Fwd files in DataFormats/ParticleFlowReco?
float hadronicOverEm() const
the total hadronic over electromagnetic fraction
std::list< reco::PFBlockElement * > elements_
actually, particles will be created by a separate producer
virtual bool trackType(TrackType trType) const
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
void setHoE(float val)
set H/E
std::vector< std::vector< reco::PFClusterRef > > scpfcRefs_
PF clusters corresponding to a given SC.
bool goodPtResolution(const reco::TrackRef &trackref)
open a resolution map
void fillFromPhoton(const reco::Photon &photon, reco::PFBlockElementSuperCluster *pfbe)
void packLinks(reco::PFBlock &block, const std::vector< PFBlockLink > &links) const
static const Mask dummyMask_
reco::PFBlockCollection::const_iterator IBC
IE associate(IE next, IE last, std::vector< PFBlockLink > &links)
const PhotonSelectorAlgo * photonSelector_
PhotonSelector.
double testLinkByVertex(const reco::PFBlockElement *elt1, const reco::PFBlockElement *elt2) const
bool isValid() const
is this point valid ?
void associatedElements(unsigned i, const LinkData &linkData, std::multimap< double, unsigned > &sortedAssociates, reco::PFBlockElement::Type type=PFBlockElement::NONE, LinkTest test=LINKTEST_RECHIT) const
static double testHFEMAndHFHADByRecHit(const reco::PFCluster &clusterHFEM, const reco::PFCluster &clusterHFHAD, bool debug=false)
test association between HFEM and HFHAD, by rechit
key_type key() const
Accessor for product key.
virtual bool trackType(TrackType trType) const
std::vector< Photon > PhotonCollection
collectin of Photon objects
void findBlocks()
build blocks
std::vector< int > pfcSCVec_
SC corresponding to the PF cluster.
float trkSumPtHollowConeDR04() const
Type
possible types. WARNING: have a look at PFBlockElement
void setParameters(std::vector< double > &DPtovPtCut, std::vector< unsigned > &NHitCut, bool useConvBremPFRecTracks, bool useIterTracking, int nuclearInteractionsPurity, bool useEGPhotons, std::vector< double > &photonSelectionCuts)
virtual ConversionRef convRef() const
GsfPFRecTrackRef GsftrackRefPF() const
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
virtual bool isLinkedToDisplacedVertex() const
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
bool debug_
if true, debug printouts activated
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
bool useEGPhotons_
Flag to turn off the import of EG Photons.
void setEcalIso(float val)
set the ecal Iso
std::vector< unsigned > NHitCut_
Number of layers crossed cut for creating atrack element.