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

Public Member Functions

 ClusterSummaryProducer (const edm::ParameterSet &)
 
 ~ClusterSummaryProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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::InputTag pixelClustersLabel
 
std::string pixelModules
 
std::string pixelVariables
 
edm::InputTag stripClustersLabel
 
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
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 74 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, and firstpassPixel_mod.

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

Definition at line 77 of file ClusterSummaryProducer.h.

77 {};

Member Function Documentation

void ClusterSummaryProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 191 of file ClusterSummaryProducer.cc.

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

192 {
193 
198 
199  if (doStrips){
200  if (verbose){
201  std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
202  std::cout << "FOR STRIPS: " << std::endl;
203  std::cout << "Getting info on " ;
204  for (unsigned int ii = 0; ii < v_stripModuleTypes.size( ); ++ii) {
205  std::cout << v_stripModuleTypes[ii] << " " ;
206  }
207  std::cout << std::endl;
208  }
209 
210  if (verbose) std::cout << "Getting info on strip variables " ;
211  for (unsigned int ii = 0; ii < v_stripVariables.size( ); ++ii) {
212  if (verbose) std::cout << v_stripVariables[ii] << " " ;
213  v_userContent.push_back(v_stripVariables[ii]);
214  }
215  if (verbose) std::cout << std::endl;
216  }
217 
218  if (doPixels){
219  if (verbose){
220  std::cout << "FOR PIXELS: " << std::endl;
221  std::cout << "Getting info on " ;
222  for (unsigned int ii = 0; ii < v_pixelModuleTypes.size( ); ++ii) {
223  std::cout << v_pixelModuleTypes[ii] << " " ;
224  }
225  std::cout << std::endl;
226  }
227 
228  if (verbose) std::cout << "Getting info on pixel variables " ;
229  for (unsigned int ii = 0; ii < v_pixelVariables.size( ); ++ii) {
230  if (verbose) std::cout << v_pixelVariables[ii] << " " ;
231  v_userContent.push_back(v_pixelVariables[ii]);
232  }
233  if (verbose) std::cout << std::endl;
234  if (verbose) std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
235  }
236 
237  //Create the summary info for output
240 }
std::vector< std::string > v_userContent
void decodeInput(std::vector< std::string > &, std::string)
void SetUserContent(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 246 of file ClusterSummaryProducer.cc.

References i, and j.

Referenced by beginJob().

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

Implements edm::EDProducer.

Definition at line 27 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::getByLabel(), ClusterSummary::GetGenericVariable(), ClusterSummary::GetUserModules(), i, edmNew::DetSetVector< T >::id(), ModuleSelectionVect, ModuleSelectionVectPixels, n, clustersummaryproducer_cfg::pixelClusters, pixelClustersLabel, ClusterSummary::PrepairGenericVariable(), edm::Event::put(), query::result, ClusterSummary::SetGenericVariable(), ClusterSummary::SetUserModules(), clustersummaryproducer_cfg::stripClusters, stripClustersLabel, v_pixelModuleTypes, and v_stripModuleTypes.

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

Member Data Documentation

ClusterSummary ClusterSummaryProducer::cCluster
private

Definition at line 99 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

bool ClusterSummaryProducer::doPixels
private

Definition at line 106 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

bool ClusterSummaryProducer::doStrips
private

Definition at line 105 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

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

Definition at line 100 of file ClusterSummaryProducer.h.

bool ClusterSummaryProducer::firstpass
private

Definition at line 108 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::firstpass_mod
private

Definition at line 109 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::firstpassPixel
private

Definition at line 110 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

bool ClusterSummaryProducer::firstpassPixel_mod
private

Definition at line 111 of file ClusterSummaryProducer.h.

Referenced by ClusterSummaryProducer(), and produce().

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

Definition at line 101 of file ClusterSummaryProducer.h.

Referenced by produce().

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

Definition at line 102 of file ClusterSummaryProducer.h.

Referenced by produce().

edm::InputTag ClusterSummaryProducer::pixelClustersLabel
private

Definition at line 88 of file ClusterSummaryProducer.h.

Referenced by produce().

std::string ClusterSummaryProducer::pixelModules
private

Definition at line 91 of file ClusterSummaryProducer.h.

Referenced by beginJob().

std::string ClusterSummaryProducer::pixelVariables
private

Definition at line 96 of file ClusterSummaryProducer.h.

Referenced by beginJob().

edm::InputTag ClusterSummaryProducer::stripClustersLabel
private

Definition at line 87 of file ClusterSummaryProducer.h.

Referenced by produce().

std::string ClusterSummaryProducer::stripModules
private

Definition at line 89 of file ClusterSummaryProducer.h.

Referenced by beginJob().

std::string ClusterSummaryProducer::stripVariables
private

Definition at line 94 of file ClusterSummaryProducer.h.

Referenced by beginJob().

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

Definition at line 92 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

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

Definition at line 97 of file ClusterSummaryProducer.h.

Referenced by beginJob().

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

Definition at line 90 of file ClusterSummaryProducer.h.

Referenced by beginJob(), and produce().

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

Definition at line 95 of file ClusterSummaryProducer.h.

Referenced by beginJob().

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

Definition at line 114 of file ClusterSummaryProducer.h.

Referenced by beginJob().

bool ClusterSummaryProducer::verbose
private

Definition at line 107 of file ClusterSummaryProducer.h.