CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ClusterSummaryProducer (const edm::ParameterSet &)
 
 ~ClusterSummaryProducer ()
 
- 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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

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

Private Member Functions

virtual void beginStream (edm::StreamID) override
 
virtual 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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

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 ( )
inline

Definition at line 71 of file ClusterSummaryProducer.h.

71 {};

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 123 of file ClusterSummaryProducer.cc.

References moduleNames.

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

Implements edm::stream::EDProducerBase.

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, edm::Event::getByToken(), ClusterSummary::getClusChargeByIndex(), ClusterSummary::getClusSizeByIndex(), ClusterSummary::getNClusByIndex(), edmNew::DetSetVector< T >::id(), python.rootplot.argparse::module, moduleNames, HLT_25ns10e33_v2_cff::pixelClusters, pixelClusters_, edm::Event::put(), ClusterSummary::reset(), mps_fire::result, selectors, HLT_25ns10e33_v2_cff::stripClusters, and stripClusters_.

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  std::auto_ptr<ClusterSummary> result(new ClusterSummary (0) );
116  //Cleanup empty selections
117  result->copyNonEmpty(cCluster);
118  iEvent.put( result );
119 }
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
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:462
void addClusSizeByIndex(const int mod, const int val)
data_type const * const_iterator
Definition: DetSetNew.h:30
id_type id(size_t cell) const
tuple result
Definition: mps_fire.py:84
int getClusSizeByIndex(const int mod) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
int getNClusByIndex(const int mod) const
float getClusChargeByIndex(const int mod) const
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
Definition: vlib.h:208
void addNClusByIndex(const int mod, const int val)
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.