CMS 3D CMS Logo

TestSuite.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: TestSuite
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 // user include files
23 
24 #include "TFile.h"
27 
28 using namespace edm;
29 
30 TestSuite::TestSuite(const edm::ParameterSet& iConfig): filename_(iConfig.getParameter<std::string>("fileName")), bunchcr_(iConfig.getParameter<int>("BunchNr")), minbunch_(iConfig.getParameter<int>("minBunch")),maxbunch_(iConfig.getParameter<int>("maxBunch")), dbe_(0),
31  cfTrackToken_(consumes<CrossingFrame<SimTrack> > (
32  iConfig.getParameter<edm::InputTag>("cfTrackTag"))),
33  cfVertexToken_(consumes<CrossingFrame<SimTrack> > (
34  iConfig.getParameter<edm::InputTag>("cfVertexTag"))),
35  g4SimHits_Token_(consumes<CrossingFrame<PSimHit> > (
36  edm::InputTag("mix", "g4SimHitsTrackerHitsTECLowTof"))),
37  g4SimHits_Ecal_Token_(consumes<CrossingFrame<PCaloHit> > (
38  edm::InputTag("mix", "g4SimHitsEcalHitsEB"))),
39  g4SimHits_HCal_Token_(consumes<CrossingFrame<PCaloHit> > (
40  edm::InputTag("mix", "g4SimHitsHcalHits")))
41 {
42  std::cout << "Constructed testSuite , bunchcr " << bunchcr_
43  << " filename: " << filename_ << std::endl;
44 }
45 
46 
48 {
49 
50  // do anything here that needs to be done at desctruction time
51  // (e.g. close files, deallocate resources etc.)
52 }
53 
55 
56  // get hold of back-end interface
58  dbe_->showDirStructure();
59  dbe_->setCurrentFolder("MixingV/Mixing");
60 }
61 
63  if (filename_.size() != 0 && dbe_ ) dbe_->save(filename_);
64 }
65 
66 
67 
68 // ------------ method called to analyze the data ------------
69 void
71 {
72  using namespace edm;
73 
74  // Get input
78  edm::Handle<CrossingFrame<PCaloHit> > cf_calohitEcal;
79  edm::Handle<CrossingFrame<PCaloHit> > cf_calohitHcal;
80  std::string subdetTracker("g4SimHitsTrackerHitsTECLowTof");
81  std::string ecalsubdet("g4SimHitsEcalHitsEB");
82  std::string hcalsubdet("g4SimHitsHcalHits");
83  iEvent.getByToken(cfTrackToken_, cf_track);
84  iEvent.getByToken(cfVertexToken_, cf_vertex);
85  iEvent.getByToken(g4SimHits_Token_, cf_simhit);
86  iEvent.getByToken(g4SimHits_Ecal_Token_, cf_calohitEcal);
87  iEvent.getByToken(g4SimHits_HCal_Token_, cf_calohitHcal);
88 
89  // use MixCollection and its iterator
90  // Please note that bunch() and getTrigger() are methods of the iterator itself
91  // while operator-> points to the templated objects!!!!
92 
93  //track histo
94  char histotracks[30],sighistotracks[30],histotracksindsig[30],histotracksind[30];
95  sprintf(histotracks,"Tracks_bcr_%d",bunchcr_);
96  sprintf(sighistotracks,"SignalTracks_bcr_%d",bunchcr_);
97  sprintf(histotracksind,"VtxPointers_%d",bunchcr_);
98  sprintf(histotracksindsig,"VtxPointers_signal_%d",bunchcr_);
99  MonitorElement * trhist = dbe_->book1D(histotracks,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
100  MonitorElement * trhistsig = dbe_->book1D(sighistotracks,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
101  MonitorElement * trindhist = dbe_->book1D(histotracksind,"Track to Vertex indices",100,0,500);
102  MonitorElement * trindhistsig = dbe_->book1D(histotracksindsig,"Signal Track to Vertex indices",100,0,500);
103  std::auto_ptr<MixCollection<SimTrack> > col1(new MixCollection<SimTrack>(cf_track.product()));
105  for (cfi1=col1->begin(); cfi1!=col1->end();cfi1++) {
106  if (cfi1.getTrigger()==0) {
107  trhist->Fill(cfi1.bunch());
108  trindhist->Fill(cfi1->vertIndex());
109  } else {
110  trindhistsig->Fill(cfi1->vertIndex());
111  trhistsig->Fill(cfi1.bunch());
112  }
113  }
114 
115 
116  //vertex histo
117  char histovertices[30], sighistovertices[30],histovertexindices[30],histovertexindicessig[30];
118  sprintf(histovertices,"Vertices_bcr_%d",bunchcr_);
119  sprintf(sighistovertices,"SignalVertices_bcr_%d",bunchcr_);
120  sprintf(histovertexindices,"TrackPointers_%d",bunchcr_);
121  sprintf(histovertexindicessig,"TrackPointers_signal_%d",bunchcr_);
122  MonitorElement * vtxhist = dbe_->book1D(histovertices,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
123  MonitorElement * vtxhistsig = dbe_->book1D(sighistovertices,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
124  MonitorElement * vtxindhist = dbe_->book1D(histovertexindices,"Vertex to Track Indices",100,0,300);
125  MonitorElement * vtxindhistsig = dbe_->book1D(histovertexindicessig,"Signal Vertex to Track Indices",100,0,300);
126  std::auto_ptr<MixCollection<SimVertex> > col2(new MixCollection<SimVertex>(cf_vertex.product()));
128  for (cfi2=col2->begin(); cfi2!=col2->end();cfi2++) {
129  if (cfi2.getTrigger()==0) {
130  vtxhist->Fill(cfi2.bunch());
131  if (!cfi2->noParent()) vtxindhist->Fill(cfi2->parentIndex());
132  } else {
133  vtxhistsig->Fill(cfi2.bunch());
134  if (!cfi2->noParent()) vtxindhistsig->Fill(cfi2->parentIndex());
135  }
136  }
137 
138  //tracker
139  int bsp=cf_simhit->getBunchSpace();
140  char tof[30];
141 
142  sprintf(tof,"TrackerHit_Tof_bcr_%d",bunchcr_);
143  MonitorElement * tofhist = dbe_->book1D(tof,"TrackerHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
144  sprintf(tof,"SignalTrackerHit_Tof_bcr_%d",bunchcr_);
145  MonitorElement * tofhist_sig = dbe_->book1D(tof,"TrackerHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
146  std::auto_ptr<MixCollection<PSimHit> > colsh(new MixCollection<PSimHit>(cf_simhit.product()));
148  for (cfish=colsh->begin(); cfish!=colsh->end();cfish++) {
149  if (cfish.getTrigger()) {
150  tofhist_sig->Fill(cfish->timeOfFlight());
151  }
152  else {
153  tofhist->Fill(cfish->timeOfFlight());
154  }
155  }
156 
157  //Ecal
158  sprintf(tof,"EcalEBHit_Tof_bcr_%d",bunchcr_);
159  MonitorElement * tofecalhist = dbe_->book1D(tof,"EcalEBHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
160  sprintf(tof,"SignalEcalEBHit_Tof_bcr_%d",bunchcr_);
161  MonitorElement * tofecalhist_sig = dbe_->book1D(tof,"EcalEBHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
162  // std::string ecalsubdet("EcalHitsEB");
163  std::auto_ptr<MixCollection<PCaloHit> > colecal(new MixCollection<PCaloHit>(cf_calohitEcal.product()));
165  for (cfiecal=colecal->begin(); cfiecal!=colecal->end();cfiecal++) {
166  if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
167  else tofecalhist->Fill(cfiecal->time());
168  }
169 
170  // Hcal
171  sprintf(tof,"HcalHit_Tof_bcr_%d",bunchcr_);
172  MonitorElement * tofhcalhist = dbe_->book1D(tof,"HcalHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
173  sprintf(tof,"SignalHcalHit_Tof_bcr_%d",bunchcr_);
174  MonitorElement * tofhcalhist_sig = dbe_->book1D(tof,"HcalHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
175  // std::string hcalsubdet("HcalHits");
176  std::auto_ptr<MixCollection<PCaloHit> > colhcal(new MixCollection<PCaloHit>(cf_calohitHcal.product()));
178 
179  for (cfihcal=colhcal->begin(); cfihcal!=colhcal->end();cfihcal++) {
180  if (cfihcal.getTrigger()) tofhcalhist_sig->Fill(cfihcal->time());
181  else tofhcalhist->Fill(cfihcal->time());
182  }
183 }
184 
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfVertexToken_
Definition: TestSuite.h:64
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: TestSuite.cc:70
virtual void endJob()
Definition: TestSuite.cc:62
int maxbunch_
Definition: TestSuite.h:60
~TestSuite()
Definition: TestSuite.cc:47
TestSuite(const edm::ParameterSet &)
Definition: TestSuite.cc:30
bool getTrigger() const
Definition: MixCollection.h:90
void Fill(long long x)
int minbunch_
Definition: TestSuite.h:59
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< CrossingFrame< SimTrack > > cfTrackToken_
Definition: TestSuite.h:63
DQMStore * dbe_
Definition: TestSuite.h:61
edm::EDGetTokenT< CrossingFrame< PSimHit > > g4SimHits_Token_
Definition: TestSuite.h:65
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_HCal_Token_
Definition: TestSuite.h:67
DQMStore * dbe_
std::string filename_
Definition: TestSuite.h:57
T const * product() const
Definition: Handle.h:81
HLT enums.
edm::EDGetTokenT< CrossingFrame< PCaloHit > > g4SimHits_Ecal_Token_
Definition: TestSuite.h:66
virtual void beginJob()
Definition: TestSuite.cc:54
int bunchcr_
Definition: TestSuite.h:58