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 Attributes | Static Private Attributes
GlobalTest Class Reference

#include <GlobalTest.h>

Inheritance diagram for GlobalTest:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
void beginJob ()
 
void endJob ()
 
 GlobalTest (const edm::ParameterSet &)
 
 ~GlobalTest ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

MonitorElementcaloEnergyEBH_ [nMaxH]
 
MonitorElementcaloEnergyEEH_ [nMaxH]
 
DQMStoredbe_
 
std::string filename_
 
TFile * histfile_
 
char * labels [nrHistos]
 
int maxbunch_
 
int minbunch_
 
MonitorElementnrPileupsH_ [nMaxH]
 
MonitorElementnrTracksH_ [nMaxH]
 
MonitorElementnrVerticesH_ [nMaxH]
 
MonitorElementtrackPartIdH_ [nMaxH]
 

Static Private Attributes

static const int nMaxH =10
 
static const int nrHistos =6
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Description: test suite for Mixing Module

Definition at line 38 of file GlobalTest.h.

Constructor & Destructor Documentation

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

Definition at line 47 of file GlobalTest.cc.

References gather_cfg::cout, filename_, maxbunch_, and minbunch_.

47  :
48 filename_(iConfig.getParameter<std::string>("fileName")),
49 minbunch_(iConfig.getParameter<int>("minBunch")),maxbunch_(iConfig.getParameter<int>("maxBunch")), dbe_(0)
50 {
51  std::cout << "Constructed GlobalTest, filename: "<<filename_<<" minbunch: "<<minbunch_<<", maxbunch: "<<maxbunch_<<std::endl;
52 
53 }
T getParameter(std::string const &) const
int maxbunch_
Definition: GlobalTest.h:51
DQMStore * dbe_
Definition: GlobalTest.h:62
int minbunch_
Definition: GlobalTest.h:50
std::string filename_
Definition: GlobalTest.h:49
tuple cout
Definition: gather_cfg.py:41
GlobalTest::~GlobalTest ( )

Definition at line 55 of file GlobalTest.cc.

56 {
57 
58  // do anything here that needs to be done at desctruction time
59  // (e.g. close files, deallocate resources etc.)
60 }

Member Function Documentation

void GlobalTest::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 128 of file GlobalTest.cc.

References caloEnergyEBH_, caloEnergyEEH_, MonitorElement::Fill(), edm::Event::getByLabel(), edm::Event::getByType(), i, maxbunch_, minbunch_, nrTracksH_, nrVerticesH_, and trackPartIdH_.

129 {
130  using namespace edm;
131  using namespace std;
132 
133 // Get input
138  std::string ecalsubdetb("g4SimHitsEcalHitsEB");
139  std::string ecalsubdete("g4SimHitsEcalHitsEE");
140  iEvent.getByType(cf_track);
141  iEvent.getByType(cf_vertex);
142  iEvent.getByLabel("mix",ecalsubdetb,cf_calohitB);
143  iEvent.getByLabel("mix",ecalsubdete,cf_calohitE);
144 
145  // number of events/bcr ??
146 
147  // number of tracks
148  for (int i=minbunch_;i<=maxbunch_;++i) {
149  nrTracksH_[i-minbunch_]->Fill(cf_track->getNrPileups(i));
150  }
151 
152  // number of vertices
153  for (int i=minbunch_;i<=maxbunch_;++i) {
154  nrVerticesH_[i-minbunch_]->Fill(cf_vertex->getNrPileups(i));
155  }
156 
157  // part id for each track
158  std::auto_ptr<MixCollection<SimTrack> > coltr(new MixCollection<SimTrack>(cf_track.product()));
160  for (cfitr=coltr->begin(); cfitr!=coltr->end();cfitr++) {
161  trackPartIdH_[cfitr.bunch()-minbunch_]->Fill(cfitr->type());
162  }
163 
164  // energy sum
165  double sumE[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
166  std::auto_ptr<MixCollection<PCaloHit> > colecalb(new MixCollection<PCaloHit>(cf_calohitB.product()));
168  for (cfiecalb=colecalb->begin(); cfiecalb!=colecalb->end();cfiecalb++) {
169  sumE[cfiecalb.bunch()-minbunch_]+=cfiecalb->energy();
170  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
171  // else tofecalhist->Fill(cfiecal->time());
172  }
173  for (int i=minbunch_;i<=maxbunch_;++i) {
175  }
176  double sumEE[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
177  std::auto_ptr<MixCollection<PCaloHit> > colecale(new MixCollection<PCaloHit>(cf_calohitE.product()));
179  for (cfiecale=colecale->begin(); cfiecale!=colecale->end();cfiecale++) {
180  sumEE[cfiecale.bunch()-minbunch_]+=cfiecale->energy();
181  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
182  // else tofecalhist->Fill(cfiecal->time());
183  }
184  for (int i=minbunch_;i<=maxbunch_;++i) {
186  }
187 }
int i
Definition: DBlmapReader.cc:9
int maxbunch_
Definition: GlobalTest.h:51
MonitorElement * caloEnergyEEH_[nMaxH]
Definition: GlobalTest.h:60
bool getByType(Handle< PROD > &result) const
Definition: Event.h:397
int minbunch_
Definition: GlobalTest.h:50
MonitorElement * trackPartIdH_[nMaxH]
Definition: GlobalTest.h:58
MonitorElement * caloEnergyEBH_[nMaxH]
Definition: GlobalTest.h:59
void Fill(long long x)
MonitorElement * nrTracksH_[nMaxH]
Definition: GlobalTest.h:57
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
MonitorElement * nrVerticesH_[nMaxH]
Definition: GlobalTest.h:56
void GlobalTest::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 62 of file GlobalTest.cc.

References DQMStore::book1D(), caloEnergyEBH_, caloEnergyEEH_, dbe_, i, label, labels, maxbunch_, minbunch_, nrPileupsH_, nrTracksH_, nrVerticesH_, cmsCodeRules.cppFunctionSkipper::operator, DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), and trackPartIdH_.

62  {
63  using namespace std;
64 
65  // get hold of back-end interface
68  dbe_->setCurrentFolder("MixingV/Mixing");
69  //book histos
70  std::string NrPileupEvts = "NrPileupEvts";
71  size_t NrPileupEvtsSize = NrPileupEvts.size() + 1;
72  std::string NrVertices = "NrVertices";
73  size_t NrVerticesSize = NrVertices.size() + 1;
74  std::string NrTracks = "NrTracks";
75  size_t NrTracksSize = NrTracks.size() + 1;
76  std::string TrackPartId = "TrackPartId";
77  size_t TrackPartIdSize = TrackPartId.size() + 1;
78  std::string CaloEnergyEB = "CaloEnergyEB";
79  size_t CaloEnergyEBSize = CaloEnergyEB.size() + 1;
80  std::string CaloEnergyEE = "CaloEnergyEE";
81  size_t CaloEnergyEESize = CaloEnergyEE.size() + 1;
82 
83  labels[0] = new char [NrPileupEvtsSize];
84  strncpy(labels[0], NrPileupEvts.c_str(), NrPileupEvtsSize);
85  labels[1] = new char [NrVerticesSize];
86  strncpy(labels[1], NrVertices.c_str(), NrVerticesSize);
87  labels[2] = new char [NrTracksSize];
88  strncpy(labels[2], NrTracks.c_str(), NrTracksSize);
89  labels[3] = new char [TrackPartIdSize];
90  strncpy(labels[3], TrackPartId.c_str(), TrackPartIdSize);
91  labels[4] = new char [CaloEnergyEBSize];
92  strncpy(labels[4], CaloEnergyEB.c_str(), CaloEnergyEBSize);
93  labels[5] = new char [CaloEnergyEESize];
94  strncpy(labels[5], CaloEnergyEE.c_str(), CaloEnergyEESize);
95 
96  //FIXME: test for max nr of histos
97  for (int i=minbunch_;i<=maxbunch_;++i) {
98  int ii=i-minbunch_;
99  char label[50];
100  sprintf(label,"%s_%d",labels[0],i);
101  nrPileupsH_[ii] = dbe_->book1D(label,label,100,0,100);
102  sprintf(label,"%s_%d",labels[1],i);
103  nrVerticesH_[ii] = dbe_->book1D(label,label,100,0,5000);
104  sprintf(label,"%s_%d",labels[2],i);
105  nrTracksH_[ii] = dbe_->book1D(label,label,100,0,10000);
106  sprintf(label,"%s_%d",labels[3],i);
107  trackPartIdH_[ii] = dbe_->book1D(label,label,100,0,100);
108  sprintf(label,"%s_%d",labels[4],i);
109  caloEnergyEBH_ [ii] = dbe_->book1D(label,label,100,0.,1000.);
110  sprintf(label,"%s_%d",labels[5],i);
111  caloEnergyEEH_ [ii] = dbe_->book1D(label,label,100,0.,1000.);
112  }
113 }
int i
Definition: DBlmapReader.cc:9
int maxbunch_
Definition: GlobalTest.h:51
const std::string & label
Definition: MVAComputer.cc:186
DQMStore * dbe_
Definition: GlobalTest.h:62
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
MonitorElement * caloEnergyEEH_[nMaxH]
Definition: GlobalTest.h:60
char * labels[nrHistos]
Definition: GlobalTest.h:65
int minbunch_
Definition: GlobalTest.h:50
MonitorElement * trackPartIdH_[nMaxH]
Definition: GlobalTest.h:58
MonitorElement * caloEnergyEBH_[nMaxH]
Definition: GlobalTest.h:59
MonitorElement * nrPileupsH_[nMaxH]
Definition: GlobalTest.h:55
MonitorElement * nrTracksH_[nMaxH]
Definition: GlobalTest.h:57
MonitorElement * nrVerticesH_[nMaxH]
Definition: GlobalTest.h:56
void showDirStructure(void) const
Definition: DQMStore.cc:2554
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void GlobalTest::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 116 of file GlobalTest.cc.

References dbe_, filename_, i, labels, and DQMStore::save().

116  {
117  if (filename_.size() != 0 && dbe_ ) dbe_->save(filename_);
118 
119  for (int i = 0; i < 6; i++) delete[] labels[i];
120 }
int i
Definition: DBlmapReader.cc:9
DQMStore * dbe_
Definition: GlobalTest.h:62
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:1898
char * labels[nrHistos]
Definition: GlobalTest.h:65
std::string filename_
Definition: GlobalTest.h:49

Member Data Documentation

MonitorElement* GlobalTest::caloEnergyEBH_[nMaxH]
private

Definition at line 59 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

MonitorElement* GlobalTest::caloEnergyEEH_[nMaxH]
private

Definition at line 60 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

DQMStore* GlobalTest::dbe_
private

Definition at line 62 of file GlobalTest.h.

Referenced by beginJob(), and endJob().

std::string GlobalTest::filename_
private

Definition at line 49 of file GlobalTest.h.

Referenced by endJob(), and GlobalTest().

TFile* GlobalTest::histfile_
private

Definition at line 52 of file GlobalTest.h.

char* GlobalTest::labels[nrHistos]
private

Definition at line 65 of file GlobalTest.h.

Referenced by beginJob(), and endJob().

int GlobalTest::maxbunch_
private

Definition at line 51 of file GlobalTest.h.

Referenced by analyze(), beginJob(), and GlobalTest().

int GlobalTest::minbunch_
private

Definition at line 50 of file GlobalTest.h.

Referenced by analyze(), beginJob(), and GlobalTest().

const int GlobalTest::nMaxH =10
staticprivate

Definition at line 54 of file GlobalTest.h.

const int GlobalTest::nrHistos =6
staticprivate

Definition at line 64 of file GlobalTest.h.

MonitorElement* GlobalTest::nrPileupsH_[nMaxH]
private

Definition at line 55 of file GlobalTest.h.

Referenced by beginJob().

MonitorElement* GlobalTest::nrTracksH_[nMaxH]
private

Definition at line 57 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

MonitorElement* GlobalTest::nrVerticesH_[nMaxH]
private

Definition at line 56 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

MonitorElement* GlobalTest::trackPartIdH_[nMaxH]
private

Definition at line 58 of file GlobalTest.h.

Referenced by analyze(), and beginJob().