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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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);
91  algo->setAlgoId(algoId, true);
92  } else {
93  algo = HGCalLayerClusterAlgoFactory::get()->create(pluginPSet.getParameter<std::string>("type"), pluginPSet);
94  algo->setAlgoId(algoId);
95  }
96 
97  produces<std::vector<float>>("InitialLayerClustersMask");
98  produces<std::vector<reco::BasicCluster>>();
99  produces<std::vector<reco::BasicCluster>>("sharing");
100  //density
101  produces<Density>();
102  //time for layer clusters
103  produces<edm::ValueMap<std::pair<float, float>>>(timeClname);
104 }

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.

◆ ~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 106 of file HGCalLayerClusterProducer.cc.

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

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

◆ produce()

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

Definition at line 126 of file HGCalLayerClusterProducer.cc.

126  {
131 
132  std::unique_ptr<std::vector<reco::BasicCluster>> clusters(new std::vector<reco::BasicCluster>),
133  clusters_sharing(new std::vector<reco::BasicCluster>);
134  auto density = std::make_unique<Density>();
135 
136  algo->getEventSetup(es);
137 
138  //make a map detid-rechit
139  // NB for the moment just host EE and FH hits
140  // timing in digi for BH not implemented for now
141  std::unordered_map<uint32_t, const HGCRecHit*> hitmap;
142 
143  switch (algoId) {
145  evt.getByToken(hits_hfnose_token, hfnose_hits);
146  algo->populate(*hfnose_hits);
147  for (auto const& it : *hfnose_hits)
148  hitmap[it.detid().rawId()] = &(it);
149  break;
151  evt.getByToken(hits_ee_token, ee_hits);
152  algo->populate(*ee_hits);
153  for (auto const& it : *ee_hits)
154  hitmap[it.detid().rawId()] = &(it);
155  break;
157  evt.getByToken(hits_fh_token, fh_hits);
158  evt.getByToken(hits_bh_token, bh_hits);
159  if (fh_hits.isValid()) {
160  algo->populate(*fh_hits);
161  for (auto const& it : *fh_hits)
162  hitmap[it.detid().rawId()] = &(it);
163  } else if (bh_hits.isValid()) {
164  algo->populate(*bh_hits);
165  }
166  break;
168  evt.getByToken(hits_ee_token, ee_hits);
169  algo->populate(*ee_hits);
170  for (auto const& it : *ee_hits) {
171  hitmap[it.detid().rawId()] = &(it);
172  }
173  evt.getByToken(hits_fh_token, fh_hits);
174  algo->populate(*fh_hits);
175  for (auto const& it : *fh_hits) {
176  hitmap[it.detid().rawId()] = &(it);
177  }
178  evt.getByToken(hits_bh_token, bh_hits);
179  algo->populate(*bh_hits);
180  break;
181  default:
182  break;
183  }
184  algo->makeClusters();
185  *clusters = algo->getClusters(false);
186  if (doSharing)
187  *clusters_sharing = algo->getClusters(true);
188 
189  auto clusterHandle = evt.put(std::move(clusters));
190  auto clusterHandleSharing = evt.put(std::move(clusters_sharing), "sharing");
191 
192  //Keep the density
193  *density = algo->getDensity();
194  evt.put(std::move(density));
195 
196  edm::PtrVector<reco::BasicCluster> clusterPtrs, clusterPtrsSharing;
197 
198  std::vector<std::pair<float, float>> times;
199  times.reserve(clusterHandle->size());
200 
201  for (unsigned i = 0; i < clusterHandle->size(); ++i) {
202  edm::Ptr<reco::BasicCluster> ptr(clusterHandle, i);
203  clusterPtrs.push_back(ptr);
204 
205  std::pair<float, float> timeCl(-99., -1.);
206 
207  const reco::CaloCluster& sCl = (*clusterHandle)[i];
208  if (sCl.size() >= nHitsTime) {
209  std::vector<float> timeClhits;
210  std::vector<float> timeErrorClhits;
211 
212  for (auto const& hit : sCl.hitsAndFractions()) {
213  auto finder = hitmap.find(hit.first);
214  if (finder == hitmap.end())
215  continue;
216 
217  //time is computed wrt 0-25ns + offset and set to -1 if no time
218  const HGCRecHit* rechit = finder->second;
219  float rhTimeE = rechit->timeError();
220  //check on timeError to exclude scintillator
221  if (rhTimeE < 0.)
222  continue;
223  timeClhits.push_back(rechit->time() - timeOffset);
224  timeErrorClhits.push_back(1. / (rhTimeE * rhTimeE));
225  }
227  timeCl = timeEstimator.fixSizeHighestDensity(timeClhits, timeErrorClhits, nHitsTime);
228  }
229  times.push_back(timeCl);
230  }
231  std::unique_ptr<std::vector<float>> layerClustersMask(new std::vector<float>);
232  layerClustersMask->resize(clusterHandle->size(), 1.0);
233  evt.put(std::move(layerClustersMask), "InitialLayerClustersMask");
234 
235  auto timeCl = std::make_unique<edm::ValueMap<std::pair<float, float>>>();
237  filler.insert(clusterHandle, times.begin(), times.end());
238  filler.fill();
239  evt.put(std::move(timeCl), timeClname);
240 
241  if (doSharing) {
242  for (unsigned i = 0; i < clusterHandleSharing->size(); ++i) {
243  edm::Ptr<reco::BasicCluster> ptr(clusterHandleSharing, i);
244  clusterPtrsSharing.push_back(ptr);
245  }
246  }
247  algo->reset();
248 }

References algo, algoId, bsc_activity_cfg::clusters, fastSimProducer_cff::density, doSharing, trigObjTnPSource_cfi::filler, HLT_FULL_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, HGCRecHit::timeError(), and timeOffset.

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.

Referenced by produce().

reco::CaloCluster::size
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:187
mps_fire.i
i
Definition: mps_fire.py:428
HGCalLayerClusterProducer::doSharing
bool doSharing
Definition: HGCalLayerClusterProducer.cc:52
HLT_FULL_cff.finder
finder
Definition: HLT_FULL_cff.py:51931
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
HGCalLayerClusterProducer::algoId
reco::CaloCluster::AlgoId algoId
Definition: HGCalLayerClusterProducer.cc:49
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::PluginDescription
Definition: PluginDescription.h:98
HGCalLayerClusterProducer::timeClname
std::string timeClname
Definition: HGCalLayerClusterProducer.cc:55
edm::Handle
Definition: AssociativeIterator.h:50
HGCRecHit::timeError
float timeError() const
Definition: HGCRecHit.cc:79
HGCalLayerClusterProducer::hits_bh_token
edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token
Definition: HGCalLayerClusterProducer.cc:46
hgcalsimclustertime::ComputeClusterTime::fixSizeHighestDensity
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)
Definition: ComputeClusterTime.cc:66
HGCalLayerClusterProducer::hits_hfnose_token
edm::EDGetTokenT< HGCRecHitCollection > hits_hfnose_token
Definition: HGCalLayerClusterProducer.cc:47
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::PtrVector
Definition: PtrVector.h:36
reco::CaloCluster
Definition: CaloCluster.h:31
reco::CaloCluster::undefined
Definition: CaloCluster.h:44
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
HGCalLayerClusterProducer::timeOffset
double timeOffset
Definition: HGCalLayerClusterProducer.cc:56
reco::CaloCluster::hfnose
Definition: CaloCluster.h:43
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CaloRecHit::time
constexpr float time() const
Definition: CaloRecHit.h:31
HGCRecHit
Definition: HGCRecHit.h:14
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
HGCalLayerClusterProducer::hits_ee_token
edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token
Definition: HGCalLayerClusterProducer.cc:44
HGCalLayerClusterProducer::algo
std::unique_ptr< HGCalClusteringAlgoBase > algo
Definition: HGCalLayerClusterProducer.cc:51
edm::ParameterSet
Definition: ParameterSet.h:47
HGCalLayerClusterProducer::hits_fh_token
edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token
Definition: HGCalLayerClusterProducer.cc:45
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
HGCalLayerClusterProducer::detector
std::string detector
Definition: HGCalLayerClusterProducer.cc:53
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::ParameterSetDescription::addNode
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
Definition: ParameterSetDescription.cc:41
get
#define get
reco::CaloCluster::hgcal_had
Definition: CaloCluster.h:41
edm::Ptr
Definition: AssociationVector.h:31
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::CaloCluster::hgcal_mixed
Definition: CaloCluster.h:42
edm::ValueMap
Definition: ValueMap.h:107
HGCalLayerClusterProducer::nHitsTime
unsigned int nHitsTime
Definition: HGCalLayerClusterProducer.cc:57
hgcalsimclustertime::ComputeClusterTime
Definition: ComputeClusterTime.h:23
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::CaloCluster::hgcal_em
Definition: CaloCluster.h:40
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
fastSimProducer_cff.density
density
Definition: fastSimProducer_cff.py:61
edm::PtrVectorBase::reserve
void reserve(size_type n)
Reserve space for RefVector.
Definition: PtrVectorBase.h:93