CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EcalDigiSelector Class Reference

#include <EcalDigiSelector.h>

Inheritance diagram for EcalDigiSelector:
edm::stream::EDProducer<>

Public Member Functions

 EcalDigiSelector (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &) 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
 

Private Attributes

edm::EDGetTokenT< reco::SuperClusterCollectionbarrelSuperClusterProducer_
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordcaloTopologyToken_
 
double cluster_pt_thresh_
 
edm::EDGetTokenT< EBDigiCollectionEcalEBDigiToken_
 
edm::EDGetTokenT< EcalRecHitCollectionEcalEBRecHitToken_
 
edm::EDGetTokenT< EEDigiCollectionEcalEEDigiToken_
 
edm::EDGetTokenT< EcalRecHitCollectionEcalEERecHitToken_
 
edm::EDGetTokenT< reco::SuperClusterCollectionendcapSuperClusterProducer_
 
int nclus_sel_
 
std::string selectedEcalEBDigiCollection_
 
std::string selectedEcalEEDigiCollection_
 
double single_cluster_thresh_
 

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 22 of file EcalDigiSelector.h.

Constructor & Destructor Documentation

◆ EcalDigiSelector()

EcalDigiSelector::EcalDigiSelector ( const edm::ParameterSet ps)

Definition at line 20 of file EcalDigiSelector.cc.

20  {
21  selectedEcalEBDigiCollection_ = ps.getParameter<std::string>("selectedEcalEBDigiCollection");
22  selectedEcalEEDigiCollection_ = ps.getParameter<std::string>("selectedEcalEEDigiCollection");
23 
25  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("barrelSuperClusterProducer"));
27  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapSuperClusterProducer"));
28 
29  EcalEBRecHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEBRecHitTag"));
30  EcalEERecHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEERecHitTag"));
31 
32  EcalEBDigiToken_ = consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EcalEBDigiTag"));
33  EcalEEDigiToken_ = consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EcalEEDigiTag"));
34 
35  caloTopologyToken_ = esConsumes<CaloTopology, CaloTopologyRecord>();
36 
37  cluster_pt_thresh_ = ps.getParameter<double>("cluster_pt_thresh");
38  single_cluster_thresh_ = ps.getParameter<double>("single_cluster_thresh");
39 
40  nclus_sel_ = ps.getParameter<int>("nclus_sel");
41  produces<EBDigiCollection>(selectedEcalEBDigiCollection_);
42  produces<EEDigiCollection>(selectedEcalEEDigiCollection_);
43 }

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

Member Function Documentation

◆ produce()

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

Definition at line 45 of file EcalDigiSelector.cc.

45  {
46  //Get BarrelSuperClusters to start.
47  edm::Handle<reco::SuperClusterCollection> pBarrelSuperClusters;
48 
49  evt.getByToken(barrelSuperClusterProducer_, pBarrelSuperClusters);
50 
51  const reco::SuperClusterCollection& BarrelSuperClusters = *pBarrelSuperClusters;
52  //Got BarrelSuperClusters
53 
54  //Get BarrelSuperClusters to start.
55  edm::Handle<reco::SuperClusterCollection> pEndcapSuperClusters;
56 
57  evt.getByToken(endcapSuperClusterProducer_, pEndcapSuperClusters);
58 
59  const reco::SuperClusterCollection& EndcapSuperClusters = *pEndcapSuperClusters;
60  //Got EndcapSuperClusters
61 
62  reco::SuperClusterCollection saveBarrelSuperClusters;
63  reco::SuperClusterCollection saveEndcapSuperClusters;
64  bool meet_single_thresh = false;
65  //Loop over barrel superclusters, and apply threshold
66  for (int loop = 0; loop < int(BarrelSuperClusters.size()); loop++) {
67  SuperCluster clus1 = BarrelSuperClusters[loop];
68  float eta1 = clus1.eta();
69  float energy1 = clus1.energy();
70  float theta1 = 2 * atan(exp(-1. * eta1));
71  float cluspt1 = energy1 * sin(theta1);
72  if (cluspt1 > cluster_pt_thresh_) {
73  saveBarrelSuperClusters.push_back(clus1);
74  if (cluspt1 > single_cluster_thresh_)
75  meet_single_thresh = true;
76  }
77  }
78 
79  //Loop over endcap superclusters, and apply threshold
80  for (int loop = 0; loop < int(EndcapSuperClusters.size()); loop++) {
81  SuperCluster clus1 = EndcapSuperClusters[loop];
82  float eta1 = clus1.eta();
83  float energy1 = clus1.energy();
84  float theta1 = 2 * atan(exp(-1. * eta1));
85  float cluspt1 = energy1 * sin(theta1);
86  if (cluspt1 > cluster_pt_thresh_) {
87  saveEndcapSuperClusters.push_back(clus1);
88  if (cluspt1 > single_cluster_thresh_)
89  meet_single_thresh = true;
90  }
91  }
92 
93  auto SEBDigiCol = std::make_unique<EBDigiCollection>();
94  auto SEEDigiCol = std::make_unique<EEDigiCollection>();
95  int TotClus = saveBarrelSuperClusters.size() + saveEndcapSuperClusters.size();
96 
97  if (TotClus >= nclus_sel_ || meet_single_thresh) {
98  if (!saveBarrelSuperClusters.empty()) {
100  const CaloTopology* topology = pTopology.product();
101 
102  //get barrel digi collection
104  const EBDigiCollection* digis = nullptr;
105  evt.getByToken(EcalEBDigiToken_, pdigis);
106  digis = pdigis.product(); // get a ptr to the product
107 
109  const EcalRecHitCollection* rechits = nullptr;
110  evt.getByToken(EcalEBRecHitToken_, prechits);
111  rechits = prechits.product(); // get a ptr to the product
112 
113  if (digis) {
114  std::vector<DetId> saveTheseDetIds;
115  //pick out the detids for the 3x3 in each of the selected superclusters
116  for (int loop = 0; loop < int(saveBarrelSuperClusters.size()); loop++) {
117  SuperCluster clus1 = saveBarrelSuperClusters[loop];
118  const CaloClusterPtr& bcref = clus1.seed();
119  const BasicCluster* bc = bcref.get();
120  //Get the maximum detid
121  DetId maxDetId = EcalClusterTools::getMaximum(*bc, rechits).first;
122  // Loop over the 3x3 array centered on maximum detid
123  for (DetId detId : CaloRectangleRange(1, maxDetId, *topology))
124  saveTheseDetIds.push_back(detId);
125  }
126  for (int detloop = 0; detloop < int(saveTheseDetIds.size()); ++detloop) {
127  EBDetId detL = EBDetId(saveTheseDetIds[detloop]);
128 
129  for (EBDigiCollection::const_iterator blah = digis->begin(); blah != digis->end(); blah++) {
130  if (detL == blah->id()) {
131  EBDataFrame myDigi = (*blah);
132  SEBDigiCol->push_back(detL);
133 
134  EBDataFrame df(SEBDigiCol->back());
135  for (int iq = 0; iq < myDigi.size(); ++iq) {
136  df.setSample(iq, myDigi.sample(iq).raw());
137  }
138  //ebcounter++;
139  }
140  }
141  //if (ebcounter >= int(saveTheseDetIds.size())) break;
142  } //loop over dets
143  }
144 
145  } //If barrel superclusters need saving.
146 
147  if (!saveEndcapSuperClusters.empty()) {
149  const CaloTopology* topology = pTopology.product();
150 
151  //Get endcap rec hit collection
152  //get endcap digi collection
154  const EEDigiCollection* digis = nullptr;
155  evt.getByToken(EcalEEDigiToken_, pdigis);
156  digis = pdigis.product(); // get a ptr to the product
157 
159  const EcalRecHitCollection* rechits = nullptr;
160  evt.getByToken(EcalEERecHitToken_, prechits);
161  rechits = prechits.product(); // get a ptr to the product
162 
163  if (digis) {
164  //std::vector<DetId> saveTheseDetIds;
165  std::set<DetId> saveTheseDetIds;
166  //pick out the digis for the 3x3 in each of the selected superclusters
167  for (int loop = 0; loop < int(saveEndcapSuperClusters.size()); loop++) {
168  SuperCluster clus1 = saveEndcapSuperClusters[loop];
169  const CaloClusterPtr& bcref = clus1.seed();
170  const BasicCluster* bc = bcref.get();
171  //Get the maximum detid
172  DetId maxDetId = EcalClusterTools::getMaximum(*bc, rechits).first;
173  // Loop over the 3x3 array centered on maximum detid
174  for (DetId detId : CaloRectangleRange(1, maxDetId, *topology))
175  saveTheseDetIds.insert(detId);
176  }
177  int eecounter = 0;
178  for (EEDigiCollection::const_iterator blah = digis->begin(); blah != digis->end(); blah++) {
179  std::set<DetId>::const_iterator finder = saveTheseDetIds.find(blah->id());
180  if (finder != saveTheseDetIds.end()) {
181  EEDetId detL = EEDetId(*finder);
182 
183  if (detL == blah->id()) {
184  EEDataFrame myDigi = (*blah);
185  SEEDigiCol->push_back(detL);
186  EEDataFrame df(SEEDigiCol->back());
187  for (int iq = 0; iq < myDigi.size(); ++iq) {
188  df.setSample(iq, myDigi.sample(iq).raw());
189  }
190  eecounter++;
191  }
192  }
193  if (eecounter >= int(saveTheseDetIds.size()))
194  break;
195  } //loop over digis
196  }
197  } //If endcap superclusters need saving.
198 
199  } //If we're actually saving stuff
200 
201  //Okay, either my collections have been filled with the requisite Digis, or they haven't.
202 
203  //Empty collection, or full, still put in event.
204  SEBDigiCol->sort();
205  SEEDigiCol->sort();
206  evt.put(std::move(SEBDigiCol), selectedEcalEBDigiCollection_);
207  evt.put(std::move(SEEDigiCol), selectedEcalEEDigiCollection_);
208 }

References edm::DataFrameContainer::begin(), hgcalPerformanceValidation::df, edm::DataFrameContainer::end(), reco::CaloCluster::energy(), reco::CaloCluster::eta(), HLT_FULL_cff::eta1, JetChargeProducer_cfi::exp, HLT_FULL_cff::finder, edm::Ptr< T >::get(), edm::Event::getByToken(), edm::EventSetup::getHandle(), createfilelist::int, heppy_loop::loop, eostools::move(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), EcalMGPASample::raw(), HI_PhotonSkim_cff::rechits, EcalDataFrame::sample(), reco::SuperCluster::seed(), funct::sin(), EcalDataFrame::size(), and ecaldqm::topology().

Member Data Documentation

◆ barrelSuperClusterProducer_

edm::EDGetTokenT<reco::SuperClusterCollection> EcalDigiSelector::barrelSuperClusterProducer_
private

Definition at line 32 of file EcalDigiSelector.h.

◆ caloTopologyToken_

edm::ESGetToken<CaloTopology, CaloTopologyRecord> EcalDigiSelector::caloTopologyToken_
private

Definition at line 40 of file EcalDigiSelector.h.

◆ cluster_pt_thresh_

double EcalDigiSelector::cluster_pt_thresh_
private

Definition at line 42 of file EcalDigiSelector.h.

◆ EcalEBDigiToken_

edm::EDGetTokenT<EBDigiCollection> EcalDigiSelector::EcalEBDigiToken_
private

Definition at line 38 of file EcalDigiSelector.h.

◆ EcalEBRecHitToken_

edm::EDGetTokenT<EcalRecHitCollection> EcalDigiSelector::EcalEBRecHitToken_
private

Definition at line 36 of file EcalDigiSelector.h.

◆ EcalEEDigiToken_

edm::EDGetTokenT<EEDigiCollection> EcalDigiSelector::EcalEEDigiToken_
private

Definition at line 39 of file EcalDigiSelector.h.

◆ EcalEERecHitToken_

edm::EDGetTokenT<EcalRecHitCollection> EcalDigiSelector::EcalEERecHitToken_
private

Definition at line 37 of file EcalDigiSelector.h.

◆ endcapSuperClusterProducer_

edm::EDGetTokenT<reco::SuperClusterCollection> EcalDigiSelector::endcapSuperClusterProducer_
private

Definition at line 33 of file EcalDigiSelector.h.

◆ nclus_sel_

int EcalDigiSelector::nclus_sel_
private

Definition at line 44 of file EcalDigiSelector.h.

◆ selectedEcalEBDigiCollection_

std::string EcalDigiSelector::selectedEcalEBDigiCollection_
private

Definition at line 29 of file EcalDigiSelector.h.

◆ selectedEcalEEDigiCollection_

std::string EcalDigiSelector::selectedEcalEEDigiCollection_
private

Definition at line 30 of file EcalDigiSelector.h.

◆ single_cluster_thresh_

double EcalDigiSelector::single_cluster_thresh_
private

Definition at line 43 of file EcalDigiSelector.h.

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalDataFrame::sample
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
EcalDigiSelector::selectedEcalEBDigiCollection_
std::string selectedEcalEBDigiCollection_
Definition: EcalDigiSelector.h:29
CaloRectangleRange
Definition: CaloRectangle.h:36
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
HLT_FULL_cff.finder
finder
Definition: HLT_FULL_cff.py:51924
reco::SuperCluster
Definition: SuperCluster.h:18
EBDetId
Definition: EBDetId.h:17
EBDataFrame
Definition: EBDataFrame.h:11
EcalDigiSelector::cluster_pt_thresh_
double cluster_pt_thresh_
Definition: EcalDigiSelector.h:42
EcalDigiSelector::EcalEEDigiToken_
edm::EDGetTokenT< EEDigiCollection > EcalEEDigiToken_
Definition: EcalDigiSelector.h:39
edm::SortedCollection< EcalRecHit >
EcalDigiSelector::EcalEERecHitToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEERecHitToken_
Definition: EcalDigiSelector.h:37
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
edm::Handle
Definition: AssociativeIterator.h:50
CaloTopology
Definition: CaloTopology.h:19
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
DetId
Definition: DetId.h:17
ecaldqm::topology
const CaloTopology * topology(nullptr)
EcalDigiSelector::EcalEBRecHitToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEBRecHitToken_
Definition: EcalDigiSelector.h:36
reco::CaloCluster
Definition: CaloCluster.h:31
edm::ESHandle< CaloTopology >
EcalDigiSelector::endcapSuperClusterProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSuperClusterProducer_
Definition: EcalDigiSelector.h:33
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
EcalMGPASample::raw
uint16_t raw() const
get the raw word
Definition: EcalMGPASample.h:29
EcalDigiSelector::caloTopologyToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
Definition: EcalDigiSelector.h:40
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9541
EcalDigiSelector::EcalEBDigiToken_
edm::EDGetTokenT< EBDigiCollection > EcalEBDigiToken_
Definition: EcalDigiSelector.h:38
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
EBDigiCollection
Definition: EcalDigiCollections.h:56
EEDigiCollection
Definition: EcalDigiCollections.h:69
heppy_loop.loop
loop
Definition: heppy_loop.py:28
createfilelist.int
int
Definition: createfilelist.py:10
EcalDigiSelector::single_cluster_thresh_
double single_cluster_thresh_
Definition: EcalDigiSelector.h:43
edm::DataFrameContainer::begin
const_iterator begin() const
The iterator returned can not safely be used across threads.
Definition: DataFrameContainer.h:149
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::Ptr< CaloCluster >
EcalDigiSelector::barrelSuperClusterProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > barrelSuperClusterProducer_
Definition: EcalDigiSelector.h:32
eostools.move
def move(src, dest)
Definition: eostools.py:511
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:640
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalDataFrame::size
int size() const
Definition: EcalDataFrame.h:26
EcalDigiSelector::selectedEcalEEDigiCollection_
std::string selectedEcalEEDigiCollection_
Definition: EcalDigiSelector.h:30
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
EEDataFrame
Definition: EEDataFrame.h:12
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
edm::InputTag
Definition: InputTag.h:15
EcalDigiSelector::nclus_sel_
int nclus_sel_
Definition: EcalDigiSelector.h:44