CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFClusterAlgo.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFClusterAlgo_h
2 #define RecoParticleFlow_PFClusterProducer_PFClusterAlgo_h
3 
4 
10 
11 // for E/gamma position calc
14 
15 #include <string>
16 #include <vector>
17 #include <map>
18 #include <set>
19 
20 #include <memory>
21 
22 class TFile;
23 class TH2F;
24 
26 
37 namespace edm {
38  template<>
39  struct StrictWeakOrdering<reco::PFRecHit> {
40  typedef unsigned key_type;
41  bool operator()(unsigned a, reco::PFRecHit const& b) const {
42  return a < b.detId();
43  }
44  bool operator()(reco::PFRecHit const& a, unsigned b) const {
45  return a.detId() < b;
46  }
47  bool operator()(reco::PFRecHit const& a, reco::PFRecHit const& b) const {
48  return ( a.detId() < b.detId() );
49  }
50  };
51 }
52 
54 
55  public:
56 
60 
65 
67  PFClusterAlgo();
68 
70  virtual ~PFClusterAlgo() {;}
71 
73  // void init(const std::map<unsigned, reco::PFRecHit* >& rechits );
74 
76  void enableDebugging(bool debug) { debug_ = debug;}
77 
78 
80 
84  const std::vector<bool> & mask );
85 
87  void doClustering( const PFRecHitHandle& rechitsHandle );
88  void doClustering( const PFRecHitHandle& rechitsHandle,
89  const std::vector<bool> & mask );
90 
92 
96 
100 
103  void setS4S1CleanBarrel(const std::vector<double>& coeffs) {minS4S1Barrel_ = coeffs;}
104 
108 
112 
116 
119  void setS4S1CleanEndcap(const std::vector<double>& coeffs) {minS4S1Endcap_ = coeffs;}
120 
124 
126  void setHistos(TFile* file, TH2F* hB, TH2F* hE) {file_=file; hBNeighbour = hB; hENeighbour = hE;}
127 
129  void setNNeighbours(int n) { nNeighbours_ = n;}
130 
131  // set position calculation variant
133 
134  // setup E/gamma position calc
136  eg_pos_calc.reset(new PositionCalc(conf));
137  }
139  eb_geom = esh;
140  }
142  ee_geom = esh;
143  }
145  preshower_geom = esh;
146  }
147 
148  // set W0 parameter for EG-type position formula
149  void setPosCalcW0( double w0 ) { param_W0_ = w0; }
150 
152  void setPosCalcP1( double p1 ) { posCalcP1_ = p1; }
153 
156 
158  void setShowerSigma( double sigma ) { showerSigma_ = sigma;}
159 
161  void setUseCornerCells( bool usecornercells ) { useCornerCells_ = usecornercells;}
162 
164  void setCleanRBXandHPDs( bool cleanRBXandHPDs) { cleanRBXandHPDs_ = cleanRBXandHPDs; }
165 
167 
169  double threshBarrel() const {return threshBarrel_;}
170 
172  double threshSeedBarrel() const {return threshSeedBarrel_;}
173 
174 
176  double threshEndcap() const {return threshEndcap_;}
177 
179  double threshSeedEndcap() const {return threshSeedEndcap_;}
180 
181 
183  int nNeighbours() const { return nNeighbours_;}
184 
186  double posCalcP1() const { return posCalcP1_; }
187 
189  int posCalcNCrystal() const {return posCalcNCrystal_;}
190 
192  double showerSigma() const { return showerSigma_ ;}
193 
195  void write();
197 
198 
199 
201  const reco::PFRecHit& rechit(unsigned i,
203 
205  bool masked(unsigned rhi) const;
206 
207  enum Color {
208  NONE=0,
211  };
212 
214  unsigned color(unsigned rhi) const;
215 
217  bool isSeed(unsigned rhi) const;
218 
220  std::auto_ptr< std::vector< reco::PFCluster > >& clusters()
221  {return pfClusters_;}
222 
224  std::auto_ptr< std::vector< reco::PFRecHit > >& rechitsCleaned()
225  {return pfRecHitsCleaned_;}
226 
229 
230  enum Parameter { THRESH,
238  };
239 
242  double parameter( Parameter paramtype, PFLayer::Layer layer, unsigned iCoeff = 0, int iring0=0) const;
243 
244 
245  enum SeedState {
247  NO=0,
248  YES=1,
250  };
251 
252 
253  friend std::ostream& operator<<(std::ostream& out,const PFClusterAlgo& algo);
254 
255  typedef std::map<unsigned, unsigned >::const_iterator IDH;
256  typedef std::multimap<double, unsigned >::iterator EH;
257 
258 
259  private:
262 
265 
268 
271 
273  void buildTopoCluster( std::vector< unsigned >& cluster, unsigned rhi,
275 
277  void buildPFClusters( const std::vector< unsigned >& cluster,
279 
282  reco::PFCluster& clusterwodepthcor,
283  bool depcor = true,
284  int posCalcNCrystal=0);
285 
289  unsigned rhi );
290 
292  void paint( unsigned rhi, unsigned color=1 );
293 
295  std::pair<double,double> dCrack(double phi, double eta);
296 
298  // for E\gamma Position calc
299  std::auto_ptr<SortedPFRecHitCollection> sortedRecHits_;
300 
302  std::set<unsigned> idUsedRecHits_;
303 
305  std::multimap<double, unsigned, std::greater<double> > eRecHits_;
306 
309  std::vector< bool > mask_;
310 
312  std::vector< unsigned > color_;
313 
315  std::vector< SeedState > seedStates_;
316 
318  std::vector< bool > usedInTopo_;
319 
321  std::vector< unsigned > seeds_;
322 
324  std::vector< std::vector< unsigned > > topoClusters_;
325 
327  // std::vector< reco::PFCluster > allClusters_;
328 
330  std::auto_ptr< std::vector<reco::PFCluster> > pfClusters_;
331 
333  std::auto_ptr< std::vector<reco::PFRecHit> > pfRecHitsCleaned_;
334 
338 
342 
346 
350 
353  std::vector<double> minS4S1Barrel_;
354 
358 
361  std::vector<double> minS4S1Endcap_;
362 
366 
369 
372 
375  double posCalcP1_;
376  double param_W0_; // for EG position calc variant
377  std::auto_ptr<PositionCalc> eg_pos_calc; //directly use E/gamma pos calc
379 
381  double showerSigma_;
382 
385 
388 
390  bool debug_;
391 
392 
394  static unsigned prodNum_;
395 
396  // Histograms
397  TH2F* hBNeighbour;
398  TH2F* hENeighbour;
399  TFile* file_;
400 
401 };
402 
403 #endif
friend std::ostream & operator<<(std::ostream &out, const PFClusterAlgo &algo)
double posCalcP1() const
get p1 for position calculation
void setThreshCleanBarrel(double thresh)
set barrel clean threshold
void cleanRBXAndHPD(const reco::PFRecHitCollection &rechits)
Clean HCAL readout box noise and HPD discharge.
int i
Definition: DBlmapReader.cc:9
edm::Handle< reco::PFRecHitCollection > PFRecHitHandle
Definition: PFClusterAlgo.h:79
void setThreshDoubleSpikeEndcap(double thresh)
set endcap thresholds for double spike cleaning
std::multimap< double, unsigned >::iterator EH
int posCalcNCrystal_
number of crystals for position calculation
double showerSigma() const
get shower sigma
double threshEndcap_
endcap threshold
void setShowerSigma(double sigma)
set shower sigma for
double threshDoubleSpikeBarrel_
Barrel double-spike cleaning.
double threshBarrel() const
getters -------------------------------------------------——
void setPositionCalcType(const PositionCalcType &t)
void setPosCalcP1(double p1)
set p1 for position calculation
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:43
void doClustering(const reco::PFRecHitCollection &rechits)
perform clustering
const CaloSubdetectorGeometry * eb_geom
std::vector< unsigned > color_
color, for all rechits
void setPosCalcNCrystal(int n)
set number of crystals for position calculation (-1 all,5, or 9)
PFRecHitHandle rechitsHandle_
void setThreshSeedBarrel(double thresh)
set barrel seed threshold
Definition: PFClusterAlgo.h:98
unsigned detId() const
rechit detId
Definition: PFRecHit.h:105
edm::StrictWeakOrdering< reco::PFRecHit > PFStrictWeakOrdering
Definition: PFClusterAlgo.h:57
void setS6S2DoubleSpikeEndcap(double cut)
std::pair< double, double > dCrack(double phi, double eta)
distance to a crack in the ECAL barrel in eta and phi direction
bool isSeed(unsigned rhi) const
const reco::PFRecHit & rechit(unsigned i, const reco::PFRecHitCollection &rechits)
double threshDoubleSpikeEndcap_
Endcap double-spike cleaning.
double threshPtEndcap_
TH2F * hENeighbour
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
std::multimap< double, unsigned, std::greater< double > > eRecHits_
indices to rechits, sorted by decreasing E (not E_T)
std::vector< double > minS4S1Barrel_
bool operator()(reco::PFRecHit const &a, reco::PFRecHit const &b) const
Definition: PFClusterAlgo.h:47
double threshPtSeedEndcap_
void setThreshBarrel(double thresh)
setters -------------------------------------------------——
Definition: PFClusterAlgo.h:94
double threshPtSeedBarrel_
T eta() const
std::map< unsigned, unsigned >::const_iterator IDH
std::vector< SeedState > seedStates_
seed state, for all rechits
void setUseCornerCells(bool usecornercells)
activate use of cells with a common corner to build topo-clusters
std::vector< std::vector< unsigned > > topoClusters_
sets of cells having one common side, and energy over threshold
std::auto_ptr< std::vector< reco::PFRecHit > > pfRecHitsCleaned_
particle flow rechits cleaned
std::vector< bool > usedInTopo_
used in topo cluster? for all rechits
bool operator()(reco::PFRecHit const &a, unsigned b) const
Definition: PFClusterAlgo.h:44
void setThreshPtSeedBarrel(double thresh)
Definition: PFClusterAlgo.h:99
double threshSeedBarrel_
barrel seed threshold
std::set< unsigned > idUsedRecHits_
ids of rechits used in seed search
void setThreshSeedEndcap(double thresh)
set endcap seed threshold
edm::Handle< edm::View< reco::PFCluster > > PFClusterHandle
Definition: PFClusterAlgo.h:59
bool masked(unsigned rhi) const
std::vector< unsigned > seeds_
vector of indices for seeds.
void doClusteringWorker(const reco::PFRecHitCollection &rechits)
perform clustering
TH2F * hBNeighbour
int posCalcNCrystal() const
get number of crystals for position calculation (-1 all,5, or 9)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
bool operator()(unsigned a, reco::PFRecHit const &b) const
Definition: PFClusterAlgo.h:41
const CaloSubdetectorGeometry * preshower_geom
std::vector< bool > mask_
bool cleanRBXandHPDs_
option to clean HCAL RBX&#39;s and HPD&#39;s
std::auto_ptr< std::vector< reco::PFRecHit > > & rechitsCleaned()
void setNNeighbours(int n)
set number of neighbours for
double threshEndcap() const
get endcap threshold
void buildTopoClusters(const reco::PFRecHitCollection &rechits)
build topoclusters around seeds
void setS4S1CleanBarrel(const std::vector< double > &coeffs)
void setThreshPtSeedEndcap(double thresh)
std::auto_ptr< PositionCalc > eg_pos_calc
void setThreshPtEndcap(double thresh)
std::vector< double > minS4S1Endcap_
void setThreshEndcap(double thresh)
set endcap threshold
void findSeeds(const reco::PFRecHitCollection &rechits)
look for seeds
tuple conf
Definition: dbtoconf.py:185
PFClusterAlgo()
constructor
void setThreshDoubleSpikeBarrel(double thresh)
set endcap thresholds for double spike cleaning
tuple out
Definition: dbtoconf.py:99
Layer
layer definition
Definition: PFLayer.h:31
double threshCleanBarrel_
Barrel cleaning threshold and S4/S1 smallest fractiom.
bool debug_
debugging on/off
virtual ~PFClusterAlgo()
destructor
Definition: PFClusterAlgo.h:70
int nNeighbours_
number of neighbours
reco::PFRecHitRef createRecHitRef(const reco::PFRecHitCollection &rechits, unsigned rhi)
#define debug
Definition: HDRShower.cc:19
void buildTopoCluster(std::vector< unsigned > &cluster, unsigned rhi, const reco::PFRecHitCollection &rechits)
build a topocluster (recursive)
double minS6S2DoubleSpikeEndcap_
void write()
write histos
PositionCalcType which_pos_calc_
parameter for position calculation
double showerSigma_
sigma of shower (cm)
double b
Definition: hdecay.h:120
void paint(unsigned rhi, unsigned color=1)
paint a rechit with a color.
double parameter(Parameter paramtype, PFLayer::Layer layer, unsigned iCoeff=0, int iring0=0) const
double threshSeedBarrel() const
get barrel seed threshold
void setThreshPtBarrel(double thresh)
Definition: PFClusterAlgo.h:95
std::auto_ptr< std::vector< reco::PFCluster > > & clusters()
double p1[4]
Definition: TauolaWrapper.h:89
double a
Definition: hdecay.h:121
void setCleanRBXandHPDs(bool cleanRBXandHPDs)
Activate cleaning of HCAL RBX&#39;s and HPD&#39;s.
double threshBarrel_
barrel threshold
bool useCornerCells_
option to use cells with a common corner to build topo-clusters
void setS6S2DoubleSpikeBarrel(double cut)
static unsigned prodNum_
product number
void enableDebugging(bool debug)
set hits on which clustering will be performed
Definition: PFClusterAlgo.h:76
void setS4S1CleanEndcap(const std::vector< double > &coeffs)
void calculateClusterPosition(reco::PFCluster &cluster, reco::PFCluster &clusterwodepthcor, bool depcor=true, int posCalcNCrystal=0)
calculate position of a cluster
const CaloSubdetectorGeometry * ee_geom
std::auto_ptr< SortedPFRecHitCollection > sortedRecHits_
double threshSeedEndcap_
endcap seed threshold
std::auto_ptr< std::vector< reco::PFCluster > > pfClusters_
all clusters
void setEEGeom(const CaloSubdetectorGeometry *esh)
double threshPtBarrel_
void setThreshCleanEndcap(double thresh)
set endcap clean threshold
void setEBGeom(const CaloSubdetectorGeometry *esh)
void setPosCalcW0(double w0)
void setHistos(TFile *file, TH2F *hB, TH2F *hE)
set endcap clean threshold
edm::SortedCollection< reco::PFRecHit > SortedPFRecHitCollection
Definition: PFClusterAlgo.h:58
void buildPFClusters(const std::vector< unsigned > &cluster, const reco::PFRecHitCollection &rechits)
build PFClusters from a topocluster
unsigned color(unsigned rhi) const
double minS6S2DoubleSpikeBarrel_
void setEGammaPosCalc(const edm::ParameterSet &conf)
double threshCleanEndcap_
Endcap cleaning threshold and S4/S1 smallest fractiom.
void setPreshowerGeom(const CaloSubdetectorGeometry *esh)
double threshSeedEndcap() const
get endcap seed threshold
int nNeighbours() const
get number of neighbours for
Definition: DDAxes.h:10