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

Private Attributes

edm::EDGetTokenT< reco::SuperClusterCollectionbarrelSuperClusterProducer_
 
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 19 of file EcalDigiSelector.h.

Constructor & Destructor Documentation

◆ EcalDigiSelector()

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

Definition at line 22 of file EcalDigiSelector.cc.

22  {
23  selectedEcalEBDigiCollection_ = ps.getParameter<std::string>("selectedEcalEBDigiCollection");
24  selectedEcalEEDigiCollection_ = ps.getParameter<std::string>("selectedEcalEEDigiCollection");
25 
27  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("barrelSuperClusterProducer"));
29  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapSuperClusterProducer"));
30 
31  EcalEBRecHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEBRecHitTag"));
32  EcalEERecHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEERecHitTag"));
33 
34  EcalEBDigiToken_ = consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EcalEBDigiTag"));
35  EcalEEDigiToken_ = consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EcalEEDigiTag"));
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  es.get<CaloTopologyRecord>().get(pTopology);
101  const CaloTopology* topology = pTopology.product();
102 
103  //get barrel digi collection
105  const EBDigiCollection* digis = nullptr;
106  evt.getByToken(EcalEBDigiToken_, pdigis);
107  digis = pdigis.product(); // get a ptr to the product
108 
110  const EcalRecHitCollection* rechits = nullptr;
111  evt.getByToken(EcalEBRecHitToken_, prechits);
112  rechits = prechits.product(); // get a ptr to the product
113 
114  if (digis) {
115  std::vector<DetId> saveTheseDetIds;
116  //pick out the detids for the 3x3 in each of the selected superclusters
117  for (int loop = 0; loop < int(saveBarrelSuperClusters.size()); loop++) {
118  SuperCluster clus1 = saveBarrelSuperClusters[loop];
119  const CaloClusterPtr& bcref = clus1.seed();
120  const BasicCluster* bc = bcref.get();
121  //Get the maximum detid
122  DetId maxDetId = EcalClusterTools::getMaximum(*bc, rechits).first;
123  // Loop over the 3x3 array centered on maximum detid
124  for (DetId detId : CaloRectangleRange(1, maxDetId, *topology))
125  saveTheseDetIds.push_back(detId);
126  }
127  for (int detloop = 0; detloop < int(saveTheseDetIds.size()); ++detloop) {
128  EBDetId detL = EBDetId(saveTheseDetIds[detloop]);
129 
130  for (EBDigiCollection::const_iterator blah = digis->begin(); blah != digis->end(); blah++) {
131  if (detL == blah->id()) {
132  EBDataFrame myDigi = (*blah);
133  SEBDigiCol->push_back(detL);
134 
135  EBDataFrame df(SEBDigiCol->back());
136  for (int iq = 0; iq < myDigi.size(); ++iq) {
137  df.setSample(iq, myDigi.sample(iq).raw());
138  }
139  //ebcounter++;
140  }
141  }
142  //if (ebcounter >= int(saveTheseDetIds.size())) break;
143  } //loop over dets
144  }
145 
146  } //If barrel superclusters need saving.
147 
148  if (!saveEndcapSuperClusters.empty()) {
149  edm::ESHandle<CaloTopology> pTopology;
150  es.get<CaloTopologyRecord>().get(pTopology);
151  const CaloTopology* topology = pTopology.product();
152 
153  //Get endcap rec hit collection
154  //get endcap digi collection
156  const EEDigiCollection* digis = nullptr;
157  evt.getByToken(EcalEEDigiToken_, pdigis);
158  digis = pdigis.product(); // get a ptr to the product
159 
161  const EcalRecHitCollection* rechits = nullptr;
162  evt.getByToken(EcalEERecHitToken_, prechits);
163  rechits = prechits.product(); // get a ptr to the product
164 
165  if (digis) {
166  //std::vector<DetId> saveTheseDetIds;
167  std::set<DetId> saveTheseDetIds;
168  //pick out the digis for the 3x3 in each of the selected superclusters
169  for (int loop = 0; loop < int(saveEndcapSuperClusters.size()); loop++) {
170  SuperCluster clus1 = saveEndcapSuperClusters[loop];
171  const CaloClusterPtr& bcref = clus1.seed();
172  const BasicCluster* bc = bcref.get();
173  //Get the maximum detid
174  DetId maxDetId = EcalClusterTools::getMaximum(*bc, rechits).first;
175  // Loop over the 3x3 array centered on maximum detid
176  for (DetId detId : CaloRectangleRange(1, maxDetId, *topology))
177  saveTheseDetIds.insert(detId);
178  }
179  int eecounter = 0;
180  for (EEDigiCollection::const_iterator blah = digis->begin(); blah != digis->end(); blah++) {
181  std::set<DetId>::const_iterator finder = saveTheseDetIds.find(blah->id());
182  if (finder != saveTheseDetIds.end()) {
183  EEDetId detL = EEDetId(*finder);
184 
185  if (detL == blah->id()) {
186  EEDataFrame myDigi = (*blah);
187  SEEDigiCol->push_back(detL);
188  EEDataFrame df(SEEDigiCol->back());
189  for (int iq = 0; iq < myDigi.size(); ++iq) {
190  df.setSample(iq, myDigi.sample(iq).raw());
191  }
192  eecounter++;
193  }
194  }
195  if (eecounter >= int(saveTheseDetIds.size()))
196  break;
197  } //loop over digis
198  }
199  } //If endcap superclusters need saving.
200 
201  } //If we're actually saving stuff
202 
203  //Okay, either my collections have been filled with the requisite Digis, or they haven't.
204 
205  //Empty collection, or full, still put in event.
206  SEBDigiCol->sort();
207  SEEDigiCol->sort();
208  evt.put(std::move(SEBDigiCol), selectedEcalEBDigiCollection_);
209  evt.put(std::move(SEEDigiCol), selectedEcalEEDigiCollection_);
210 }

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

Member Data Documentation

◆ barrelSuperClusterProducer_

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

Definition at line 29 of file EcalDigiSelector.h.

◆ cluster_pt_thresh_

double EcalDigiSelector::cluster_pt_thresh_
private

Definition at line 38 of file EcalDigiSelector.h.

◆ EcalEBDigiToken_

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

Definition at line 35 of file EcalDigiSelector.h.

◆ EcalEBRecHitToken_

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

Definition at line 33 of file EcalDigiSelector.h.

◆ EcalEEDigiToken_

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

Definition at line 36 of file EcalDigiSelector.h.

◆ EcalEERecHitToken_

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

Definition at line 34 of file EcalDigiSelector.h.

◆ endcapSuperClusterProducer_

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

Definition at line 30 of file EcalDigiSelector.h.

◆ nclus_sel_

int EcalDigiSelector::nclus_sel_
private

Definition at line 40 of file EcalDigiSelector.h.

◆ selectedEcalEBDigiCollection_

std::string EcalDigiSelector::selectedEcalEBDigiCollection_
private

Definition at line 26 of file EcalDigiSelector.h.

◆ selectedEcalEEDigiCollection_

std::string EcalDigiSelector::selectedEcalEEDigiCollection_
private

Definition at line 27 of file EcalDigiSelector.h.

◆ single_cluster_thresh_

double EcalDigiSelector::single_cluster_thresh_
private

Definition at line 39 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:26
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
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:38
HLT_2018_cff.eta1
eta1
Definition: HLT_2018_cff.py:8220
EcalDigiSelector::EcalEEDigiToken_
edm::EDGetTokenT< EEDigiCollection > EcalEEDigiToken_
Definition: EcalDigiSelector.h:36
edm::SortedCollection< EcalRecHit >
EcalDigiSelector::EcalEERecHitToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEERecHitToken_
Definition: EcalDigiSelector.h:34
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
CaloTopologyRecord
Definition: CaloTopologyRecord.h:10
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
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ecaldqm::topology
const CaloTopology * topology(nullptr)
EcalDigiSelector::EcalEBRecHitToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEBRecHitToken_
Definition: EcalDigiSelector.h:33
reco::CaloCluster
Definition: CaloCluster.h:31
edm::ESHandle< CaloTopology >
EcalDigiSelector::endcapSuperClusterProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSuperClusterProducer_
Definition: EcalDigiSelector.h:30
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
EcalMGPASample::raw
uint16_t raw() const
get the raw word
Definition: EcalMGPASample.h:29
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalDigiSelector::EcalEBDigiToken_
edm::EDGetTokenT< EBDigiCollection > EcalEBDigiToken_
Definition: EcalDigiSelector.h:35
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:32
EEDigiCollection
Definition: EcalDigiCollections.h:45
heppy_loop.loop
loop
Definition: heppy_loop.py:28
TrackInfoProducer_cfi.rechits
rechits
Definition: TrackInfoProducer_cfi.py:9
createfilelist.int
int
Definition: createfilelist.py:10
EcalDigiSelector::single_cluster_thresh_
double single_cluster_thresh_
Definition: EcalDigiSelector.h:39
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:132
get
#define get
edm::Ptr< CaloCluster >
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalDigiSelector::barrelSuperClusterProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > barrelSuperClusterProducer_
Definition: EcalDigiSelector.h:29
HLT_2018_cff.finder
finder
Definition: HLT_2018_cff.py:50398
eostools.move
def move(src, dest)
Definition: eostools.py:511
EcalDataFrame::size
int size() const
Definition: EcalDataFrame.h:26
EcalDigiSelector::selectedEcalEEDigiCollection_
std::string selectedEcalEEDigiCollection_
Definition: EcalDigiSelector.h:27
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
EEDataFrame
Definition: EEDataFrame.h:12
EcalDataFrame::setSample
void setSample(int i, EcalMGPASample sam)
Definition: EcalDataFrame.h:43
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:40