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
00054 void doClustering( const PFRecHitHandle& rechitsHandle );
00055
00057
00059 void setThreshBarrel(double thresh) {threshBarrel_ = thresh;}
00060 void setThreshPtBarrel(double thresh) {threshPtBarrel_ = thresh;}
00061
00063 void setThreshSeedBarrel(double thresh) {threshSeedBarrel_ = thresh;}
00064 void setThreshPtSeedBarrel(double thresh) {threshPtSeedBarrel_ = thresh;}
00065
00067 void setThreshCleanBarrel(double thresh) {threshCleanBarrel_ = thresh;}
00068 void setS4S1CleanBarrel(const std::vector<double>& coeffs) {minS4S1Barrel_ = coeffs;}
00069
00071 void setThreshDoubleSpikeBarrel( double thresh ) { threshDoubleSpikeBarrel_ = thresh;}
00072 void setS6S2DoubleSpikeBarrel( double cut ) { minS6S2DoubleSpikeBarrel_ = cut;}
00073
00075 void setThreshEndcap(double thresh) {threshEndcap_ = thresh;}
00076 void setThreshPtEndcap(double thresh) {threshPtEndcap_ = thresh;}
00077
00079 void setThreshSeedEndcap(double thresh) {threshSeedEndcap_ = thresh;}
00080 void setThreshPtSeedEndcap(double thresh) {threshPtSeedEndcap_ = thresh;}
00081
00083 void setThreshCleanEndcap(double thresh) {threshCleanEndcap_ = thresh;}
00084 void setS4S1CleanEndcap(const std::vector<double>& coeffs) {minS4S1Endcap_ = coeffs;}
00085
00087 void setThreshDoubleSpikeEndcap( double thresh ) { threshDoubleSpikeEndcap_ = thresh;}
00088 void setS6S2DoubleSpikeEndcap( double cut ) { minS6S2DoubleSpikeEndcap_ = cut;}
00089
00091 void setHistos(TFile* file, TH2F* hB, TH2F* hE) {file_=file; hBNeighbour = hB; hENeighbour = hE;}
00092
00094 void setNNeighbours(int n) { nNeighbours_ = n;}
00095
00097 void setPosCalcP1( double p1 ) { posCalcP1_ = p1; }
00098
00100 void setPosCalcNCrystal(int n) { posCalcNCrystal_ = n;}
00101
00103 void setShowerSigma( double sigma ) { showerSigma_ = sigma;}
00104
00106 void setUseCornerCells( bool usecornercells ) { useCornerCells_ = usecornercells;}
00107
00109 void setCleanRBXandHPDs( bool cleanRBXandHPDs) { cleanRBXandHPDs_ = cleanRBXandHPDs; }
00110
00112 void setMask( const std::vector<bool>& mask );
00113
00115
00117 double threshBarrel() const {return threshBarrel_;}
00118
00120 double threshSeedBarrel() const {return threshSeedBarrel_;}
00121
00122
00124 double threshEndcap() const {return threshEndcap_;}
00125
00127 double threshSeedEndcap() const {return threshSeedEndcap_;}
00128
00129
00131 int nNeighbours() const { return nNeighbours_;}
00132
00134 double posCalcP1() const { return posCalcP1_; }
00135
00137 int posCalcNCrystal() const {return posCalcNCrystal_;}
00138
00140 double showerSigma() const { return showerSigma_ ;}
00141
00143 void write();
00145
00146
00147
00149 const reco::PFRecHit& rechit(unsigned i,
00150 const reco::PFRecHitCollection& rechits );
00151
00153 bool masked(unsigned rhi) const;
00154
00155 enum Color {
00156 NONE=0,
00157 SEED,
00158 SPECIAL
00159 };
00160
00162 unsigned color(unsigned rhi) const;
00163
00165 bool isSeed(unsigned rhi) const;
00166
00168 std::auto_ptr< std::vector< reco::PFCluster > >& clusters()
00169 {return pfClusters_;}
00170
00172 std::auto_ptr< std::vector< reco::PFRecHit > >& rechitsCleaned()
00173 {return pfRecHitsCleaned_;}
00174
00177
00178 enum Parameter { THRESH,
00179 SEED_THRESH,
00180 PT_THRESH,
00181 SEED_PT_THRESH,
00182 CLEAN_THRESH,
00183 CLEAN_S4S1,
00184 DOUBLESPIKE_THRESH,
00185 DOUBLESPIKE_S6S2
00186 };
00187
00188
00191 double parameter( Parameter paramtype, PFLayer::Layer layer, unsigned iCoeff = 0) const;
00192
00193
00194 enum SeedState {
00195 UNKNOWN=-1,
00196 NO=0,
00197 YES=1,
00198 CLEAN=2
00199 };
00200
00201
00202 friend std::ostream& operator<<(std::ostream& out,const PFClusterAlgo& algo);
00203
00204 typedef std::map<unsigned, unsigned >::const_iterator IDH;
00205 typedef std::multimap<double, unsigned >::iterator EH;
00206
00207
00208 private:
00209
00211 void cleanRBXAndHPD( const reco::PFRecHitCollection& rechits );
00212
00214 void findSeeds( const reco::PFRecHitCollection& rechits );
00215
00217 void buildTopoClusters( const reco::PFRecHitCollection& rechits );
00218
00220 void buildTopoCluster( std::vector< unsigned >& cluster, unsigned rhi,
00221 const reco::PFRecHitCollection& rechits );
00222
00224 void buildPFClusters( const std::vector< unsigned >& cluster,
00225 const reco::PFRecHitCollection& rechits );
00226
00228 void calculateClusterPosition( reco::PFCluster& cluster,
00229 reco::PFCluster& clusterwodepthcor,
00230 bool depcor = true,
00231 int posCalcNCrystal=0);
00232
00235 reco::PFRecHitRef createRecHitRef( const reco::PFRecHitCollection& rechits,
00236 unsigned rhi );
00237
00239 void paint( unsigned rhi, unsigned color=1 );
00240
00242 std::pair<double,double> dCrack(double phi, double eta);
00243
00244
00245 PFRecHitHandle rechitsHandle_;
00246
00248 std::set<unsigned> idUsedRecHits_;
00249
00251 std::multimap<double, unsigned, std::greater<double> > eRecHits_;
00252
00255 std::vector< bool > mask_;
00256
00258 std::vector< unsigned > color_;
00259
00261 std::vector< SeedState > seedStates_;
00262
00264 std::vector< bool > usedInTopo_;
00265
00267 std::vector< unsigned > seeds_;
00268
00270 std::vector< std::vector< unsigned > > topoClusters_;
00271
00273
00274
00276 std::auto_ptr< std::vector<reco::PFCluster> > pfClusters_;
00277
00279 std::auto_ptr< std::vector<reco::PFRecHit> > pfRecHitsCleaned_;
00280
00282 double threshBarrel_;
00283 double threshPtBarrel_;
00284
00286 double threshSeedBarrel_;
00287 double threshPtSeedBarrel_;
00288
00290 double threshEndcap_;
00291 double threshPtEndcap_;
00292
00294 double threshSeedEndcap_;
00295 double threshPtSeedEndcap_;
00296
00298 double threshCleanBarrel_;
00299 std::vector<double> minS4S1Barrel_;
00300
00302 double threshDoubleSpikeBarrel_;
00303 double minS6S2DoubleSpikeBarrel_;
00304
00306 double threshCleanEndcap_;
00307 std::vector<double> minS4S1Endcap_;
00308
00310 double threshDoubleSpikeEndcap_;
00311 double minS6S2DoubleSpikeEndcap_;
00312
00314 int nNeighbours_;
00315
00317 int posCalcNCrystal_;
00318
00320 double posCalcP1_;
00321
00323 double showerSigma_;
00324
00326 bool useCornerCells_;
00327
00329 bool cleanRBXandHPDs_;
00330
00332 bool debug_;
00333
00334
00336 static unsigned prodNum_;
00337
00338
00339 TH2F* hBNeighbour;
00340 TH2F* hENeighbour;
00341 TFile* file_;
00342
00343 };
00344
00345 #endif