Go to the documentation of this file.00001 #ifndef RecoParticleFlow_PFClusterProducer_PFClusterAlgo_h
00002 #define RecoParticleFlow_PFClusterProducer_PFClusterAlgo_h
00003
00004 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
00005 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
00006 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h"
00007 #include "DataFormats/ParticleFlowReco/interface/PFLayer.h"
00008 #include "DataFormats/Common/interface/OrphanHandle.h"
00009
00010 #include <string>
00011 #include <vector>
00012 #include <map>
00013 #include <set>
00014
00015 #include <memory>
00016
00017 class TFile;
00018 class TH2F;
00019
00021
00031 class PFClusterAlgo {
00032
00033 public:
00034
00036 PFClusterAlgo();
00037
00039 virtual ~PFClusterAlgo() {;}
00040
00042
00043
00045 void enableDebugging(bool debug) { debug_ = debug;}
00046
00047
00048 typedef edm::Handle< reco::PFRecHitCollection > PFRecHitHandle;
00049
00051 void doClustering( const reco::PFRecHitCollection& rechits );
00052 void doClustering( const reco::PFRecHitCollection& rechits, const std::vector<bool> & mask );
00053
00055 void doClustering( const PFRecHitHandle& rechitsHandle );
00056 void doClustering( const PFRecHitHandle& rechitsHandle, const std::vector<bool> & mask );
00057
00059
00061 void setThreshBarrel(double thresh) {threshBarrel_ = thresh;}
00062 void setThreshPtBarrel(double thresh) {threshPtBarrel_ = thresh;}
00063
00065 void setThreshSeedBarrel(double thresh) {threshSeedBarrel_ = thresh;}
00066 void setThreshPtSeedBarrel(double thresh) {threshPtSeedBarrel_ = thresh;}
00067
00069 void setThreshCleanBarrel(double thresh) {threshCleanBarrel_ = thresh;}
00070 void setS4S1CleanBarrel(const std::vector<double>& coeffs) {minS4S1Barrel_ = coeffs;}
00071
00073 void setThreshDoubleSpikeBarrel( double thresh ) { threshDoubleSpikeBarrel_ = thresh;}
00074 void setS6S2DoubleSpikeBarrel( double cut ) { minS6S2DoubleSpikeBarrel_ = cut;}
00075
00077 void setThreshEndcap(double thresh) {threshEndcap_ = thresh;}
00078 void setThreshPtEndcap(double thresh) {threshPtEndcap_ = thresh;}
00079
00081 void setThreshSeedEndcap(double thresh) {threshSeedEndcap_ = thresh;}
00082 void setThreshPtSeedEndcap(double thresh) {threshPtSeedEndcap_ = thresh;}
00083
00085 void setThreshCleanEndcap(double thresh) {threshCleanEndcap_ = thresh;}
00086 void setS4S1CleanEndcap(const std::vector<double>& coeffs) {minS4S1Endcap_ = coeffs;}
00087
00089 void setThreshDoubleSpikeEndcap( double thresh ) { threshDoubleSpikeEndcap_ = thresh;}
00090 void setS6S2DoubleSpikeEndcap( double cut ) { minS6S2DoubleSpikeEndcap_ = cut;}
00091
00093 void setHistos(TFile* file, TH2F* hB, TH2F* hE) {file_=file; hBNeighbour = hB; hENeighbour = hE;}
00094
00096 void setNNeighbours(int n) { nNeighbours_ = n;}
00097
00099 void setPosCalcP1( double p1 ) { posCalcP1_ = p1; }
00100
00102 void setPosCalcNCrystal(int n) { posCalcNCrystal_ = n;}
00103
00105 void setShowerSigma( double sigma ) { showerSigma_ = sigma;}
00106
00108 void setUseCornerCells( bool usecornercells ) { useCornerCells_ = usecornercells;}
00109
00111 void setCleanRBXandHPDs( bool cleanRBXandHPDs) { cleanRBXandHPDs_ = cleanRBXandHPDs; }
00112
00114
00116 double threshBarrel() const {return threshBarrel_;}
00117
00119 double threshSeedBarrel() const {return threshSeedBarrel_;}
00120
00121
00123 double threshEndcap() const {return threshEndcap_;}
00124
00126 double threshSeedEndcap() const {return threshSeedEndcap_;}
00127
00128
00130 int nNeighbours() const { return nNeighbours_;}
00131
00133 double posCalcP1() const { return posCalcP1_; }
00134
00136 int posCalcNCrystal() const {return posCalcNCrystal_;}
00137
00139 double showerSigma() const { return showerSigma_ ;}
00140
00142 void write();
00144
00145
00146
00148 const reco::PFRecHit& rechit(unsigned i,
00149 const reco::PFRecHitCollection& rechits );
00150
00152 bool masked(unsigned rhi) const;
00153
00154 enum Color {
00155 NONE=0,
00156 SEED,
00157 SPECIAL
00158 };
00159
00161 unsigned color(unsigned rhi) const;
00162
00164 bool isSeed(unsigned rhi) const;
00165
00167 std::auto_ptr< std::vector< reco::PFCluster > >& clusters()
00168 {return pfClusters_;}
00169
00171 std::auto_ptr< std::vector< reco::PFRecHit > >& rechitsCleaned()
00172 {return pfRecHitsCleaned_;}
00173
00176
00177 enum Parameter { THRESH,
00178 SEED_THRESH,
00179 PT_THRESH,
00180 SEED_PT_THRESH,
00181 CLEAN_THRESH,
00182 CLEAN_S4S1,
00183 DOUBLESPIKE_THRESH,
00184 DOUBLESPIKE_S6S2
00185 };
00186
00187
00190 double parameter( Parameter paramtype, PFLayer::Layer layer, unsigned iCoeff = 0, int iring0=0) const;
00191
00192
00193 enum SeedState {
00194 UNKNOWN=-1,
00195 NO=0,
00196 YES=1,
00197 CLEAN=2
00198 };
00199
00200
00201 friend std::ostream& operator<<(std::ostream& out,const PFClusterAlgo& algo);
00202
00203 typedef std::map<unsigned, unsigned >::const_iterator IDH;
00204 typedef std::multimap<double, unsigned >::iterator EH;
00205
00206
00207 private:
00209 void doClusteringWorker( const reco::PFRecHitCollection& rechits );
00210
00212 void cleanRBXAndHPD( const reco::PFRecHitCollection& rechits );
00213
00215 void findSeeds( const reco::PFRecHitCollection& rechits );
00216
00218 void buildTopoClusters( const reco::PFRecHitCollection& rechits );
00219
00221 void buildTopoCluster( std::vector< unsigned >& cluster, unsigned rhi,
00222 const reco::PFRecHitCollection& rechits );
00223
00225 void buildPFClusters( const std::vector< unsigned >& cluster,
00226 const reco::PFRecHitCollection& rechits );
00227
00229 void calculateClusterPosition( reco::PFCluster& cluster,
00230 reco::PFCluster& clusterwodepthcor,
00231 bool depcor = true,
00232 int posCalcNCrystal=0);
00233
00236 reco::PFRecHitRef createRecHitRef( const reco::PFRecHitCollection& rechits,
00237 unsigned rhi );
00238
00240 void paint( unsigned rhi, unsigned color=1 );
00241
00243 std::pair<double,double> dCrack(double phi, double eta);
00244
00245
00246 PFRecHitHandle rechitsHandle_;
00247
00249 std::set<unsigned> idUsedRecHits_;
00250
00252 std::multimap<double, unsigned, std::greater<double> > eRecHits_;
00253
00256 std::vector< bool > mask_;
00257
00259 std::vector< unsigned > color_;
00260
00262 std::vector< SeedState > seedStates_;
00263
00265 std::vector< bool > usedInTopo_;
00266
00268 std::vector< unsigned > seeds_;
00269
00271 std::vector< std::vector< unsigned > > topoClusters_;
00272
00274
00275
00277 std::auto_ptr< std::vector<reco::PFCluster> > pfClusters_;
00278
00280 std::auto_ptr< std::vector<reco::PFRecHit> > pfRecHitsCleaned_;
00281
00283 double threshBarrel_;
00284 double threshPtBarrel_;
00285
00287 double threshSeedBarrel_;
00288 double threshPtSeedBarrel_;
00289
00291 double threshEndcap_;
00292 double threshPtEndcap_;
00293
00295 double threshSeedEndcap_;
00296 double threshPtSeedEndcap_;
00297
00299 double threshCleanBarrel_;
00300 std::vector<double> minS4S1Barrel_;
00301
00303 double threshDoubleSpikeBarrel_;
00304 double minS6S2DoubleSpikeBarrel_;
00305
00307 double threshCleanEndcap_;
00308 std::vector<double> minS4S1Endcap_;
00309
00311 double threshDoubleSpikeEndcap_;
00312 double minS6S2DoubleSpikeEndcap_;
00313
00315 int nNeighbours_;
00316
00318 int posCalcNCrystal_;
00319
00321 double posCalcP1_;
00322
00324 double showerSigma_;
00325
00327 bool useCornerCells_;
00328
00330 bool cleanRBXandHPDs_;
00331
00333 bool debug_;
00334
00335
00337 static unsigned prodNum_;
00338
00339
00340 TH2F* hBNeighbour;
00341 TH2F* hENeighbour;
00342 TFile* file_;
00343
00344 };
00345
00346 #endif