CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
HGCalLayerClusterProducer Class Reference
Inheritance diagram for HGCalLayerClusterProducer:
edm::stream::EDProducer<>

Public Member Functions

 HGCalLayerClusterProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~HGCalLayerClusterProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

std::unique_ptr< HGCalClusteringAlgoBasealgo
 
reco::CaloCluster::AlgoId algoId
 
std::string detector
 
bool doSharing
 
edm::EDGetTokenT< HGCRecHitCollectionhits_bh_token
 
edm::EDGetTokenT< HGCRecHitCollectionhits_ee_token
 
edm::EDGetTokenT< HGCRecHitCollectionhits_fh_token
 
edm::EDGetTokenT< HGCRecHitCollectionhits_hfnose_token
 
unsigned int nHitsTime
 
std::string timeClname
 
double timeOffset
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 35 of file HGCalLayerClusterProducer.cc.

Constructor & Destructor Documentation

◆ HGCalLayerClusterProducer()

HGCalLayerClusterProducer::HGCalLayerClusterProducer ( const edm::ParameterSet ps)

Definition at line 62 of file HGCalLayerClusterProducer.cc.

References algo, algoId, detector, get, edm::ParameterSet::getParameter(), reco::CaloCluster::hfnose, reco::CaloCluster::hgcal_em, reco::CaloCluster::hgcal_had, reco::CaloCluster::hgcal_mixed, hits_bh_token, hits_ee_token, hits_fh_token, hits_hfnose_token, AlCaHLTBitMon_QueryRunRegistry::string, timeClname, and undefined.

64  doSharing(ps.getParameter<bool>("doSharing")),
65  detector(ps.getParameter<std::string>("detector")), // one of EE, FH, BH or "all"
66  timeClname(ps.getParameter<std::string>("timeClname")),
67  timeOffset(ps.getParameter<double>("timeOffset")),
68  nHitsTime(ps.getParameter<unsigned int>("nHitsTime")) {
69  if (detector == "HFNose") {
70  hits_hfnose_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HFNoseInput"));
72  } else if (detector == "all") {
73  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
74  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
75  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
77  } else if (detector == "EE") {
78  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
80  } else if (detector == "FH") {
81  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
83  } else {
84  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
86  }
87 
88  auto pluginPSet = ps.getParameter<edm::ParameterSet>("plugin");
89  if (detector == "HFNose") {
90  algo = HGCalLayerClusterAlgoFactory::get()->create("HFNoseCLUE", pluginPSet, consumesCollector());
91  algo->setAlgoId(algoId, true);
92  } else {
94  pluginPSet.getParameter<std::string>("type"), pluginPSet, consumesCollector());
95  algo->setAlgoId(algoId);
96  }
97 
98  produces<std::vector<float>>("InitialLayerClustersMask");
99  produces<std::vector<reco::BasicCluster>>();
100  produces<std::vector<reco::BasicCluster>>("sharing");
101  //density
102  produces<Density>();
103  //time for layer clusters
104  produces<edm::ValueMap<std::pair<float, float>>>(timeClname);
105 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::CaloCluster::AlgoId algoId
edm::EDGetTokenT< HGCRecHitCollection > hits_hfnose_token
std::unique_ptr< HGCalClusteringAlgoBase > algo
edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token
edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token
edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token
#define get

◆ ~HGCalLayerClusterProducer()

HGCalLayerClusterProducer::~HGCalLayerClusterProducer ( )
inlineoverride

Definition at line 38 of file HGCalLayerClusterProducer.cc.

38 {}

Member Function Documentation

◆ fillDescriptions()

void HGCalLayerClusterProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 107 of file HGCalLayerClusterProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addNode(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

107  {
108  // hgcalLayerClusters
110  edm::ParameterSetDescription pluginDesc;
111  pluginDesc.addNode(edm::PluginDescription<HGCalLayerClusterAlgoFactory>("type", "CLUE", true));
112 
113  desc.add<edm::ParameterSetDescription>("plugin", pluginDesc);
114  desc.add<std::string>("detector", "all")
115  ->setComment("all (does not include HFNose); other options: EE, FH, HFNose; other value defaults to BH");
116  desc.add<bool>("doSharing", false);
117  desc.add<edm::InputTag>("HFNoseInput", edm::InputTag("HGCalRecHit", "HGCHFNoseRecHits"));
118  desc.add<edm::InputTag>("HGCEEInput", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
119  desc.add<edm::InputTag>("HGCFHInput", edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
120  desc.add<edm::InputTag>("HGCBHInput", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
121  desc.add<std::string>("timeClname", "timeLayerCluster");
122  desc.add<double>("timeOffset", 0.0);
123  desc.add<unsigned int>("nHitsTime", 3);
124  descriptions.add("hgcalLayerClusters", desc);
125 }
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void HGCalLayerClusterProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 127 of file HGCalLayerClusterProducer.cc.

References algo, algoId, bsc_activity_cfg::clusters, fastSimProducer_cff::density, doSharing, trigObjTnPSource_cfi::filler, HLT_2022v15_cff::finder, hgcalsimclustertime::ComputeClusterTime::fixSizeHighestDensity(), edm::Event::getByToken(), reco::CaloCluster::hfnose, reco::CaloCluster::hgcal_em, reco::CaloCluster::hgcal_had, reco::CaloCluster::hgcal_mixed, hits_bh_token, hits_ee_token, hits_fh_token, hits_hfnose_token, reco::CaloCluster::hitsAndFractions(), mps_fire::i, edm::HandleBase::isValid(), eostools::move(), nHitsTime, edm::PtrVector< T >::push_back(), edm::Event::put(), edm::PtrVectorBase::reserve(), reco::CaloCluster::size(), CaloRecHit::time(), timeClname, and HGCRecHit::timeError().

127  {
132 
133  std::unique_ptr<std::vector<reco::BasicCluster>> clusters(new std::vector<reco::BasicCluster>),
134  clusters_sharing(new std::vector<reco::BasicCluster>);
135  auto density = std::make_unique<Density>();
136 
137  algo->getEventSetup(es);
138 
139  //make a map detid-rechit
140  // NB for the moment just host EE and FH hits
141  // timing in digi for BH not implemented for now
142  std::unordered_map<uint32_t, const HGCRecHit*> hitmap;
143 
144  switch (algoId) {
146  evt.getByToken(hits_hfnose_token, hfnose_hits);
147  algo->populate(*hfnose_hits);
148  for (auto const& it : *hfnose_hits)
149  hitmap[it.detid().rawId()] = &(it);
150  break;
152  evt.getByToken(hits_ee_token, ee_hits);
153  algo->populate(*ee_hits);
154  for (auto const& it : *ee_hits)
155  hitmap[it.detid().rawId()] = &(it);
156  break;
158  evt.getByToken(hits_fh_token, fh_hits);
159  evt.getByToken(hits_bh_token, bh_hits);
160  if (fh_hits.isValid()) {
161  algo->populate(*fh_hits);
162  for (auto const& it : *fh_hits)
163  hitmap[it.detid().rawId()] = &(it);
164  } else if (bh_hits.isValid()) {
165  algo->populate(*bh_hits);
166  }
167  break;
169  evt.getByToken(hits_ee_token, ee_hits);
170  algo->populate(*ee_hits);
171  for (auto const& it : *ee_hits) {
172  hitmap[it.detid().rawId()] = &(it);
173  }
174  evt.getByToken(hits_fh_token, fh_hits);
175  algo->populate(*fh_hits);
176  for (auto const& it : *fh_hits) {
177  hitmap[it.detid().rawId()] = &(it);
178  }
179  evt.getByToken(hits_bh_token, bh_hits);
180  algo->populate(*bh_hits);
181  break;
182  default:
183  break;
184  }
185  algo->makeClusters();
186  *clusters = algo->getClusters(false);
187  if (doSharing)
188  *clusters_sharing = algo->getClusters(true);
189 
190  auto clusterHandle = evt.put(std::move(clusters));
191  auto clusterHandleSharing = evt.put(std::move(clusters_sharing), "sharing");
192 
193  //Keep the density
194  *density = algo->getDensity();
195  evt.put(std::move(density));
196 
197  edm::PtrVector<reco::BasicCluster> clusterPtrs, clusterPtrsSharing;
198 
199  std::vector<std::pair<float, float>> times;
200  times.reserve(clusterHandle->size());
201 
202  for (unsigned i = 0; i < clusterHandle->size(); ++i) {
203  edm::Ptr<reco::BasicCluster> ptr(clusterHandle, i);
204  clusterPtrs.push_back(ptr);
205 
206  std::pair<float, float> timeCl(-99., -1.);
207 
208  const reco::CaloCluster& sCl = (*clusterHandle)[i];
209  if (sCl.size() >= nHitsTime) {
210  std::vector<float> timeClhits;
211  std::vector<float> timeErrorClhits;
212 
213  for (auto const& hit : sCl.hitsAndFractions()) {
214  auto finder = hitmap.find(hit.first);
215  if (finder == hitmap.end())
216  continue;
217 
218  //time is computed wrt 0-25ns + offset and set to -1 if no time
219  const HGCRecHit* rechit = finder->second;
220  float rhTimeE = rechit->timeError();
221  //check on timeError to exclude scintillator
222  if (rhTimeE < 0.)
223  continue;
224  timeClhits.push_back(rechit->time());
225  timeErrorClhits.push_back(1. / (rhTimeE * rhTimeE));
226  }
228  timeCl = timeEstimator.fixSizeHighestDensity(timeClhits, timeErrorClhits, nHitsTime);
229  }
230  times.push_back(timeCl);
231  }
232  std::unique_ptr<std::vector<float>> layerClustersMask(new std::vector<float>);
233  layerClustersMask->resize(clusterHandle->size(), 1.0);
234  evt.put(std::move(layerClustersMask), "InitialLayerClustersMask");
235 
236  auto timeCl = std::make_unique<edm::ValueMap<std::pair<float, float>>>();
238  filler.insert(clusterHandle, times.begin(), times.end());
239  filler.fill();
240  evt.put(std::move(timeCl), timeClname);
241 
242  if (doSharing) {
243  for (unsigned i = 0; i < clusterHandleSharing->size(); ++i) {
244  edm::Ptr<reco::BasicCluster> ptr(clusterHandleSharing, i);
245  clusterPtrsSharing.push_back(ptr);
246  }
247  }
248  algo->reset();
249 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
reco::CaloCluster::AlgoId algoId
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
edm::EDGetTokenT< HGCRecHitCollection > hits_hfnose_token
std::unique_ptr< HGCalClusteringAlgoBase > algo
edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token
std::pair< float, float > fixSizeHighestDensity(std::vector< float > &time, std::vector< float > weight=std::vector< float >(), unsigned int minNhits=3, float deltaT=0.210, float timeWidthBy=0.5)
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:187
edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token
bool isValid() const
Definition: HandleBase.h:70
constexpr float time() const
Definition: CaloRecHit.h:31
void reserve(size_type n)
Reserve space for RefVector.
Definition: PtrVectorBase.h:95
edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token
float timeError() const
Definition: HGCRecHit.cc:79
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ algo

std::unique_ptr<HGCalClusteringAlgoBase> HGCalLayerClusterProducer::algo
private

Definition at line 51 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

◆ algoId

reco::CaloCluster::AlgoId HGCalLayerClusterProducer::algoId
private

Definition at line 49 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

◆ detector

std::string HGCalLayerClusterProducer::detector
private

Definition at line 53 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer().

◆ doSharing

bool HGCalLayerClusterProducer::doSharing
private

Definition at line 52 of file HGCalLayerClusterProducer.cc.

Referenced by produce().

◆ hits_bh_token

edm::EDGetTokenT<HGCRecHitCollection> HGCalLayerClusterProducer::hits_bh_token
private

Definition at line 46 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

◆ hits_ee_token

edm::EDGetTokenT<HGCRecHitCollection> HGCalLayerClusterProducer::hits_ee_token
private

Definition at line 44 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

◆ hits_fh_token

edm::EDGetTokenT<HGCRecHitCollection> HGCalLayerClusterProducer::hits_fh_token
private

Definition at line 45 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

◆ hits_hfnose_token

edm::EDGetTokenT<HGCRecHitCollection> HGCalLayerClusterProducer::hits_hfnose_token
private

Definition at line 47 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

◆ nHitsTime

unsigned int HGCalLayerClusterProducer::nHitsTime
private

Definition at line 57 of file HGCalLayerClusterProducer.cc.

Referenced by produce().

◆ timeClname

std::string HGCalLayerClusterProducer::timeClname
private

Definition at line 55 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

◆ timeOffset

double HGCalLayerClusterProducer::timeOffset
private

Definition at line 56 of file HGCalLayerClusterProducer.cc.