CMS 3D CMS Logo

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

Producer for particle flow clusters (PFCluster). More...

#include <PFClusterProducer.h>

Inheritance diagram for PFClusterProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlock const &iL, edm::EventSetup const &iE)
 
 PFClusterProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~PFClusterProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool applyCrackCorrections_
 
PFClusterAlgo clusterAlgo_
 clustering algorithm More...
 
const CaloGeometryRecordgeom
 
edm::InputTag inputTagPFClustersPS_
 
edm::InputTag inputTagPFRecHits_
 
std::shared_ptr
< PFEnergyCalibration
pfEnergyCalibration_
 
bool produces_eeps
 
double threshPFClusterES_
 
bool verbose_
 verbose ? More...
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Producer for particle flow clusters (PFCluster).

This producer makes use of PFClusterAlgo, the clustering algorithm for particle flow clusters.

Author
Colin Bernet
Date
July 2006

Definition at line 43 of file PFClusterProducer.h.

Constructor & Destructor Documentation

PFClusterProducer::PFClusterProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 64 of file PFClusterProducer.cc.

References PFClusterAlgo::EGPositionCalc, PFClusterAlgo::EGPositionFormula, edm::hlt::Exception, edm::ParameterSet::existsAs(), relativeConstraints::geom, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::ParameterSet::getUntrackedParameter(), NULL, PFClusterAlgo::PFPositionCalc, reco::PFCluster::setDepthCorParameters(), and AlCaHLTBitMon_QueryRunRegistry::string.

65 {
66 
67  verbose_ =
68  iConfig.getUntrackedParameter<bool>("verbose",false);
69 
71  std::shared_ptr<PFEnergyCalibration>(new PFEnergyCalibration());
72 
73  // parameters for clustering
74 
75  double threshBarrel =
76  iConfig.getParameter<double>("thresh_Barrel");
77  double threshSeedBarrel =
78  iConfig.getParameter<double>("thresh_Seed_Barrel");
79 
80  double threshPtBarrel =
81  iConfig.getParameter<double>("thresh_Pt_Barrel");
82  double threshPtSeedBarrel =
83  iConfig.getParameter<double>("thresh_Pt_Seed_Barrel");
84 
85  double threshCleanBarrel =
86  iConfig.getParameter<double>("thresh_Clean_Barrel");
87  std::vector<double> minS4S1CleanBarrel =
88  iConfig.getParameter< std::vector<double> >("minS4S1_Clean_Barrel");
89 
90  double threshEndcap =
91  iConfig.getParameter<double>("thresh_Endcap");
92  double threshSeedEndcap =
93  iConfig.getParameter<double>("thresh_Seed_Endcap");
94 
95  double threshPtEndcap =
96  iConfig.getParameter<double>("thresh_Pt_Endcap");
97  double threshPtSeedEndcap =
98  iConfig.getParameter<double>("thresh_Pt_Seed_Endcap");
99 
100  double threshCleanEndcap =
101  iConfig.getParameter<double>("thresh_Clean_Endcap");
102  std::vector<double> minS4S1CleanEndcap =
103  iConfig.getParameter< std::vector<double> >("minS4S1_Clean_Endcap");
104 
105  double threshDoubleSpikeBarrel =
106  iConfig.getParameter<double>("thresh_DoubleSpike_Barrel");
107  double minS6S2DoubleSpikeBarrel =
108  iConfig.getParameter<double>("minS6S2_DoubleSpike_Barrel");
109  double threshDoubleSpikeEndcap =
110  iConfig.getParameter<double>("thresh_DoubleSpike_Endcap");
111  double minS6S2DoubleSpikeEndcap =
112  iConfig.getParameter<double>("minS6S2_DoubleSpike_Endcap");
113 
114  int nNeighbours =
115  iConfig.getParameter<int>("nNeighbours");
116 
117 // double posCalcP1 =
118 // iConfig.getParameter<double>("posCalcP1");
119 
120  int posCalcNCrystal =
121  iConfig.getParameter<int>("posCalcNCrystal");
122 
123  double showerSigma =
124  iConfig.getParameter<double>("showerSigma");
125 
126  bool useCornerCells =
127  iConfig.getParameter<bool>("useCornerCells");
128 
129  bool cleanRBXandHPDs =
130  iConfig.getParameter<bool>("cleanRBXandHPDs");
131 
132 
133  clusterAlgo_.setThreshBarrel( threshBarrel );
134  clusterAlgo_.setThreshSeedBarrel( threshSeedBarrel );
135 
136  clusterAlgo_.setThreshPtBarrel( threshPtBarrel );
137  clusterAlgo_.setThreshPtSeedBarrel( threshPtSeedBarrel );
138 
139  clusterAlgo_.setThreshCleanBarrel(threshCleanBarrel);
140  clusterAlgo_.setS4S1CleanBarrel(minS4S1CleanBarrel);
141 
142  clusterAlgo_.setThreshDoubleSpikeBarrel( threshDoubleSpikeBarrel );
143  clusterAlgo_.setS6S2DoubleSpikeBarrel( minS6S2DoubleSpikeBarrel );
144 
145  clusterAlgo_.setThreshEndcap( threshEndcap );
146  clusterAlgo_.setThreshSeedEndcap( threshSeedEndcap );
147 
148  clusterAlgo_.setThreshPtEndcap( threshPtEndcap );
149  clusterAlgo_.setThreshPtSeedEndcap( threshPtSeedEndcap );
150 
151  clusterAlgo_.setThreshCleanEndcap(threshCleanEndcap);
152  clusterAlgo_.setS4S1CleanEndcap(minS4S1CleanEndcap);
153 
154  clusterAlgo_.setThreshDoubleSpikeEndcap( threshDoubleSpikeEndcap );
155  clusterAlgo_.setS6S2DoubleSpikeEndcap( minS6S2DoubleSpikeEndcap );
156 
157  clusterAlgo_.setNNeighbours( nNeighbours );
158 
159  // setup the position calculation (only affects ECAL position correction)
160  std::string poscalctype = PositionCalcType__PFPositionCalc;
161  if( iConfig.existsAs<std::string>("PositionCalcType") ) {
162  poscalctype = iConfig.getParameter<std::string>("PositionCalcType");
163  }
164  if( poscalctype == PositionCalcType__EGPositionCalc ) {
166  edm::ParameterSet pc_config =
167  iConfig.getParameterSet("PositionCalcConfig");
168  clusterAlgo_.setEGammaPosCalc(pc_config);
169  } else if( poscalctype == PositionCalcType__EGPositionFormula) {
171  edm::ParameterSet pc_config =
172  iConfig.getParameterSet("PositionCalcConfig");
173  double w0 = pc_config.getParameter<double>("W0");
175  } else if( poscalctype == PositionCalcType__PFPositionCalc) {
177  } else {
178  throw cms::Exception("InvalidClusteringType")
179  << "You have not chosen a valid position calculation type,"
180  << " please choose from \""
181  << PositionCalcType__EGPositionCalc << "\", \""
182  << PositionCalcType__EGPositionFormula << "\", or \""
183  << PositionCalcType__PFPositionCalc << "\"!";
184  }
185 
186  // p1 set to the minimum rechit threshold:
187  double posCalcP1 = threshBarrel<threshEndcap ? threshBarrel:threshEndcap;
188  clusterAlgo_.setPosCalcP1( posCalcP1 );
189  clusterAlgo_.setPosCalcNCrystal( posCalcNCrystal );
190  clusterAlgo_.setShowerSigma( showerSigma );
191 
192  clusterAlgo_.setUseCornerCells( useCornerCells );
193  clusterAlgo_.setCleanRBXandHPDs( cleanRBXandHPDs);
194 
195  int dcormode =
196  iConfig.getParameter<int>("depthCor_Mode");
197 
198  double dcora =
199  iConfig.getParameter<double>("depthCor_A");
200  double dcorb =
201  iConfig.getParameter<double>("depthCor_B");
202  double dcorap =
203  iConfig.getParameter<double>("depthCor_A_preshower");
204  double dcorbp =
205  iConfig.getParameter<double>("depthCor_B_preshower");
206 
207  if( dcormode !=0 )
209  dcora, dcorb,
210  dcorap, dcorbp );
211 
212 
213  geom = NULL;
214  // access to the collections of rechits from the various detectors:
215 
216 
218  iConfig.getParameter<InputTag>("PFRecHits");
219  //---ab
220  produces_eeps = iConfig.existsAs<InputTag>("PFClustersPS");
221  if( produces_eeps ) {
223  iConfig.getParameter<InputTag>("PFClustersPS");
224  threshPFClusterES_ = iConfig.getParameter<double>("thresh_Preshower");
226  iConfig.getParameter<bool>("applyCrackCorrections");
227  if (inputTagPFClustersPS_.label().empty()) {
228  produces_eeps = false;
229  } else {
230  produces<reco::PFCluster::EEtoPSAssociation>();
231  }
232  }
233 
234  //inputTagClusterCollectionName_ = iConfig.getParameter<string>("PFClusterCollectionName");
235 
236  // produces<reco::PFClusterCollection>(inputTagClusterCollectionName_);
237  produces<reco::PFClusterCollection>();
238  produces<reco::PFRecHitCollection>("Cleaned");
239 
240  //---ab
241 }
void setThreshCleanBarrel(double thresh)
set barrel clean threshold
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setThreshDoubleSpikeEndcap(double thresh)
set endcap thresholds for double spike cleaning
edm::InputTag inputTagPFRecHits_
void setShowerSigma(double sigma)
set shower sigma for
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
void setPositionCalcType(const PositionCalcType &t)
void setPosCalcP1(double p1)
set p1 for position calculation
std::shared_ptr< PFEnergyCalibration > pfEnergyCalibration_
static void setDepthCorParameters(int mode, double a, double b, double ap, double bp)
Definition: PFCluster.h:101
void setPosCalcNCrystal(int n)
set number of crystals for position calculation (-1 all,5, or 9)
void setThreshSeedBarrel(double thresh)
set barrel seed threshold
Definition: PFClusterAlgo.h:98
void setS6S2DoubleSpikeEndcap(double cut)
#define NULL
Definition: scimark2.h:8
void setThreshBarrel(double thresh)
setters -------------------------------------------------——
Definition: PFClusterAlgo.h:94
void setUseCornerCells(bool usecornercells)
activate use of cells with a common corner to build topo-clusters
bool verbose_
verbose ?
PFClusterAlgo clusterAlgo_
clustering algorithm
void setThreshPtSeedBarrel(double thresh)
Definition: PFClusterAlgo.h:99
void setThreshSeedEndcap(double thresh)
set endcap seed threshold
const CaloGeometryRecord * geom
void setNNeighbours(int n)
set number of neighbours for
edm::InputTag inputTagPFClustersPS_
void setS4S1CleanBarrel(const std::vector< double > &coeffs)
void setThreshPtSeedEndcap(double thresh)
void setThreshPtEndcap(double thresh)
void setThreshEndcap(double thresh)
set endcap threshold
void setThreshDoubleSpikeBarrel(double thresh)
set endcap thresholds for double spike cleaning
ParameterSet const & getParameterSet(std::string const &) const
std::string const & label() const
Definition: InputTag.h:42
void setThreshPtBarrel(double thresh)
Definition: PFClusterAlgo.h:95
void setCleanRBXandHPDs(bool cleanRBXandHPDs)
Activate cleaning of HCAL RBX&#39;s and HPD&#39;s.
void setS6S2DoubleSpikeBarrel(double cut)
void setS4S1CleanEndcap(const std::vector< double > &coeffs)
void setThreshCleanEndcap(double thresh)
set endcap clean threshold
void setPosCalcW0(double w0)
void setEGammaPosCalc(const edm::ParameterSet &conf)
PFClusterProducer::~PFClusterProducer ( )

Definition at line 245 of file PFClusterProducer.cc.

245 {}

Member Function Documentation

void PFClusterProducer::beginLuminosityBlock ( edm::LuminosityBlock const &  iL,
edm::EventSetup const &  iE 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 248 of file PFClusterProducer.cc.

References edm::eventsetup::EventSetupRecord::cacheIdentifier(), DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, relativeConstraints::geom, edm::EventSetup::get(), NULL, and groupFilesInBlocks::temp.

249  {
250  const CaloGeometryRecord& temp = iE.get<CaloGeometryRecord>();
251  if( geom == NULL || (geom->cacheIdentifier() != temp.cacheIdentifier()) ) {
252  geom = &temp;
254  geom->get(cgeom);
255  clusterAlgo_.setEBGeom(cgeom->getSubdetectorGeometry(DetId::Ecal,
256  EcalBarrel));
257  clusterAlgo_.setEEGeom(cgeom->getSubdetectorGeometry(DetId::Ecal,
258  EcalEndcap));
259  clusterAlgo_.setPreshowerGeom(cgeom->getSubdetectorGeometry(DetId::Ecal,
260  EcalPreshower));
261  }
262 }
unsigned long long cacheIdentifier() const
#define NULL
Definition: scimark2.h:8
PFClusterAlgo clusterAlgo_
clustering algorithm
const CaloGeometryRecord * geom
void get(HolderT &iHolder) const
void setEEGeom(const CaloSubdetectorGeometry *esh)
void setEBGeom(const CaloSubdetectorGeometry *esh)
void setPreshowerGeom(const CaloSubdetectorGeometry *esh)
void PFClusterProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 264 of file PFClusterProducer.cc.

References PFLayer::ECAL_ENDCAP, eCorr(), edm::hlt::Exception, newFWLiteAna::found, edm::Event::getByLabel(), edm::Ptr< T >::isNonnull(), edm::Ptr< T >::key(), PFLayer::PS1, PFLayer::PS2, edm::Event::put(), and python.multivaluedict::sort().

265  {
266 
267 
269  edm::Handle< edm::View<reco::PFCluster> > psclustersHandle;
270 
271  // access the rechits in the event
272  bool found = iEvent.getByLabel( inputTagPFRecHits_, rechitsHandle );
273 
274  if(!found ) {
275 
276  ostringstream err;
277  err<<"cannot find rechits: "<<inputTagPFRecHits_;
278  LogError("PFClusterProducer")<<err.str()<<endl;
279 
280  throw cms::Exception( "MissingProduct", err.str());
281  }
282 
283  // do clustering
284  clusterAlgo_.doClustering( rechitsHandle );
285 
286  if( verbose_ ) {
287  LogInfo("PFClusterProducer")
288  <<" clusters --------------------------------- "<<endl
289  <<clusterAlgo_<<endl;
290  }
291 
292  std::auto_ptr< std::vector<reco::PFCluster> > clusters =
294 
295  if( produces_eeps ) {
296  iEvent.getByLabel( inputTagPFClustersPS_, psclustersHandle );
297  // associate psclusters to ecal rechits
298  std::auto_ptr<reco::PFCluster::EEtoPSAssociation>
299  outEEPS( new reco::PFCluster::EEtoPSAssociation );
300  // make the association map of ECAL clusters to preshower clusters
301  edm::PtrVector<reco::PFCluster> clusterPtrsPS =
302  psclustersHandle->ptrVector();
303  double dist = -1.0, min_dist = -1.0;
304  // match PS clusters to EE clusters, minimum distance to EE is ensured
305  // since the inner loop is over the EE clusters
306  for( const auto& psclus : clusterPtrsPS ) {
307  if( psclus->energy() < threshPFClusterES_ ) continue;
308  switch( psclus->layer() ) { // just in case this isn't the ES...
309  case PFLayer::PS1:
310  case PFLayer::PS2:
311  break;
312  default:
313  continue;
314  }
315  edm::Ptr<reco::PFCluster> eematch,eeclus;
316  dist = min_dist = -1.0; // reset
317  for( size_t ic = 0; ic < clusters->size(); ++ic ) {
318  eeclus = edm::Ptr<reco::PFCluster>(clusters.get(),ic);
319  if( eeclus->layer() != PFLayer::ECAL_ENDCAP ) continue;
320  dist = testPreshowerDistance(eeclus,psclus);
321  if( dist == -1.0 || (min_dist != -1.0 && dist > min_dist) ) continue;
322  if( dist < min_dist || min_dist == -1.0 ) {
323  eematch = eeclus;
324  min_dist = dist;
325  }
326  } // loop on EE clusters
327  if( eematch.isNonnull() ) {
328  outEEPS->push_back(std::make_pair(eematch.key(),psclus));
329  }
330  } // loop on PS clusters
331  //sort the ps association
332  std::sort(outEEPS->begin(),outEEPS->end(),sortByKey);
333 
334  std::vector<double> ps1_energies,ps2_energies;
335  double ePS1, ePS2;
336  for( size_t ic = 0 ; ic < clusters->size(); ++ic ) {
337  ps1_energies.clear();
338  ps2_energies.clear();
339  ePS1 = ePS2 = 0;
340  auto ee_key_val = std::make_pair(ic,edm::Ptr<reco::PFCluster>());
341  const auto clustops = std::equal_range(outEEPS->begin(),
342  outEEPS->end(),
343  ee_key_val,
344  sortByKey);
345  for( auto i_ps = clustops.first; i_ps != clustops.second; ++i_ps) {
346  edm::Ptr<reco::PFCluster> psclus(i_ps->second);
347  switch( psclus->layer() ) {
348  case PFLayer::PS1:
349  ps1_energies.push_back(psclus->energy());
350  break;
351  case PFLayer::PS2:
352  ps2_energies.push_back(psclus->energy());
353  break;
354  default:
355  break;
356  }
357  }
358  const double eCorr=
359  pfEnergyCalibration_->energyEm(clusters->at(ic),
360  ps1_energies,ps2_energies,
361  ePS1,ePS2,
363  clusters->at(ic).setCorrectedEnergy(eCorr);
364  }
365 
366  iEvent.put(outEEPS);
367  }
368 
369  // get clusters out of the clustering algorithm
370  // and put them in the event. There is no copy.
371  //auto_ptr< vector<reco::PFCluster> > outClusters( clusters );
372  auto_ptr< vector<reco::PFRecHit> > recHitsCleaned ( clusterAlgo_.rechitsCleaned() );
374  iEvent.put( clusters );
375  iEvent.put( recHitsCleaned, "Cleaned" );
376 }
edm::InputTag inputTagPFRecHits_
void doClustering(const reco::PFRecHitCollection &rechits)
perform clustering
std::shared_ptr< PFEnergyCalibration > pfEnergyCalibration_
bool verbose_
verbose ?
PFClusterAlgo clusterAlgo_
clustering algorithm
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::auto_ptr< std::vector< reco::PFRecHit > > & rechitsCleaned()
std::vector< std::pair< CaloClusterPtr::key_type, edm::Ptr< PFCluster > > > EEtoPSAssociation
Definition: PFCluster.h:46
edm::InputTag inputTagPFClustersPS_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
key_type key() const
Definition: Ptr.h:169
std::auto_ptr< std::vector< reco::PFCluster > > & clusters()
static float eCorr(int ieta, int iphi, double ampl, int runnum)
Ugly hack to apply energy corrections to some HB- cells.

Member Data Documentation

bool PFClusterProducer::applyCrackCorrections_
private

Definition at line 61 of file PFClusterProducer.h.

PFClusterAlgo PFClusterProducer::clusterAlgo_
private

clustering algorithm

Definition at line 59 of file PFClusterProducer.h.

const CaloGeometryRecord* PFClusterProducer::geom
private

Definition at line 60 of file PFClusterProducer.h.

edm::InputTag PFClusterProducer::inputTagPFClustersPS_
private

Definition at line 70 of file PFClusterProducer.h.

edm::InputTag PFClusterProducer::inputTagPFRecHits_
private

Definition at line 68 of file PFClusterProducer.h.

std::shared_ptr<PFEnergyCalibration> PFClusterProducer::pfEnergyCalibration_
private

Definition at line 62 of file PFClusterProducer.h.

bool PFClusterProducer::produces_eeps
private

Definition at line 69 of file PFClusterProducer.h.

double PFClusterProducer::threshPFClusterES_
private

Definition at line 71 of file PFClusterProducer.h.

bool PFClusterProducer::verbose_
private

verbose ?

Definition at line 65 of file PFClusterProducer.h.