CMS 3D CMS Logo

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 //
14 //
15 
16 
18 
19 // system include files
20 #include <memory>
21 #include <utility>
22 
23 #include <string>
24 
25 // user include files
28 
31 
33 
34 #include "TFile.h"
37 
38 using namespace edm;
39 
41  filename_(iConfig.getParameter<std::string>("fileName")),
42  minbunch_(iConfig.getParameter<int>("minBunch")),
43  maxbunch_(iConfig.getParameter<int>("maxBunch")),
44  cfTrackToken_(consumes<CrossingFrame<SimTrack> > (
45  iConfig.getParameter<edm::InputTag>("cfTrackTag"))),
46  cfVertexToken_(consumes<CrossingFrame<SimTrack> >(
47  iConfig.getParameter<edm::InputTag>("cfVertexTag")))
48 {
49  std::string ecalsubdetb("");
50  std::string ecalsubdete("g4SimHitsEcalHitsEE");
51  g4SimHits_EB_Token_ = consumes<CrossingFrame<PCaloHit> > (
52  edm::InputTag("mix", "g4SimHitsEcalHitsEB"));
53  g4SimHits_EE_Token_ = consumes<CrossingFrame<PCaloHit> > (
54  edm::InputTag("mix", "g4SimHitsEcalHitsEE"));
55 
56  std::cout << "Constructed GlobalTest, filename: "
57  << filename_ << " minbunch: "
58  << minbunch_ << ", maxbunch: "
59  << maxbunch_ << std::endl;
60 
61 }
62 
64 {
65  for (int i = 0; i < 6; i++) delete[] labels[i];
66 }
67 
69  edm::Run const &, edm::EventSetup const & ){
70  using namespace std;
71 
72  ibooker.setCurrentFolder("MixingV/Mixing");
73  //book histos
74  std::string NrPileupEvts = "NrPileupEvts";
75  size_t NrPileupEvtsSize = NrPileupEvts.size() + 1;
76  std::string NrVertices = "NrVertices";
77  size_t NrVerticesSize = NrVertices.size() + 1;
78  std::string NrTracks = "NrTracks";
79  size_t NrTracksSize = NrTracks.size() + 1;
80  std::string TrackPartId = "TrackPartId";
81  size_t TrackPartIdSize = TrackPartId.size() + 1;
82  std::string CaloEnergyEB = "CaloEnergyEB";
83  size_t CaloEnergyEBSize = CaloEnergyEB.size() + 1;
84  std::string CaloEnergyEE = "CaloEnergyEE";
85  size_t CaloEnergyEESize = CaloEnergyEE.size() + 1;
86 
87  labels[0] = new char [NrPileupEvtsSize];
88  strncpy(labels[0], NrPileupEvts.c_str(), NrPileupEvtsSize);
89  labels[1] = new char [NrVerticesSize];
90  strncpy(labels[1], NrVertices.c_str(), NrVerticesSize);
91  labels[2] = new char [NrTracksSize];
92  strncpy(labels[2], NrTracks.c_str(), NrTracksSize);
93  labels[3] = new char [TrackPartIdSize];
94  strncpy(labels[3], TrackPartId.c_str(), TrackPartIdSize);
95  labels[4] = new char [CaloEnergyEBSize];
96  strncpy(labels[4], CaloEnergyEB.c_str(), CaloEnergyEBSize);
97  labels[5] = new char [CaloEnergyEESize];
98  strncpy(labels[5], CaloEnergyEE.c_str(), CaloEnergyEESize);
99 
100  //FIXME: test for max nr of histos
101  for (int i=minbunch_;i<=maxbunch_;++i) {
102  int ii=i-minbunch_;
103  char label[50];
104  sprintf(label,"%s_%d",labels[0],i);
105  nrPileupsH_[ii] = ibooker.book1D(label,label,100,0,100);
106  sprintf(label,"%s_%d",labels[1],i);
107  nrVerticesH_[ii] = ibooker.book1D(label,label,100,0,5000);
108  sprintf(label,"%s_%d",labels[2],i);
109  nrTracksH_[ii] = ibooker.book1D(label,label,100,0,10000);
110  sprintf(label,"%s_%d",labels[3],i);
111  trackPartIdH_[ii] = ibooker.book1D(label,label,100,0,100);
112  sprintf(label,"%s_%d",labels[4],i);
113  caloEnergyEBH_ [ii] = ibooker.book1D(label,label,100,0.,1000.);
114  sprintf(label,"%s_%d",labels[5],i);
115  caloEnergyEEH_ [ii] = ibooker.book1D(label,label,100,0.,1000.);
116  }
117 }
118 
119 
120 //
121 // member functions
122 //
123 
124 // ------------ method called to analyze the data ------------
125 void
127 {
128  using namespace edm;
129  using namespace std;
130 
131  // Get input
136  std::string ecalsubdetb("g4SimHitsEcalHitsEB");
137  std::string ecalsubdete("g4SimHitsEcalHitsEE");
138  iEvent.getByToken(cfTrackToken_, cf_track);
139  iEvent.getByToken(cfVertexToken_, cf_vertex);
140  iEvent.getByToken(g4SimHits_EB_Token_, cf_calohitB);
141  iEvent.getByToken(g4SimHits_EE_Token_, cf_calohitE);
142 
143  // number of events/bcr ??
144 
145  // number of tracks
146  for (int i=minbunch_;i<=maxbunch_;++i) {
147  nrTracksH_[i-minbunch_]->Fill(cf_track->getNrPileups(i));
148  }
149 
150  // number of vertices
151  for (int i=minbunch_;i<=maxbunch_;++i) {
152  nrVerticesH_[i-minbunch_]->Fill(cf_vertex->getNrPileups(i));
153  }
154 
155  // part id for each track
156  std::auto_ptr<MixCollection<SimTrack> > coltr(new MixCollection<SimTrack>(cf_track.product()));
158  for (cfitr=coltr->begin(); cfitr!=coltr->end();cfitr++) {
159  trackPartIdH_[cfitr.bunch()-minbunch_]->Fill(cfitr->type());
160  }
161 
162  // energy sum
163  double sumE[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
164  std::auto_ptr<MixCollection<PCaloHit> > colecalb(new MixCollection<PCaloHit>(cf_calohitB.product()));
166  for (cfiecalb=colecalb->begin(); cfiecalb!=colecalb->end();cfiecalb++) {
167  sumE[cfiecalb.bunch()-minbunch_]+=cfiecalb->energy();
168  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
169  // else tofecalhist->Fill(cfiecal->time());
170  }
171  for (int i=minbunch_;i<=maxbunch_;++i) {
173  }
174  double sumEE[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
175  std::auto_ptr<MixCollection<PCaloHit> > colecale(new MixCollection<PCaloHit>(cf_calohitE.product()));
177  for (cfiecale=colecale->begin(); cfiecale!=colecale->end();cfiecale++) {
178  sumEE[cfiecale.bunch()-minbunch_]+=cfiecale->energy();
179  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
180  // else tofecalhist->Fill(cfiecal->time());
181  }
182  for (int i=minbunch_;i<=maxbunch_;++i) {
184  }
185 }
186 
int maxbunch_
Definition: GlobalTest.h:58
MonitorElement * caloEnergyEEH_[nMaxH]
Definition: GlobalTest.h:67
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
char * labels[nrHistos]
Definition: GlobalTest.h:70
int minbunch_
Definition: GlobalTest.h:57
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EE_Token_
Definition: GlobalTest.h:75
MonitorElement * trackPartIdH_[nMaxH]
Definition: GlobalTest.h:65
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfTrackToken_
Definition: GlobalTest.h:72
std::string filename_
Definition: GlobalTest.h:56
MonitorElement * caloEnergyEBH_[nMaxH]
Definition: GlobalTest.h:66
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
GlobalTest(const edm::ParameterSet &)
Definition: GlobalTest.cc:40
~GlobalTest() override
Definition: GlobalTest.cc:63
MonitorElement * nrPileupsH_[nMaxH]
Definition: GlobalTest.h:62
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
MonitorElement * nrTracksH_[nMaxH]
Definition: GlobalTest.h:64
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfVertexToken_
Definition: GlobalTest.h:73
ii
Definition: cuy.py:588
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GlobalTest.cc:68
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
T const * product() const
Definition: Handle.h:81
MonitorElement * nrVerticesH_[nMaxH]
Definition: GlobalTest.h:63
HLT enums.
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EB_Token_
Definition: GlobalTest.h:74
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GlobalTest.cc:126
Definition: Run.h:43