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 Member Functions | Private Attributes
ClusterSummaryProducer Class Reference

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

Inheritance diagram for ClusterSummaryProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ClusterSummaryProducer (const edm::ParameterSet &)
 
 ~ClusterSummaryProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
void decodeInput (std::vector< std::string > &, std::string)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

ClusterSummary cCluster
 
bool doPixels
 
bool doStrips
 
std::map< std::string, int > EnumMap
 
bool firstpass
 
bool firstpass_mod
 
bool firstpassPixel
 
bool firstpassPixel_mod
 
std::vector
< ClusterSummary::ModuleSelection * > 
ModuleSelectionVect
 
std::vector
< ClusterSummary::ModuleSelection * > 
ModuleSelectionVectPixels
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiPixelCluster > > 
pixelClusters_
 
std::string pixelModules
 
std::string pixelVariables
 
edm::EDGetTokenT
< edmNew::DetSetVector
< SiStripCluster > > 
stripClusters_
 
std::string stripModules
 
std::string stripVariables
 
std::vector< std::string > v_pixelModuleTypes
 
std::vector< std::string > v_pixelVariables
 
std::vector< std::string > v_stripModuleTypes
 
std::vector< std::string > v_stripVariables
 
std::vector< std::string > v_userContent
 
bool verbose
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 67 of file ClusterSummaryProducer.h.

Constructor & Destructor Documentation

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

Definition at line 3 of file ClusterSummaryProducer.cc.

References firstpass, firstpass_mod, firstpassPixel, firstpassPixel_mod, edm::ParameterSet::getParameter(), pixelClusters_, and stripClusters_.

4  : stripModules(iConfig.getParameter<std::string>("stripModule")),
5  pixelModules(iConfig.getParameter<std::string>("pixelModule")),
6  stripVariables(iConfig.getParameter<std::string>("stripVariables")),
7  pixelVariables(iConfig.getParameter<std::string>("pixelVariables")),
8  doStrips(iConfig.getParameter<bool>("doStrips")),
9  doPixels(iConfig.getParameter<bool>("doPixels")),
10  verbose(iConfig.getParameter<bool>("verbose"))
11 {
12 
13  pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("pixelClusters"));
14  stripClusters_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("stripClusters"));
15 
16  //register your products
17  produces<ClusterSummary>().setBranchAlias("SummaryCollection");
18 
19  firstpass = true;
20  firstpass_mod = true;
21  firstpassPixel = true;
22  firstpassPixel_mod = true;
23 
24 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
ClusterSummaryProducer::~ClusterSummaryProducer ( )
inline

Definition at line 70 of file ClusterSummaryProducer.h.

70 {};

Member Function Documentation

void ClusterSummaryProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 192 of file ClusterSummaryProducer.cc.

References cCluster, gather_cfg::cout, decodeInput(), doPixels, doStrips, cuy::ii, pixelModules, pixelVariables, ClusterSummary::SetUserContent(), ClusterSummary::SetUserIterator(), stripModules, stripVariables, v_pixelModuleTypes, v_pixelVariables, v_stripModuleTypes, v_stripVariables, and v_userContent.

193 {
194 
199 
200  if (doStrips){
201  if (verbose){
202  std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
203  std::cout << "FOR STRIPS: " << std::endl;
204  std::cout << "Getting info on " ;
205  for (unsigned int ii = 0; ii < v_stripModuleTypes.size( ); ++ii) {
206  std::cout << v_stripModuleTypes[ii] << " " ;
207  }
208  std::cout << std::endl;
209  }
210 
211  if (verbose) std::cout << "Getting info on strip variables " ;
212  for (unsigned int ii = 0; ii < v_stripVariables.size( ); ++ii) {
213  if (verbose) std::cout << v_stripVariables[ii] << " " ;
214  v_userContent.push_back(v_stripVariables[ii]);
215  }
216  if (verbose) std::cout << std::endl;
217  }
218 
219  if (doPixels){
220  if (verbose){
221  std::cout << "FOR PIXELS: " << std::endl;
222  std::cout << "Getting info on " ;
223  for (unsigned int ii = 0; ii < v_pixelModuleTypes.size( ); ++ii) {
224  std::cout << v_pixelModuleTypes[ii] << " " ;
225  }
226  std::cout << std::endl;
227  }
228 
229  if (verbose) std::cout << "Getting info on pixel variables " ;
230  for (unsigned int ii = 0; ii < v_pixelVariables.size( ); ++ii) {
231  if (verbose) std::cout << v_pixelVariables[ii] << " " ;
232  v_userContent.push_back(v_pixelVariables[ii]);
233  }
234  if (verbose) std::cout << std::endl;
235  if (verbose) std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
236  }
237 
238  //Create the summary info for output
241 }
std::vector< std::string > v_userContent
void decodeInput(std::vector< std::string > &, std::string)
int ii
Definition: cuy.py:588
void SetUserContent(const std::vector< std::string > &Content) const
std::vector< std::string > v_pixelVariables
void SetUserIterator()
std::vector< std::string > v_pixelModuleTypes
std::vector< std::string > v_stripModuleTypes
tuple cout
Definition: gather_cfg.py:121
std::vector< std::string > v_stripVariables
void ClusterSummaryProducer::decodeInput ( std::vector< std::string > &  vec,
std::string  mod 
)
private

Definition at line 247 of file ClusterSummaryProducer.cc.

References i, and j.

Referenced by beginJob().

248 {
249 
250  // Define the Modules to get the summary info out of
252  std::string::size_type j = mod.find(',');
253 
254  if ( j == std::string::npos ){
255  vec.push_back(mod);
256  }
257  else{
258  while (j != std::string::npos) {
259  vec.push_back(mod.substr(i, j-i));
260  i = ++j;
261  j = mod.find(',', j);
262  if (j == std::string::npos)
263  vec.push_back(mod.substr(i, mod.length( )));
264  }
265  }
266 
267 
268 }
int i
Definition: DBlmapReader.cc:9
uint16_t size_type
int j
Definition: DBlmapReader.cc:9
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void ClusterSummaryProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 28 of file ClusterSummaryProducer.cc.

References edmNew::DetSetVector< T >::begin(), cCluster, ClusterVariables::charge(), ClusterSummary::ClearGenericVariable(), ClusterSummary::ClearUserModules(), ClusterVariables::clusterSize(), gather_cfg::cout, cond::rpcobgas::detid, doPixels, doStrips, edmNew::DetSetVector< T >::end(), firstpass, firstpass_mod, firstpassPixel, firstpassPixel_mod, edm::Event::getByToken(), ClusterSummary::GetGenericVariable(), ClusterSummary::GetUserModules(), i, edmNew::DetSetVector< T >::id(), ModuleSelectionVect, ModuleSelectionVectPixels, n, clustersummaryproducer_cfg::pixelClusters, pixelClusters_, ClusterSummary::PrepairGenericVariable(), edm::Event::put(), query::result, ClusterSummary::SetGenericVariable(), ClusterSummary::SetUserModules(), clustersummaryproducer_cfg::stripClusters, stripClusters_, v_pixelModuleTypes, and v_stripModuleTypes.

29 {
30  using namespace edm;
31 
33 
34  //===================++++++++++++========================
35  //
36  // For SiStrips
37  //
38  //===================++++++++++++========================
39  if (doStrips){
41  iEvent.getByToken(stripClusters_, stripClusters);
42 
43  ModuleSelectionVect.clear();
44  for ( std::vector<std::string>::iterator it=v_stripModuleTypes.begin() ; it < v_stripModuleTypes.end(); it++ ){
46  }
47 
48  firstpass_mod = true;
49 
50  int CurrMod = -1;
51  //Loop over all the ModuleSelectors
52  for ( unsigned int i = 0; i < ModuleSelectionVect.size(); i++){
53 
54  // Loop over the strip clusters
55  edmNew::DetSetVector<SiStripCluster>::const_iterator itClusters=stripClusters->begin();
56  for(;itClusters!=stripClusters->end();++itClusters){
57  uint32_t id = itClusters->id();
58  for(edmNew::DetSet<SiStripCluster>::const_iterator cluster=itClusters->begin(); cluster!=itClusters->end();++cluster){
59 
60  const ClusterVariables Summaryinfo(*cluster);
61 
62  // For each ModuleSelector, check if the detID belongs to a desired module. If so, update the summary information for that module
63 
64  std::pair<int, int> ModSelect = ModuleSelectionVect.at(i) -> IsStripSelected( id );
65  int mod_pair = ModSelect.first;
66  int mod_pair2 = ModSelect.second;
67 
68  if ( mod_pair ){
69  if ( firstpass_mod ) {
70  CurrMod = mod_pair2;
71  cCluster.SetUserModules( mod_pair2 ) ;
72  }
73 
74  firstpass_mod = false;
75  int CurrModTmp = mod_pair2;
76 
77  if ( CurrMod != CurrModTmp ) {
78  cCluster.SetUserModules( mod_pair2 ) ;
79  CurrMod = CurrModTmp;
80  }
81 
82  cCluster.SetGenericVariable( "cHits", mod_pair2, 1 );
83  cCluster.SetGenericVariable( "cSize", mod_pair2, Summaryinfo.clusterSize() );
84  cCluster.SetGenericVariable( "cCharge", mod_pair2, Summaryinfo.charge() );
85 
86  }
87  }
88  }
89  }
90 
91  }
92 
93  //===================++++++++++++========================
94  //
95  // For SiPixels
96  //
97  //===================++++++++++++========================
98  if (doPixels){
100  iEvent.getByToken(pixelClusters_, pixelClusters);
101 
103  for ( std::vector<std::string>::iterator it=v_pixelModuleTypes.begin() ; it < v_pixelModuleTypes.end(); it++ ){
105  }
106 
107  firstpassPixel_mod = true;
108 
109  int CurrModPixel = -1;
110  //Loop over all the ModuleSelectors
111  for ( unsigned int i = 0; i < ModuleSelectionVectPixels.size(); i++){
112 
113  // Loop over the pixel clusters
114  edmNew::DetSetVector<SiPixelCluster>::const_iterator itClusters=pixelClusters->begin();
115  for(;itClusters!=pixelClusters->end();++itClusters){
116  uint32_t detid = itClusters->detId();
117  for(edmNew::DetSet<SiPixelCluster>::const_iterator cluster=itClusters->begin(); cluster!=itClusters->end();++cluster){
118 
119  // For each ModuleSelector, check if the detID belongs to a desired module. If so, update the summary information for that module
120 
121  std::pair<int, int> ModSelectPixel = ModuleSelectionVectPixels.at(i) -> IsPixelSelected( detid );
122  int mod_pair = ModSelectPixel.first;
123  int mod_pair2 = ModSelectPixel.second;
124  if ( mod_pair ){
125  if ( firstpassPixel_mod ) {
126  CurrModPixel = mod_pair2;
127  cCluster.SetUserModules( mod_pair2 ) ;
128  }
129  firstpassPixel_mod = false;
130  int CurrModTmp = mod_pair2;
131  if ( CurrModPixel != CurrModTmp ) {
132  cCluster.SetUserModules( mod_pair2 ) ;
133  CurrModPixel = CurrModTmp;
134  }
135 
136  cCluster.SetGenericVariable( "pHits", mod_pair2, 1 );
137  cCluster.SetGenericVariable( "pSize", mod_pair2, cluster->size() );
138  cCluster.SetGenericVariable( "pCharge", mod_pair2, float(cluster->charge())/1000. );
139 
140  }
141  }
142  }
143  }
144 
145  }
146 
147 
148  //===================+++++++++++++========================
149  //
150  // Fill Producer
151  //
152  //===================+++++++++++++========================
153 
154 
155  unsigned int n = 0;
156  int n_pixel = 0;
157 
159 
160  std::vector<int> _mod = cCluster.GetUserModules( );
161  for(std::vector<int>::iterator it = _mod.begin(); it != _mod.end(); ++it) {
162 
163  if ( n < v_stripModuleTypes.size() && doStrips ){
164  if (verbose) std::cout << "n" << v_stripModuleTypes.at(n) <<", avg size, avg charge = "<< cCluster.GetGenericVariable( "cHits",*it ) << ", " << cCluster.GetGenericVariable( "cSize",*it )/cCluster.GetGenericVariable( "cHits",*it ) << ", "<< cCluster.GetGenericVariable( "cCharge",*it )/cCluster.GetGenericVariable( "cHits",*it ) << std::endl;
165  delete ModuleSelectionVect[n];
166  }
167  else if (doPixels) {
168  if (verbose) {
169  std::cout << "n" << v_pixelModuleTypes.at(n_pixel) << ", avg size, avg charge = "<< cCluster.GetGenericVariable( "pHits",*it ) << ", " << cCluster.GetGenericVariable( "pSize",*it )/cCluster.GetGenericVariable( "pHits",*it ) << ", "<< cCluster.GetGenericVariable( "pCharge",*it )/cCluster.GetGenericVariable( "pHits",*it ) << std::endl;
170  }
171  delete ModuleSelectionVectPixels[n_pixel];
172  ++n_pixel;
173  }
174  ++n;
175  }
176 
177  if (verbose) std::cout << "-------------------------------------------------------" << std::endl;
178 
179  firstpass = false;
180  firstpassPixel = false;
181 
182  //Put the filled class into the producer
183  std::auto_ptr<ClusterSummary> result(new ClusterSummary (cCluster) );
184  iEvent.put( result );
185 
187 
188 }
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
std::vector< ClusterSummary::ModuleSelection * > ModuleSelectionVect
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
void SetGenericVariable(int variableLocation, int module, double value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
data_type const * const_iterator
Definition: DetSetNew.h:30
id_type id(size_t cell) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< std::string > v_pixelModuleTypes
tuple result
Definition: query.py:137
std::vector< int > GetUserModules() const
double GetGenericVariable(int variableLocation, int module) const
std::vector< std::string > v_stripModuleTypes
void PrepairGenericVariable()
const_iterator end(bool update=true) const
void SetUserModules(int value)
tuple cout
Definition: gather_cfg.py:121
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
std::vector< ClusterSummary::ModuleSelection * > ModuleSelectionVectPixels
void ClearGenericVariable()
const_iterator begin(bool update=true) const
void ClearUserModules()

Member Data Documentation

ClusterSummary ClusterSummaryProducer::cCluster
private

Definition at line 93 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

bool ClusterSummaryProducer::doPixels
private

Definition at line 100 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

bool ClusterSummaryProducer::doStrips
private

Definition at line 99 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

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

Definition at line 94 of file ClusterSummaryProducer.h.

bool ClusterSummaryProducer::firstpass
private

Definition at line 102 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::firstpass_mod
private

Definition at line 103 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::firstpassPixel
private

Definition at line 104 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::firstpassPixel_mod
private

Definition at line 105 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

std::vector<ClusterSummary::ModuleSelection*> ClusterSummaryProducer::ModuleSelectionVect
private

Definition at line 95 of file ClusterSummaryProducer.h.

Referenced by produce().

std::vector<ClusterSummary::ModuleSelection*> ClusterSummaryProducer::ModuleSelectionVectPixels
private

Definition at line 96 of file ClusterSummaryProducer.h.

Referenced by produce().

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

Definition at line 80 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

std::string ClusterSummaryProducer::pixelModules
private

Definition at line 85 of file ClusterSummaryProducer.h.

Referenced by beginJob().

std::string ClusterSummaryProducer::pixelVariables
private

Definition at line 90 of file ClusterSummaryProducer.h.

Referenced by beginJob().

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

Definition at line 81 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

std::string ClusterSummaryProducer::stripModules
private

Definition at line 82 of file ClusterSummaryProducer.h.

Referenced by beginJob().

std::string ClusterSummaryProducer::stripVariables
private

Definition at line 88 of file ClusterSummaryProducer.h.

Referenced by beginJob().

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

Definition at line 86 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

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

Definition at line 91 of file ClusterSummaryProducer.h.

Referenced by beginJob().

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

Definition at line 84 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

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

Definition at line 89 of file ClusterSummaryProducer.h.

Referenced by beginJob().

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

Definition at line 108 of file ClusterSummaryProducer.h.

Referenced by beginJob().

bool ClusterSummaryProducer::verbose
private

Definition at line 101 of file ClusterSummaryProducer.h.