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
ClusterAnalyzer Class Reference

#include <msegala/ClusterSummary/src/ClusterAnalyzer.cc>

Inheritance diagram for ClusterAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 ClusterAnalyzer (const edm::ParameterSet &)
 
 ~ClusterAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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 analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 

Private Attributes

bool _firstPass
 
bool _verbose
 
std::vector< double > clusterCharge_
 
std::vector< double > clusterSize_
 
bool doPixels
 
bool doStrips
 
std::map< int, std::string > enumModules_
 
edm::Service< TFileServicefs
 
std::vector< std::vector
< double > > 
genericVariables_
 
std::map< std::string, TH1D * > histos1D_
 
std::vector< string > maps
 
std::vector< int > modules_
 
std::vector< int > nType_
 
std::string ProvInfo
 
std::string ProvInfo_vars
 
std::string ProvInfoPixels
 
std::string ProvInfoPixels_vars
 
edm::EDGetTokenT< ClusterSummarytoken
 
std::vector< std::string > v_moduleTypes
 
std::vector< std::string > v_variables
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 49 of file ClusterAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 94 of file ClusterAnalyzer.cc.

References edm::ParameterSet::getParameter().

95 {
96 
97  token = consumes<ClusterSummary>(iConfig.getParameter<edm::InputTag>("clusterSum"));
98 
99  _firstPass = true;
100  _verbose = true; //set to true to see the event by event summary info
101 
102 }
T getParameter(std::string const &) const
edm::EDGetTokenT< ClusterSummary > token
ClusterAnalyzer::~ClusterAnalyzer ( )

Definition at line 105 of file ClusterAnalyzer.cc.

105 {}

Member Function Documentation

void ClusterAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 108 of file ClusterAnalyzer.cc.

References begin, hitfit::clear(), gather_cfg::cout, clustersummaryproducer_cfg::doPixels, clustersummaryproducer_cfg::doStrips, end, HcalObjRepresent::Fill(), edm::Event::getByToken(), edm::ParameterSet::getParameter(), edm::Event::getProvenance(), mod(), n, edm::parameterSet(), and AlCaHLTBitMon_QueryRunRegistry::string.

109 {
110  using namespace edm;
111 
112 
114  iEvent.getByToken( token, class_);
115 
116  if (_firstPass){
117 
118  modules_ . clear();
119  modules_ = class_ -> GetUserModules();
120 
121  // Provenance Information
122  const Provenance& prov = iEvent.getProvenance(class_.id());
123  const edm::ParameterSet& pSet = parameterSet(prov);
124 
125  ProvInfo = "";
126  ProvInfo_vars = "";
127  ProvInfoPixels = "";
128  ProvInfoPixels_vars = "";
129 
130  std::string ProvString = "";
131  std::string VarString = "";
132 
133  doStrips = pSet.getParameter<bool>("doStrips");
134  doPixels = pSet.getParameter<bool>("doPixels");
135 
136  if (doStrips){
137  ProvInfo = pSet.getParameter<string>("stripModule");
138  cout << "From provenance infomation the selected strip modules are = "<< ProvInfo << endl;
139  ProvInfo_vars = pSet.getParameter<string>("stripVariables");
140  cout << "From provenance infomation the avaliable strip variables are = "<< ProvInfo_vars << endl;
141 
142  }
143  if (doPixels){
144  ProvInfoPixels = pSet.getParameter<string>("pixelModule");
145  cout << "From provenance infomation the selected pixel modules are = "<< ProvInfoPixels << endl;
146  ProvInfoPixels_vars = pSet.getParameter<string>("pixelVariables");
147  cout << "From provenance infomation the avaliable pixel variables are = "<< ProvInfoPixels_vars << endl;
148  }
149 
150 
151  if (doStrips && doPixels) {
152  ProvString = ProvInfo + "," + ProvInfoPixels;
153  VarString = ProvInfo_vars + "," + ProvInfoPixels_vars;
154  }
155  else if (doStrips && !doPixels) {
156  ProvString = ProvInfo;
157  VarString = ProvInfo_vars;
158  }
159  else if (!doStrips && doPixels) {
160  ProvString = ProvInfoPixels;
161  VarString = ProvInfoPixels_vars;
162  }
163 
164  // Define the Modules to get the summary info out of
165  v_moduleTypes = class_ -> DecodeProvInfo( ProvString );
166  v_variables = class_ -> DecodeProvInfo( VarString );
167 
168  }
169 
170  class_ -> SetUserContent( v_variables );
171 
172  genericVariables_ = class_ -> GetGenericVariable();
173 
174  //cout << class_ -> GetGenericVariable("cHits", ClusterSummary::TIB) << endl;
175 
176  if ( _firstPass ){ //only do on the first event
177 
178  // Loop over all the modules to create a Map of Histograms to fill
179  int n = 0;
180  for ( vector<int>::const_iterator mod = modules_ . begin(); mod != modules_ . end(); mod++ ){
181 
182  //cout << "Creating histograms for " << *mod << endl;
183  cout << "Creating histograms for " << v_moduleTypes.at(n) << endl;
184 
185  std::string tmpstr = v_moduleTypes.at(n);
186 
187  histos1D_[ (tmpstr + "nclusters").c_str() ] = fs->make< TH1D >( (tmpstr + "nclusters").c_str() , (tmpstr + "nclusters").c_str() , 1000 , 0 , 3000 );
188  histos1D_[ (tmpstr + "nclusters").c_str() ]->SetXTitle( ("number of Clusters in " + tmpstr).c_str() );
189 
190  histos1D_[ (tmpstr + "avgCharge").c_str() ] = fs->make< TH1D >( (tmpstr + "avgCharge").c_str() , (tmpstr + "avgCharge").c_str() , 500 , 0 , 1000 );
191  histos1D_[ (tmpstr + "avgCharge").c_str() ]->SetXTitle( ("average cluster charge in " + tmpstr).c_str() );
192 
193  histos1D_[ (tmpstr + "avgSize").c_str() ] = fs->make< TH1D >( (tmpstr + "avgSize").c_str() , (tmpstr + "avgSize").c_str() , 30 , 0 , 10 );
194  histos1D_[ (tmpstr + "avgSize").c_str() ]->SetXTitle( ("average cluster size in " + tmpstr).c_str() );
195 
196  maps.push_back( (tmpstr + "nclusters").c_str() );
197  maps.push_back( (tmpstr + "avgSize").c_str() );
198  maps.push_back( (tmpstr + "avgCharge").c_str() );
199 
200  ++n;
201 
202  }
203 
204  _firstPass = false;
205 
206  }
207 
208  int n = 0;
209  for ( vector<int>::const_iterator mod = modules_ . begin(); mod != modules_ . end(); mod++ ){
210 
211  std::string tmpstr = v_moduleTypes.at(n);
212 
213  //Trick to see if it comes from a strip or pixel variable. If the first digit is < 6 then it is from the strips.
214  int mod_tmp = *mod;
215  while (mod_tmp > 9 ){
216  mod_tmp /= 10;
217  }
218 
219  if ( mod_tmp < 5 ){
220 
221  histos1D_[ (tmpstr + "nclusters").c_str() ] -> Fill( class_ -> GetGenericVariable("cHits", *mod) );
222  histos1D_[ (tmpstr + "avgSize").c_str() ] -> Fill( class_ -> GetGenericVariable("cSize", *mod) /class_ -> GetGenericVariable("cHits", *mod) );
223  histos1D_[ (tmpstr + "avgCharge").c_str() ] -> Fill( class_ -> GetGenericVariable("cCharge", *mod)/class_ -> GetGenericVariable("cHits", *mod) );
224 
225  cout << "n"<<tmpstr <<", avg size, avg charge = "<< class_ -> GetGenericVariable( "cHits",*mod );
226  cout << ", "<< class_ -> GetGenericVariable( "cSize",*mod ) /class_ -> GetGenericVariable( "cHits",*mod );
227  cout << ", "<< class_ -> GetGenericVariable( "cCharge",*mod )/class_ -> GetGenericVariable( "cHits",*mod ) << endl;
228 
229  }
230  else{
231  histos1D_[ (tmpstr + "nclusters").c_str() ] -> Fill( class_ -> GetGenericVariable("pHits", *mod) );
232  histos1D_[ (tmpstr + "avgSize").c_str() ] -> Fill( class_ -> GetGenericVariable("pSize", *mod)/class_ -> GetGenericVariable("pHits", *mod) );
233  histos1D_[ (tmpstr + "avgCharge").c_str() ] -> Fill( class_ -> GetGenericVariable("pCharge", *mod)/class_ -> GetGenericVariable("pHits", *mod) );
234 
235  cout << "n"<<tmpstr <<", avg size, avg charge = "<< class_ -> GetGenericVariable( "pHits",*mod );
236  cout << ", "<< class_ -> GetGenericVariable( "pSize",*mod ) /class_ -> GetGenericVariable( "pHits",*mod );
237  cout << ", "<< class_ -> GetGenericVariable( "pCharge",*mod )/class_ -> GetGenericVariable( "pHits",*mod ) << endl;
238 
239  }
240 
241  ++n;
242 
243  }
244 
245  cout << "-------------------------------------------------------" << endl;
246 
247 
248 }
T getParameter(std::string const &) const
std::string ProvInfoPixels_vars
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
std::string ProvInfo_vars
std::vector< string > maps
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
std::string ProvInfo
std::vector< int > modules_
#define end
Definition: vmac.h:37
edm::Service< TFileService > fs
std::vector< std::string > v_moduleTypes
std::vector< std::string > v_variables
#define begin
Definition: vmac.h:30
std::vector< std::vector< double > > genericVariables_
std::map< std::string, TH1D * > histos1D_
tuple cout
Definition: gather_cfg.py:121
std::string ProvInfoPixels
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:73
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
edm::EDGetTokenT< ClusterSummary > token
void ClusterAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 253 of file ClusterAnalyzer.cc.

253 {}

Member Data Documentation

bool ClusterAnalyzer::_firstPass
private

Definition at line 78 of file ClusterAnalyzer.cc.

bool ClusterAnalyzer::_verbose
private
std::vector<double> ClusterAnalyzer::clusterCharge_
private

Definition at line 71 of file ClusterAnalyzer.cc.

std::vector<double> ClusterAnalyzer::clusterSize_
private

Definition at line 70 of file ClusterAnalyzer.cc.

bool ClusterAnalyzer::doPixels
private

Definition at line 90 of file ClusterAnalyzer.cc.

bool ClusterAnalyzer::doStrips
private

Definition at line 89 of file ClusterAnalyzer.cc.

std::map<int, std::string> ClusterAnalyzer::enumModules_
private

Definition at line 64 of file ClusterAnalyzer.cc.

edm::Service<TFileService> ClusterAnalyzer::fs
private

Definition at line 79 of file ClusterAnalyzer.cc.

std::vector< std::vector<double> > ClusterAnalyzer::genericVariables_
private

Definition at line 76 of file ClusterAnalyzer.cc.

std::map< std::string, TH1D* > ClusterAnalyzer::histos1D_
private

Definition at line 65 of file ClusterAnalyzer.cc.

std::vector<string> ClusterAnalyzer::maps
private

Definition at line 80 of file ClusterAnalyzer.cc.

std::vector<int> ClusterAnalyzer::modules_
private

Definition at line 67 of file ClusterAnalyzer.cc.

std::vector<int> ClusterAnalyzer::nType_
private

Definition at line 69 of file ClusterAnalyzer.cc.

std::string ClusterAnalyzer::ProvInfo
private

Definition at line 84 of file ClusterAnalyzer.cc.

std::string ClusterAnalyzer::ProvInfo_vars
private

Definition at line 85 of file ClusterAnalyzer.cc.

std::string ClusterAnalyzer::ProvInfoPixels
private

Definition at line 86 of file ClusterAnalyzer.cc.

std::string ClusterAnalyzer::ProvInfoPixels_vars
private

Definition at line 87 of file ClusterAnalyzer.cc.

edm::EDGetTokenT<ClusterSummary> ClusterAnalyzer::token
private

Definition at line 62 of file ClusterAnalyzer.cc.

std::vector<std::string> ClusterAnalyzer::v_moduleTypes
private

Definition at line 73 of file ClusterAnalyzer.cc.

std::vector<std::string> ClusterAnalyzer::v_variables
private

Definition at line 74 of file ClusterAnalyzer.cc.