CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 //
14 //
15 
17 
18 // system include files
19 #include <memory>
20 #include <utility>
21 
22 #include <string>
23 
24 #include <fmt/format.h>
25 
26 // user include files
29 
32 
34 
36 #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>>(iConfig.getParameter<edm::InputTag>("cfTrackTag"))),
45  cfVertexToken_(consumes<CrossingFrame<SimTrack>>(iConfig.getParameter<edm::InputTag>("cfVertexTag"))) {
46  std::string ecalsubdetb("");
47  std::string ecalsubdete("g4SimHitsEcalHitsEE");
48  g4SimHits_EB_Token_ = consumes<CrossingFrame<PCaloHit>>(edm::InputTag("mix", "g4SimHitsEcalHitsEB"));
49  g4SimHits_EE_Token_ = consumes<CrossingFrame<PCaloHit>>(edm::InputTag("mix", "g4SimHitsEcalHitsEE"));
50 
51  std::cout << "Constructed GlobalTest, filename: " << filename_ << " minbunch: " << minbunch_
52  << ", maxbunch: " << maxbunch_ << std::endl;
53 }
54 
56  using namespace std;
57 
58  ibooker.setCurrentFolder("MixingV/Mixing");
59  // book histos
60 
61  for (int i = minbunch_; i <= maxbunch_; ++i) {
62  int ii = i - minbunch_;
63  auto label = fmt::format("NrPileupEvts_{}", i);
64  nrPileupsH_[ii] = ibooker.book1D(label, label, 100, 0, 100);
65  label = fmt::format("NrVertices_{}", i);
66  nrVerticesH_[ii] = ibooker.book1D(label, label, 100, 0, 5000);
67  label = fmt::format("NrTracks_{}", i);
68  nrTracksH_[ii] = ibooker.book1D(label, label, 100, 0, 10000);
69  label = fmt::format("TrackPartId", i);
70  trackPartIdH_[ii] = ibooker.book1D(label, label, 100, 0, 100);
71  label = fmt::format("CaloEnergyEB", i);
72  caloEnergyEBH_[ii] = ibooker.book1D(label, label, 100, 0., 1000.);
73  label = fmt::format("CaloEnergyEE", i);
74  caloEnergyEEH_[ii] = ibooker.book1D(label, label, 100, 0., 1000.);
75  }
76 }
77 
78 //
79 // member functions
80 //
81 
82 // ------------ method called to analyze the data ------------
84  using namespace edm;
85  using namespace std;
86 
87  // Get input
92  std::string ecalsubdetb("g4SimHitsEcalHitsEB");
93  std::string ecalsubdete("g4SimHitsEcalHitsEE");
94  iEvent.getByToken(cfTrackToken_, cf_track);
95  iEvent.getByToken(cfVertexToken_, cf_vertex);
96  iEvent.getByToken(g4SimHits_EB_Token_, cf_calohitB);
97  iEvent.getByToken(g4SimHits_EE_Token_, cf_calohitE);
98 
99  // number of events/bcr ??
100 
101  // number of tracks
102  for (int i = minbunch_; i <= maxbunch_; ++i) {
103  nrTracksH_[i - minbunch_]->Fill(cf_track->getNrPileups(i));
104  }
105 
106  // number of vertices
107  for (int i = minbunch_; i <= maxbunch_; ++i) {
108  nrVerticesH_[i - minbunch_]->Fill(cf_vertex->getNrPileups(i));
109  }
110 
111  // part id for each track
112  std::unique_ptr<MixCollection<SimTrack>> coltr(new MixCollection<SimTrack>(cf_track.product()));
114  for (cfitr = coltr->begin(); cfitr != coltr->end(); cfitr++) {
115  trackPartIdH_[cfitr.bunch() - minbunch_]->Fill(cfitr->type());
116  }
117 
118  // energy sum
119  double sumE[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
120  std::unique_ptr<MixCollection<PCaloHit>> colecalb(new MixCollection<PCaloHit>(cf_calohitB.product()));
122  for (cfiecalb = colecalb->begin(); cfiecalb != colecalb->end(); cfiecalb++) {
123  sumE[cfiecalb.bunch() - minbunch_] += cfiecalb->energy();
124  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
125  // else tofecalhist->Fill(cfiecal->time());
126  }
127  for (int i = minbunch_; i <= maxbunch_; ++i) {
128  caloEnergyEBH_[i - minbunch_]->Fill(sumE[i - minbunch_]);
129  }
130  double sumEE[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
131  std::unique_ptr<MixCollection<PCaloHit>> colecale(new MixCollection<PCaloHit>(cf_calohitE.product()));
133  for (cfiecale = colecale->begin(); cfiecale != colecale->end(); cfiecale++) {
134  sumEE[cfiecale.bunch() - minbunch_] += cfiecale->energy();
135  // if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
136  // else tofecalhist->Fill(cfiecal->time());
137  }
138  for (int i = minbunch_; i <= maxbunch_; ++i) {
139  caloEnergyEEH_[i - minbunch_]->Fill(sumEE[i - minbunch_]);
140  }
141 }
int maxbunch_
Definition: GlobalTest.h:53
MonitorElement * caloEnergyEEH_[nMaxH]
Definition: GlobalTest.h:62
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
int minbunch_
Definition: GlobalTest.h:52
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EE_Token_
Definition: GlobalTest.h:67
int ii
Definition: cuy.py:589
MonitorElement * trackPartIdH_[nMaxH]
Definition: GlobalTest.h:60
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfTrackToken_
Definition: GlobalTest.h:64
std::string filename_
Definition: GlobalTest.h:51
MonitorElement * caloEnergyEBH_[nMaxH]
Definition: GlobalTest.h:61
void Fill(long long x)
char const * label
int iEvent
Definition: GenABIO.cc:224
GlobalTest(const edm::ParameterSet &)
Definition: GlobalTest.cc:40
MonitorElement * nrPileupsH_[nMaxH]
Definition: GlobalTest.h:57
MonitorElement * nrTracksH_[nMaxH]
Definition: GlobalTest.h:59
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfVertexToken_
Definition: GlobalTest.h:65
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GlobalTest.cc:55
MonitorElement * nrVerticesH_[nMaxH]
Definition: GlobalTest.h:58
tuple cout
Definition: gather_cfg.py:144
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EB_Token_
Definition: GlobalTest.h:66
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GlobalTest.cc:83
Definition: Run.h:45