CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
PFBlockAlgo Class Reference

Particle Flow Algorithm. More...

#include <PFBlockAlgo.h>

Public Types

typedef
reco::PFBlockCollection::const_iterator 
IBC
 
typedef std::list
< reco::PFBlockElement * >
::iterator 
IE
 define these in *Fwd files in DataFormats/ParticleFlowReco? More...
 
typedef std::list
< reco::PFBlockElement * >
::const_iterator 
IEC
 
typedef std::vector< bool > Mask
 

Public Member Functions

const std::auto_ptr
< reco::PFBlockCollection > & 
blocks () const
 
void findBlocks ()
 build blocks More...
 
 PFBlockAlgo ()
 
void setDebug (bool debug)
 sets debug printout flag More...
 
void setHOTag (bool ho)
 
template<template< typename > class T>
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 More...
 
template<template< typename > class T>
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... More...
 
template<template< typename > class T>
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? More...
 
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)
 
void setUseOptimization (bool useKDTreeTrackEcalLinker)
 
std::auto_ptr
< reco::PFBlockCollection
transferBlocks ()
 
 ~PFBlockAlgo ()
 

Private Member Functions

IE associate (IE next, IE last, std::vector< PFBlockLink > &links)
 
void buildGraph ()
 
void checkDisplacedVertexLinks (reco::PFBlock &block) const
 remove extra links between primary track and clusters More...
 
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
 
template<template< typename > class T>
void fillFromPhoton (const T< reco::PhotonCollection > &, unsigned isc, reco::PFBlockElementSuperCluster *pfbe)
 
bool goodPtResolution (const reco::TrackRef &trackref)
 open a resolution map More...
 
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 More...
 
bool linkPrefilter (const reco::PFBlockElement *last, const reco::PFBlockElement *next) const
 Avoid to check links when not useful. More...
 
int muAssocToTrack (const reco::TrackRef &trackref, const edm::Handle< reco::MuonCollection > &muonh) const
 
int muAssocToTrack (const reco::TrackRef &trackref, const edm::OrphanHandle< reco::MuonCollection > &muonh) const
 
void packLinks (reco::PFBlock &block, const std::vector< PFBlockLink > &links) const
 
double testECALAndHCAL (const reco::PFCluster &ecal, const reco::PFCluster &hcal) const
 
double testHCALAndHO (const reco::PFCluster &hcal, const reco::PFCluster &ho) const
 
double testLinkBySuperCluster (const reco::PFClusterRef &elt1, const reco::PFClusterRef &elt2) const
 test association by Supercluster between two ECAL More...
 
double testLinkByVertex (const reco::PFBlockElement *elt1, const reco::PFBlockElement *elt2) const
 
double testPS1AndPS2 (const reco::PFCluster &ps1, const reco::PFCluster &ps2) const
 
double testSuperClusterPFCluster (const reco::SuperClusterRef &sct1, const reco::PFClusterRef &elt2) const
 test association between SuperClusters and ECAL More...
 
double testTrackAndPS (const reco::PFRecTrack &track, const reco::PFCluster &ps) const
 

Private Attributes

std::auto_ptr
< reco::PFBlockCollection
blocks_
 
bool bNoSuperclus_
 
bool debug_
 if true, debug printouts activated More...
 
std::vector< double > DPtovPtCut_
 DPt/Pt cut for creating atrack element. More...
 
std::list< reco::PFBlockElement * > elements_
 actually, particles will be created by a separate producer More...
 
std::vector< unsigned > NHitCut_
 Number of layers crossed cut for creating atrack element. More...
 
int nuclearInteractionsPurity_
 
const edm::ValueMap
< reco::CaloClusterPtr > * 
pfclusterassoc_
 
std::vector< int > pfcSCVec_
 SC corresponding to the PF cluster. More...
 
const PhotonSelectorAlgophotonSelector_
 PhotonSelector. More...
 
KDTreeLinkerPSEcal PSELinker_
 
std::vector< std::vector
< reco::PFClusterRef > > 
scpfcRefs_
 PF clusters corresponding to a given SC. More...
 
bool superClusterMatchByRef_
 
std::vector
< reco::SuperClusterRef
superClusters_
 list of superclusters More...
 
KDTreeLinkerTrackEcal TELinker_
 
KDTreeLinkerTrackHcal THLinker_
 
bool useConvBremPFRecTracks_
 switch on/off Conversions Brem Recovery with KF Tracks More...
 
bool useEGPhotons_
 Flag to turn off the import of EG Photons. More...
 
bool useHO_
 
bool useIterTracking_
 Flag to turn off quality cuts which require iterative tracking (for heavy-ions) More...
 
bool useKDTreeTrackEcalLinker_
 
bool useSuperClusters_
 Flag to turn off the import of SuperCluster collections. More...
 

Static Private Attributes

static const Mask dummyMask_
 

Friends

std::ostream & operator<< (std::ostream &, const PFBlockAlgo &)
 

Detailed Description

Particle Flow Algorithm.

Author
Colin Bernet
Date
January 2006

Definition at line 71 of file PFBlockAlgo.h.

Member Typedef Documentation

typedef reco::PFBlockCollection::const_iterator PFBlockAlgo::IBC

Definition at line 203 of file PFBlockAlgo.h.

define these in *Fwd files in DataFormats/ParticleFlowReco?

Definition at line 201 of file PFBlockAlgo.h.

typedef std::list< reco::PFBlockElement* >::const_iterator PFBlockAlgo::IEC

Definition at line 202 of file PFBlockAlgo.h.

typedef std::vector<bool> PFBlockAlgo::Mask

Definition at line 95 of file PFBlockAlgo.h.

Constructor & Destructor Documentation

PFBlockAlgo::PFBlockAlgo ( )

Definition at line 21 of file PFBlockAlgo.cc.

21  :
23  DPtovPtCut_(std::vector<double>(4,static_cast<double>(999.))),
24  NHitCut_(std::vector<unsigned int>(4,static_cast<unsigned>(0))),
25  useIterTracking_(true),
26  photonSelector_(0),
27  debug_(false) {}
bool useIterTracking_
Flag to turn off quality cuts which require iterative tracking (for heavy-ions)
Definition: PFBlockAlgo.h:335
std::auto_ptr< reco::PFBlockCollection > blocks_
Definition: PFBlockAlgo.h:311
std::vector< double > DPtovPtCut_
DPt/Pt cut for creating atrack element.
Definition: PFBlockAlgo.h:329
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
Definition: PFBlockFwd.h:11
const PhotonSelectorAlgo * photonSelector_
PhotonSelector.
Definition: PFBlockAlgo.h:363
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
std::vector< unsigned > NHitCut_
Number of layers crossed cut for creating atrack element.
Definition: PFBlockAlgo.h:332
PFBlockAlgo::~PFBlockAlgo ( )

Definition at line 73 of file PFBlockAlgo.cc.

References gather_cfg::cout, debug_, elements_, and photonSelector_.

73  {
74 
75 #ifdef PFLOW_DEBUG
76  if(debug_)
77  cout<<"~PFBlockAlgo - number of remaining elements: "
78  <<elements_.size()<<endl;
79 #endif
80 
82 
83 }
std::list< reco::PFBlockElement * > elements_
actually, particles will be created by a separate producer
Definition: PFBlockAlgo.h:317
const PhotonSelectorAlgo * photonSelector_
PhotonSelector.
Definition: PFBlockAlgo.h:363
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377

Member Function Documentation

PFBlockAlgo::IE PFBlockAlgo::associate ( IE  next,
IE  last,
std::vector< PFBlockLink > &  links 
)
private

recursive procedure which adds elements from elements_ to the current block, ie blocks_->back(). the resulting links between elements are stored in links, not in the block. afterwards, packLinks( reco::PFBlock& block, const vector<PFBlockLink>& links) has to be called in order to pack the link information in the block.

Definition at line 128 of file PFBlockAlgo.cc.

References blocks_, gather_cfg::cout, debug_, elements_, link(), linkPrefilter(), GetRecoTauVFromDQM_MC_cff::next, and PFBlockLink::NONE.

Referenced by findBlocks().

130  {
131 
132 
133 #ifdef PFLOW_DEBUG
134  if(debug_ ) cout<<"PFBlockAlgo::associate start ----"<<endl;
135 #endif
136 
137  if( last!= elements_.end() ) {
139  double dist = -1;
140  PFBlock::LinkTest linktest = PFBlock::LINKTEST_RECHIT;
141  link( *last, *next, linktype, linktest, dist );
142 
143 
144  if(dist<-0.5) {
145 #ifdef PFLOW_DEBUG
146  if(debug_ ) cout<<"link failed"<<endl;
147 #endif
148  return ++next; // association failed
149  }
150  else {
151  // add next element to the current pflowblock
152  blocks_->back().addElement( *next );
153 
154  // (*next)->setIndex( blocks_->back()->indexToLastElement() );
155 
156  // this is not necessary?
157  // next->setPFBlock(this);
158 
159  // create a link between next and last
160  links.push_back( PFBlockLink(linktype,
161  linktest,
162  dist,
163  (*last)->index(),
164  (*next)->index() ) );
165  // not necessary ?
166  // next->connect( links_.size()-1 );
167  // last->connect( links_.size()-1 );
168  }
169  }
170  else {
171  // add next element to this eflowblock
172 #ifdef PFLOW_DEBUG
173  if(debug_ ) cout<<"adding to block element "<<(**next)<<endl;
174 #endif
175  blocks_->back().addElement( *next );
176  // (*next)->setIndex( blocks_->back()->indexToLastElement() );
177  // next->setPFBlock(this);
178  }
179 
180  // recursive call: associate next and other unused elements
181 
182  // IE afterNext = next;
183  // ++afterNext;
184  // cout<<"last "<<**last<<" next "<<**next<<endl;
185 
186  for(IE ie = elements_.begin();
187  ie != elements_.end();) {
188 
189  if( ie == last || ie == next ) {
190  ++ie;
191  continue;
192  }
193  bool bTestLink = linkPrefilter(*next, *ie);
194 
195  if(!bTestLink) {
196  ++ie;
197  continue;
198  }
199 
200  // *ie already included to a block
201  if( (*ie)->locked() ) {
202 #ifdef PFLOW_DEBUG
203  if(debug_ ) cout<<"element "<<(**ie)<<"already used"<<endl;
204 #endif
205  ++ie;
206  continue;
207  }
208 
209 
210 #ifdef PFLOW_DEBUG
211  if(debug_ ) cout<<"calling associate "<<(**next)<<" & "<<(**ie)<<endl;
212 #endif
213  ie = associate(next, ie, links);
214  }
215 
216 #ifdef PFLOW_DEBUG
217  if(debug_ ) {
218  cout<<"**** deleting element "<<endl;
219  cout<<**next<<endl;
220  }
221 #endif
222  delete *next;
223 
224 #ifdef PFLOW_DEBUG
225  if(debug_ ) {
226  cout<<"**** removing element "<<endl;
227  }
228 #endif
229 
230  IE iteratorToNextFreeElement = elements_.erase( next );
231 
232 #ifdef PFLOW_DEBUG
233  if(debug_ ) cout<<"PFBlockAlgo::associate stop ----"<<endl;
234 #endif
235 
236  return iteratorToNextFreeElement;
237 }
std::auto_ptr< reco::PFBlockCollection > blocks_
Definition: PFBlockAlgo.h:311
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
Definition: PFBlockAlgo.cc:323
std::list< reco::PFBlockElement * >::iterator IE
define these in *Fwd files in DataFormats/ParticleFlowReco?
Definition: PFBlockAlgo.h:201
std::list< reco::PFBlockElement * > elements_
actually, particles will be created by a separate producer
Definition: PFBlockAlgo.h:317
IE associate(IE next, IE last, std::vector< PFBlockLink > &links)
Definition: PFBlockAlgo.cc:128
bool linkPrefilter(const reco::PFBlockElement *last, const reco::PFBlockElement *next) const
Avoid to check links when not useful.
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
const std::auto_ptr< reco::PFBlockCollection >& PFBlockAlgo::blocks ( ) const
inline
Returns
collection of blocks

Definition at line 194 of file PFBlockAlgo.h.

References blocks_.

Referenced by operator<<().

195  {return blocks_;}
std::auto_ptr< reco::PFBlockCollection > blocks_
Definition: PFBlockAlgo.h:311
void PFBlockAlgo::buildGraph ( )
private

COLIN: not used. Could be removed. Could also be implemented, to produce a graph of a block, Showing the connections between the elements

Definition at line 316 of file PFBlockAlgo.cc.

316  {
317  // loop on all blocks and create a big graph
318 }
void PFBlockAlgo::checkDisplacedVertexLinks ( reco::PFBlock block) const
private

remove extra links between primary track and clusters

void PFBlockAlgo::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
private

checks size of the masks with respect to the vectors they refer to. throws std::length_error if one of the masks has the wrong size

Definition at line 1179 of file PFBlockAlgo.cc.

Referenced by setInput().

1199  {
1200 
1201  if( !trackMask.empty() &&
1202  trackMask.size() != tracks.size() ) {
1203  string err = "PFBlockAlgo::setInput: ";
1204  err += "The size of the track mask is different ";
1205  err += "from the size of the track vector.";
1206  throw std::length_error( err.c_str() );
1207  }
1208 
1209  if( !gsftrackMask.empty() &&
1210  gsftrackMask.size() != gsftracks.size() ) {
1211  string err = "PFBlockAlgo::setInput: ";
1212  err += "The size of the gsf track mask is different ";
1213  err += "from the size of the gsftrack vector.";
1214  throw std::length_error( err.c_str() );
1215  }
1216 
1217  if( !ecalMask.empty() &&
1218  ecalMask.size() != ecals.size() ) {
1219  string err = "PFBlockAlgo::setInput: ";
1220  err += "The size of the ecal mask is different ";
1221  err += "from the size of the ecal clusters vector.";
1222  throw std::length_error( err.c_str() );
1223  }
1224 
1225  if( !hcalMask.empty() &&
1226  hcalMask.size() != hcals.size() ) {
1227  string err = "PFBlockAlgo::setInput: ";
1228  err += "The size of the hcal mask is different ";
1229  err += "from the size of the hcal clusters vector.";
1230  throw std::length_error( err.c_str() );
1231  }
1232 
1233  if( !hoMask.empty() &&
1234  hoMask.size() != hos.size() ) {
1235  string err = "PFBlockAlgo::setInput: ";
1236  err += "The size of the ho mask is different ";
1237  err += "from the size of the ho clusters vector.";
1238  throw std::length_error( err.c_str() );
1239  }
1240 
1241 
1242  if( !hfemMask.empty() &&
1243  hfemMask.size() != hfems.size() ) {
1244  string err = "PFBlockAlgo::setInput: ";
1245  err += "The size of the hfem mask is different ";
1246  err += "from the size of the hfem clusters vector.";
1247  throw std::length_error( err.c_str() );
1248  }
1249 
1250  if( !hfhadMask.empty() &&
1251  hfhadMask.size() != hfhads.size() ) {
1252  string err = "PFBlockAlgo::setInput: ";
1253  err += "The size of the hfhad mask is different ";
1254  err += "from the size of the hfhad clusters vector.";
1255  throw std::length_error( err.c_str() );
1256  }
1257 
1258  if( !psMask.empty() &&
1259  psMask.size() != pss.size() ) {
1260  string err = "PFBlockAlgo::setInput: ";
1261  err += "The size of the ps mask is different ";
1262  err += "from the size of the ps clusters vector.";
1263  throw std::length_error( err.c_str() );
1264  }
1265 
1266  if( !phMask.empty() &&
1267  phMask.size() != egphh.size() ) {
1268  string err = "PFBlockAlgo::setInput: ";
1269  err += "The size of the photon mask is different ";
1270  err += "from the size of the photon vector.";
1271  throw std::length_error( err.c_str() );
1272  }
1273 
1274  if( !scMask.empty() &&
1275  scMask.size() != (sceb.size() + scee.size()) ) {
1276  string err = "PFBlockAlgo::setInput: ";
1277  err += "The size of the SC mask is different ";
1278  err += "from the size of the SC vectors.";
1279  throw std::length_error( err.c_str() );
1280  }
1281 
1282 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
tuple tracks
Definition: testEve_cfg.py:39
template<template< typename > class T>
void PFBlockAlgo::fillFromPhoton ( const T< reco::PhotonCollection > &  egh,
unsigned  isc,
reco::PFBlockElementSuperCluster pfbe 
)
private

Definition at line 1228 of file PFBlockAlgo.h.

References reco::PFBlockElementSuperCluster::setEcalIso(), reco::PFBlockElementSuperCluster::setFromPhoton(), reco::PFBlockElementSuperCluster::setHcalIso(), reco::PFBlockElementSuperCluster::setHoE(), reco::PFBlockElementSuperCluster::setPhotonRef(), and reco::PFBlockElementSuperCluster::setTrackIso().

Referenced by setInput().

1228  {
1229  reco::PhotonRef photonRef(egh,isc);
1230  pfbe->setTrackIso(photonRef->trkSumPtHollowConeDR04());
1231  pfbe->setEcalIso(photonRef->ecalRecHitSumEtConeDR04());
1232  pfbe->setHcalIso(photonRef->hcalTowerSumEtConeDR04());
1233  pfbe->setHoE(photonRef->hadronicOverEm());
1234  pfbe->setPhotonRef(photonRef);
1235  pfbe->setFromPhoton(true);
1236  }
void setFromPhoton(bool val)
set provenance
void setHcalIso(float val)
set the had Iso
void setTrackIso(float val)
set the track Iso
void setPhotonRef(const PhotonRef &ref)
set photonRef
void setEcalIso(float val)
set the ecal Iso
void PFBlockAlgo::findBlocks ( )

build blocks

Definition at line 86 of file PFBlockAlgo.cc.

References associate(), blocks_, gather_cfg::cout, debug_, elements_, electronStore::links, packLinks(), KDTreeLinkerBase::process(), PSELinker_, TELinker_, THLinker_, and useKDTreeTrackEcalLinker_.

Referenced by PFRootEventManager::particleFlow().

86  {
87 
88  // Glowinski & Gouzevitch
93  }
94  // !Glowinski & Gouzevitch
95 
96  // the blocks have not been passed to the event, and need to be cleared
97  if(blocks_.get() )blocks_->clear();
98  else
99  blocks_.reset( new reco::PFBlockCollection );
100 
101  blocks_->reserve(elements_.size());
102  for(IE ie = elements_.begin();
103  ie != elements_.end();) {
104 
105 #ifdef PFLOW_DEBUG
106  if(debug_) {
107  cout<<" PFBlockAlgo::findBlocks() ----------------------"<<endl;
108  cout<<" element "<<**ie<<endl;
109  cout<<" creating new block"<<endl;
110  }
111 #endif
112 
113  blocks_->push_back( PFBlock() );
114 
115  vector< PFBlockLink > links;
116 
117  // list< IE > used;
118  ie = associate( elements_.end() , ie, links );
119 
120  packLinks( blocks_->back(), links );
121  }
122 }
KDTreeLinkerTrackEcal TELinker_
Definition: PFBlockAlgo.h:321
KDTreeLinkerPSEcal PSELinker_
Definition: PFBlockAlgo.h:323
std::auto_ptr< reco::PFBlockCollection > blocks_
Definition: PFBlockAlgo.h:311
KDTreeLinkerTrackHcal THLinker_
Definition: PFBlockAlgo.h:322
std::list< reco::PFBlockElement * >::iterator IE
define these in *Fwd files in DataFormats/ParticleFlowReco?
Definition: PFBlockAlgo.h:201
std::list< reco::PFBlockElement * > elements_
actually, particles will be created by a separate producer
Definition: PFBlockAlgo.h:317
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
Definition: PFBlockFwd.h:11
void packLinks(reco::PFBlock &block, const std::vector< PFBlockLink > &links) const
Definition: PFBlockAlgo.cc:242
IE associate(IE next, IE last, std::vector< PFBlockLink > &links)
Definition: PFBlockAlgo.cc:128
virtual void process()
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
bool useKDTreeTrackEcalLinker_
Definition: PFBlockAlgo.h:320
Block of elements.
Definition: PFBlock.h:30
bool PFBlockAlgo::goodPtResolution ( const reco::TrackRef trackref)
private

open a resolution map

check the Pt resolution

Definition at line 1321 of file PFBlockAlgo.cc.

References gather_cfg::cout, debug_, DPtovPtCut_, NHitCut_, P, reco::tau::disc::Pt(), mathSSE::sqrt(), and useIterTracking_.

Referenced by setInput().

1321  {
1322 
1323  double P = trackref->p();
1324  double Pt = trackref->pt();
1325  double DPt = trackref->ptError();
1326  unsigned int NHit = trackref->hitPattern().trackerLayersWithMeasurement();
1327  unsigned int NLostHit = trackref->hitPattern().trackerLayersWithoutMeasurement();
1328  unsigned int LostHits = trackref->numberOfLostHits();
1329  double sigmaHad = sqrt(1.20*1.20/P+0.06*0.06) / (1.+LostHits);
1330 
1331  // iteration 1,2,3,4,5 correspond to algo = 1/4,5,6,7,8,9
1332  unsigned int Algo = 0;
1333  switch (trackref->algo()) {
1334  case TrackBase::ctf:
1335  case TrackBase::iter0:
1336  case TrackBase::iter1:
1337  case TrackBase::iter2:
1338  Algo = 0;
1339  break;
1340  case TrackBase::iter3:
1341  Algo = 1;
1342  break;
1343  case TrackBase::iter4:
1344  Algo = 2;
1345  break;
1346  case TrackBase::iter5:
1347  Algo = 3;
1348  break;
1349  case TrackBase::iter6:
1350  Algo = 4;
1351  break;
1352  default:
1353  Algo = useIterTracking_ ? 5 : 0;
1354  break;
1355  }
1356 
1357  // Protection against 0 momentum tracks
1358  if ( P < 0.05 ) return false;
1359 
1360  // Temporary : Reject all tracking iteration beyond 5th step.
1361  if ( Algo > 4 ) return false;
1362 
1363  if (debug_) cout << " PFBlockAlgo: PFrecTrack->Track Pt= "
1364  << Pt << " DPt = " << DPt << endl;
1365  if ( ( DPtovPtCut_[Algo] > 0. &&
1366  DPt/Pt > DPtovPtCut_[Algo]*sigmaHad ) ||
1367  NHit < NHitCut_[Algo] ) {
1368  // (Algo >= 3 && LostHits != 0) ) {
1369  if (debug_) cout << " PFBlockAlgo: skip badly measured track"
1370  << ", P = " << P
1371  << ", Pt = " << Pt
1372  << " DPt = " << DPt
1373  << ", N(hits) = " << NHit << " (Lost : " << LostHits << "/" << NLostHit << ")"
1374  << ", Algo = " << Algo
1375  << endl;
1376  if (debug_) cout << " cut is DPt/Pt < " << DPtovPtCut_[Algo] * sigmaHad << endl;
1377  if (debug_) cout << " cut is NHit >= " << NHitCut_[Algo] << endl;
1378  /*
1379  std::cout << "Track REJECTED : ";
1380  std::cout << ", P = " << P
1381  << ", Pt = " << Pt
1382  << " DPt = " << DPt
1383  << ", N(hits) = " << NHit << " (Lost : " << LostHits << "/" << NLostHit << ")"
1384  << ", Algo = " << Algo
1385  << std::endl;
1386  */
1387  return false;
1388  }
1389 
1390  /*
1391  std::cout << "Track Accepted : ";
1392  std::cout << ", P = " << P
1393  << ", Pt = " << Pt
1394  << " DPt = " << DPt
1395  << ", N(hits) = " << NHit << " (Lost : " << LostHits << "/" << NLostHit << ")"
1396  << ", Algo = " << Algo
1397  << std::endl;
1398  */
1399  return true;
1400 }
bool useIterTracking_
Flag to turn off quality cuts which require iterative tracking (for heavy-ions)
Definition: PFBlockAlgo.h:335
#define P
std::vector< double > DPtovPtCut_
DPt/Pt cut for creating atrack element.
Definition: PFBlockAlgo.h:329
T sqrt(T t)
Definition: SSEVec.h:48
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
Definition: fakeMenu.h:4
std::vector< unsigned > NHitCut_
Number of layers crossed cut for creating atrack element.
Definition: PFBlockAlgo.h:332
void PFBlockAlgo::link ( const reco::PFBlockElement el1,
const reco::PFBlockElement el2,
PFBlockLink::Type linktype,
reco::PFBlock::LinkTest linktest,
double &  dist 
) const
private

check whether 2 elements are linked. Returns distance and linktype

Definition at line 323 of file PFBlockAlgo.cc.

References reco::PFBlockElement::clusterRef(), LinkByRecHit::computeDist(), gather_cfg::cout, debug_, PFBlockLink::ECALandBREM, PFBlockLink::ECALandECAL, PFBlockLink::ECALandGSF, PFBlockLink::ECALandHCAL, reco::PFTrajectoryPoint::ECALShowerMax, reco::PFTrack::extrapolatedPoint(), reco::PFBlockElement::getMultilinks(), PFBlockLink::GSFandBREM, PFBlockLink::GSFandGSF, reco::PFBlockElementBrem::GsftrackRefPF(), reco::PFBlockElementGsfTrack::GsftrackRefPF(), PFBlockLink::HCALandBREM, PFBlockLink::HCALandGSF, PFBlockLink::HCALandHO, reco::PFTrajectoryPoint::HCALEntrance, reco::PFTrajectoryPoint::HCALExit, PFBlockLink::HFEMandHFHAD, reco::PFTrajectoryPoint::HOLayer, reco::PFBlockElement::isLinkedToDisplacedVertex(), reco::PFBlockElement::isMultilinksValide(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), reco::PFTrajectoryPoint::isValid(), M_PI, reco::PFTrajectoryPoint::position(), reco::PFTrajectoryPoint::positionREP(), PFBlockLink::PS1andECAL, PFBlockLink::PS2andECAL, PFBlockLink::SCandECAL, reco::PFBlockElement::T_FROM_GAMMACONV, testECALAndHCAL(), LinkByRecHit::testECALAndPSByRecHit(), testHCALAndHO(), LinkByRecHit::testHFEMAndHFHADByRecHit(), testLinkBySuperCluster(), testLinkByVertex(), testSuperClusterPFCluster(), LinkByRecHit::testTrackAndClusterByRecHit(), PFBlockLink::TRACKandECAL, PFBlockLink::TRACKandGSF, PFBlockLink::TRACKandHCAL, PFBlockLink::TRACKandHO, PFBlockLink::TRACKandTRACK, reco::PFBlockElement::trackRef(), reco::PFBlockElement::trackRefPF(), reco::PFBlockElementGsfTrack::trackType(), reco::PFBlockElement::trackType(), reco::PFBlockElement::type(), useConvBremPFRecTracks_, and useKDTreeTrackEcalLinker_.

Referenced by associate(), and packLinks().

327  {
328 
329  // ACHTUNG!!!! If you introduce new links check that they are not desabled in linkPrefilter!!!!
330 
331 
332  dist=-1.;
333  linktest = PFBlock::LINKTEST_RECHIT; //rechit by default
334 
335  PFBlockElement::Type type1 = el1->type();
336  PFBlockElement::Type type2 = el2->type();
337 
338  linktype = static_cast<PFBlockLink::Type>
339  ((1<< (type1-1) ) | (1<< (type2-1) ));
340 
341  if(debug_ ) std::cout << " PFBlockAlgo links type1 " << type1 << " type2 " << type2 << std::endl;
342 
343  const PFBlockElement* lowEl = el1;
344  const PFBlockElement* highEl = el2;
345 
346  if(type1>type2) {
347  lowEl = el2;
348  highEl = el1;
349  }
350 
351  switch(linktype) {
352  // Track and preshower cluster links are not used for now - disable
355  {
356  // if(debug_ ) cout<< "PSandECAL" <<endl;
357  PFClusterRef psref = lowEl->clusterRef();
358  PFClusterRef ecalref = highEl->clusterRef();
359  assert( !psref.isNull() );
360  assert( !ecalref.isNull() );
361 
362  // Check if the linking has been done using the KDTree algo
363  // Glowinski & Gouzevitch
364  if ( useKDTreeTrackEcalLinker_ && lowEl->isMultilinksValide() ) { // KDTree algo
365  const reco::PFMultilinksType& multilinks = lowEl->getMultilinks();
366 
367  double ecalPhi = ecalref->positionREP().Phi();
368  double ecalEta = ecalref->positionREP().Eta();
369 
370  // Check if the link PS/Ecal exist
371  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
372  for (; mlit != multilinks.end(); ++mlit)
373  if ((mlit->first == ecalPhi) && (mlit->second == ecalEta))
374  break;
375 
376  // If the link exist, we fill dist and linktest. We use old algorithme method.
377  if (mlit != multilinks.end()){
378  double xPS = psref->position().X();
379  double yPS = psref->position().Y();
380  double xECAL = ecalref->position().X();
381  double yECAL = ecalref->position().Y();
382 
383  dist = LinkByRecHit::computeDist(xECAL/1000.,yECAL/1000.,xPS/1000. ,yPS/1000, false);
384  }
385 
386  } else { //Old algorithm
387  dist = LinkByRecHit::testECALAndPSByRecHit( *ecalref, *psref ,debug_);
388  }
389 
390  // linktest = PFBlock::LINKTEST_RECHIT;
391 
392  break;
393  }
395  {
396  if(debug_ ) cout<<"TRACKandECAL"<<endl;
397 
398  PFRecTrackRef trackref = lowEl->trackRefPF();
399  PFClusterRef clusterref = highEl->clusterRef();
400  assert( !trackref.isNull() );
401  assert( !clusterref.isNull() );
402 
403  if(debug_ ) std::cout << " Track pt " << trackref->trackRef()->pt() << std::endl;
404 
405  // Check if the linking has been done using the KDTree algo
406  // Glowinski & Gouzevitch
407  if ( useKDTreeTrackEcalLinker_ && lowEl->isMultilinksValide() ) { //KDTree Algo
408 
409  const reco::PFMultilinksType& multilinks = lowEl->getMultilinks();
410  double ecalphi = clusterref->positionREP().Phi();
411  double ecaleta = clusterref->positionREP().Eta();
412 
413  // Check if the link Track/Ecal exist
414  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
415  for (; mlit != multilinks.end(); ++mlit)
416  if ((mlit->first == ecalphi) && (mlit->second == ecaleta))
417  break;
418 
419 
420  // If the link exist, we fill dist and linktest. We use old algorithme method.
421  if (mlit != multilinks.end()){
422 
423 
424  //Should be something like this :
425  // const reco::PFRecTrack& track = *trackref;
426  //instead of this :
427  /*
428  reco::PFRecTrack track (*trackref);
429  const reco::PFTrajectoryPoint& atECAL_tmp =
430  (*trackref).extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax );
431  if(std::abs(atECAL_tmp.positionREP().Eta())<1E-9 &&
432  std::abs(atECAL_tmp.positionREP().Phi())<1E-9 &&
433  atECAL_tmp.positionREP().R()<1E-9)
434  track.calculatePositionREP();
435  */
436 
437  const reco::PFTrajectoryPoint& atECAL =
438  trackref->extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax );
439 
440  double tracketa = atECAL.positionREP().Eta();
441  double trackphi = atECAL.positionREP().Phi();
442 
443  dist = LinkByRecHit::computeDist(ecaleta, ecalphi, tracketa, trackphi);
444  }
445 
446  } else {// Old algorithm
447  if ( trackref->extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() )
448  dist = LinkByRecHit::testTrackAndClusterByRecHit( *trackref, *clusterref, false, debug_ );
449  else
450  dist = -1.;
451  }
452 
453  if ( debug_ ) {
454  if( dist > 0. ) {
455  std::cout << " Here a link has been established"
456  << " between a track an Ecal with dist "
457  << dist << std::endl;
458  } else
459  std::cout << " No link found " << std::endl;
460  }
461 
462  // linktest = PFBlock::LINKTEST_RECHIT;
463  break;
464  }
466  {
467  // if(debug_ ) cout<<"TRACKandHCAL"<<endl;
468 
469  PFRecTrackRef trackref = lowEl->trackRefPF();
470  PFClusterRef clusterref = highEl->clusterRef();
471  assert( !trackref.isNull() );
472  assert( !clusterref.isNull() );
473 
474  // Check if the linking has been done using the KDTree algo
475  // Glowinski & Gouzevitch
476  if ( useKDTreeTrackEcalLinker_ && highEl->isMultilinksValide() ) { //KDTree Algo
477 
478  const reco::PFMultilinksType& multilinks = highEl->getMultilinks();
479 
480  /*
481  reco::PFRecTrack track (*trackref);
482  const reco::PFTrajectoryPoint& atHCALEntrance_tmp =
483  (*trackref).extrapolatedPoint( reco::PFTrajectoryPoint::HCALEntrance);
484  if (std::abs(atHCALEntrance_tmp.positionREP().Eta())<1E-9 &&
485  std::abs(atHCALEntrance_tmp.positionREP().Phi())<1E-9 &&
486  atHCALEntrance_tmp.positionREP().R()<1E-9)
487  track.calculatePositionREP();
488  */
489 
490  const reco::PFTrajectoryPoint& atHCAL =
491  trackref->extrapolatedPoint(reco::PFTrajectoryPoint::HCALEntrance);
492 
493 
494  double tracketa = atHCAL.positionREP().Eta();
495  double trackphi = atHCAL.positionREP().Phi();
496 
497  // Check if the link Track/Ecal exist
498  reco::PFMultilinksType::const_iterator mlit = multilinks.begin();
499  for (; mlit != multilinks.end(); ++mlit)
500  if ((mlit->first == trackphi) && (mlit->second == tracketa))
501  break;
502 
503  // If the link exist, we fill dist and linktest. We use old algorithme method.
504  if (mlit != multilinks.end()){
505 
506  const reco::PFTrajectoryPoint& atHCALExit =
507  trackref->extrapolatedPoint(reco::PFTrajectoryPoint::HCALExit);
508  double dHEta = 0.0;
509  double dHPhi = 0.0;
510  if (atHCALExit.position().R()>atHCAL.position().R()) {
511  dHEta = atHCALExit.positionREP().Eta()-atHCAL.positionREP().Eta();
512  dHPhi = atHCALExit.positionREP().Phi()-atHCAL.positionREP().Phi();
513  if ( dHPhi > M_PI ) dHPhi = dHPhi - 2.*M_PI;
514  else if ( dHPhi < -M_PI ) dHPhi = dHPhi + 2.*M_PI;
515  } else {
516  std::cout << "Qu'est ce que c'est que ce gag ? "
517  << atHCALExit.position().R() << " is larger than "
518  << atHCAL.position().R() << " !" << std::endl;
519  }
520 
521  tracketa += 0.1 * dHEta;
522  trackphi += 0.1 * dHPhi;
523 
524  double clusterphi = clusterref->positionREP().Phi();
525  double clustereta = clusterref->positionREP().Eta();
526 
527  dist = LinkByRecHit::computeDist(clustereta, clusterphi, tracketa, trackphi);
528  }
529 
530  } else {// Old algorithm
531  if ( trackref->extrapolatedPoint( reco::PFTrajectoryPoint::HCALEntrance ).isValid() )
532  dist = LinkByRecHit::testTrackAndClusterByRecHit( *trackref, *clusterref, false, debug_ );
533  else
534  dist = -1.;
535  }
536 
537  // linktest = PFBlock::LINKTEST_RECHIT;
538  break;
539  }
541  {
542  if(debug_ ) cout<<"TRACKandHO"<<endl;
543 
544  PFRecTrackRef trackref = lowEl->trackRefPF();
545  PFClusterRef clusterref = highEl->clusterRef();
546 
547  assert( !trackref.isNull() );
548  assert( !clusterref.isNull() );
549 
550 
551  // Old algorithm
552  // cout<<"TRACKandHO1"<<trackref->pt()<<" "<<trackref->eta()<<" "<<trackref->phi()<<endl;
553  //Same value is used in PFTrackTransformer::addPoints() for HOLayer, but allow for some rounding precision
554  if ( lowEl->trackRef()->pt() > 3.00001 && trackref->extrapolatedPoint( reco::PFTrajectoryPoint::HOLayer ).isValid() ) {
555  // cout<<"TRACKandHO2"<<endl;
556  dist = LinkByRecHit::testTrackAndClusterByRecHit( *trackref, *clusterref, false, debug_ );
557 
558  // cout <<"dist TRACKandHO "<<dist<<endl;
559  } else {
560  dist = -1.;
561  }
562  // linktest = PFBlock::LINKTEST_RECHIT;
563  break;
564  }
566  {
567  // cout<<"ECALandHCAL"<<endl;
568  PFClusterRef ecalref = lowEl->clusterRef();
569  PFClusterRef hcalref = highEl->clusterRef();
570  assert( !ecalref.isNull() );
571  assert( !hcalref.isNull() );
572  // PJ - 14-May-09 : A link by rechit is needed here !
573  dist = testECALAndHCAL( *ecalref, *hcalref );
574  // dist = -1.;
575  // linktest = PFBlock::LINKTEST_RECHIT;
576  break;
577  }
579  {
580  // cout<<"HCALandH0"<<endl;
581  PFClusterRef hcalref = lowEl->clusterRef();
582  PFClusterRef horef = highEl->clusterRef();
583  assert( !hcalref.isNull() );
584  assert( !horef.isNull() );
585  // PJ - 14-May-09 : A link by rechit is needed here !
586  dist = testHCALAndHO( *hcalref, *horef );
587  // dist = -1.;
588  // cout <<"Dist "<<dist<<endl;
589  // linktest = PFBlock::LINKTEST_RECHIT;
590  break;
591  }
593  {
594  // cout<<"HFEMandHFHAD"<<endl;
595  PFClusterRef eref = lowEl->clusterRef();
596  PFClusterRef href = highEl->clusterRef();
597  assert( !eref.isNull() );
598  assert( !href.isNull() );
599  dist = LinkByRecHit::testHFEMAndHFHADByRecHit( *eref, *href, debug_ );
600  // linktest = PFBlock::LINKTEST_RECHIT;
601  break;
602  }
603 
605  {
606  if(debug_ )
607  cout<<"TRACKandTRACK"<<endl;
608  dist = testLinkByVertex(lowEl, highEl);
609  if(debug_ )
610  std::cout << " PFBlockLink::TRACKandTRACK dist " << dist << std::endl;
611  // linktest = PFBlock::LINKTEST_RECHIT;
612  break;
613  }
614 
616  {
617 
618  PFClusterRef ecal1ref = lowEl->clusterRef();
619  PFClusterRef ecal2ref = highEl->clusterRef();
620  assert( !ecal1ref.isNull() );
621  assert( !ecal2ref.isNull() );
622  if(debug_)
623  cout << " PFBlockLink::ECALandECAL" << endl;
624  dist = testLinkBySuperCluster(ecal1ref,ecal2ref);
625  break;
626  }
627 
629  {
630  PFClusterRef clusterref = lowEl->clusterRef();
631  assert( !clusterref.isNull() );
632  const reco::PFBlockElementGsfTrack * GsfEl = dynamic_cast<const reco::PFBlockElementGsfTrack*>(highEl);
633  const PFRecTrack * myTrack = &(GsfEl->GsftrackPF());
635  dist = LinkByRecHit::testTrackAndClusterByRecHit( *myTrack, *clusterref, false, debug_ );
636  else
637  dist = -1.;
638  // linktest = PFBlock::LINKTEST_RECHIT;
639 
640  if ( debug_ ) {
641  if ( dist > 0. ) {
642  std::cout << " Here a link has been established"
643  << " between a GSF track an Ecal with dist "
644  << dist << std::endl;
645  } else {
646  if(debug_ ) std::cout << " No link found " << std::endl;
647  }
648  }
649  break;
650  }
652  {
653  PFRecTrackRef trackref = lowEl->trackRefPF();
654  assert( !trackref.isNull() );
655  const reco::PFBlockElementGsfTrack * GsfEl =
656  dynamic_cast<const reco::PFBlockElementGsfTrack*>(highEl);
657  GsfPFRecTrackRef gsfref = GsfEl->GsftrackRefPF();
658  reco::TrackRef kftrackref= (*trackref).trackRef();
659  assert( !gsfref.isNull() );
660  PFRecTrackRef refkf = (*gsfref).kfPFRecTrackRef();
661  if(refkf.isNonnull()) {
662  reco::TrackRef gsftrackref = (*refkf).trackRef();
663  if (gsftrackref.isNonnull()&&kftrackref.isNonnull()) {
664  if (kftrackref == gsftrackref) {
665  dist = 0.001;
666  } else {
667  dist = -1.;
668  }
669  } else {
670  dist = -1.;
671  }
672  } else {
673  dist = -1.;
674  }
675 
676 
678  if(lowEl->isLinkedToDisplacedVertex()){
679  vector<PFRecTrackRef> pfrectrack_vec = GsfEl->GsftrackRefPF()->convBremPFRecTrackRef();
680  if(pfrectrack_vec.size() > 0){
681  for(unsigned int iconv = 0; iconv < pfrectrack_vec.size(); ++iconv) {
683  // use track ref
684  if(kftrackref == (*pfrectrack_vec[iconv]).trackRef()) {
685  dist = 0.001;
686  }
687  }
688  else{
689  // use the track base ref
690  reco::TrackBaseRef newTrackBaseRef((*pfrectrack_vec[iconv]).trackRef());
691  reco::TrackBaseRef elemTrackBaseRef(kftrackref);
692  if(newTrackBaseRef == elemTrackBaseRef){
693  dist = 0.001;
694  }
695  }
696  }
697  }
698  }
699  }
700 
701 
702  break;
703  }
704 
706  {
707  const reco::PFBlockElementGsfTrack * GsfEl = dynamic_cast<const reco::PFBlockElementGsfTrack*>(lowEl);
708  const reco::PFBlockElementBrem * BremEl = dynamic_cast<const reco::PFBlockElementBrem*>(highEl);
709  GsfPFRecTrackRef gsfref = GsfEl->GsftrackRefPF();
710  GsfPFRecTrackRef bremref = BremEl->GsftrackRefPF();
711  assert( !gsfref.isNull() );
712  assert( !bremref.isNull() );
713  if (gsfref == bremref) {
714  dist = 0.001;
715  } else {
716  dist = -1.;
717  }
718  break;
719  }
721  {
722  const reco::PFBlockElementGsfTrack * lowGsfEl =
723  dynamic_cast<const reco::PFBlockElementGsfTrack*>(lowEl);
724  const reco::PFBlockElementGsfTrack * highGsfEl =
725  dynamic_cast<const reco::PFBlockElementGsfTrack*>(highEl);
726 
727  GsfPFRecTrackRef lowgsfref = lowGsfEl->GsftrackRefPF();
728  GsfPFRecTrackRef highgsfref = highGsfEl->GsftrackRefPF();
729  assert( !lowgsfref.isNull() );
730  assert( !highgsfref.isNull() );
731 
732  if( (lowGsfEl->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) == false &&
734  (highGsfEl->trackType(reco::PFBlockElement::T_FROM_GAMMACONV) == false &&
736  if(lowgsfref->trackId() == highgsfref->trackId()) {
737  dist = 0.001;
738  }
739  else {
740  dist = -1.;
741  }
742  }
743  break;
744  }
746  {
747  PFClusterRef clusterref = lowEl->clusterRef();
748  assert( !clusterref.isNull() );
749  const reco::PFBlockElementBrem * BremEl =
750  dynamic_cast<const reco::PFBlockElementBrem*>(highEl);
751  const PFRecTrack * myTrack = &(BremEl->trackPF());
752  /*
753  double DP = (BremEl->DeltaP())*(-1.);
754  double SigmaDP = BremEl->SigmaDeltaP();
755  double SignBremDp = DP/SigmaDP;
756  */
757  bool isBrem = true;
759  dist = LinkByRecHit::testTrackAndClusterByRecHit( *myTrack, *clusterref, isBrem, debug_);
760  else
761  dist = -1.;
762  if( debug_ && dist > 0. )
763  std::cout << "ECALandBREM: dist testTrackAndClusterByRecHit "
764  << dist << std::endl;
765  // linktest = PFBlock::LINKTEST_RECHIT;
766  break;
767  }
769  {
770  PFClusterRef clusterref = lowEl->clusterRef();
771  assert( !clusterref.isNull() );
772  const reco::PFBlockElementGsfTrack * GsfEl = dynamic_cast<const reco::PFBlockElementGsfTrack*>(highEl);
773  const PFRecTrack * myTrack = &(GsfEl->GsftrackPF());
775  dist = LinkByRecHit::testTrackAndClusterByRecHit( *myTrack, *clusterref, false, debug_ );
776  else
777  dist = -1.;
778 
779  // linktest = PFBlock::LINKTEST_RECHIT;
780  break;
781  }
783  {
784  PFClusterRef clusterref = lowEl->clusterRef();
785  assert( !clusterref.isNull() );
786  const reco::PFBlockElementBrem * BremEl = dynamic_cast<const reco::PFBlockElementBrem*>(highEl);
787  const PFRecTrack * myTrack = &(BremEl->trackPF());
788  bool isBrem = true;
790  dist = LinkByRecHit::testTrackAndClusterByRecHit( *myTrack, *clusterref, isBrem, debug_);
791  else
792  dist = -1.;
793  break;
794  }
796  {
797  PFClusterRef clusterref = lowEl->clusterRef();
798 
799  assert( !clusterref.isNull() );
800 
801  const reco::PFBlockElementSuperCluster * scEl =
802  dynamic_cast<const reco::PFBlockElementSuperCluster*>(highEl);
803  assert (!scEl->superClusterRef().isNull());
804  dist = testSuperClusterPFCluster(scEl->superClusterRef(),
805  clusterref);
806  break;
807  }
808  /*
809  // Links between the two preshower layers are not used for now - disable
810  case PFBlockLink::PS1andPS2:
811  {
812  PFClusterRef ps1ref = lowEl->clusterRef();
813  PFClusterRef ps2ref = highEl->clusterRef();
814  assert( !ps1ref.isNull() );
815  assert( !ps2ref.isNull() );
816  // PJ - 14-May-09 : A link by rechit is needed here !
817  // dist = testPS1AndPS2( *ps1ref, *ps2ref );
818  dist = -1.;
819  linktest = PFBlock::LINKTEST_RECHIT;
820  break;
821  }
822  case PFBlockLink::TRACKandPS1:
823  case PFBlockLink::TRACKandPS2:
824  {
825  //cout<<"TRACKandPS"<<endl;
826  PFRecTrackRef trackref = lowEl->trackRefPF();
827  PFClusterRef clusterref = highEl->clusterRef();
828  assert( !trackref.isNull() );
829  assert( !clusterref.isNull() );
830  // PJ - 14-May-09 : A link by rechit is needed here !
831  dist = testTrackAndPS( *trackref, *clusterref );
832  linktest = PFBlock::LINKTEST_RECHIT;
833  break;
834  }
835  // GSF Track/Brem Track and preshower cluster links are not used for now - disable
836  case PFBlockLink::PS1andGSF:
837  case PFBlockLink::PS2andGSF:
838  {
839  PFClusterRef psref = lowEl->clusterRef();
840  assert( !psref.isNull() );
841  const reco::PFBlockElementGsfTrack * GsfEl = dynamic_cast<const reco::PFBlockElementGsfTrack*>(highEl);
842  const PFRecTrack * myTrack = &(GsfEl->GsftrackPF());
843  // PJ - 14-May-09 : A link by rechit is needed here !
844  dist = testTrackAndPS( *myTrack, *psref );
845  linktest = PFBlock::LINKTEST_RECHIT;
846  break;
847  }
848  case PFBlockLink::PS1andBREM:
849  case PFBlockLink::PS2andBREM:
850  {
851  PFClusterRef psref = lowEl->clusterRef();
852  assert( !psref.isNull() );
853  const reco::PFBlockElementBrem * BremEl = dynamic_cast<const reco::PFBlockElementBrem*>(highEl);
854  const PFRecTrack * myTrack = &(BremEl->trackPF());
855  // PJ - 14-May-09 : A link by rechit is needed here !
856  dist = testTrackAndPS( *myTrack, *psref );
857  linktest = PFBlock::LINKTEST_RECHIT;
858  break;
859  }
860  */
861 
862  default:
863  dist = -1.;
864  // linktest = PFBlock::LINKTEST_RECHIT;
865  // cerr<<"link type not implemented yet: 0x"<<hex<<linktype<<dec<<endl;
866  // assert(0);
867  return;
868  }
869 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
std::vector< std::pair< double, double > > PFMultilinksType
Abstract This class is used by the KDTree Track / Ecal Cluster linker to store all found links...
Abstract base class for a PFBlock element (track, cluster...)
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
double testECALAndHCAL(const reco::PFCluster &ecal, const reco::PFCluster &hcal) const
Definition: PFBlockAlgo.cc:936
GsfPFRecTrackRef GsftrackRefPF() const
double testSuperClusterPFCluster(const reco::SuperClusterRef &sct1, const reco::PFClusterRef &elt2) const
test association between SuperClusters and ECAL
double testHCALAndHO(const reco::PFCluster &hcal, const reco::PFCluster &ho) const
Definition: PFBlockAlgo.cc:966
static double testECALAndPSByRecHit(const reco::PFCluster &clusterECAL, const reco::PFCluster &clusterPS, bool debug=false)
const math::XYZPoint & position() const
cartesian position (x, y, z)
Type type() const
double testLinkBySuperCluster(const reco::PFClusterRef &elt1, const reco::PFClusterRef &elt2) const
test association by Supercluster between two ECAL
Definition: PFBlockAlgo.cc:997
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool isNull() const
Checks for null.
Definition: Ref.h:247
virtual reco::TrackRef trackRef() const
bool useConvBremPFRecTracks_
switch on/off Conversions Brem Recovery with KF Tracks
Definition: PFBlockAlgo.h:360
virtual PFClusterRef clusterRef() const
virtual PFRecTrackRef trackRefPF() const
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
virtual bool trackType(TrackType trType) const
#define M_PI
Definition: BFit3D.cc:3
double testLinkByVertex(const reco::PFBlockElement *elt1, const reco::PFBlockElement *elt2) const
bool isValid() const
is this point valid ?
static double testHFEMAndHFHADByRecHit(const reco::PFCluster &clusterHFEM, const reco::PFCluster &clusterHFHAD, bool debug=false)
test association between HFEM and HFHAD, by rechit
bool isMultilinksValide() const
virtual bool trackType(TrackType trType) const
GsfPFRecTrackRef GsftrackRefPF() const
tuple cout
Definition: gather_cfg.py:121
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
Definition: PFBlockAlgo.h:377
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
Definition: LinkByRecHit.cc:10
bool useKDTreeTrackEcalLinker_
Definition: PFBlockAlgo.h:320
const PFMultilinksType & getMultilinks() const
bool PFBlockAlgo::linkPrefilter ( const reco::PFBlockElement last,
const reco::PFBlockElement next 
) const
inlineprivate

Avoid to check links when not useful.

Definition at line 1432 of file PFBlockAlgo.cc.

References bNoSuperclus_, ECAL, reco::PFBlockElement::getMultilinks(), reco::PFBlockElement::isMultilinksValide(), prof2calltree::last, GetRecoTauVFromDQM_MC_cff::next, and useKDTreeTrackEcalLinker_.

Referenced by associate(), and packLinks().

1432  {
1433 
1434  PFBlockElement::Type type1 = (last)->type();
1435  PFBlockElement::Type type2 = (next)->type();
1436 
1437  if( type1==type2 ) {
1438  // cannot link 2 elements of the same type.
1439  // except if the elements are 2 tracks or 2 ECAL
1440  if( type1!=PFBlockElement::TRACK && type1!=PFBlockElement::GSF &&
1441  type1!=PFBlockElement::ECAL) { // && type1!=PFBlockElement::HCAL) {
1442  return false;
1443  }
1444 
1445  if (type1==PFBlockElement::ECAL && bNoSuperclus_) return false;
1446 
1447  // cannot link two primary tracks (except if they come from a V0)
1448  if( type1 ==PFBlockElement::TRACK) {
1449  if ( !((last)->isLinkedToDisplacedVertex()) || !((next)->isLinkedToDisplacedVertex()))
1450  return false;
1451  }
1452  }
1453 
1454  if ((type1 == PFBlockElement::PS1 || type1 == PFBlockElement::PS2) && (type2 != PFBlockElement::ECAL)) return false;
1455  if ((type2 == PFBlockElement::PS1 || type2 == PFBlockElement::PS2) && (type1 != PFBlockElement::ECAL)) return false;
1456  if ((type1 == PFBlockElement::HFEM && type2 != PFBlockElement::HFHAD) || (type1 == PFBlockElement::HFHAD && type2 != PFBlockElement::HFEM)) return false;
1457 
1459 
1460  if ( type1 == PFBlockElement::TRACK && type2 == PFBlockElement::ECAL)
1461  if ( last->isMultilinksValide() && last->getMultilinks().size()==0 ) return false;
1462  if ( type2 == PFBlockElement::TRACK && type1 == PFBlockElement::ECAL)
1463  if ( next->isMultilinksValide() && next->getMultilinks().size()==0 ) return false;
1464  if ( type1 == PFBlockElement::PS1 || type1 == PFBlockElement::PS2)
1465  if ( last->isMultilinksValide() && last->getMultilinks().size()==0 ) return false;
1466  if ( type2 == PFBlockElement::PS1 || type2 == PFBlockElement::PS2)
1467  if ( next->isMultilinksValide() && next->getMultilinks().size()==0 ) return false;
1468 
1469  }
1470 
1471  return true;
1472 
1473 }
type
Definition: HCALResponse.h:21
bool isMultilinksValide() const
bool bNoSuperclus_
Definition: PFBlockAlgo.h:372
bool useKDTreeTrackEcalLinker_
Definition: PFBlockAlgo.h:320
const PFMultilinksType & getMultilinks() const
int PFBlockAlgo::muAssocToTrack ( const reco::TrackRef trackref,
const edm::Handle< reco::MuonCollection > &  muonh 
) const
private

Definition at line 1403 of file PFBlockAlgo.cc.

References edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), and j.

Referenced by setInput().

1404  {
1405  if(muonh.isValid() ) {
1406  for(unsigned j=0;j<muonh->size(); ++j) {
1407  reco::MuonRef muonref( muonh, j );
1408  if (muonref->track().isNonnull())
1409  if( muonref->track() == trackref ) return j;
1410  }
1411  }
1412  return -1; // not found
1413 }
int j
Definition: DBlmapReader.cc:9
bool isValid() const
Definition: HandleBase.h:76
int PFBlockAlgo::muAssocToTrack ( const reco::TrackRef trackref,
const edm::OrphanHandle< reco::MuonCollection > &  muonh 
) const
private

Definition at line 1416 of file PFBlockAlgo.cc.

References edm::Ref< C, T, F >::isNonnull(), edm::OrphanHandleBase::isValid(), and j.

1417  {
1418  if(muonh.isValid() ) {
1419  for(unsigned j=0;j<muonh->size(); ++j) {
1420  reco::MuonRef muonref( muonh, j );
1421  if (muonref->track().isNonnull())
1422  if( muonref->track() == trackref ) return j;
1423  }
1424  }
1425  return -1; // not found
1426 }
int j
Definition: DBlmapReader.cc:9
void PFBlockAlgo::packLinks ( reco::PFBlock block,
const std::vector< PFBlockLink > &  links 
) const
private

compute missing links in the blocks (the recursive procedure does not build all links)

Definition at line 242 of file PFBlockAlgo.cc.

References reco::PFBlock::bookLinkData(), gather_cfg::cout, debug_, reco::PFBlock::elements(), asciidump::els, link(), reco::PFBlock::linkData(), linkPrefilter(), PFBlockLink::NONE, reco::PFBlock::setLink(), and edm::OwnVector< T, P >::size().

Referenced by findBlocks().

243  {
244 
245 
247 
248  block.bookLinkData();
249  unsigned elsize = els.size();
250  unsigned ilStart = 0;
251  //First Loop: update all link data
252  for( unsigned i1=0; i1<elsize; ++i1 ) {
253  for( unsigned i2=0; i2<i1; ++i2 ) {
254 
255  // no reflexive link
256  //if( i1==i2 ) continue;
257 
258  double dist = -1;
259 
260  bool linked = false;
261  PFBlock::LinkTest linktest
262  = PFBlock::LINKTEST_RECHIT;
263 
264  // are these elements already linked ?
265  // this can be optimized
266  unsigned linksize = links.size();
267  for( unsigned il = ilStart; il<linksize; ++il ) {
268  // The following three lines exploits the increasing-element2 ordering of links.
269  if ( links[il].element2() < i1 ) ilStart = il;
270  if ( links[il].element2() > i1 ) break;
271  if( (links[il].element1() == i2 &&
272  links[il].element2() == i1) ) { // yes
273 
274  dist = links[il].dist();
275  linked = true;
276 
277  //modif-beg
278  //retrieve type of test used to get distance
279  linktest = links[il].test();
280 #ifdef PFLOW_DEBUG
281  if( debug_ )
282  cout << "Reading link vector: linktest used="
283  << linktest
284  << " distance = " << dist
285  << endl;
286 #endif
287  //modif-end
288 
289  break;
290  }
291  }
292 
293  if(!linked) {
295  bool bTestLink = linkPrefilter(&els[i1], &els[i2]);
296  if (bTestLink) link( & els[i1], & els[i2], linktype, linktest, dist);
297  }
298 
299  //loading link data according to link test used: RECHIT
300  //block.setLink( i1, i2, chi2, block.linkData() );
301 #ifdef PFLOW_DEBUG
302  if( debug_ )
303  cout << "Setting link between elements " << i1 << " and " << i2
304  << " of dist =" << dist << " computed from link test "
305  << linktest << endl;
306 #endif
307  block.setLink( i1, i2, dist, block.linkData(), linktest );
308  }
309  }
310 
311 }
size_type size() const
Definition: OwnVector.h:247
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
const LinkData & linkData() const
Definition: PFBlock.h:112
tuple els
Definition: asciidump.py:420
void setLink(unsigned i1, unsigned i2, double dist, LinkData &linkData, LinkTest test=LINKTEST_RECHIT) const
Definition: PFBlock.cc:26
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
Definition: PFBlockAlgo.cc:323
void bookLinkData()
Definition: PFBlock.cc:20
bool linkPrefilter(const reco::PFBlockElement *last, const reco::PFBlockElement *next) const
Avoid to check links when not useful.
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
void PFBlockAlgo::setDebug ( bool  debug)
inline

sets debug printout flag

Definition at line 186 of file PFBlockAlgo.h.

References debug, and debug_.

Referenced by PFRootEventManager::readOptions().

186 {debug_ = debug;}
#define debug
Definition: HDRShower.cc:19
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
void PFBlockAlgo::setHOTag ( bool  ho)
inline

Definition at line 205 of file PFBlockAlgo.h.

References useHO_.

Referenced by PFRootEventManager::readOptions().

205 { useHO_ = ho;}
template<template< typename > class T>
void PFBlockAlgo::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

–———— GSF Primary tracks and brems ———————

get tracks from converted brems

Loop over the photons

Loop over the SuperClusters

–———— conversions ———————

The tracks from conversions are filled into the elements collection

–———— V0 ———————

The tracks from V0 are filled into the elements collection

One need to cross check if those tracks was not already filled from the conversion collection

This is a new track not yet included into the elements collection

–———— Displaced Vertices ———————

The tracks from Displaced Vertices are filled into the elements collection

One need to cross check if those tracks was not already filled from the conversion or V0 collections

This is a new track not yet included into the elements collection

Fill the displaced vertex ref

--------—— Tracks ---------------——

Mask the tracks in trackh collection already included from Conversions V0 and Displaced Vertices. Take care that all those collections come from the same "generalTracks" collection.

Definition at line 394 of file PFBlockAlgo.h.

References bNoSuperclus_, checkMaskSize(), ClusterClusterMapping::checkOverlap(), edm::ValueMap< T >::clear(), gather_cfg::cout, debug_, reco::PFBlockElement::DEFAULT, reco::PFBlockElement::ECAL, reco::PFTrajectoryPoint::ECALShowerMax, elements_, fillFromPhoton(), spr::find(), goodPtResolution(), reco::PFBlockElement::HCAL, reco::PFTrajectoryPoint::HCALEntrance, reco::PFBlockElement::HFEM, reco::PFBlockElement::HFHAD, reco::PFBlockElement::HO, i, KDTreeLinkerTrackHcal::insertFieldClusterElt(), KDTreeLinkerTrackEcal::insertFieldClusterElt(), KDTreeLinkerPSEcal::insertFieldClusterElt(), KDTreeLinkerPSEcal::insertTargetElt(), KDTreeLinkerTrackEcal::insertTargetElt(), KDTreeLinkerTrackHcal::insertTargetElt(), listHistos::IP, edm::Ref< C, T, F >::isAvailable(), PFMuonAlgo::isLooseMuon(), PFMuonAlgo::isMuon(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::key(), muAssocToTrack(), reco::PFBlockElement::NONE, nuclearInteractionsPurity_, PhotonSelectorAlgo::passPhotonSelection(), pfclusterassoc_, pfcSCVec_, photonSelector_, PFLayer::PS1, reco::PFBlockElement::PS1, PFLayer::PS2, reco::PFBlockElement::PS2, PSELinker_, scpfcRefs_, reco::PFBlockElement::setConversionRef(), reco::PFBlockElement::setDisplacedVertexRef(), reco::PFBlockElementSuperCluster::setFromGsfElectron(), reco::PFBlockElementSuperCluster::setFromPFSuperCluster(), reco::PFBlockElementSuperCluster::setFromPhoton(), reco::PFBlockElement::setMuonRef(), reco::PFBlockElement::setTrackType(), reco::PFBlockElement::setV0Ref(), findQualityFiles::size, superClusterMatchByRef_, superClusters_, reco::PFBlockElement::T_FROM_DISP, reco::PFBlockElement::T_FROM_GAMMACONV, reco::PFBlockElement::T_FROM_V0, reco::PFBlockElement::T_TO_DISP, TELinker_, THLinker_, reco::PFBlockElement::TRACK, useConvBremPFRecTracks_, useEGPhotons_, useHO_, useKDTreeTrackEcalLinker_, useSuperClusters_, and relativeConstraints::value.

Referenced by PFRootEventManager::particleFlow().

421  {
422 
423 
424  checkMaskSize( *trackh,
425  *gsftrackh,
426  *ecalh,
427  *hcalh,
428  *hoh,
429  *hfemh,
430  *hfhadh,
431  *psh,
432  *egphh,
433  *sceb,
434  *scee,
435  trackMask,
436  gsftrackMask,
437  ecalMask,
438  hcalMask,
439  hoMask,
440  hfemMask,
441  hfhadMask,
442  psMask,
443  phMask,
444  scMask);
445 
446  /*
447  if (nucleartrackh.isValid()){
448  for(unsigned i=0;i<nucleartrackh->size(); i++) {
449  reco::PFRecTrackRef trackRef(nucleartrackh,i);
450  std::cout << *trackRef << std::endl;
451  }
452  }
453  */
454 
456  pfclusterassoc_ = pfclusterassoc.product();
457  }
458 
460  std::vector<reco::PFRecTrackRef> convBremPFRecTracks;
461  convBremPFRecTracks.clear();
462  // Super cluster mapping
463  superClusters_.clear();
464  scpfcRefs_.clear();
465  pfcSCVec_.clear();
466 
467  if(gsftrackh.isValid() ) {
468  const reco::GsfPFRecTrackCollection PFGsfProd = *(gsftrackh.product());
469  for(unsigned i=0;i<gsftrackh->size(); ++i) {
470  if( !gsftrackMask.empty() &&
471  !gsftrackMask[i] ) continue;
472  reco::GsfPFRecTrackRef refgsf(gsftrackh,i );
473 
474  if((refgsf).isNull()) continue;
475  reco::GsfTrackRef gsf=refgsf->gsfTrackRef();
476 
477  // retrieve and save the SC if ECAL-driven - Florian
478  if(gsf->extra().isAvailable() && gsf->extra()->seedRef().isAvailable()) {
479  reco::ElectronSeedRef seedRef= gsf->extra()->seedRef().castTo<reco::ElectronSeedRef>();
480  // check that the seed is valid
481  if(seedRef.isAvailable() && seedRef->isEcalDriven()) {
482  reco::SuperClusterRef scRef = seedRef->caloCluster().castTo<reco::SuperClusterRef>();
483  if(scRef.isNonnull()) {
484  std::vector<reco::SuperClusterRef>::iterator itcheck=find(superClusters_.begin(),superClusters_.end(),scRef);
485  // not present, add it
486  if(itcheck==superClusters_.end())
487  {
488  superClusters_.push_back(scRef);
491  sce->setFromGsfElectron(true);
493  elements_.push_back(sce);
494  }
495  else // it is already present, update the PFBE
496  {
497  PFBlockElementSCEqual myEqual(scRef);
498  std::list<reco::PFBlockElement*>::iterator itcheck=find_if(elements_.begin(),elements_.end(),myEqual);
499  if(itcheck!=elements_.end())
500  {
501  reco::PFBlockElementSuperCluster* thePFBE=dynamic_cast<reco::PFBlockElementSuperCluster*>(*itcheck);
502  thePFBE->setFromGsfElectron(true);
503  // std::cout << " Updating element to add electron information" << std::endl;
504  }
505 // else
506 // {
507 // std::cout << " Missing element " << std::endl;
508 // }
509  }
510  }
511  }
512  }
513 
514  reco::PFBlockElement* gsfEl;
515 
516  const std::vector<reco::PFTrajectoryPoint>
517  PfGsfPoint = PFGsfProd[i].trajectoryPoints();
518 
519  unsigned int c_gsf=0;
520  bool PassTracker = false;
521  bool GetPout = false;
522  unsigned int IndexPout = 0;
523 
524  typedef std::vector<reco::PFTrajectoryPoint>::const_iterator IP;
525  for(IP itPfGsfPoint = PfGsfPoint.begin();
526  itPfGsfPoint!= PfGsfPoint.end();++itPfGsfPoint) {
527 
528  if (itPfGsfPoint->isValid()){
529  int layGsfP = itPfGsfPoint->layer();
530  if (layGsfP == -1) PassTracker = true;
531  if (PassTracker && layGsfP > 0 && GetPout == false) {
532  IndexPout = c_gsf-1;
533  GetPout = true;
534  }
535  //const math::XYZTLorentzVector GsfMoment = itPfGsfPoint->momentum();
536  ++c_gsf;
537  }
538  }
539  math::XYZTLorentzVector pin = PfGsfPoint[0].momentum();
540  math::XYZTLorentzVector pout = PfGsfPoint[IndexPout].momentum();
541 
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]);
548  }
549  }
550  }
551 
552  gsfEl = new reco::PFBlockElementGsfTrack(refgsf, pin, pout);
553 
554  elements_.push_back( gsfEl);
555 
556  std::vector<reco::PFBrem> pfbrem = refgsf->PFRecBrem();
557 
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;
563 
564  reco::PFBlockElement* bremEl;
565  bremEl = new reco::PFBlockElementBrem(refgsf,DP,SigmaDP,TrajP);
566  elements_.push_back(bremEl);
567 
568  }
569  }
570 
571  }
572 
574  if(useEGPhotons_ && egphh.isValid()) {
575  unsigned size=egphh->size();
576  for(unsigned isc=0; isc<size; ++isc) {
577  if(!phMask.empty() && !(phMask)[isc] ) continue;
578  if(!photonSelector_->passPhotonSelection((*egphh)[isc])) continue;
579  // std::cout << " Selected a supercluster" << std::endl;
580  // Add only the super clusters not already included
581  reco::SuperClusterRef scRef((*egphh)[isc].superCluster());
582  std::vector<reco::SuperClusterRef>::iterator itcheck=find(superClusters_.begin(),superClusters_.end(),(*egphh)[isc].superCluster());
583  if(itcheck==superClusters_.end())
584  {
585  superClusters_.push_back(scRef);
587  new reco::PFBlockElementSuperCluster((*egphh)[isc].superCluster());
588  fillFromPhoton(egphh,isc,sce);
590  elements_.push_back(sce);
591  }
592  else
593  {
594  PFBlockElementSCEqual myEqual(scRef);
595  std::list<reco::PFBlockElement*>::iterator itcheck=find_if(elements_.begin(),elements_.end(),myEqual);
596  if(itcheck!=elements_.end())
597  {
598  reco::PFBlockElementSuperCluster* thePFBE=dynamic_cast<reco::PFBlockElementSuperCluster*>(*itcheck);
599  fillFromPhoton(egphh,isc,thePFBE);
600  thePFBE->setFromPhoton(true);
601  // std::cout << " Updating element to add Photon information " << photonSelector_->passPhotonSelection((*egphh)[isc]) << std::endl;
602 
603  }
604 // else
605 // {
606 // std::cout << " Missing element " << std::endl;
607 // }
608  }
609  }
610  }
611 
613  if(useSuperClusters_ && sceb.isValid() && scee.isValid()) {
614  std::vector<reco::SuperClusterRef> screfs;
615  screfs.reserve(sceb->size()+scee->size());
616 
617  for (unsigned int isc=0; isc<sceb->size(); ++isc) {
618  reco::SuperClusterRef scRef(sceb,isc);
619  screfs.push_back(scRef);
620  }
621 
622  for (unsigned int isc=0; isc<scee->size(); ++isc) {
623  reco::SuperClusterRef scRef(scee,isc);
624  screfs.push_back(scRef);
625  }
626 
627  unsigned size=screfs.size();
628  for(unsigned isc=0; isc<size; ++isc) {
629  if(!scMask.empty() && !(scMask)[isc] ) continue;
630  //if(!photonSelector_->passPhotonSelection((*egphh)[isc])) continue;
631 
632  // std::cout << " Selected a supercluster" << std::endl;
633  // Add only the super clusters not already included
634  reco::SuperClusterRef &scRef = screfs[isc];
635  std::vector<reco::SuperClusterRef>::iterator itcheck=find(superClusters_.begin(),superClusters_.end(),scRef);
636  if(itcheck==superClusters_.end())
637  {
638  superClusters_.push_back(scRef);
642  //fillFromPhoton(egphh,isc,sce);
643  //sce->setFromPhoton(true);
644  elements_.push_back(sce);
645  }
646 // else
647 // {
648 // PFBlockElementSCEqual myEqual(scRef);
649 // std::list<reco::PFBlockElement*>::iterator itcheck=find_if(elements_.begin(),elements_.end(),myEqual);
650 // if(itcheck!=elements_.end())
651 // {
652 // reco::PFBlockElementSuperCluster* thePFBE=dynamic_cast<reco::PFBlockElementSuperCluster*>(*itcheck);
653 // //fillFromPhoton(egphh,isc,thePFBE);
654 // //thePFBE->setFromPhoton(true);
655 // // std::cout << " Updating element to add Photon information " << photonSelector_->passPhotonSelection((*egphh)[isc]) << std::endl;
656 //
657 // }
658 // // else
659 // // {
660 // // std::cout << " Missing element " << std::endl;
661 // // }
662 // }
663  }
664  }
665 
666  // set the vector to the right size so to allow random access
667  scpfcRefs_.resize(superClusters_.size());
668 
670 
672 
673  if(convh.isValid() ) {
674  reco::PFBlockElement* trkFromConversionElement;
675  for(unsigned i=0;i<convh->size(); ++i) {
676  reco::PFConversionRef convRef(convh,i);
677 
678  unsigned int trackSize=(convRef->pfTracks()).size();
679  if ( convRef->pfTracks().size() < 2) continue;
680  for(unsigned iTk=0;iTk<trackSize; ++iTk) {
681 
682  reco::PFRecTrackRef compPFTkRef = convRef->pfTracks()[iTk];
683  trkFromConversionElement = new reco::PFBlockElementTrack(convRef->pfTracks()[iTk]);
684  trkFromConversionElement->setConversionRef( convRef->originalConversion(), reco::PFBlockElement::T_FROM_GAMMACONV);
685 
686  elements_.push_back( trkFromConversionElement );
687 
688 
689  if (debug_){
690  std::cout << "PF Block Element from Conversion electron " <<
691  (*trkFromConversionElement).trackRef().key() << std::endl;
692  std::cout << *trkFromConversionElement << std::endl;
693  }
694 
695  }
696  }
697  }
698 
699 
701 
703 
704  if(v0.isValid() ) {
705  reco::PFBlockElement* trkFromV0Element = 0;
706  for(unsigned i=0;i<v0->size(); ++i) {
707  reco::PFV0Ref v0Ref( v0, i );
708  unsigned int trackSize=(v0Ref->pfTracks()).size();
709  for(unsigned iTk=0;iTk<trackSize; ++iTk) {
710 
711  reco::PFRecTrackRef newPFRecTrackRef = (v0Ref->pfTracks())[iTk];
712  reco::TrackBaseRef newTrackBaseRef(newPFRecTrackRef->trackRef());
713  bool bNew = true;
714 
717  for(IE iel = elements_.begin(); iel != elements_.end(); ++iel){
718  reco::TrackBaseRef elemTrackBaseRef((*iel)->trackRef());
719  if (newTrackBaseRef == elemTrackBaseRef){
720  trkFromV0Element = *iel;
721  bNew = false;
722  continue;
723  }
724  }
725 
727  if (bNew) {
728  trkFromV0Element = new reco::PFBlockElementTrack(v0Ref->pfTracks()[iTk]);
729  elements_.push_back( trkFromV0Element );
730  }
731 
732  trkFromV0Element->setV0Ref( v0Ref->originalV0(),
734 
735  if (debug_){
736  std::cout << "PF Block Element from V0 track New = " << bNew
737  << (*trkFromV0Element).trackRef().key() << std::endl;
738  std::cout << *trkFromV0Element << std::endl;
739  }
740 
741 
742  }
743  }
744  }
745 
747 
749 
750  if(nuclearh.isValid()) {
751  reco::PFBlockElement* trkFromDisplacedVertexElement = 0;
752  for(unsigned i=0;i<nuclearh->size(); ++i) {
753 
754  const reco::PFDisplacedTrackerVertexRef dispacedVertexRef( nuclearh, i );
755 
756  // std::cout << "Nuclear Interactions Purity " << nuclearInteractionsPurity_ << std::endl;
757  // dispacedVertexRef->displacedVertexRef()->Dump();
758  //bool bIncludeVertices = true;
759  // We add a cut at rho > 2.7 since this corresponds to the lower edge of the beam pipe
760  // This cut have to be changer when a new beam pipe would be installed
761 
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();
767 
768  if (nuclearInteractionsPurity_ >= 1) bIncludeVertices = bNucl;
769  if (nuclearInteractionsPurity_ >= 2) bIncludeVertices = bIncludeVertices || bNucl_Loose;
770  if (nuclearInteractionsPurity_ >= 3) bIncludeVertices = bIncludeVertices || bNucl_Kink;
771 
772  if (bIncludeVertices){
773 
774  unsigned int trackSize= dispacedVertexRef->pfRecTracks().size();
775  if (debug_){
776  std::cout << "" << std::endl;
777  std::cout << "Displaced Vertex " << i << std::endl;
778  dispacedVertexRef->displacedVertexRef()->Dump();
779  }
780  for(unsigned iTk=0;iTk < trackSize; ++iTk) {
781 
782 
783  // This peace of code looks weired at first but it seems to be necessary to let
784  // PFRooTEvent work properly. Since the track position called REPPoint is transient
785  // it has to be calculated and the PFRecTrack collection associted to Displaced Vertex is not
786  // anymore the original collection. So here we match both collections if possible
787  reco::PFRecTrackRef newPFRecTrackRef = dispacedVertexRef->pfRecTracks()[iTk];
788  reco::TrackBaseRef constTrackBaseRef(newPFRecTrackRef->trackRef());
789 
790 
791  if (nucleartrackh.isValid()){
792  for(unsigned i=0;i<nucleartrackh->size(); ++i) {
793  reco::PFRecTrackRef transientPFRecTrackRef(nucleartrackh,i);
794  reco::TrackBaseRef transientTrackBaseRef(transientPFRecTrackRef->trackRef());
795  if (constTrackBaseRef==transientTrackBaseRef){
796  newPFRecTrackRef = transientPFRecTrackRef;
797  break;
798  }
799  }
800  }
801  reco::TrackBaseRef newTrackBaseRef(newPFRecTrackRef->trackRef());
802 
803 
804 
805  bool bNew = true;
807 
810  for(IE iel = elements_.begin(); iel != elements_.end(); ++iel){
811  reco::TrackBaseRef elemTrackBaseRef((*iel)->trackRef());
812  if (newTrackBaseRef == elemTrackBaseRef){
813  trkFromDisplacedVertexElement = *iel;
814  bNew = false;
815  continue;
816  }
817  }
818 
819 
821  if (bNew) {
822 
823 
824 
825  trkFromDisplacedVertexElement = new reco::PFBlockElementTrack(newPFRecTrackRef);
826  elements_.push_back( trkFromDisplacedVertexElement );
827  }
828 
829  if (dispacedVertexRef->isIncomingTrack(newPFRecTrackRef))
831  else if (dispacedVertexRef->isOutgoingTrack(newPFRecTrackRef))
833  else
834  blockType = reco::PFBlockElement::DEFAULT;
835 
837  trkFromDisplacedVertexElement->setDisplacedVertexRef( dispacedVertexRef, blockType );
838 
839 
840  if (debug_){
841  std::cout << "PF Block Element from DisplacedTrackingVertex track New = " << bNew
842  << (*trkFromDisplacedVertexElement).trackRef().key() << std::endl;
843  std::cout << *trkFromDisplacedVertexElement << std::endl;
844  }
845 
846 
847  }
848  }
849  }
850 
851  if (debug_) std::cout << "" << std::endl;
852 
853  }
854 
856 
860 
861  if(trackh.isValid() ) {
862 
863  if (debug_) std::cout << "Tracks already in from Displaced Vertices " << std::endl;
864 
865  Mask trackMaskVertex;
866 
867  for(unsigned i=0;i<trackh->size(); ++i) {
868  reco::PFRecTrackRef pfRefTrack( trackh,i );
869  reco::TrackRef trackRef = pfRefTrack->trackRef();
870 
871  bool bMask = true;
872  for(IE iel = elements_.begin(); iel != elements_.end(); ++iel){
873  reco::TrackRef elemTrackRef = (*iel)->trackRef();
874  if( trackRef == elemTrackRef ) {
875  if (debug_) std::cout << " " << trackRef.key();
876  bMask = false; continue;
877  }
878  }
879 
880  trackMaskVertex.push_back(bMask);
881  }
882 
883  if (debug_) std::cout << "" << std::endl;
884 
885  if (debug_) std::cout << "Additionnal tracks from main collection " << std::endl;
886 
887  for(unsigned i=0;i<trackh->size(); ++i) {
888 
889 
890  // this track has been disabled
891  if( !trackMask.empty() && !trackMask[i] ) continue;
892 
893  reco::PFRecTrackRef ref( trackh,i );
894 
895  if (debug_) std::cout << " " << ref->trackRef().key();
896 
897  // Get the eventual muon associated to this track
898  int muId_ = muAssocToTrack( ref->trackRef(), muonh );
899  bool thisIsAPotentialMuon = false;
900  if( muId_ != -1 ) {
901  reco::MuonRef muonref( muonh, muId_ );
902  thisIsAPotentialMuon =
903  PFMuonAlgo::isLooseMuon(muonref) ||
904  PFMuonAlgo::isMuon(muonref);
905  }
906  // Reject bad tracks (except if identified as muon
907  if( !thisIsAPotentialMuon && !goodPtResolution( ref->trackRef() ) ) continue;
908 
909  if (thisIsAPotentialMuon && debug_) std::cout << "Potential Muon P " << ref->trackRef()->p()
910  << " pt " << ref->trackRef()->p() << std::endl;
911 
912 
913 
914  reco::PFBlockElement* primaryElement = new reco::PFBlockElementTrack( ref );
915 
916  if( muId_ != -1 ) {
917  // if a muon has been found
918  reco::MuonRef muonref( muonh, muId_ );
919 
920  // If this track was already added to the collection, we just need to find the associated element and
921  // attach to it the reference
922  if (!trackMaskVertex.empty() && !trackMaskVertex[i]){
923  reco::TrackRef primaryTrackRef = ref->trackRef();
924  for(IE iel = elements_.begin(); iel != elements_.end(); ++iel){
925  reco::TrackRef elemTrackRef = (*iel)->trackRef();
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;
929  }
930  }
931  } else primaryElement->setMuonRef( muonref );
932 
933  }
934 
935  if (!trackMaskVertex.empty() && !trackMaskVertex[i]) continue;
936 
937 
938  // set track type T_FROM_GAMMA for pfrectracks associated to conv brems
940  if(convBremPFRecTracks.size() > 0.) {
941  for(unsigned int iconv = 0; iconv < convBremPFRecTracks.size(); ++iconv) {
942  if((*ref).trackRef() == (*convBremPFRecTracks[iconv]).trackRef()) {
943  bool value = true;
945  }
946  }
947  }
948  }
949  elements_.push_back( primaryElement );
950  }
951 
952  if (debug_) std::cout << " " << std::endl;
953 
954  }
955 
956 
957  // -------------- GSF tracks and brems for Conversion Recovery ----------
958 
959  if(convbremgsftrackh.isValid() ) {
960 
961 
962  const reco::GsfPFRecTrackCollection ConvPFGsfProd = *(convbremgsftrackh.product());
963  for(unsigned i=0;i<convbremgsftrackh->size(); ++i) {
964 
965  reco::GsfPFRecTrackRef refgsf(convbremgsftrackh,i );
966 
967  if((refgsf).isNull()) continue;
968 
969  reco::PFBlockElement* gsfEl;
970 
971  const std::vector<reco::PFTrajectoryPoint>
972  PfGsfPoint = ConvPFGsfProd[i].trajectoryPoints();
973 
974  unsigned int c_gsf=0;
975  bool PassTracker = false;
976  bool GetPout = false;
977  unsigned int IndexPout = -1;
978 
979  typedef std::vector<reco::PFTrajectoryPoint>::const_iterator IP;
980  for(IP itPfGsfPoint = PfGsfPoint.begin();
981  itPfGsfPoint!= PfGsfPoint.end();++itPfGsfPoint) {
982 
983  if (itPfGsfPoint->isValid()){
984  int layGsfP = itPfGsfPoint->layer();
985  if (layGsfP == -1) PassTracker = true;
986  if (PassTracker && layGsfP > 0 && GetPout == false) {
987  IndexPout = c_gsf-1;
988  GetPout = true;
989  }
990  //const math::XYZTLorentzVector GsfMoment = itPfGsfPoint->momentum();
991  ++c_gsf;
992  }
993  }
994  math::XYZTLorentzVector pin = PfGsfPoint[0].momentum();
995  math::XYZTLorentzVector pout = PfGsfPoint[IndexPout].momentum();
996 
997 
998 
999  gsfEl = new reco::PFBlockElementGsfTrack(refgsf, pin, pout);
1000 
1001  bool valuegsf = true;
1002  // IMPORTANT SET T_FROM_GAMMACONV trackType() FOR CONVERSIONS
1004 
1005 
1006 
1007  elements_.push_back( gsfEl);
1008  std::vector<reco::PFBrem> pfbrem = refgsf->PFRecBrem();
1009 
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;
1015 
1016  reco::PFBlockElement* bremEl;
1017  bremEl = new reco::PFBlockElementBrem(refgsf,DP,SigmaDP,TrajP);
1018  elements_.push_back(bremEl);
1019 
1020  }
1021  }
1022  }
1023 
1024 
1025  // -------------- ECAL clusters ---------------------
1026 
1027 
1028  if(ecalh.isValid() ) {
1029  // pfcSCVec_.resize(ecalh->size(),-1);
1030 
1031  bNoSuperclus_ = (superClusters_.size() == 0);
1032  if (!bNoSuperclus_) pfcSCVec_.resize(ecalh->size(),-1);
1033 
1034 
1035  for(unsigned i=0;i<ecalh->size(); ++i) {
1036 
1037  // this ecal cluster has been disabled
1038  if( !ecalMask.empty() &&
1039  !ecalMask[i] ) continue;
1040 
1041  reco::PFClusterRef ref( ecalh,i );
1043  = new reco::PFBlockElementCluster( ref,
1045  elements_.push_back( te );
1046 
1047  if (!bNoSuperclus_) {
1048 
1049  // Now mapping with Superclusters
1050  int scindex = -1;
1053  }
1054  else {
1056  }
1057 
1058  if(scindex>=0) {
1059  pfcSCVec_[ref.key()]=scindex;
1060  scpfcRefs_[scindex].push_back(ref);
1061  }
1062  }
1063 
1064  }
1065 
1066  bNoSuperclus_ = (scpfcRefs_.size() == 0);
1067 
1068  }
1069 
1070  // -------------- HCAL clusters ---------------------
1071 
1072  if(hcalh.isValid() ) {
1073 
1074  for(unsigned i=0;i<hcalh->size(); ++i) {
1075 
1076  // this hcal cluster has been disabled
1077  if( !hcalMask.empty() &&
1078  !hcalMask[i] ) continue;
1079 
1080  reco::PFClusterRef ref( hcalh,i );
1082  = new reco::PFBlockElementCluster( ref,
1084  elements_.push_back( th );
1085  }
1086  }
1087 
1088  // -------------- HO clusters ---------------------
1089 
1090  if(useHO_ && hoh.isValid() ) {
1091 
1092  for(unsigned i=0;i<hoh->size(); ++i) {
1093 
1094  // this hcal cluster has been disabled
1095  if( !hoMask.empty() &&
1096  !hoMask[i] ) continue;
1097 
1098  reco::PFClusterRef ref( hoh,i );
1100  = new reco::PFBlockElementCluster( ref,
1102  elements_.push_back( th );
1103  }
1104  }
1105 
1106  // -------------- HFEM clusters ---------------------
1107 
1108  if(hfemh.isValid() ) {
1109 
1110  for(unsigned i=0;i<hfemh->size(); ++i) {
1111 
1112  // this hfem cluster has been disabled
1113  if( !hfemMask.empty() &&
1114  !hfemMask[i] ) continue;
1115 
1116  reco::PFClusterRef ref( hfemh,i );
1118  = new reco::PFBlockElementCluster( ref,
1120  elements_.push_back( th );
1121  }
1122  }
1123 
1124 
1125  // -------------- HFHAD clusters ---------------------
1126 
1127  if(hfhadh.isValid() ) {
1128 
1129  for(unsigned i=0;i<hfhadh->size(); ++i) {
1130 
1131  // this hfhad cluster has been disabled
1132  if( !hfhadMask.empty() &&
1133  !hfhadMask[i] ) continue;
1134 
1135  reco::PFClusterRef ref( hfhadh,i );
1137  = new reco::PFBlockElementCluster( ref,
1139  elements_.push_back( th );
1140  }
1141  }
1142 
1143 
1144 
1145 
1146  // -------------- PS clusters ---------------------
1147 
1148  if(psh.isValid() ) {
1149  for(unsigned i=0;i<psh->size(); ++i) {
1150 
1151  // this ps cluster has been disabled
1152  if( !psMask.empty() &&
1153  !psMask[i] ) continue;
1155  reco::PFClusterRef ref( psh,i );
1156  // two types of elements: PS1 (V) and PS2 (H)
1157  // depending on layer: PS1 or PS2
1158  switch(ref->layer()){
1159  case PFLayer::PS1:
1161  break;
1162  case PFLayer::PS2:
1164  break;
1165  default:
1166  break;
1167  }
1169  = new reco::PFBlockElementCluster( ref,
1170  type );
1171  elements_.push_back( tp );
1172  }
1173  }
1174 
1175 
1176  // -------------- Loop over block elements ---------------------
1177 
1178  // Here we provide to all KDTree linkers the collections to link.
1179  // Glowinski & Gouzevitch
1180 
1181  for (std::list< reco::PFBlockElement* >::iterator it = elements_.begin();
1182  it != elements_.end(); ++it) {
1183  switch ((*it)->type()){
1184 
1187  if ( (*it)->trackRefPF()->extrapolatedPoint( reco::PFTrajectoryPoint::ECALShowerMax ).isValid() )
1189  if ( (*it)->trackRefPF()->extrapolatedPoint( reco::PFTrajectoryPoint::HCALEntrance ).isValid() )
1191  }
1192 
1193  break;
1194 
1199  break;
1200 
1204  break;
1205 
1208  // THLinker_.insertFieldClusterElt(*it);
1209  }
1210  break;
1211 
1212 
1217  }
1218  break;
1219 
1220  default:
1221  break;
1222  }
1223  }
1224 }
void insertFieldClusterElt(reco::PFBlockElement *hcalCluster)
type
Definition: HCALResponse.h:21
Abstract base class for a PFBlock element (track, cluster...)
int i
Definition: DBlmapReader.cc:9
std::vector< reco::SuperClusterRef > superClusters_
list of superclusters
Definition: PFBlockAlgo.h:365
bool passPhotonSelection(const reco::Photon &) const
void clear()
Definition: ValueMap.h:154
static bool isMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:153
KDTreeLinkerTrackEcal TELinker_
Definition: PFBlockAlgo.h:321
KDTreeLinkerPSEcal PSELinker_
Definition: PFBlockAlgo.h:323
int nuclearInteractionsPurity_
Definition: PFBlockAlgo.h:357
const edm::ValueMap< reco::CaloClusterPtr > * pfclusterassoc_
Definition: PFBlockAlgo.h:348
void setFromGsfElectron(bool val)
set provenance
bool isAvailable() const
Definition: Ref.h:276
void insertFieldClusterElt(reco::PFBlockElement *ecalCluster)
bool superClusterMatchByRef_
Definition: PFBlockAlgo.h:346
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
virtual void setTrackType(TrackType trType, bool value)
the trackType
void fillFromPhoton(const T< reco::PhotonCollection > &, unsigned isc, reco::PFBlockElementSuperCluster *pfbe)
Definition: PFBlockAlgo.h:1228
void setFromPhoton(bool val)
set provenance
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
KDTreeLinkerTrackHcal THLinker_
Definition: PFBlockAlgo.h:322
bool useSuperClusters_
Flag to turn off the import of SuperCluster collections.
Definition: PFBlockAlgo.h:341
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
bool useConvBremPFRecTracks_
switch on/off Conversions Brem Recovery with KF Tracks
Definition: PFBlockAlgo.h:360
int muAssocToTrack(const reco::TrackRef &trackref, const edm::Handle< reco::MuonCollection > &muonh) const
virtual void setDisplacedVertexRef(const PFDisplacedTrackerVertexRef &niref, TrackType trType)
tuple IP
Definition: listHistos.py:76
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?
Definition: PFBlockAlgo.h:201
std::list< reco::PFBlockElement * > elements_
actually, particles will be created by a separate producer
Definition: PFBlockAlgo.h:317
void insertTargetElt(reco::PFBlockElement *track)
std::vector< std::vector< reco::PFClusterRef > > scpfcRefs_
PF clusters corresponding to a given SC.
Definition: PFBlockAlgo.h:375
bool goodPtResolution(const reco::TrackRef &trackref)
open a resolution map
const PhotonSelectorAlgo * photonSelector_
PhotonSelector.
Definition: PFBlockAlgo.h:363
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)
static bool isLooseMuon(const reco::PFBlockElement &elt)
Definition: PFMuonAlgo.cc:166
void insertTargetElt(reco::PFBlockElement *track)
key_type key() const
Accessor for product key.
Definition: Ref.h:266
std::vector< int > pfcSCVec_
SC corresponding to the PF cluster.
Definition: PFBlockAlgo.h:369
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)
tuple cout
Definition: gather_cfg.py:121
std::vector< bool > Mask
Definition: PFBlockAlgo.h:95
bool bNoSuperclus_
Definition: PFBlockAlgo.h:372
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
tuple size
Write out results.
bool useEGPhotons_
Flag to turn off the import of EG Photons.
Definition: PFBlockAlgo.h:338
bool useKDTreeTrackEcalLinker_
Definition: PFBlockAlgo.h:320
template<template< typename > class T>
void PFBlockAlgo::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_ 
)
inline

COLIN: I think this is for particle flow at HLT...

Definition at line 130 of file PFBlockAlgo.h.

142  {
144  T<reco::GsfPFRecTrackCollection> convbremgsftrackh;
145  //T<reco::MuonCollection> muonh;
147  T<reco::PFRecTrackCollection> nucleartrackh;
153  T<edm::ValueMap<reco::CaloClusterPtr> > pfclusterassoc;
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);
157  }
long double T
template<template< typename > class T>
void PFBlockAlgo::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_ 
)
inline

COLIN: what is this setinput function for? can it be removed?

Definition at line 161 of file PFBlockAlgo.h.

172  {
173  T<reco::GsfPFRecTrackCollection> convbremgsftrackh;
176  T<reco::PFRecTrackCollection> nucleartrackh;
180  setInput<T>( trackh, gsftrackh, convbremgsftrackh, muonh, nuclearh, nucleartrackh, convh, v0, ecalh, hcalh, hoh, psh, egphh,
181  trackMask, gsftrackMask,ecalMask, hcalMask, hoMask, psMask);
182  }
long double T
void PFBlockAlgo::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 
)

Definition at line 31 of file PFBlockAlgo.cc.

References DPtovPtCut_, NHitCut_, nuclearInteractionsPurity_, photonSelector_, superClusterMatchByRef_, useConvBremPFRecTracks_, useEGPhotons_, useIterTracking_, and useSuperClusters_.

Referenced by PFRootEventManager::readOptions().

40  {
41 
42  DPtovPtCut_ = DPtovPtCut;
43  NHitCut_ = NHitCut;
44  useIterTracking_ = useIterTracking;
45  useConvBremPFRecTracks_ = useConvBremPFRecTracks;
46  nuclearInteractionsPurity_ = nuclearInteractionsPurity;
47  useEGPhotons_ = useEGPhotons;
48  // Pt cut; Track iso (constant + slope), Ecal iso (constant + slope), HCAL iso (constant+slope), H/E
49  if(useEGPhotons_)
50  photonSelector_ = new PhotonSelectorAlgo(photonSelectionCuts[0],
51  photonSelectionCuts[1], photonSelectionCuts[2],
52  photonSelectionCuts[3], photonSelectionCuts[4],
53  photonSelectionCuts[5], photonSelectionCuts[6],
54  photonSelectionCuts[7],
55  photonSelectionCuts[8],
56  photonSelectionCuts[9],
57  photonSelectionCuts[10]
58  );
59 
60 
61  useSuperClusters_ = useSuperClusters;
62  superClusterMatchByRef_ = superClusterMatchByRef;
63 }
bool useIterTracking_
Flag to turn off quality cuts which require iterative tracking (for heavy-ions)
Definition: PFBlockAlgo.h:335
int nuclearInteractionsPurity_
Definition: PFBlockAlgo.h:357
std::vector< double > DPtovPtCut_
DPt/Pt cut for creating atrack element.
Definition: PFBlockAlgo.h:329
bool superClusterMatchByRef_
Definition: PFBlockAlgo.h:346
bool useSuperClusters_
Flag to turn off the import of SuperCluster collections.
Definition: PFBlockAlgo.h:341
bool useConvBremPFRecTracks_
switch on/off Conversions Brem Recovery with KF Tracks
Definition: PFBlockAlgo.h:360
const PhotonSelectorAlgo * photonSelector_
PhotonSelector.
Definition: PFBlockAlgo.h:363
bool useEGPhotons_
Flag to turn off the import of EG Photons.
Definition: PFBlockAlgo.h:338
std::vector< unsigned > NHitCut_
Number of layers crossed cut for creating atrack element.
Definition: PFBlockAlgo.h:332
void PFBlockAlgo::setUseOptimization ( bool  useKDTreeTrackEcalLinker)

Definition at line 66 of file PFBlockAlgo.cc.

References useKDTreeTrackEcalLinker_.

Referenced by PFRootEventManager::readOptions().

67 {
68  useKDTreeTrackEcalLinker_ = useKDTreeTrackEcalLinker;
69 }
bool useKDTreeTrackEcalLinker_
Definition: PFBlockAlgo.h:320
double PFBlockAlgo::testECALAndHCAL ( const reco::PFCluster ecal,
const reco::PFCluster hcal 
) const
private

tests association between an ECAL and an HCAL cluster

Returns
distance

Definition at line 936 of file PFBlockAlgo.cc.

References LinkByRecHit::computeDist(), gather_cfg::cout, debug_, and reco::PFCluster::positionREP().

Referenced by link().

937  {
938 
939  // cout<<"entering testECALAndHCAL"<<endl;
940 
941  double dist = fabs(ecal.positionREP().Eta()) > 2.5 ?
943  ecal.positionREP().Phi(),
944  hcal.positionREP().Eta(),
945  hcal.positionREP().Phi() )
946  :
947  -1.;
948 
949 #ifdef PFLOW_DEBUG
950  if(debug_) cout<<"testECALAndHCAL "<< dist <<" "<<endl;
951  if(debug_){
952  cout<<" ecaleta " << ecal.positionREP().Eta()
953  <<" ecalphi " << ecal.positionREP().Phi()
954  <<" hcaleta " << hcal.positionREP().Eta()
955  <<" hcalphi " << hcal.positionREP().Phi()
956  }
957 #endif
958 
959  if ( dist < 0.2 ) return dist;
960 
961  // Need to implement a link by RecHit
962  return -1.;
963 }
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:75
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
double PFBlockAlgo::testHCALAndHO ( const reco::PFCluster hcal,
const reco::PFCluster ho 
) const
private

tests association between an HCAL and an HO cluster

Returns
distance

Definition at line 966 of file PFBlockAlgo.cc.

References LinkByRecHit::computeDist(), gather_cfg::cout, debug_, and reco::PFCluster::positionREP().

Referenced by link().

967  {
968 
969  double dist = fabs(hcal.positionREP().Eta()) < 1.5 ?
971  hcal.positionREP().Phi(),
972  ho.positionREP().Eta(),
973  ho.positionREP().Phi() )
974  :
975  -1.;
976 
977 #ifdef PFLOW_DEBUG
978  if(debug_) cout<<"testHCALAndHO "<< dist <<" "<<endl;
979  if(debug_){
980  cout<<" hcaleta " << hcal.positionREP().Eta()
981  <<" hcalphi " << hcal.positionREP().Phi()
982  <<" hoeta " << ho.positionREP().Eta()
983  <<" hophi " << ho.positionREP().Phi()
984  <<" dist " << dist<<endl;
985  }
986 #endif
987 
988  if ( dist < 0.20 ) return dist;
989 
990  // Need to implement a link by RecHit
991  return -1.;
992 }
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:75
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
double PFBlockAlgo::testLinkBySuperCluster ( const reco::PFClusterRef elt1,
const reco::PFClusterRef elt2 
) const
private

test association by Supercluster between two ECAL

Definition at line 997 of file PFBlockAlgo.cc.

References LinkByRecHit::computeDist(), i, edm::Ref< C, T, F >::key(), pfcSCVec_, and scpfcRefs_.

Referenced by link().

998  {
999 
1000  // cout<<"entering testECALAndECAL "<< pfcRefSCMap_.size() << endl;
1001 
1002  double dist = -1;
1003 
1004  // the first one is not in any super cluster
1005  int testindex=pfcSCVec_[ecal1.key()];
1006  if(testindex == -1.) return dist;
1007  // if(itcheck==pfcRefSCMap_.end()) return dist;
1008  // now retrieve the of PFclusters in this super cluster
1009 
1010  const std::vector<reco::PFClusterRef> & thePFClusters(scpfcRefs_[testindex]);
1011 
1012  unsigned npf=thePFClusters.size();
1013  for(unsigned i=0;i<npf;++i)
1014  {
1015  if(thePFClusters[i]==ecal2) // yes they are in the same SC
1016  {
1017  dist=LinkByRecHit::computeDist( ecal1->positionREP().Eta(),
1018  ecal1->positionREP().Phi(),
1019  ecal2->positionREP().Eta(),
1020  ecal2->positionREP().Phi() );
1021 // std::cout << " DETA " << fabs(ecal1->positionREP().Eta()-ecal2->positionREP().Eta()) << std::endl;
1022 // if(fabs(ecal1->positionREP().Eta()-ecal2->positionREP().Eta())>0.2)
1023 // {
1024 // std::cout << " Super Cluster " << *(superClusters_[testindex]) << std::endl;
1025 // std::cout << " Cluster1 " << *ecal1 << std::endl;
1026 // std::cout << " Cluster2 " << *ecal2 << std::endl;
1027 // ClusterClusterMapping::checkOverlap(*ecal1,superClusters_,0.01,true);
1028 // ClusterClusterMapping::checkOverlap(*ecal2,superClusters_,0.01,true);
1029 // }
1030  return dist;
1031  }
1032  }
1033  return dist;
1034 }
int i
Definition: DBlmapReader.cc:9
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
std::vector< std::vector< reco::PFClusterRef > > scpfcRefs_
PF clusters corresponding to a given SC.
Definition: PFBlockAlgo.h:375
std::vector< int > pfcSCVec_
SC corresponding to the PF cluster.
Definition: PFBlockAlgo.h:369
double PFBlockAlgo::testLinkByVertex ( const reco::PFBlockElement elt1,
const reco::PFBlockElement elt2 
) const
private

Definition at line 1120 of file PFBlockAlgo.cc.

References reco::PFBlockElement::convRef(), gather_cfg::cout, debug_, reco::PFBlockElement::displacedVertexRef(), edm::Ref< C, T, F >::isNonnull(), query::result, reco::PFBlockElement::T_FROM_DISP, reco::PFBlockElement::T_FROM_GAMMACONV, reco::PFBlockElement::T_FROM_V0, reco::PFBlockElement::T_TO_DISP, reco::PFBlockElement::trackType(), and reco::PFBlockElement::V0Ref().

Referenced by link().

1121  {
1122 
1123  // cout << "Test link by vertex between" << endl << *elt1 << endl << " and " << endl << *elt2 << endl;
1124 
1125  double result=-1.;
1126 
1129  PFDisplacedTrackerVertexRef ni1_TO_DISP = elt1->displacedVertexRef(T_TO_DISP);
1130  PFDisplacedTrackerVertexRef ni2_TO_DISP = elt2->displacedVertexRef(T_TO_DISP);
1131  PFDisplacedTrackerVertexRef ni1_FROM_DISP = elt1->displacedVertexRef(T_FROM_DISP);
1132  PFDisplacedTrackerVertexRef ni2_FROM_DISP = elt2->displacedVertexRef(T_FROM_DISP);
1133 
1134  if( ni1_TO_DISP.isNonnull() && ni2_FROM_DISP.isNonnull())
1135  if( ni1_TO_DISP == ni2_FROM_DISP ) { result = 1.0; return result; }
1136 
1137  if( ni1_FROM_DISP.isNonnull() && ni2_TO_DISP.isNonnull())
1138  if( ni1_FROM_DISP == ni2_TO_DISP ) { result = 1.0; return result; }
1139 
1140  if( ni1_FROM_DISP.isNonnull() && ni2_FROM_DISP.isNonnull())
1141  if( ni1_FROM_DISP == ni2_FROM_DISP ) { result = 1.0; return result; }
1142 
1143 
1146 
1147  if(debug_ ) std::cout << " testLinkByVertex On Conversions " << std::endl;
1148 
1149  if ( elt1->convRef().isNonnull() && elt2->convRef().isNonnull() ) {
1150  if(debug_ ) std::cout << " PFBlockAlgo.cc testLinkByVertex Cconversion Refs are non null " << std::endl;
1151  if ( elt1->convRef() == elt2->convRef() ) {
1152  result=1.0;
1153  if(debug_ ) std::cout << " testLinkByVertex Cconversion Refs are equal " << std::endl;
1154  return result;
1155  }
1156  }
1157 
1158  }
1159 
1162  if(debug_ ) std::cout << " testLinkByVertex On V0 " << std::endl;
1163  if ( elt1->V0Ref().isNonnull() && elt2->V0Ref().isNonnull() ) {
1164  if(debug_ ) std::cout << " PFBlockAlgo.cc testLinkByVertex V0 Refs are non null " << std::endl;
1165  if ( elt1->V0Ref() == elt2->V0Ref() ) {
1166  result=1.0;
1167  if(debug_ ) std::cout << " testLinkByVertex V0 Refs are equal " << std::endl;
1168  return result;
1169  }
1170  }
1171  }
1172 
1173  return result;
1174 }
virtual PFDisplacedTrackerVertexRef displacedVertexRef(TrackType trType) const
virtual VertexCompositeCandidateRef V0Ref() const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
tuple result
Definition: query.py:137
virtual bool trackType(TrackType trType) const
virtual ConversionRef convRef() const
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
double PFBlockAlgo::testPS1AndPS2 ( const reco::PFCluster ps1,
const reco::PFCluster ps2 
) const
private

tests association between a PS1 v cluster and a PS2 h cluster returns distance

Definition at line 1068 of file PFBlockAlgo.cc.

References gather_cfg::cout, debug_, reco::CaloCluster::position(), pileupReCalc_HLTpaths::scale, and mathSSE::sqrt().

1069  {
1070 
1071 #ifdef PFLOW_DEBUG
1072  // cout<<"entering testPS1AndPS2"<<endl;
1073 
1074  // compute chi2 in y, z using swimming formulae
1075  // y2 = y1 * z2/z1 and x2 = x1 *z2/z1
1076 
1077  // ps position1 x, y, z
1078  double x1 = ps1.position().X();
1079  double y1 = ps1.position().Y();
1080  double z1 = ps1.position().Z();
1081  double x2 = ps2.position().X();
1082  double y2 = ps2.position().Y();
1083  double z2 = ps2.position().Z();
1084  // MDN Bug correction Jan 09: check that z1 and z2 have the same sign!
1085  if (z1*z2<0.) -1.;
1086  // swim to PS2
1087  double scale = z2/z1;
1088  double x1atPS2 = x1*scale;
1089  double y1atPS2 = y1*scale;
1090  // resolution of PS cluster dxdx and dydy from strip pitch and length
1091  // vertical strips in PS1, measure x with pitch precision
1092  double dx1dx1 = resPSpitch_*resPSpitch_*scale*scale;
1093  double dy1dy1 = resPSlength_*resPSlength_*scale*scale;
1094  // horizontal strips in PS2 , measure y with pitch precision
1095  double dy2dy2 = resPSpitch_*resPSpitch_;
1096  double dx2dx2 = resPSlength_*resPSlength_;
1097 
1098  // double chi2 = (x2-x1atPS2)*(x2-x1atPS2)/(dx1dx1 + dx2dx2)
1099  // + (y2-y1atPS2)*(y2-y1atPS2)/(dy1dy1 + dy2dy2);
1100 
1101  double dist = std::sqrt( (x2-x1atPS2)*(x2-x1atPS2)
1102  + (y2-y1atPS2)*(y2-y1atPS2));
1103 
1104  if(debug_) cout<<"testPS1AndPS2 "<<dist<<" "<<endl;
1105  if(debug_){
1106  cout<<" x1atPS2 "<< x1atPS2 << " dx1 "<<resPSpitch_*scale
1107  <<" y1atPS2 "<< y1atPS2 << " dy1 "<<resPSlength_*scale<< endl
1108  <<" x2 " <<x2 << " dx2 "<<resPSlength_
1109  <<" y2 " << y2 << " dy2 "<<resPSpitch_<< endl;
1110  }
1111 #endif
1112 
1113  // Need a link by rechit here
1114  return -1.;
1115 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:124
T sqrt(T t)
Definition: SSEVec.h:48
tuple cout
Definition: gather_cfg.py:121
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
double PFBlockAlgo::testSuperClusterPFCluster ( const reco::SuperClusterRef sct1,
const reco::PFClusterRef elt2 
) const
private

test association between SuperClusters and ECAL

Definition at line 1038 of file PFBlockAlgo.cc.

References LinkByRecHit::computeDist(), ClusterClusterMapping::overlap(), muon::overlap(), pfclusterassoc_, and superClusterMatchByRef_.

Referenced by link().

1039  {
1040 
1041  // cout<<"entering testECALAndECAL "<< pfcRefSCMap_.size() << endl;
1042 
1043  double dist = -1;
1044 
1046  //loop over supercluster CaloClusters, look up PFCluster ptrs in value map, and match by ref
1047  for (reco::CaloCluster_iterator caloclus = ecal1->clustersBegin(); caloclus!=ecal1->clustersEnd(); ++caloclus) {
1049  if (overlap) dist = 0.001;
1050  }
1051  }
1052  else {
1053  bool overlap=ClusterClusterMapping::overlap(*ecal1,*ecal2);
1054 
1055  if(overlap) {
1056  dist=LinkByRecHit::computeDist( ecal1->position().eta(),
1057  ecal1->position().phi(),
1058  ecal2->positionREP().Eta(),
1059  ecal2->positionREP().Phi() );
1060  }
1061  }
1062  return dist;
1063 }
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
const edm::ValueMap< reco::CaloClusterPtr > * pfclusterassoc_
Definition: PFBlockAlgo.h:348
bool superClusterMatchByRef_
Definition: PFBlockAlgo.h:346
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
double PFBlockAlgo::testTrackAndPS ( const reco::PFRecTrack track,
const reco::PFCluster ps 
) const
private

tests association between a track and a PS cluster returns distance

Definition at line 872 of file PFBlockAlgo.cc.

References gather_cfg::cout, debug_, reco::PFTrack::extrapolatedPoint(), reco::PFTrajectoryPoint::isValid(), reco::PFCluster::layer(), reco::PFTrajectoryPoint::position(), reco::CaloCluster::position(), PFLayer::PS1, reco::PFTrajectoryPoint::PS1, PFLayer::PS2, reco::PFTrajectoryPoint::PS2, and mathSSE::sqrt().

873  {
874 
875 #ifdef PFLOW_DEBUG
876  // cout<<"entering testTrackAndPS"<<endl;
877  // resolution of PS cluster dxdx and dydy from strip pitch and length
878  double dx=0.;
879  double dy=0.;
880 
881  unsigned layerid =0;
882  // PS1: vertical strips PS2: horizontal strips
883  switch (ps.layer()) {
884  case PFLayer::PS1:
886 
887  // vertical strips in PS1, measure x with pitch precision
888  dx = resPSpitch_;
889  dy = resPSlength_;
890  break;
891  case PFLayer::PS2:
893  // horizontal strips in PS2, measure y with pitch precision
894  dy = resPSpitch_;
895  dx = resPSlength_;
896  break;
897  default:
898  break;
899  }
900  const reco::PFTrajectoryPoint& atPS
901  = track.extrapolatedPoint( layerid );
902  // did not reach PS, cannot be associated with a cluster.
903  if( ! atPS.isValid() ) return -1.;
904 
905  double trackx = atPS.position().X();
906  double tracky = atPS.position().Y();
907  double trackz = atPS.position().Z(); // MDN jan 09
908 
909  // ps position x, y
910  double psx = ps.position().X();
911  double psy = ps.position().Y();
912  // MDN Jan 09: check that trackz and psz have the same sign
913  double psz = ps.position().Z();
914  if( trackz*psz < 0.) return -1.;
915 
916  // double chi2 = (psx-trackx)*(psx-trackx)/(dx*dx + trackresolx*trackresolx)
917  // + (psy-tracky)*(psy-tracky)/(dy*dy + trackresoly*trackresoly);
918 
919  double dist = std::sqrt( (psx-trackx)*(psx-trackx)
920  + (psy-tracky)*(psy-tracky));
921  if(debug_) cout<<"testTrackAndPS "<< dist <<" "<<endl;
922  if(debug_){
923  cout<<" trackx " << trackx
924  <<" tracky " << tracky
925  <<" psx " << psx
926  <<" psy " << psy
927  << endl;
928  }
929 #endif
930 
931  // Return -1. as long as no link by rechit is available
932  return -1.;
933 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:81
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:124
const math::XYZPoint & position() const
cartesian position (x, y, z)
T sqrt(T t)
Definition: SSEVec.h:48
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
bool isValid() const
is this point valid ?
tuple cout
Definition: gather_cfg.py:121
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:377
std::auto_ptr< reco::PFBlockCollection > PFBlockAlgo::transferBlocks ( )
inline
Returns
auto_ptr to collection of blocks

Definition at line 198 of file PFBlockAlgo.h.

References blocks_.

Referenced by PFRootEventManager::particleFlow().

198 {return blocks_;}
std::auto_ptr< reco::PFBlockCollection > blocks_
Definition: PFBlockAlgo.h:311

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const PFBlockAlgo a 
)
friend

Definition at line 1285 of file PFBlockAlgo.cc.

1285  {
1286  if(! out) return out;
1287 
1288  out<<"====== Particle Flow Block Algorithm ======= ";
1289  out<<endl;
1290  out<<"number of unassociated elements : "<<a.elements_.size()<<endl;
1291  out<<endl;
1292 
1293  for(PFBlockAlgo::IEC ie = a.elements_.begin();
1294  ie != a.elements_.end(); ++ie) {
1295  out<<"\t"<<**ie <<endl;
1296  }
1297 
1298 
1299  // const PFBlockCollection& blocks = a.blocks();
1300 
1301  const std::auto_ptr< reco::PFBlockCollection >& blocks
1302  = a.blocks();
1303 
1304  if(!blocks.get() ) {
1305  out<<"blocks already transfered"<<endl;
1306  }
1307  else {
1308  out<<"number of blocks : "<<blocks->size()<<endl;
1309  out<<endl;
1310 
1311  for(PFBlockAlgo::IBC ib=blocks->begin();
1312  ib != blocks->end(); ++ib) {
1313  out<<(*ib)<<endl;
1314  }
1315  }
1316 
1317  return out;
1318 }
const std::auto_ptr< reco::PFBlockCollection > & blocks() const
Definition: PFBlockAlgo.h:194
int ib
Definition: cuy.py:660
std::list< reco::PFBlockElement * >::const_iterator IEC
Definition: PFBlockAlgo.h:202
std::list< reco::PFBlockElement * > elements_
actually, particles will be created by a separate producer
Definition: PFBlockAlgo.h:317
tuple out
Definition: dbtoconf.py:99
reco::PFBlockCollection::const_iterator IBC
Definition: PFBlockAlgo.h:203

Member Data Documentation

std::auto_ptr< reco::PFBlockCollection > PFBlockAlgo::blocks_
private

Definition at line 311 of file PFBlockAlgo.h.

Referenced by associate(), blocks(), findBlocks(), and transferBlocks().

bool PFBlockAlgo::bNoSuperclus_
private

Definition at line 372 of file PFBlockAlgo.h.

Referenced by linkPrefilter(), and setInput().

bool PFBlockAlgo::debug_
private
std::vector<double> PFBlockAlgo::DPtovPtCut_
private

DPt/Pt cut for creating atrack element.

Definition at line 329 of file PFBlockAlgo.h.

Referenced by goodPtResolution(), and setParameters().

const PFBlockAlgo::Mask PFBlockAlgo::dummyMask_
staticprivate

Definition at line 326 of file PFBlockAlgo.h.

std::list< reco::PFBlockElement* > PFBlockAlgo::elements_
private

actually, particles will be created by a separate producer

Definition at line 317 of file PFBlockAlgo.h.

Referenced by associate(), findBlocks(), operator<<(), setInput(), and ~PFBlockAlgo().

std::vector<unsigned> PFBlockAlgo::NHitCut_
private

Number of layers crossed cut for creating atrack element.

Definition at line 332 of file PFBlockAlgo.h.

Referenced by goodPtResolution(), and setParameters().

int PFBlockAlgo::nuclearInteractionsPurity_
private

Definition at line 357 of file PFBlockAlgo.h.

Referenced by setInput(), and setParameters().

const edm::ValueMap<reco::CaloClusterPtr>* PFBlockAlgo::pfclusterassoc_
private

Definition at line 348 of file PFBlockAlgo.h.

Referenced by setInput(), and testSuperClusterPFCluster().

std::vector<int> PFBlockAlgo::pfcSCVec_
private

SC corresponding to the PF cluster.

Definition at line 369 of file PFBlockAlgo.h.

Referenced by setInput(), and testLinkBySuperCluster().

const PhotonSelectorAlgo* PFBlockAlgo::photonSelector_
private

PhotonSelector.

Definition at line 363 of file PFBlockAlgo.h.

Referenced by setInput(), setParameters(), and ~PFBlockAlgo().

KDTreeLinkerPSEcal PFBlockAlgo::PSELinker_
private

Definition at line 323 of file PFBlockAlgo.h.

Referenced by findBlocks(), and setInput().

std::vector<std::vector<reco::PFClusterRef> > PFBlockAlgo::scpfcRefs_
private

PF clusters corresponding to a given SC.

Definition at line 375 of file PFBlockAlgo.h.

Referenced by setInput(), and testLinkBySuperCluster().

bool PFBlockAlgo::superClusterMatchByRef_
private

Definition at line 346 of file PFBlockAlgo.h.

Referenced by setInput(), setParameters(), and testSuperClusterPFCluster().

std::vector<reco::SuperClusterRef > PFBlockAlgo::superClusters_
private

list of superclusters

Definition at line 365 of file PFBlockAlgo.h.

Referenced by setInput().

KDTreeLinkerTrackEcal PFBlockAlgo::TELinker_
private

Definition at line 321 of file PFBlockAlgo.h.

Referenced by findBlocks(), and setInput().

KDTreeLinkerTrackHcal PFBlockAlgo::THLinker_
private

Definition at line 322 of file PFBlockAlgo.h.

Referenced by findBlocks(), and setInput().

bool PFBlockAlgo::useConvBremPFRecTracks_
private

switch on/off Conversions Brem Recovery with KF Tracks

Definition at line 360 of file PFBlockAlgo.h.

Referenced by link(), setInput(), and setParameters().

bool PFBlockAlgo::useEGPhotons_
private

Flag to turn off the import of EG Photons.

Definition at line 338 of file PFBlockAlgo.h.

Referenced by setInput(), and setParameters().

bool PFBlockAlgo::useHO_
private

Definition at line 382 of file PFBlockAlgo.h.

Referenced by setHOTag(), and setInput().

bool PFBlockAlgo::useIterTracking_
private

Flag to turn off quality cuts which require iterative tracking (for heavy-ions)

Definition at line 335 of file PFBlockAlgo.h.

Referenced by goodPtResolution(), and setParameters().

bool PFBlockAlgo::useKDTreeTrackEcalLinker_
private

Definition at line 320 of file PFBlockAlgo.h.

Referenced by findBlocks(), link(), linkPrefilter(), setInput(), and setUseOptimization().

bool PFBlockAlgo::useSuperClusters_
private

Flag to turn off the import of SuperCluster collections.

Definition at line 341 of file PFBlockAlgo.h.

Referenced by setInput(), and setParameters().