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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 20 of file EcalDigiSelector.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file EcalDigiSelector.cc.

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

24 {
25  selectedEcalEBDigiCollection_ = ps.getParameter<std::string>("selectedEcalEBDigiCollection");
26  selectedEcalEEDigiCollection_ = ps.getParameter<std::string>("selectedEcalEEDigiCollection");
27 
29  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("barrelSuperClusterProducer"));
31  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapSuperClusterProducer"));
32 
33 
35  consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEBRecHitTag"));
37  consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("EcalEERecHitTag"));
38 
40  consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EcalEBDigiTag"));
42  consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EcalEEDigiTag"));
43 
44  cluster_pt_thresh_ = ps.getParameter<double>("cluster_pt_thresh");
45  single_cluster_thresh_ = ps.getParameter<double>("single_cluster_thresh");
46 
47  nclus_sel_ = ps.getParameter<int>("nclus_sel");
48  produces<EBDigiCollection>(selectedEcalEBDigiCollection_);
49  produces<EEDigiCollection>(selectedEcalEEDigiCollection_);
50 
51 }
T getParameter(std::string const &) const
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::EDGetTokenT< EcalRecHitCollection > EcalEBRecHitToken_
double single_cluster_thresh_

Member Function Documentation

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

Definition at line 53 of file EcalDigiSelector.cc.

References edm::DataFrameContainer::begin(), edm::DataFrameContainer::end(), reco::CaloCluster::energy(), reco::CaloCluster::eta(), JetChargeProducer_cfi::exp, ghostTrackVertexReco_cff::finder, 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().

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

Member Data Documentation

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

Definition at line 35 of file EcalDigiSelector.h.

double EcalDigiSelector::cluster_pt_thresh_
private

Definition at line 47 of file EcalDigiSelector.h.

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

Definition at line 41 of file EcalDigiSelector.h.

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

Definition at line 39 of file EcalDigiSelector.h.

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

Definition at line 42 of file EcalDigiSelector.h.

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

Definition at line 40 of file EcalDigiSelector.h.

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

Definition at line 36 of file EcalDigiSelector.h.

int EcalDigiSelector::nclus_sel_
private

Definition at line 49 of file EcalDigiSelector.h.

std::string EcalDigiSelector::selectedEcalEBDigiCollection_
private

Definition at line 32 of file EcalDigiSelector.h.

std::string EcalDigiSelector::selectedEcalEEDigiCollection_
private

Definition at line 33 of file EcalDigiSelector.h.

double EcalDigiSelector::single_cluster_thresh_
private

Definition at line 48 of file EcalDigiSelector.h.