CMS 3D CMS Logo

ClusterSummaryProducer.cc
Go to the documentation of this file.
2 
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 }
52 
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;
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);
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);
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) << ", "
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 }
126 
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 }
136 
ClusterSummaryProducer::cCluster
ClusterSummary cCluster
Definition: ClusterSummaryProducer.h:83
edm::StreamID
Definition: StreamID.h:30
electrons_cff.bool
bool
Definition: electrons_cff.py:372
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
LumiMonitor_cff.pixelClusters
pixelClusters
Definition: LumiMonitor_cff.py:10
edmNew::DetSetVector::id
id_type id(size_t cell) const
Definition: DetSetVectorNew.h:606
ClusterSummary::NVALIDENUMS
Definition: ClusterSummary.h:92
edm
HLT enums.
Definition: AlignableModifier.h:19
ClusterSummaryProducer::beginStream
void beginStream(edm::StreamID) override
Definition: ClusterSummaryProducer.cc:127
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::LogInfo
Definition: MessageLogger.h:254
edmNew::DetSetVector::const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetSetVectorNew.h:231
ClusterSummary::getClusSizeByIndex
int getClusSizeByIndex(const int mod) const
Definition: ClusterSummary.h:113
edmNew::DetSetVector::begin
const_iterator begin(bool update=false) const
Definition: DetSetVectorNew.h:572
ClusterSummary::STRIP
Definition: ClusterSummary.h:84
edm::Handle
Definition: AssociativeIterator.h:50
dqmdumpme.first
first
Definition: dqmdumpme.py:55
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ClusterSummaryProducer::pixelClusters_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
Definition: ClusterSummaryProducer.h:77
HLT_2018_cff.stripClusters
stripClusters
Definition: HLT_2018_cff.py:8683
ClusterSummaryProducer
Definition: ClusterSummaryProducer.h:63
ClusterSummary::addClusChargeByIndex
void addClusChargeByIndex(const int mod, const float val)
Definition: ClusterSummary.h:135
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
ClusterVariables::clusterSize
const unsigned clusterSize() const
Definition: ClusterVariables.h:25
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
ClusterSummary::subDetNames
static const std::vector< std::string > subDetNames
Definition: ClusterSummary.h:95
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ClusterSummary::addNClusByIndex
void addNClusByIndex(const int mod, const int val)
Definition: ClusterSummary.h:133
ClusterSummary::reset
void reset()
Definition: ClusterSummary.cc:83
ClusterSummaryProducer::ModuleSelection
std::pair< DetIdSelector, ClusterSummary::CMSTracker > ModuleSelection
Definition: ClusterSummaryProducer.h:72
edm::ParameterSet
Definition: ParameterSet.h:36
ClusterSummary::addClusSizeByIndex
void addClusSizeByIndex(const int mod, const int val)
Definition: ClusterSummary.h:134
selectors
Definition: selectors.py:1
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
ClusterVariables::charge
uint16_t charge() const
Definition: ClusterVariables.h:32
ClusterSummaryProducer::moduleNames
std::vector< std::string > moduleNames
Definition: ClusterSummaryProducer.h:81
ClusterSummaryProducer::stripClusters_
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
Definition: ClusterSummaryProducer.h:78
ClusterSummary::getClusChargeByIndex
float getClusChargeByIndex(const int mod) const
Definition: ClusterSummary.h:114
edm::EventSetup
Definition: EventSetup.h:57
module
Definition: vlib.h:198
ClusterVariables
Definition: ClusterVariables.h:13
ClusterSummary::NTRACKERENUMS
Definition: ClusterSummary.h:93
ClusterSummary::CMSTracker
CMSTracker
Definition: ClusterSummary.h:83
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ClusterSummaryProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ClusterSummaryProducer.cc:53
ClusterSummary::getNClusByIndex
int getNClusByIndex(const int mod) const
Definition: ClusterSummary.h:112
eostools.move
def move(src, dest)
Definition: eostools.py:511
ClusterSummaryProducer::ClusterSummaryProducer
ClusterSummaryProducer(const edm::ParameterSet &)
Definition: ClusterSummaryProducer.cc:3
ClusterSummary
Definition: ClusterSummary.h:59
ClusterSummaryProducer::doStrips
bool doStrips
Definition: ClusterSummaryProducer.h:86
ClusterSummaryProducer::verbose
bool verbose
Definition: ClusterSummaryProducer.h:88
edmNew::DetSetVector::end
const_iterator end(bool update=false) const
Definition: DetSetVectorNew.h:577
Exception
Definition: hltDiff.cc:246
clustersummaryproducer_cfg.doStrips
doStrips
Definition: clustersummaryproducer_cfg.py:20
mps_fire.result
result
Definition: mps_fire.py:303
edm::Event
Definition: Event.h:73
ClusterSummaryProducer.h
ClusterSummaryProducer::doPixels
bool doPixels
Definition: ClusterSummaryProducer.h:87
clustersummaryproducer_cfg.doPixels
doPixels
Definition: clustersummaryproducer_cfg.py:21
edm::InputTag
Definition: InputTag.h:15
DetIdSelector
Definition: DetIdSelector.h:12
ClusterSummary::subDetSelections
static const std::vector< std::vector< std::string > > subDetSelections
Definition: ClusterSummary.h:96
edmNew::DetSet::const_iterator
const data_type * const_iterator
Definition: DetSetNew.h:31