CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalTest.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: GlobalTest
4 //
10 //
11 // Original Author: Ursula Berthon
12 // Created: Fri Sep 23 11:38:38 CEST 2005
13 // $Id: GlobalTest.cc,v 1.10 2011/01/10 09:22:24 fwyzard Exp $
14 //
15 //
16 
17 
18 // system include files
19 #include <memory>
20 #include <utility>
21 
22 #include <string>
23 
24 // user include files
27 
30 
32 
36 
39 
41 #include "TFile.h"
44 
45 using namespace edm;
46 
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 }
54 
56 {
57 
58  // do anything here that needs to be done at desctruction time
59  // (e.g. close files, deallocate resources etc.)
60 }
61 
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 }
114 
115 
117  if (filename_.size() != 0 && dbe_ ) dbe_->save(filename_);
118 
119  for (int i = 0; i < 6; i++) delete[] labels[i];
120 }
121 
122 //
123 // member functions
124 //
125 
126 // ------------ method called to analyze the data ------------
127 void
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 }
188 
void endJob()
Definition: GlobalTest.cc:116
int i
Definition: DBlmapReader.cc:9
int maxbunch_
Definition: GlobalTest.h:51
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:717
MonitorElement * caloEnergyEEH_[nMaxH]
Definition: GlobalTest.h:60
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: GlobalTest.cc:128
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:2113
char * labels[nrHistos]
Definition: GlobalTest.h:65
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
int minbunch_
Definition: GlobalTest.h:50
MonitorElement * trackPartIdH_[nMaxH]
Definition: GlobalTest.h:58
std::string filename_
Definition: GlobalTest.h:49
MonitorElement * caloEnergyEBH_[nMaxH]
Definition: GlobalTest.h:59
void Fill(long long x)
void beginJob()
Definition: GlobalTest.cc:62
int iEvent
Definition: GenABIO.cc:243
GlobalTest(const edm::ParameterSet &)
Definition: GlobalTest.cc:47
MonitorElement * nrPileupsH_[nMaxH]
Definition: GlobalTest.h:55
MonitorElement * nrTracksH_[nMaxH]
Definition: GlobalTest.h:57
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
DQMStore * dbe_
MonitorElement * nrVerticesH_[nMaxH]
Definition: GlobalTest.h:56
tuple cout
Definition: gather_cfg.py:121
void showDirStructure(void) const
Definition: DQMStore.cc:2761
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429