1 #ifndef RecoParticleFlow_PFProducer_PFBlockAlgo_h
2 #define RecoParticleFlow_PFProducer_PFBlockAlgo_h
81 std::vector<unsigned>& NHitCut,
82 bool useConvBremPFRecTracks,
84 int nuclearInteractionsPurity,
86 std::vector<double> & photonSelectionCuts,
87 bool useSuperClusters,
88 bool superClusterMatchByRef
95 typedef std::vector<bool>
Mask;
98 template<
template<
typename>
class T>
129 template<
template<
typename>
class T >
154 setInput<T>( trackh, gsftrackh, convbremgsftrackh, muonh, nuclearh, nucleartrackh, convh, v0,
155 ecalh, hcalh, hoh, hfemh, hfhadh, psh, phh, scebh, sceeh, pfclusterassoc,
156 trackMask, ecalMask, hcalMask, hoMask, psMask);
160 template<
template<
typename>
class T >
180 setInput<T>( trackh, gsftrackh, convbremgsftrackh, muonh, nuclearh, nucleartrackh, convh, v0, ecalh, hcalh, hoh, psh, egphh,
181 trackMask, gsftrackMask,ecalMask, hcalMask, hoMask, psMask);
194 const std::auto_ptr< reco::PFBlockCollection >&
blocks()
const
201 typedef std::list< reco::PFBlockElement* >::iterator
IE;
202 typedef std::list< reco::PFBlockElement* >::const_iterator
IEC;
203 typedef reco::PFBlockCollection::const_iterator
IBC;
220 const std::vector<PFBlockLink>&
links)
const;
283 const Mask& trackMask,
284 const Mask& gsftrackMask,
285 const Mask& ecalMask,
286 const Mask& hcalMask,
288 const Mask& hfemMask,
289 const Mask& hfhadMask,
292 const Mask& scMask)
const;
308 template<
template<
typename>
class T>
311 std::auto_ptr< reco::PFBlockCollection >
blocks_;
392 template<
template<
typename>
class T >
412 const Mask& trackMask,
413 const Mask& gsftrackMask,
414 const Mask& ecalMask,
415 const Mask& hcalMask,
417 const Mask& hfemMask,
418 const Mask& hfhadMask,
421 const Mask& scMask) {
460 std::vector<reco::PFRecTrackRef> convBremPFRecTracks;
461 convBremPFRecTracks.
clear();
467 if(gsftrackh.isValid() ) {
469 for(
unsigned i=0;
i<gsftrackh->size(); ++
i) {
470 if( !gsftrackMask.empty() &&
471 !gsftrackMask[
i] )
continue;
474 if((refgsf).isNull())
continue;
481 if(seedRef.
isAvailable() && seedRef->isEcalDriven()) {
498 std::list<reco::PFBlockElement*>::iterator itcheck=find_if(
elements_.begin(),
elements_.end(),myEqual);
516 const std::vector<reco::PFTrajectoryPoint>
517 PfGsfPoint = PFGsfProd[
i].trajectoryPoints();
519 unsigned int c_gsf=0;
520 bool PassTracker =
false;
521 bool GetPout =
false;
522 unsigned int IndexPout = 0;
524 typedef std::vector<reco::PFTrajectoryPoint>::const_iterator
IP;
525 for(IP itPfGsfPoint = PfGsfPoint.begin();
526 itPfGsfPoint!= PfGsfPoint.end();++itPfGsfPoint) {
528 if (itPfGsfPoint->isValid()){
529 int layGsfP = itPfGsfPoint->layer();
530 if (layGsfP == -1) PassTracker =
true;
531 if (PassTracker && layGsfP > 0 && GetPout ==
false) {
544 const std::vector<reco::PFRecTrackRef>& temp_convBremPFRecTracks(refgsf->convBremPFRecTrackRef());
545 if(temp_convBremPFRecTracks.size() > 0) {
546 for(
unsigned int iconv = 0; iconv <temp_convBremPFRecTracks.size(); ++iconv) {
547 convBremPFRecTracks.push_back(temp_convBremPFRecTracks[iconv]);
556 std::vector<reco::PFBrem> pfbrem = refgsf->PFRecBrem();
558 for (
unsigned i2=0;i2<pfbrem.size(); ++i2) {
559 const double DP = pfbrem[i2].DeltaP();
560 const double SigmaDP = pfbrem[i2].SigmaDeltaP();
561 const unsigned int TrajP = pfbrem[i2].indTrajPoint();
562 if(TrajP == 99)
continue;
575 unsigned size=egphh->size();
576 for(
unsigned isc=0; isc<
size; ++isc) {
577 if(!phMask.empty() && !(phMask)[isc] )
continue;
595 std::list<reco::PFBlockElement*>::iterator itcheck=find_if(
elements_.begin(),
elements_.end(),myEqual);
614 std::vector<reco::SuperClusterRef> screfs;
615 screfs.reserve(sceb->size()+scee->size());
617 for (
unsigned int isc=0; isc<sceb->size(); ++isc) {
619 screfs.push_back(scRef);
622 for (
unsigned int isc=0; isc<scee->size(); ++isc) {
624 screfs.push_back(scRef);
627 unsigned size=screfs.size();
628 for(
unsigned isc=0; isc<
size; ++isc) {
629 if(!scMask.empty() && !(scMask)[isc] )
continue;
673 if(convh.isValid() ) {
675 for(
unsigned i=0;
i<convh->size(); ++
i) {
678 unsigned int trackSize=(convRef->pfTracks()).
size();
679 if ( convRef->pfTracks().size() < 2)
continue;
680 for(
unsigned iTk=0;iTk<trackSize; ++iTk) {
686 elements_.push_back( trkFromConversionElement );
690 std::cout <<
"PF Block Element from Conversion electron " <<
691 (*trkFromConversionElement).trackRef().key() << std::endl;
692 std::cout << *trkFromConversionElement << std::endl;
706 for(
unsigned i=0;
i<v0->size(); ++
i) {
708 unsigned int trackSize=(v0Ref->pfTracks()).
size();
709 for(
unsigned iTk=0;iTk<trackSize; ++iTk) {
719 if (newTrackBaseRef == elemTrackBaseRef){
720 trkFromV0Element = *iel;
732 trkFromV0Element->
setV0Ref( v0Ref->originalV0(),
736 std::cout <<
"PF Block Element from V0 track New = " << bNew
737 << (*trkFromV0Element).trackRef().key() << std::endl;
738 std::cout << *trkFromV0Element << std::endl;
750 if(nuclearh.isValid()) {
752 for(
unsigned i=0;
i<nuclearh->size(); ++
i) {
762 bool bIncludeVertices =
false;
763 bool bNucl = dispacedVertexRef->displacedVertexRef()->isNucl()
764 && dispacedVertexRef->displacedVertexRef()->position().rho()> 2.7;
765 bool bNucl_Loose = dispacedVertexRef->displacedVertexRef()->isNucl_Loose();
766 bool bNucl_Kink = dispacedVertexRef->displacedVertexRef()->isNucl_Kink();
772 if (bIncludeVertices){
774 unsigned int trackSize= dispacedVertexRef->pfRecTracks().size();
777 std::cout <<
"Displaced Vertex " <<
i << std::endl;
778 dispacedVertexRef->displacedVertexRef()->Dump();
780 for(
unsigned iTk=0;iTk < trackSize; ++iTk) {
791 if (nucleartrackh.isValid()){
792 for(
unsigned i=0;
i<nucleartrackh->size(); ++
i) {
795 if (constTrackBaseRef==transientTrackBaseRef){
796 newPFRecTrackRef = transientPFRecTrackRef;
812 if (newTrackBaseRef == elemTrackBaseRef){
813 trkFromDisplacedVertexElement = *iel;
826 elements_.push_back( trkFromDisplacedVertexElement );
829 if (dispacedVertexRef->isIncomingTrack(newPFRecTrackRef))
831 else if (dispacedVertexRef->isOutgoingTrack(newPFRecTrackRef))
841 std::cout <<
"PF Block Element from DisplacedTrackingVertex track New = " << bNew
842 << (*trkFromDisplacedVertexElement).trackRef().key() << std::endl;
843 std::cout << *trkFromDisplacedVertexElement << std::endl;
861 if(trackh.isValid() ) {
863 if (
debug_)
std::cout <<
"Tracks already in from Displaced Vertices " << std::endl;
865 Mask trackMaskVertex;
867 for(
unsigned i=0;
i<trackh->size(); ++
i) {
874 if( trackRef == elemTrackRef ) {
876 bMask =
false;
continue;
880 trackMaskVertex.push_back(bMask);
885 if (
debug_)
std::cout <<
"Additionnal tracks from main collection " << std::endl;
887 for(
unsigned i=0;
i<trackh->size(); ++
i) {
891 if( !trackMask.empty() && !trackMask[
i] )
continue;
899 bool thisIsAPotentialMuon =
false;
902 thisIsAPotentialMuon =
907 if( !thisIsAPotentialMuon && !
goodPtResolution( ref->trackRef() ) )
continue;
909 if (thisIsAPotentialMuon &&
debug_)
std::cout <<
"Potential Muon P " << ref->trackRef()->p()
910 <<
" pt " << ref->trackRef()->p() << std::endl;
922 if (!trackMaskVertex.empty() && !trackMaskVertex[
i]){
926 if( primaryTrackRef == elemTrackRef ) {
927 (*iel)->setMuonRef( muonref );
928 if (
debug_)
std::cout <<
"One of the tracks identified in displaced vertices collections was spotted as muon" <<std:: endl;
935 if (!trackMaskVertex.empty() && !trackMaskVertex[
i])
continue;
940 if(convBremPFRecTracks.size() > 0.) {
941 for(
unsigned int iconv = 0; iconv < convBremPFRecTracks.size(); ++iconv) {
942 if((*ref).trackRef() == (*convBremPFRecTracks[iconv]).trackRef()) {
959 if(convbremgsftrackh.isValid() ) {
963 for(
unsigned i=0;
i<convbremgsftrackh->size(); ++
i) {
967 if((refgsf).isNull())
continue;
971 const std::vector<reco::PFTrajectoryPoint>
972 PfGsfPoint = ConvPFGsfProd[
i].trajectoryPoints();
974 unsigned int c_gsf=0;
975 bool PassTracker =
false;
976 bool GetPout =
false;
977 unsigned int IndexPout = -1;
979 typedef std::vector<reco::PFTrajectoryPoint>::const_iterator
IP;
980 for(IP itPfGsfPoint = PfGsfPoint.begin();
981 itPfGsfPoint!= PfGsfPoint.end();++itPfGsfPoint) {
983 if (itPfGsfPoint->isValid()){
984 int layGsfP = itPfGsfPoint->layer();
985 if (layGsfP == -1) PassTracker =
true;
986 if (PassTracker && layGsfP > 0 && GetPout ==
false) {
1001 bool valuegsf =
true;
1008 std::vector<reco::PFBrem> pfbrem = refgsf->PFRecBrem();
1010 for (
unsigned i2=0;i2<pfbrem.size(); ++i2) {
1011 const double DP = pfbrem[i2].DeltaP();
1012 const double SigmaDP = pfbrem[i2].SigmaDeltaP();
1013 const unsigned int TrajP = pfbrem[i2].indTrajPoint();
1014 if(TrajP == 99)
continue;
1028 if(ecalh.isValid() ) {
1035 for(
unsigned i=0;
i<ecalh->size(); ++
i) {
1038 if( !ecalMask.empty() &&
1039 !ecalMask[
i] )
continue;
1072 if(hcalh.isValid() ) {
1074 for(
unsigned i=0;
i<hcalh->size(); ++
i) {
1077 if( !hcalMask.empty() &&
1078 !hcalMask[
i] )
continue;
1090 if(
useHO_ && hoh.isValid() ) {
1092 for(
unsigned i=0;
i<hoh->size(); ++
i) {
1095 if( !hoMask.empty() &&
1096 !hoMask[
i] )
continue;
1108 if(hfemh.isValid() ) {
1110 for(
unsigned i=0;
i<hfemh->size(); ++
i) {
1113 if( !hfemMask.empty() &&
1114 !hfemMask[
i] )
continue;
1127 if(hfhadh.isValid() ) {
1129 for(
unsigned i=0;
i<hfhadh->size(); ++
i) {
1132 if( !hfhadMask.empty() &&
1133 !hfhadMask[
i] )
continue;
1148 if(psh.isValid() ) {
1149 for(
unsigned i=0;
i<psh->size(); ++
i) {
1152 if( !psMask.empty() &&
1153 !psMask[
i] )
continue;
1158 switch(ref->layer()){
1181 for (std::list< reco::PFBlockElement* >::iterator it =
elements_.begin();
1183 switch ((*it)->type()){
1227 template<
template<
typename>
class T>
1230 pfbe->
setTrackIso(photonRef->trkSumPtHollowConeDR04());
1231 pfbe->
setEcalIso(photonRef->ecalRecHitSumEtConeDR04());
1232 pfbe->
setHcalIso(photonRef->hcalTowerSumEtConeDR04());
1233 pfbe->
setHoE(photonRef->hadronicOverEm());
const std::auto_ptr< reco::PFBlockCollection > & blocks() const
void insertFieldClusterElt(reco::PFBlockElement *hcalCluster)
Abstract base class for a PFBlock element (track, cluster...)
reconstructed track used as an input to particle flow
std::vector< reco::SuperClusterRef > superClusters_
list of superclusters
bool passPhotonSelection(const reco::Photon &) const
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.
static bool isMuon(const reco::PFBlockElement &elt)
static HepMC::IO_HEPEVT conv
double testSuperClusterPFCluster(const reco::SuperClusterRef &sct1, const reco::PFClusterRef &elt2) const
test association between SuperClusters and ECAL
KDTreeLinkerTrackEcal TELinker_
double testHCALAndHO(const reco::PFCluster &hcal, const reco::PFCluster &ho) const
KDTreeLinkerPSEcal PSELinker_
friend std::ostream & operator<<(std::ostream &, const PFBlockAlgo &)
int nuclearInteractionsPurity_
const edm::ValueMap< reco::CaloClusterPtr > * pfclusterassoc_
void checkDisplacedVertexLinks(reco::PFBlock &block) const
remove extra links between primary track and clusters
void setInput(const T< reco::PFRecTrackCollection > &trackh, const T< reco::GsfPFRecTrackCollection > &gsftrackh, const T< reco::PFClusterCollection > &ecalh, const T< reco::PFClusterCollection > &hcalh, const T< reco::PFClusterCollection > &hoh, const T< reco::PFClusterCollection > &psh, const Mask &trackMask=dummyMask_, const Mask &gsftrackMask=dummyMask_, const Mask &ecalMask=dummyMask_, const Mask &hcalMask=dummyMask_, const Mask &hoMask=dummyMask_, const Mask &psMask=dummyMask_)
COLIN: what is this setinput function for? can it be removed?
void setFromGsfElectron(bool val)
set provenance
std::auto_ptr< reco::PFBlockCollection > blocks_
std::vector< double > DPtovPtCut_
DPt/Pt cut for creating atrack element.
void insertFieldClusterElt(reco::PFBlockElement *ecalCluster)
bool superClusterMatchByRef_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
double testTrackAndPS(const reco::PFRecTrack &track, const reco::PFCluster &ps) const
std::list< reco::PFBlockElement * >::const_iterator IEC
virtual void setTrackType(TrackType trType, bool value)
the trackType
void fillFromPhoton(const T< reco::PhotonCollection > &, unsigned isc, reco::PFBlockElementSuperCluster *pfbe)
void setFromPhoton(bool val)
set provenance
void setHcalIso(float val)
set the had Iso
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
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.
KDTreeLinkerTrackHcal THLinker_
double testPS1AndPS2(const reco::PFCluster &ps1, const reco::PFCluster &ps2) const
bool useSuperClusters_
Flag to turn off the import of SuperCluster collections.
void setInput(const T< reco::PFRecTrackCollection > &trackh, const T< reco::MuonCollection > &muonh, const T< reco::PFClusterCollection > &ecalh, const T< reco::PFClusterCollection > &hcalh, const T< reco::PFClusterCollection > &hoh, const T< reco::PFClusterCollection > &hfemh, const T< reco::PFClusterCollection > &hfhadh, const T< reco::PFClusterCollection > &psh, const Mask &trackMask=dummyMask_, const Mask &ecalMask=dummyMask_, const Mask &hcalMask=dummyMask_, const Mask &hoMask=dummyMask_, const Mask &psMask=dummyMask_)
COLIN: I think this is for particle flow at HLT...
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void setTrackIso(float val)
set the track Iso
bool useConvBremPFRecTracks_
switch on/off Conversions Brem Recovery with KF Tracks
void setPhotonRef(const PhotonRef &ref)
set photonRef
int muAssocToTrack(const reco::TrackRef &trackref, const edm::Handle< reco::MuonCollection > &muonh) const
void setDebug(bool debug)
sets debug printout flag
virtual void setDisplacedVertexRef(const PFDisplacedTrackerVertexRef &niref, TrackType trType)
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 void setV0Ref(const VertexCompositeCandidateRef &v0ref, TrackType trType)
void insertFieldClusterElt(reco::PFBlockElement *ecalCluster)
std::list< reco::PFBlockElement * >::iterator IE
define these in *Fwd files in DataFormats/ParticleFlowReco?
std::list< reco::PFBlockElement * > elements_
actually, particles will be created by a separate producer
void setHoE(float val)
set H/E
void insertTargetElt(reco::PFBlockElement *track)
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 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.
void setInput(const T< reco::PFRecTrackCollection > &trackh, const T< reco::GsfPFRecTrackCollection > &gsftrackh, const T< reco::GsfPFRecTrackCollection > &convbremgsftrackh, const T< reco::MuonCollection > &muonh, const T< reco::PFDisplacedTrackerVertexCollection > &nuclearh, const T< reco::PFRecTrackCollection > &nucleartrackh, const T< reco::PFConversionCollection > &conv, const T< reco::PFV0Collection > &v0, const T< reco::PFClusterCollection > &ecalh, const T< reco::PFClusterCollection > &hcalh, const T< reco::PFClusterCollection > &hoh, const T< reco::PFClusterCollection > &hfemh, const T< reco::PFClusterCollection > &hfhadh, const T< reco::PFClusterCollection > &psh, const T< reco::PhotonCollection > &egphh, const T< reco::SuperClusterCollection > &sceb, const T< reco::SuperClusterCollection > &scee, const T< edm::ValueMap< reco::CaloClusterPtr > > &pfclusterassoc, const Mask &trackMask=dummyMask_, const Mask &gsftrackMask=dummyMask_, const Mask &ecalMask=dummyMask_, const Mask &hcalMask=dummyMask_, const Mask &hoMask=dummyMask_, const Mask &hfemMask=dummyMask_, const Mask &hfhadMask=dummyMask_, const Mask &psMask=dummyMask_, const Mask &phMask=dummyMask_, const Mask &scMask=dummyMask_)
set input collections of tracks and clusters
void checkMaskSize(const reco::PFRecTrackCollection &tracks, const reco::GsfPFRecTrackCollection &gsftracks, const reco::PFClusterCollection &ecals, const reco::PFClusterCollection &hcals, const reco::PFClusterCollection &hos, const reco::PFClusterCollection &hfems, const reco::PFClusterCollection &hfhads, const reco::PFClusterCollection &pss, const reco::PhotonCollection &egphh, const reco::SuperClusterCollection &sceb, const reco::SuperClusterCollection &scee, const Mask &trackMask, const Mask &gsftrackMask, const Mask &ecalMask, const Mask &hcalMask, const Mask &hoMask, const Mask &hfemMask, const Mask &hfhadMask, const Mask &psMask, const Mask &phMask, const Mask &scMask) const
virtual void setConversionRef(const ConversionRef &convRef, TrackType trType)
double testLinkByVertex(const reco::PFBlockElement *elt1, const reco::PFBlockElement *elt2) const
static bool isLooseMuon(const reco::PFBlockElement &elt)
std::auto_ptr< reco::PFBlockCollection > transferBlocks()
void insertTargetElt(reco::PFBlockElement *track)
key_type key() const
Accessor for product key.
bool linkPrefilter(const reco::PFBlockElement *last, const reco::PFBlockElement *next) const
Avoid to check links when not useful.
std::vector< Photon > PhotonCollection
collectin of Photon objects
void findBlocks()
build blocks
std::vector< int > pfcSCVec_
SC corresponding to the PF cluster.
Type
possible types. WARNING: have a look at PFBlockElement
void insertTargetElt(reco::PFBlockElement *psCluster)
virtual void setMuonRef(const MuonRef &muref)
static int checkOverlap(const reco::PFCluster &pfc, const std::vector< const reco::SuperCluster * > &sc, float minfrac=0.01, bool debug=false)
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
void setUseOptimization(bool useKDTreeTrackEcalLinker)
bool debug_
if true, debug printouts activated
void setParameters(std::vector< double > &DPtovPtCut, std::vector< unsigned > &NHitCut, bool useConvBremPFRecTracks, bool useIterTracking, int nuclearInteractionsPurity, bool useEGPhotons, std::vector< double > &photonSelectionCuts, bool useSuperClusters, bool superClusterMatchByRef)
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
tuple size
Write out results.
bool useEGPhotons_
Flag to turn off the import of EG Photons.
bool useKDTreeTrackEcalLinker_
void setEcalIso(float val)
set the ecal Iso
void setFromPFSuperCluster(bool val)
std::vector< unsigned > NHitCut_
Number of layers crossed cut for creating atrack element.