CMS 3D CMS Logo

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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

typedef std::pair< DetIdSelector, ClusterSummary::CMSTrackerModuleSelection
 
typedef std::vector< ModuleSelectionModuleSelections
 

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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 68 of file ClusterSummaryProducer.h.

Member Typedef Documentation

Definition at line 78 of file ClusterSummaryProducer.h.

Definition at line 79 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, and ClusterSummary::subDetSelections.

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

Definition at line 71 of file ClusterSummaryProducer.h.

References beginStream(), and produce().

71 {};

Member Function Documentation

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

Definition at line 123 of file ClusterSummaryProducer.cc.

References DEFINE_FWK_MODULE, and moduleNames.

Referenced by ~ClusterSummaryProducer().

124 {
125  if(!verbose) return;
126  edm::LogInfo("ClusterSummaryProducer") << "+++++++++++++++++++++++++++++++ " << std::endl << "Getting info on " ;
127  for (const auto& iS : moduleNames ) { edm::LogInfo("ClusterSummaryProducer") << iS<< " " ;}
128  edm::LogInfo("ClusterSummaryProducer") << std::endl;
129 }
std::vector< std::string > moduleNames
void ClusterSummaryProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 48 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(), plotBeamSpotDB::first, objects.autophobj::float, edm::Event::getByToken(), ClusterSummary::getClusChargeByIndex(), ClusterSummary::getClusSizeByIndex(), ClusterSummary::getNClusByIndex(), edmNew::DetSetVector< T >::id(), python.rootplot.argparse::module, moduleNames, eostools::move(), HiRegitMuonDetachedTripletStep_cff::pixelClusters, pixelClusters_, edm::Event::put(), ClusterSummary::reset(), mps_fire::result, selectors, HiRegitMuonDetachedTripletStep_cff::stripClusters, and stripClusters_.

Referenced by ~ClusterSummaryProducer().

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

Member Data Documentation

ClusterSummary ClusterSummaryProducer::cCluster
private

Definition at line 89 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::doPixels
private

Definition at line 94 of file ClusterSummaryProducer.h.

Referenced by produce().

bool ClusterSummaryProducer::doStrips
private

Definition at line 93 of file ClusterSummaryProducer.h.

Referenced by produce().

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

Definition at line 90 of file ClusterSummaryProducer.h.

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

Definition at line 87 of file ClusterSummaryProducer.h.

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

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

Definition at line 83 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

ModuleSelections ClusterSummaryProducer::selectors
private

Definition at line 86 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

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

Definition at line 84 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::verbose
private

Definition at line 95 of file ClusterSummaryProducer.h.