CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EcalDigiSelector Class Reference
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 32 of file EcalDigiSelector.cc.

Constructor & Destructor Documentation

◆ EcalDigiSelector()

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

Definition at line 61 of file EcalDigiSelector.cc.

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

61  {
62  selectedEcalEBDigiCollection_ = ps.getParameter<std::string>("selectedEcalEBDigiCollection");
63  selectedEcalEEDigiCollection_ = ps.getParameter<std::string>("selectedEcalEEDigiCollection");
64 
66  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("barrelSuperClusterProducer"));
68  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapSuperClusterProducer"));
69 
70  EcalEBRecHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEBRecHitTag"));
71  EcalEERecHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEERecHitTag"));
72 
73  EcalEBDigiToken_ = consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EcalEBDigiTag"));
74  EcalEEDigiToken_ = consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EcalEEDigiTag"));
75 
76  caloTopologyToken_ = esConsumes<CaloTopology, CaloTopologyRecord>();
77 
78  cluster_pt_thresh_ = ps.getParameter<double>("cluster_pt_thresh");
79  single_cluster_thresh_ = ps.getParameter<double>("single_cluster_thresh");
80 
81  nclus_sel_ = ps.getParameter<int>("nclus_sel");
82  produces<EBDigiCollection>(selectedEcalEBDigiCollection_);
83  produces<EEDigiCollection>(selectedEcalEEDigiCollection_);
84 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string selectedEcalEEDigiCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > barrelSuperClusterProducer_
std::string selectedEcalEBDigiCollection_
edm::EDGetTokenT< EEDigiCollection > EcalEEDigiToken_
edm::EDGetTokenT< EBDigiCollection > EcalEBDigiToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEERecHitToken_
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSuperClusterProducer_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEBRecHitToken_

Member Function Documentation

◆ produce()

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

Definition at line 86 of file EcalDigiSelector.cc.

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

86  {
87  //Get BarrelSuperClusters to start.
88  edm::Handle<reco::SuperClusterCollection> pBarrelSuperClusters;
89 
90  evt.getByToken(barrelSuperClusterProducer_, pBarrelSuperClusters);
91 
92  const reco::SuperClusterCollection& BarrelSuperClusters = *pBarrelSuperClusters;
93  //Got BarrelSuperClusters
94 
95  //Get BarrelSuperClusters to start.
96  edm::Handle<reco::SuperClusterCollection> pEndcapSuperClusters;
97 
98  evt.getByToken(endcapSuperClusterProducer_, pEndcapSuperClusters);
99 
100  const reco::SuperClusterCollection& EndcapSuperClusters = *pEndcapSuperClusters;
101  //Got EndcapSuperClusters
102 
103  reco::SuperClusterCollection saveBarrelSuperClusters;
104  reco::SuperClusterCollection saveEndcapSuperClusters;
105  bool meet_single_thresh = false;
106  //Loop over barrel superclusters, and apply threshold
107  for (int loop = 0; loop < int(BarrelSuperClusters.size()); loop++) {
108  const SuperCluster& clus1 = BarrelSuperClusters[loop];
109  float eta1 = clus1.eta();
110  float energy1 = clus1.energy();
111  float theta1 = 2 * atan(exp(-1. * eta1));
112  float cluspt1 = energy1 * sin(theta1);
113  if (cluspt1 > cluster_pt_thresh_) {
114  saveBarrelSuperClusters.push_back(clus1);
115  if (cluspt1 > single_cluster_thresh_)
116  meet_single_thresh = true;
117  }
118  }
119 
120  //Loop over endcap superclusters, and apply threshold
121  for (int loop = 0; loop < int(EndcapSuperClusters.size()); loop++) {
122  const SuperCluster& clus1 = EndcapSuperClusters[loop];
123  float eta1 = clus1.eta();
124  float energy1 = clus1.energy();
125  float theta1 = 2 * atan(exp(-1. * eta1));
126  float cluspt1 = energy1 * sin(theta1);
127  if (cluspt1 > cluster_pt_thresh_) {
128  saveEndcapSuperClusters.push_back(clus1);
129  if (cluspt1 > single_cluster_thresh_)
130  meet_single_thresh = true;
131  }
132  }
133 
134  auto SEBDigiCol = std::make_unique<EBDigiCollection>();
135  auto SEEDigiCol = std::make_unique<EEDigiCollection>();
136  int TotClus = saveBarrelSuperClusters.size() + saveEndcapSuperClusters.size();
137 
138  if (TotClus >= nclus_sel_ || meet_single_thresh) {
139  if (!saveBarrelSuperClusters.empty()) {
141  const CaloTopology* topology = pTopology.product();
142 
143  //get barrel digi collection
145  const EBDigiCollection* digis = nullptr;
146  evt.getByToken(EcalEBDigiToken_, pdigis);
147  digis = pdigis.product(); // get a ptr to the product
148 
150  const EcalRecHitCollection* rechits = nullptr;
151  evt.getByToken(EcalEBRecHitToken_, prechits);
152  rechits = prechits.product(); // get a ptr to the product
153 
154  if (digis) {
155  std::vector<DetId> saveTheseDetIds;
156  //pick out the detids for the 3x3 in each of the selected superclusters
157  for (int loop = 0; loop < int(saveBarrelSuperClusters.size()); loop++) {
158  SuperCluster clus1 = saveBarrelSuperClusters[loop];
159  const CaloClusterPtr& bcref = clus1.seed();
160  const BasicCluster* bc = bcref.get();
161  //Get the maximum detid
162  DetId maxDetId = EcalClusterTools::getMaximum(*bc, rechits).first;
163  // Loop over the 3x3 array centered on maximum detid
164  for (DetId detId : CaloRectangleRange(1, maxDetId, *topology))
165  saveTheseDetIds.push_back(detId);
166  }
167  for (int detloop = 0; detloop < int(saveTheseDetIds.size()); ++detloop) {
168  EBDetId detL = EBDetId(saveTheseDetIds[detloop]);
169 
170  for (EBDigiCollection::const_iterator blah = digis->begin(); blah != digis->end(); blah++) {
171  if (detL == blah->id()) {
172  EBDataFrame myDigi = (*blah);
173  SEBDigiCol->push_back(detL);
174 
175  EBDataFrame df(SEBDigiCol->back());
176  for (int iq = 0; iq < myDigi.size(); ++iq) {
177  df.setSample(iq, myDigi.sample(iq).raw());
178  }
179  //ebcounter++;
180  }
181  }
182  //if (ebcounter >= int(saveTheseDetIds.size())) break;
183  } //loop over dets
184  }
185 
186  } //If barrel superclusters need saving.
187 
188  if (!saveEndcapSuperClusters.empty()) {
190  const CaloTopology* topology = pTopology.product();
191 
192  //Get endcap rec hit collection
193  //get endcap digi collection
195  const EEDigiCollection* digis = nullptr;
196  evt.getByToken(EcalEEDigiToken_, pdigis);
197  digis = pdigis.product(); // get a ptr to the product
198 
200  const EcalRecHitCollection* rechits = nullptr;
201  evt.getByToken(EcalEERecHitToken_, prechits);
202  rechits = prechits.product(); // get a ptr to the product
203 
204  if (digis) {
205  //std::vector<DetId> saveTheseDetIds;
206  std::set<DetId> saveTheseDetIds;
207  //pick out the digis for the 3x3 in each of the selected superclusters
208  for (int loop = 0; loop < int(saveEndcapSuperClusters.size()); loop++) {
209  SuperCluster clus1 = saveEndcapSuperClusters[loop];
210  const CaloClusterPtr& bcref = clus1.seed();
211  const BasicCluster* bc = bcref.get();
212  //Get the maximum detid
213  DetId maxDetId = EcalClusterTools::getMaximum(*bc, rechits).first;
214  // Loop over the 3x3 array centered on maximum detid
215  for (DetId detId : CaloRectangleRange(1, maxDetId, *topology))
216  saveTheseDetIds.insert(detId);
217  }
218  int eecounter = 0;
219  for (EEDigiCollection::const_iterator blah = digis->begin(); blah != digis->end(); blah++) {
220  std::set<DetId>::const_iterator finder = saveTheseDetIds.find(blah->id());
221  if (finder != saveTheseDetIds.end()) {
222  EEDetId detL = EEDetId(*finder);
223 
224  if (detL == blah->id()) {
225  EEDataFrame myDigi = (*blah);
226  SEEDigiCol->push_back(detL);
227  EEDataFrame df(SEEDigiCol->back());
228  for (int iq = 0; iq < myDigi.size(); ++iq) {
229  df.setSample(iq, myDigi.sample(iq).raw());
230  }
231  eecounter++;
232  }
233  }
234  if (eecounter >= int(saveTheseDetIds.size()))
235  break;
236  } //loop over digis
237  }
238  } //If endcap superclusters need saving.
239 
240  } //If we're actually saving stuff
241 
242  //Okay, either my collections have been filled with the requisite Digis, or they haven't.
243 
244  //Empty collection, or full, still put in event.
245  SEBDigiCol->sort();
246  SEEDigiCol->sort();
247  evt.put(std::move(SEBDigiCol), selectedEcalEBDigiCollection_);
248  evt.put(std::move(SEEDigiCol), selectedEcalEEDigiCollection_);
249 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T const * product() const
Definition: Handle.h:70
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
std::string selectedEcalEEDigiCollection_
int size() const
Definition: EcalDataFrame.h:26
double getMaximum(TObjArray *array)
edm::EDGetTokenT< reco::SuperClusterCollection > barrelSuperClusterProducer_
std::string selectedEcalEBDigiCollection_
T const * product() const
Definition: ESHandle.h:86
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
edm::EDGetTokenT< EEDigiCollection > EcalEEDigiToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
const_iterator end() const
double energy() const
cluster energy
Definition: CaloCluster.h:148
Definition: DetId.h:17
const_iterator begin() const
The iterator returned can not safely be used across threads.
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:79
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:180
edm::EDGetTokenT< EBDigiCollection > EcalEBDigiToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEERecHitToken_
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSuperClusterProducer_
uint16_t raw() const
get the raw word
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEBRecHitToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ barrelSuperClusterProducer_

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

Definition at line 42 of file EcalDigiSelector.cc.

◆ caloTopologyToken_

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

Definition at line 50 of file EcalDigiSelector.cc.

◆ cluster_pt_thresh_

double EcalDigiSelector::cluster_pt_thresh_
private

Definition at line 52 of file EcalDigiSelector.cc.

◆ EcalEBDigiToken_

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

Definition at line 48 of file EcalDigiSelector.cc.

◆ EcalEBRecHitToken_

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

Definition at line 46 of file EcalDigiSelector.cc.

◆ EcalEEDigiToken_

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

Definition at line 49 of file EcalDigiSelector.cc.

◆ EcalEERecHitToken_

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

Definition at line 47 of file EcalDigiSelector.cc.

◆ endcapSuperClusterProducer_

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

Definition at line 43 of file EcalDigiSelector.cc.

◆ nclus_sel_

int EcalDigiSelector::nclus_sel_
private

Definition at line 54 of file EcalDigiSelector.cc.

◆ selectedEcalEBDigiCollection_

std::string EcalDigiSelector::selectedEcalEBDigiCollection_
private

Definition at line 39 of file EcalDigiSelector.cc.

◆ selectedEcalEEDigiCollection_

std::string EcalDigiSelector::selectedEcalEEDigiCollection_
private

Definition at line 40 of file EcalDigiSelector.cc.

◆ single_cluster_thresh_

double EcalDigiSelector::single_cluster_thresh_
private

Definition at line 53 of file EcalDigiSelector.cc.