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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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
 
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 ( const edm::ParameterSet ps)

Definition at line 60 of file HGCalLayerClusterProducer.cc.

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

62  doSharing(ps.getParameter<bool>("doSharing")),
63  detector(ps.getParameter<std::string>("detector")), // one of EE, FH, BH or "all"
64  timeClname(ps.getParameter<std::string>("timeClname")),
65  timeOffset(ps.getParameter<double>("timeOffset")) {
66  if (detector == "all") {
67  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
68  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
69  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
71  } else if (detector == "EE") {
72  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
74  } else if (detector == "FH") {
75  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
77  } else {
78  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
80  }
81 
82  auto pluginPSet = ps.getParameter<edm::ParameterSet>("plugin");
83  algo = HGCalLayerClusterAlgoFactory::get()->create(pluginPSet.getParameter<std::string>("type"), pluginPSet);
84  algo->setAlgoId(algoId);
85 
86  produces<std::vector<float>>("InitialLayerClustersMask");
87  produces<std::vector<reco::BasicCluster>>();
88  produces<std::vector<reco::BasicCluster>>("sharing");
89  //density
90  produces<Density>();
91  //time for layer clusters
92  produces<edm::ValueMap<float>>(timeClname);
93 }
T getParameter(std::string const &) const
reco::CaloCluster::AlgoId algoId
std::unique_ptr< HGCalClusteringAlgoBase > algo
edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token
edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token
edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token
HGCalLayerClusterProducer::~HGCalLayerClusterProducer ( )
inlineoverride

Definition at line 38 of file HGCalLayerClusterProducer.cc.

References fillDescriptions(), and produce().

38 {}

Member Function Documentation

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

Definition at line 95 of file HGCalLayerClusterProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~HGCalLayerClusterProducer().

95  {
96  // hgcalLayerClusters
99  pluginDesc.addNode(edm::PluginDescription<HGCalLayerClusterAlgoFactory>("type", "CLUE", true));
100 
101  desc.add<edm::ParameterSetDescription>("plugin", pluginDesc);
102  desc.add<std::string>("detector", "all");
103  desc.add<bool>("doSharing", false);
104  desc.add<edm::InputTag>("HGCEEInput", edm::InputTag("HGCalRecHit", "HGCEERecHits"));
105  desc.add<edm::InputTag>("HGCFHInput", edm::InputTag("HGCalRecHit", "HGCHEFRecHits"));
106  desc.add<edm::InputTag>("HGCBHInput", edm::InputTag("HGCalRecHit", "HGCHEBRecHits"));
107  desc.add<std::string>("timeClname", "timeLayerCluster");
108  desc.add<double>("timeOffset", 0.0);
109  descriptions.add("hgcalLayerClusters", desc);
110 }
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void HGCalLayerClusterProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 112 of file HGCalLayerClusterProducer.cc.

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

Referenced by ~HGCalLayerClusterProducer().

112  {
116 
117  std::unique_ptr<std::vector<reco::BasicCluster>> clusters(new std::vector<reco::BasicCluster>),
118  clusters_sharing(new std::vector<reco::BasicCluster>);
119  auto density = std::make_unique<Density>();
120 
121  algo->reset();
122 
123  algo->getEventSetup(es);
124 
125  //make a map detid-rechit
126  // NB for the moment just host EE and FH hits
127  // timing in digi for BH not implemented for now
128  std::unordered_map<uint32_t, float> hitmap;
129 
130  switch (algoId) {
132  evt.getByToken(hits_ee_token, ee_hits);
133  algo->populate(*ee_hits);
134  for (auto const& it : *ee_hits)
135  hitmap[it.detid().rawId()] = it.time();
136  break;
138  evt.getByToken(hits_fh_token, fh_hits);
139  evt.getByToken(hits_bh_token, bh_hits);
140  if (fh_hits.isValid()) {
141  algo->populate(*fh_hits);
142  for (auto const& it : *fh_hits)
143  hitmap[it.detid().rawId()] = it.time();
144  } else if (bh_hits.isValid()) {
145  algo->populate(*bh_hits);
146  }
147  break;
149  evt.getByToken(hits_ee_token, ee_hits);
150  algo->populate(*ee_hits);
151  for (auto const& it : *ee_hits) {
152  hitmap[it.detid().rawId()] = it.time();
153  }
154  evt.getByToken(hits_fh_token, fh_hits);
155  algo->populate(*fh_hits);
156  for (auto const& it : *fh_hits) {
157  hitmap[it.detid().rawId()] = it.time();
158  }
159  evt.getByToken(hits_bh_token, bh_hits);
160  algo->populate(*bh_hits);
161  break;
162  default:
163  break;
164  }
165  algo->makeClusters();
166  *clusters = algo->getClusters(false);
167  if (doSharing)
168  *clusters_sharing = algo->getClusters(true);
169 
170  auto clusterHandle = evt.put(std::move(clusters));
171  auto clusterHandleSharing = evt.put(std::move(clusters_sharing), "sharing");
172 
173  //Keep the density
174  *density = algo->getDensity();
175  evt.put(std::move(density));
176 
177  edm::PtrVector<reco::BasicCluster> clusterPtrs, clusterPtrsSharing;
178 
179  std::vector<float> times;
180  times.reserve(clusterHandle->size());
181 
182  for (unsigned i = 0; i < clusterHandle->size(); ++i) {
183  edm::Ptr<reco::BasicCluster> ptr(clusterHandle, i);
184  clusterPtrs.push_back(ptr);
185 
186  float timeCl = -99.;
187  const reco::CaloCluster& sCl = (*clusterHandle)[i];
188  if (sCl.size() >= 3) {
189  std::vector<float> timeClhits;
190 
191  for (auto const& hit : sCl.hitsAndFractions()) {
192  auto finder = hitmap.find(hit.first);
193  if (finder == hitmap.end())
194  continue;
195 
196  //time is computed wrt 0-25ns + offset and set to -1 if no time
197  float rhTime = finder->second;
198  if (rhTime < 0.)
199  continue;
200  timeClhits.push_back(rhTime - timeOffset);
201  }
202  if (timeClhits.size() >= 3)
203  timeCl = hgcalsimclustertime::fixSizeHighestDensity(timeClhits);
204  }
205  times.push_back(timeCl);
206  }
207  std::unique_ptr<std::vector<float>> layerClustersMask(new std::vector<float>);
208  layerClustersMask->resize(clusterHandle->size(), 1.0);
209  evt.put(std::move(layerClustersMask), "InitialLayerClustersMask");
210 
211  auto timeCl = std::make_unique<edm::ValueMap<float>>();
213  filler.insert(clusterHandle, times.begin(), times.end());
214  filler.fill();
215  evt.put(std::move(timeCl), timeClname);
216 
217  if (doSharing) {
218  for (unsigned i = 0; i < clusterHandleSharing->size(); ++i) {
219  edm::Ptr<reco::BasicCluster> ptr(clusterHandleSharing, i);
220  clusterPtrsSharing.push_back(ptr);
221  }
222  }
223 }
float fixSizeHighestDensity(std::vector< float > &t, float deltaT=0.210, float timeWidthBy=0.5)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
reco::CaloCluster::AlgoId algoId
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
std::unique_ptr< HGCalClusteringAlgoBase > algo
edm::EDGetTokenT< HGCRecHitCollection > hits_bh_token
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:209
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< HGCRecHitCollection > hits_ee_token
void reserve(size_type n)
Reserve space for RefVector.
Definition: PtrVectorBase.h:93
size_t size() const
size in number of hits (e.g. in crystals for ECAL)
Definition: CaloCluster.h:186
edm::EDGetTokenT< HGCRecHitCollection > hits_fh_token
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 50 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

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

Definition at line 48 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

std::string HGCalLayerClusterProducer::detector
private

Definition at line 52 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer().

bool HGCalLayerClusterProducer::doSharing
private

Definition at line 51 of file HGCalLayerClusterProducer.cc.

Referenced by produce().

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

Definition at line 46 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

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

Definition at line 44 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

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

Definition at line 45 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

std::string HGCalLayerClusterProducer::timeClname
private

Definition at line 54 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

double HGCalLayerClusterProducer::timeOffset
private

Definition at line 55 of file HGCalLayerClusterProducer.cc.

Referenced by produce().