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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 61 of file HGCalLayerClusterProducer.cc.

References algo, algoId, beamerCreator::create(), detector, reco::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.

61  :
63  doSharing(ps.getParameter<bool>("doSharing")),
64  detector(ps.getParameter<std::string >("detector")), // one of EE, FH, BH or "all"
65  timeClname(ps.getParameter<std::string >("timeClname")),
66  timeOffset(ps.getParameter<double>("timeOffset")) {
67 
68  if(detector=="all") {
69  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
70  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
71  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
73  }else if(detector=="EE") {
74  hits_ee_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCEEInput"));
76  }else if(detector=="FH") {
77  hits_fh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCFHInput"));
79  } else {
80  hits_bh_token = consumes<HGCRecHitCollection>(ps.getParameter<edm::InputTag>("HGCBHInput"));
82  }
83 
84 
85  auto pluginPSet = ps.getParameter<edm::ParameterSet>("plugin");
86  algo.reset(HGCalLayerClusterAlgoFactory::get()->create(pluginPSet.getParameter<std::string>("type"), pluginPSet));
87  algo->setAlgoId(algoId);
88 
89  produces<std::vector<reco::BasicCluster> >();
90  produces<std::vector<reco::BasicCluster> >("sharing");
91  //density
92  produces< Density >();
93  //time for layer clusters
94  produces<edm::ValueMap<float> > (timeClname);
95 
96 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
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
T get(const Candidate &c)
Definition: component.h:55
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 99 of file HGCalLayerClusterProducer.cc.

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

Referenced by ~HGCalLayerClusterProducer().

99  {
100  // hgcalLayerClusters
102  edm::ParameterSetDescription pluginDesc;
103  pluginDesc.addNode(edm::PluginDescription<HGCalLayerClusterAlgoFactory>("type", "CLUE", true));
104 
105  desc.add<edm::ParameterSetDescription>("plugin", pluginDesc);
106  desc.add<std::string>("detector", "all");
107  desc.add<bool>("doSharing", false);
108  desc.add<edm::InputTag>("HGCEEInput", edm::InputTag("HGCalRecHit","HGCEERecHits"));
109  desc.add<edm::InputTag>("HGCFHInput", edm::InputTag("HGCalRecHit","HGCHEFRecHits"));
110  desc.add<edm::InputTag>("HGCBHInput", edm::InputTag("HGCalRecHit","HGCHEBRecHits"));
111  desc.add<std::string>("timeClname", "timeLayerCluster");
112  desc.add<double>("timeOffset", 0.0);
113  descriptions.add("hgcalLayerClusters", desc);
114 }
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 116 of file HGCalLayerClusterProducer.cc.

References algo, algoId, fastPrimaryVertexProducer_cfi::clusters, doSharing, objects.autophobj::filler, ghostTrackVertexReco_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(), reco::CaloCluster::size(), timeClname, timeOffset, and create_public_lumi_plots::times.

Referenced by ~HGCalLayerClusterProducer().

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

Referenced by HGCalLayerClusterProducer(), and produce().

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

Definition at line 49 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

std::string HGCalLayerClusterProducer::detector
private

Definition at line 53 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer().

bool HGCalLayerClusterProducer::doSharing
private

Definition at line 52 of file HGCalLayerClusterProducer.cc.

Referenced by produce().

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

Definition at line 47 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

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

Definition at line 45 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

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

Definition at line 46 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

std::string HGCalLayerClusterProducer::timeClname
private

Definition at line 55 of file HGCalLayerClusterProducer.cc.

Referenced by HGCalLayerClusterProducer(), and produce().

double HGCalLayerClusterProducer::timeOffset
private

Definition at line 56 of file HGCalLayerClusterProducer.cc.

Referenced by produce().