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 
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 }
GlobalTest::cfVertexToken_
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfVertexToken_
Definition: GlobalTest.h:65
GlobalTest.h
mps_fire.i
i
Definition: mps_fire.py:428
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
GlobalTest::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: GlobalTest.cc:55
DQMStore.h
EDAnalyzer.h
edm::Handle
Definition: AssociativeIterator.h:50
MixCollection::MixItr
Definition: MixCollection.h:62
GlobalTest::nrVerticesH_
MonitorElement * nrVerticesH_[nMaxH]
Definition: GlobalTest.h:58
CrossingFrame
Definition: CrossingFrame.h:38
MakerMacros.h
MixCollection::MixItr::bunch
int bunch() const
Definition: MixCollection.h:91
GlobalTest::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: GlobalTest.cc:83
MixCollection
Definition: MixCollection.h:11
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
GlobalTest::g4SimHits_EB_Token_
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EB_Token_
Definition: GlobalTest.h:66
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
GlobalTest::caloEnergyEEH_
MonitorElement * caloEnergyEEH_[nMaxH]
Definition: GlobalTest.h:62
GlobalTest::maxbunch_
int maxbunch_
Definition: GlobalTest.h:53
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
GlobalTest::minbunch_
int minbunch_
Definition: GlobalTest.h:52
std
Definition: JetResolutionObject.h:76
SimTrack
Definition: SimTrack.h:6
Frameworkfwd.h
GlobalTest::filename_
std::string filename_
Definition: GlobalTest.h:51
GlobalTest::caloEnergyEBH_
MonitorElement * caloEnergyEBH_[nMaxH]
Definition: GlobalTest.h:61
GlobalTest::g4SimHits_EE_Token_
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_EE_Token_
Definition: GlobalTest.h:67
GlobalTest::trackPartIdH_
MonitorElement * trackPartIdH_[nMaxH]
Definition: GlobalTest.h:60
dqm::implementation::IBooker
Definition: DQMStore.h:43
GlobalTest::cfTrackToken_
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfTrackToken_
Definition: GlobalTest.h:64
ParameterSet.h
edm::Event
Definition: Event.h:73
GlobalTest::GlobalTest
GlobalTest(const edm::ParameterSet &)
Definition: GlobalTest.cc:40
cuy.ii
ii
Definition: cuy.py:590
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
GlobalTest::nrPileupsH_
MonitorElement * nrPileupsH_[nMaxH]
Definition: GlobalTest.h:57
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
GlobalTest::nrTracksH_
MonitorElement * nrTracksH_[nMaxH]
Definition: GlobalTest.h:59