CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
ClusterSummaryProducer Class Reference

#include <msegala/ClusterSummaryProducer/src/ClusterSummaryProducer.cc>

Inheritance diagram for ClusterSummaryProducer:
edm::stream::EDProducer<>

Public Member Functions

 ClusterSummaryProducer (const edm::ParameterSet &)
 
 ~ClusterSummaryProducer () 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 Types

typedef std::pair
< DetIdSelector,
ClusterSummary::CMSTracker
ModuleSelection
 
typedef std::vector
< ModuleSelection
ModuleSelections
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

ClusterSummary cCluster
 
bool doPixels
 
bool doStrips
 
std::map< std::string, int > EnumMap
 
std::vector< std::string > moduleNames
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiPixelCluster > > 
pixelClusters_
 
ModuleSelections selectors
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiStripCluster > > 
stripClusters_
 
bool verbose
 

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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 63 of file ClusterSummaryProducer.h.

Member Typedef Documentation

Definition at line 72 of file ClusterSummaryProducer.h.

Definition at line 73 of file ClusterSummaryProducer.h.

Constructor & Destructor Documentation

ClusterSummaryProducer::ClusterSummaryProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 3 of file ClusterSummaryProducer.cc.

References cCluster, Exception, edm::ParameterSet::getParameter(), moduleNames, ClusterSummary::NTRACKERENUMS, ClusterSummary::NVALIDENUMS, pixelClusters_, corrVsCorr::selection, selectors, AlCaHLTBitMon_QueryRunRegistry::string, ClusterSummary::STRIP, stripClusters_, ClusterSummary::subDetNames, ClusterSummary::subDetSelections, and verbose.

4  : doStrips(iConfig.getParameter<bool>("doStrips")),
5  doPixels(iConfig.getParameter<bool>("doPixels")),
6  verbose(iConfig.getParameter<bool>("verbose")) {
8  consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("pixelClusters"));
10  consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("stripClusters"));
11 
13 
14  std::vector<std::string> wantedsubdets = iConfig.getParameter<std::vector<std::string> >("wantedSubDets");
15  for (const auto& iS : wantedsubdets) {
17  for (int iN = 0; iN < ClusterSummary::NVALIDENUMS; ++iN)
18  if (ClusterSummary::subDetNames[iN] == iS)
19  subdet = ClusterSummary::CMSTracker(iN);
20  if (subdet == ClusterSummary::NVALIDENUMS)
21  throw cms::Exception("No standard selection: ") << iS;
22 
24  if (subdet > maxEnum)
25  maxEnum = subdet;
26  if (verbose)
27  moduleNames.push_back(ClusterSummary::subDetNames[subdet]);
28  }
29 
30  std::vector<edm::ParameterSet> wantedusersubdets_ps =
31  iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedUserSubDets");
32  for (const auto& iS : wantedusersubdets_ps) {
33  ClusterSummary::CMSTracker subdet = (ClusterSummary::CMSTracker)iS.getParameter<unsigned int>("detSelection");
34  std::string detname = iS.getParameter<std::string>("detLabel");
35  std::vector<std::string> selection = iS.getParameter<std::vector<std::string> >("selection");
36 
37  if (subdet <= ClusterSummary::NVALIDENUMS)
38  throw cms::Exception("Already predefined selection: ") << subdet;
39  if (subdet >= ClusterSummary::NTRACKERENUMS)
40  throw cms::Exception("Selection is out of range: ") << subdet;
41 
42  selectors.push_back(ModuleSelection(DetIdSelector(selection), subdet));
43  if (subdet > maxEnum)
44  maxEnum = subdet;
45  if (verbose)
46  moduleNames.push_back(detname);
47  }
48 
49  cCluster = ClusterSummary(maxEnum + 1);
50  produces<ClusterSummary>().setBranchAlias("trackerClusterSummary");
51 }
std::vector< std::string > moduleNames
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
static const std::vector< std::string > subDetNames
selection
main part
Definition: corrVsCorr.py:100
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const std::vector< std::vector< std::string > > subDetSelections
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
std::pair< DetIdSelector, ClusterSummary::CMSTracker > ModuleSelection
ClusterSummaryProducer::~ClusterSummaryProducer ( )
inlineoverride

Definition at line 66 of file ClusterSummaryProducer.h.

66 {};

Member Function Documentation

void ClusterSummaryProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 127 of file ClusterSummaryProducer.cc.

References moduleNames, and verbose.

127  {
128  if (!verbose)
129  return;
130  edm::LogInfo("ClusterSummaryProducer") << "+++++++++++++++++++++++++++++++ " << std::endl << "Getting info on ";
131  for (const auto& iS : moduleNames) {
132  edm::LogInfo("ClusterSummaryProducer") << iS << " ";
133  }
134  edm::LogInfo("ClusterSummaryProducer") << std::endl;
135 }
std::vector< std::string > moduleNames
Log< level::Info, false > LogInfo
void ClusterSummaryProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 53 of file ClusterSummaryProducer.cc.

References ClusterSummary::addClusChargeByIndex(), ClusterSummary::addClusSizeByIndex(), ClusterSummary::addNClusByIndex(), edmNew::DetSetVector< T >::begin(), cCluster, ClusterVariables::charge(), ClusterVariables::clusterSize(), gather_cfg::cout, doPixels, doStrips, edmNew::DetSetVector< T >::end(), first, edm::Event::getByToken(), ClusterSummary::getClusChargeByIndex(), ClusterSummary::getClusSizeByIndex(), ClusterSummary::getNClusByIndex(), edmNew::DetSetVector< T >::id(), callgraph::module, moduleNames, eostools::move(), HLT_FULL_cff::pixelClusters, pixelClusters_, edm::Event::put(), ClusterSummary::reset(), mps_fire::result, selectors, HLT_FULL_cff::stripClusters, stripClusters_, and verbose.

53  {
54  using namespace edm;
55  cCluster.reset();
56  std::vector<bool> selectedVector(selectors.size(), false);
57 
58  auto getSelections = [&](const uint32_t detid) {
59  for (unsigned int iS = 0; iS < selectors.size(); ++iS)
60  selectedVector[iS] = selectors[iS].first.isSelected(detid);
61  };
62  auto fillSelections = [&](const int clusterSize, const float clusterCharge) {
63  for (unsigned int iS = 0; iS < selectors.size(); ++iS) {
64  if (!selectedVector[iS])
65  continue;
66  const ClusterSummary::CMSTracker module = selectors[iS].second;
67  cCluster.addNClusByIndex(module, 1);
68  cCluster.addClusSizeByIndex(module, clusterSize);
69  cCluster.addClusChargeByIndex(module, clusterCharge);
70  }
71  };
72 
73  //===================++++++++++++========================
74  // For SiStrips
75  //===================++++++++++++========================
76  if (doStrips) {
78  iEvent.getByToken(stripClusters_, stripClusters);
79  edmNew::DetSetVector<SiStripCluster>::const_iterator itClusters = stripClusters->begin();
80  for (; itClusters != stripClusters->end(); ++itClusters) {
81  getSelections(itClusters->id());
82  for (edmNew::DetSet<SiStripCluster>::const_iterator cluster = itClusters->begin(); cluster != itClusters->end();
83  ++cluster) {
84  const ClusterVariables Summaryinfo(*cluster);
85  fillSelections(Summaryinfo.clusterSize(), Summaryinfo.charge());
86  }
87  }
88  }
89 
90  //===================++++++++++++========================
91  // For SiPixels
92  //===================++++++++++++========================
93  if (doPixels) {
95  iEvent.getByToken(pixelClusters_, pixelClusters);
96  edmNew::DetSetVector<SiPixelCluster>::const_iterator itClusters = pixelClusters->begin();
97  for (; itClusters != pixelClusters->end(); ++itClusters) {
98  getSelections(itClusters->id());
99  for (edmNew::DetSet<SiPixelCluster>::const_iterator cluster = itClusters->begin(); cluster != itClusters->end();
100  ++cluster) {
101  fillSelections(cluster->size(), float(cluster->charge()) / 1000.);
102  }
103  }
104  }
105 
106  //===================+++++++++++++========================
107  // Fill Producer
108  //===================+++++++++++++========================
109  if (verbose) {
110  for (const auto& iS : selectors) {
111  const ClusterSummary::CMSTracker module = iS.second;
112  edm::LogInfo("ClusterSummaryProducer")
113  << "n" << moduleNames[module] << ", avg size, avg charge = " << cCluster.getNClusByIndex(module) << ", "
114  << cCluster.getClusSizeByIndex(module) / cCluster.getNClusByIndex(module) << ", "
115  << cCluster.getClusChargeByIndex(module) / cCluster.getNClusByIndex(module) << std::endl;
116  }
117  std::cout << "-------------------------------------------------------" << std::endl;
118  }
119 
120  //Put the filled class into the producer
121  auto result = std::make_unique<ClusterSummary>();
122  //Cleanup empty selections
123  result->copyNonEmpty(cCluster);
124  iEvent.put(std::move(result));
125 }
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::vector< std::string > moduleNames
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
void addClusChargeByIndex(const int mod, const float val)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void addClusSizeByIndex(const int mod, const int val)
data_type const * const_iterator
Definition: DetSetNew.h:31
id_type id(size_t cell) const
tuple result
Definition: mps_fire.py:311
int getClusSizeByIndex(const int mod) const
int getNClusByIndex(const int mod) const
def move
Definition: eostools.py:511
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
float getClusChargeByIndex(const int mod) const
tuple cout
Definition: gather_cfg.py:144
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
void addNClusByIndex(const int mod, const int val)
const_iterator begin(bool update=false) const
tuple module
Definition: callgraph.py:69

Member Data Documentation

ClusterSummary ClusterSummaryProducer::cCluster
private

Definition at line 83 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::doPixels
private

Definition at line 87 of file ClusterSummaryProducer.h.

Referenced by produce().

bool ClusterSummaryProducer::doStrips
private

Definition at line 86 of file ClusterSummaryProducer.h.

Referenced by produce().

std::map<std::string, int> ClusterSummaryProducer::EnumMap
private

Definition at line 84 of file ClusterSummaryProducer.h.

std::vector<std::string> ClusterSummaryProducer::moduleNames
private

Definition at line 81 of file ClusterSummaryProducer.h.

Referenced by beginStream(), ClusterSummaryProducer(), and produce().

edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > ClusterSummaryProducer::pixelClusters_
private

Definition at line 77 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

ModuleSelections ClusterSummaryProducer::selectors
private

Definition at line 80 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > ClusterSummaryProducer::stripClusters_
private

Definition at line 78 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::verbose
private

Definition at line 88 of file ClusterSummaryProducer.h.

Referenced by beginStream(), ClusterSummaryProducer(), and produce().