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.

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 }

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 86 of file EcalDigiSelector.cc.

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  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  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 }

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(), and EcalDataFrame::size().

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.

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.cc:39
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:51974
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.cc:52
EcalDigiSelector::EcalEEDigiToken_
edm::EDGetTokenT< EEDigiCollection > EcalEEDigiToken_
Definition: EcalDigiSelector.cc:49
edm::SortedCollection< EcalRecHit >
EcalDigiSelector::EcalEERecHitToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEERecHitToken_
Definition: EcalDigiSelector.cc:47
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
EcalDigiSelector::EcalEBRecHitToken_
edm::EDGetTokenT< EcalRecHitCollection > EcalEBRecHitToken_
Definition: EcalDigiSelector.cc:46
reco::CaloCluster
Definition: CaloCluster.h:31
edm::ESHandle< CaloTopology >
EcalDigiSelector::endcapSuperClusterProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSuperClusterProducer_
Definition: EcalDigiSelector.cc:43
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:539
EcalMGPASample::raw
uint16_t raw() const
get the raw word
Definition: EcalMGPASample.h:29
EcalDigiSelector::caloTopologyToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
Definition: EcalDigiSelector.cc:50
EEDetId
Definition: EEDetId.h:14
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9550
EcalDigiSelector::EcalEBDigiToken_
edm::EDGetTokenT< EBDigiCollection > EcalEBDigiToken_
Definition: EcalDigiSelector.cc:48
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.cc:53
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:155
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Ptr< CaloCluster >
EcalDigiSelector::barrelSuperClusterProducer_
edm::EDGetTokenT< reco::SuperClusterCollection > barrelSuperClusterProducer_
Definition: EcalDigiSelector.cc:42
eostools.move
def move(src, dest)
Definition: eostools.py:511
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
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.cc:40
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.cc:54