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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalDigiSelector (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 
)

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.size() > 0){
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=0;
120  evt.getByToken(EcalEBDigiToken_,pdigis);
121  digis = pdigis.product(); // get a ptr to the product
122 
124  const EcalRecHitCollection* rechits=0;
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  CaloClusterPtr bcref = clus1.seed();
135  const BasicCluster *bc = bcref.get();
136  //Get the maximum detid
137  std::pair<DetId, float> EDetty =
138  EcalClusterTools::getMaximum(*bc,rechits);
139  //get the 3x3 array centered on maximum detid.
140  std::vector<DetId> detvec =
141  EcalClusterTools::matrixDetId(topology,EDetty.first, -1, 1, -1, 1);
142  //Loop over the 3x3
143  for (int ik = 0;ik<int(detvec.size());++ik)
144  saveTheseDetIds.push_back(detvec[ik]);
145 
146  }
147  for (int detloop=0; detloop < int(saveTheseDetIds.size());++detloop){
148  EBDetId detL = EBDetId(saveTheseDetIds[detloop]);
149 
150  for (EBDigiCollection::const_iterator blah = digis->begin();
151  blah!=digis->end();blah++){
152 
153  if (detL == blah->id()){
154  EBDataFrame myDigi = (*blah);
155  SEBDigiCol->push_back(detL);
156 
157  EBDataFrame df( SEBDigiCol->back());
158  for (int iq =0;iq<myDigi.size();++iq){
159  df.setSample(iq, myDigi.sample(iq).raw());
160  }
161  //ebcounter++;
162  }
163  }
164  //if (ebcounter >= int(saveTheseDetIds.size())) break;
165  }//loop over dets
166 
167  }
168 
169  }//If barrel superclusters need saving.
170 
171 
172  if (saveEndcapSuperClusters.size() > 0){
173 
174  edm::ESHandle<CaloTopology> pTopology;
175  es.get<CaloTopologyRecord>().get(pTopology);
176  const CaloTopology *topology = pTopology.product();
177 
178  //Get endcap rec hit collection
179  //get endcap digi collection
181  const EEDigiCollection* digis=0;
182  evt.getByToken(EcalEEDigiToken_,pdigis);
183  digis = pdigis.product(); // get a ptr to the product
184 
186  const EcalRecHitCollection* rechits=0;
187  evt.getByToken(EcalEERecHitToken_,prechits);
188  rechits = prechits.product(); // get a ptr to the product
189 
190  if ( digis ) {
191  //std::vector<DetId> saveTheseDetIds;
192  std::set<DetId> saveTheseDetIds;
193  //pick out the digis for the 3x3 in each of the selected superclusters
194  for (int loop = 0;loop < int(saveEndcapSuperClusters.size());loop++){
195  SuperCluster clus1 = saveEndcapSuperClusters[loop];
196  CaloClusterPtr bcref = clus1.seed();
197  const BasicCluster *bc = bcref.get();
198  //Get the maximum detid
199  std::pair<DetId, float> EDetty = EcalClusterTools::getMaximum(*bc,rechits);
200  //get the 3x3 array centered on maximum detid.
201  std::vector<DetId> detvec =
202  EcalClusterTools::matrixDetId(topology,EDetty.first, -1, 1, -1, 1);
203  //Loop over the 3x3
204  for (int ik = 0;ik<int(detvec.size());++ik)
205  saveTheseDetIds.insert(detvec[ik]);
206  }
207  int eecounter=0;
208  for (EEDigiCollection::const_iterator blah = digis->begin();
209  blah!=digis->end();blah++){
210  std::set<DetId>::const_iterator finder = saveTheseDetIds.find(blah->id());
211  if (finder!=saveTheseDetIds.end()){
212  EEDetId detL = EEDetId(*finder);
213 
214  if (detL == blah->id()){
215  EEDataFrame myDigi = (*blah);
216  SEEDigiCol->push_back(detL);
217  EEDataFrame df( SEEDigiCol->back());
218  for (int iq =0;iq<myDigi.size();++iq){
219  df.setSample(iq, myDigi.sample(iq).raw());
220  }
221  eecounter++;
222 
223  }
224  }
225  if (eecounter >= int(saveTheseDetIds.size())) break;
226  }//loop over digis
227  }
228  }//If endcap superclusters need saving.
229 
230  }//If we're actually saving stuff
231 
232  //Okay, either my collections have been filled with the requisite Digis, or they haven't.
233 
234 
235  //Empty collection, or full, still put in event.
236  SEBDigiCol->sort();
237  SEEDigiCol->sort();
238  evt.put(std::move(SEBDigiCol), selectedEcalEBDigiCollection_);
239  evt.put(std::move(SEEDigiCol), selectedEcalEEDigiCollection_);
240 
241 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
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:460
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:166
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:124
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
const_iterator end() const
void setSample(int i, EcalMGPASample sam)
Definition: EcalDataFrame.h:43
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:510
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.