CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: TestSuite.cc,v 1.13 2012/10/10 14:39:02 wdd Exp $
14 //
15 //
16 
17 
18 // system include files
19 #include <memory>
20 #include <utility>
21 
22 // user include files
23 
27 
32 
34 
35 #include "TFile.h"
38 
39 using namespace edm;
40 
41 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),
42  cfTrackTag_(iConfig.getParameter<edm::InputTag>("cfTrackTag")),
43  cfVertexTag_(iConfig.getParameter<edm::InputTag>("cfVertexTag"))
44 {
45  std::cout << "Constructed testSuite , bunchcr "<<bunchcr_<<" filename: "<<filename_<<std::endl;
46 
47 }
48 
49 
51 {
52 
53  // do anything here that needs to be done at desctruction time
54  // (e.g. close files, deallocate resources etc.)
55 }
56 
58 
59  // get hold of back-end interface
62  dbe_->setCurrentFolder("MixingV/Mixing");
63 }
64 
66  if (filename_.size() != 0 && dbe_ ) dbe_->save(filename_);
67 }
68 
69 
70 
71 // ------------ method called to analyze the data ------------
72 void
74 {
75  using namespace edm;
76 
77 // Get input
81  edm::Handle<CrossingFrame<PCaloHit> > cf_calohitEcal;
82  edm::Handle<CrossingFrame<PCaloHit> > cf_calohitHcal;
83  std::string subdetTracker("g4SimHitsTrackerHitsTECLowTof");
84  std::string ecalsubdet("g4SimHitsEcalHitsEB");
85  std::string hcalsubdet("g4SimHitsHcalHits");
86  iEvent.getByLabel(cfTrackTag_, cf_track);
87  iEvent.getByLabel(cfVertexTag_, cf_vertex);
88  iEvent.getByLabel("mix",subdetTracker,cf_simhit);
89  iEvent.getByLabel("mix",ecalsubdet,cf_calohitEcal);
90  iEvent.getByLabel("mix",hcalsubdet,cf_calohitHcal);
91 
92 // use MixCollection and its iterator
93 // Please note that bunch() and getTrigger() are methods of the iterator itself
94 // while operator-> points to the templated objects!!!!
95 
96 //track histo
97  char histotracks[30],sighistotracks[30],histotracksindsig[30],histotracksind[30];
98  sprintf(histotracks,"Tracks_bcr_%d",bunchcr_);
99  sprintf(sighistotracks,"SignalTracks_bcr_%d",bunchcr_);
100  sprintf(histotracksind,"VtxPointers_%d",bunchcr_);
101  sprintf(histotracksindsig,"VtxPointers_signal_%d",bunchcr_);
102  MonitorElement * trhist = dbe_->book1D(histotracks,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
103  MonitorElement * trhistsig = dbe_->book1D(sighistotracks,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
104  MonitorElement * trindhist = dbe_->book1D(histotracksind,"Track to Vertex indices",100,0,500);
105  MonitorElement * trindhistsig = dbe_->book1D(histotracksindsig,"Signal Track to Vertex indices",100,0,500);
106  std::auto_ptr<MixCollection<SimTrack> > col1(new MixCollection<SimTrack>(cf_track.product()));
108  for (cfi1=col1->begin(); cfi1!=col1->end();cfi1++) {
109  if (cfi1.getTrigger()==0) {
110  trhist->Fill(cfi1.bunch());
111  trindhist->Fill(cfi1->vertIndex());
112  } else {
113  trindhistsig->Fill(cfi1->vertIndex());
114  trhistsig->Fill(cfi1.bunch());
115  }
116  }
117 
118 
119 //vertex histo
120  char histovertices[30], sighistovertices[30],histovertexindices[30],histovertexindicessig[30];
121  sprintf(histovertices,"Vertices_bcr_%d",bunchcr_);
122  sprintf(sighistovertices,"SignalVertices_bcr_%d",bunchcr_);
123  sprintf(histovertexindices,"TrackPointers_%d",bunchcr_);
124  sprintf(histovertexindicessig,"TrackPointers_signal_%d",bunchcr_);
125  MonitorElement * vtxhist = dbe_->book1D(histovertices,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
126  MonitorElement * vtxhistsig = dbe_->book1D(sighistovertices,"Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
127  MonitorElement * vtxindhist = dbe_->book1D(histovertexindices,"Vertex to Track Indices",100,0,300);
128  MonitorElement * vtxindhistsig = dbe_->book1D(histovertexindicessig,"Signal Vertex to Track Indices",100,0,300);
129  std::auto_ptr<MixCollection<SimVertex> > col2(new MixCollection<SimVertex>(cf_vertex.product()));
131  for (cfi2=col2->begin(); cfi2!=col2->end();cfi2++) {
132  if (cfi2.getTrigger()==0) {
133  vtxhist->Fill(cfi2.bunch());
134  if (!cfi2->noParent()) vtxindhist->Fill(cfi2->parentIndex());
135  } else {
136  vtxhistsig->Fill(cfi2.bunch());
137  if (!cfi2->noParent()) vtxindhistsig->Fill(cfi2->parentIndex());
138  }
139  }
140 
141  //tracker
142  int bsp=cf_simhit->getBunchSpace();
143  char tof[30];
144 
145  sprintf(tof,"TrackerHit_Tof_bcr_%d",bunchcr_);
146  MonitorElement * tofhist = dbe_->book1D(tof,"TrackerHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
147  sprintf(tof,"SignalTrackerHit_Tof_bcr_%d",bunchcr_);
148  MonitorElement * tofhist_sig = dbe_->book1D(tof,"TrackerHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
149  std::auto_ptr<MixCollection<PSimHit> > colsh(new MixCollection<PSimHit>(cf_simhit.product()));
151  for (cfish=colsh->begin(); cfish!=colsh->end();cfish++) {
152  if (cfish.getTrigger()) {
153  tofhist_sig->Fill(cfish->timeOfFlight());
154  }
155  else {
156  tofhist->Fill(cfish->timeOfFlight());
157  }
158  }
159 
160  //Ecal
161  sprintf(tof,"EcalEBHit_Tof_bcr_%d",bunchcr_);
162  MonitorElement * tofecalhist = dbe_->book1D(tof,"EcalEBHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
163  sprintf(tof,"SignalEcalEBHit_Tof_bcr_%d",bunchcr_);
164  MonitorElement * tofecalhist_sig = dbe_->book1D(tof,"EcalEBHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
165  // std::string ecalsubdet("EcalHitsEB");
166  std::auto_ptr<MixCollection<PCaloHit> > colecal(new MixCollection<PCaloHit>(cf_calohitEcal.product()));
168  for (cfiecal=colecal->begin(); cfiecal!=colecal->end();cfiecal++) {
169  if (cfiecal.getTrigger()) tofecalhist_sig->Fill(cfiecal->time());
170  else tofecalhist->Fill(cfiecal->time());
171  }
172 
173  // Hcal
174  sprintf(tof,"HcalHit_Tof_bcr_%d",bunchcr_);
175  MonitorElement * tofhcalhist = dbe_->book1D(tof,"HcalHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
176  sprintf(tof,"SignalHcalHit_Tof_bcr_%d",bunchcr_);
177  MonitorElement * tofhcalhist_sig = dbe_->book1D(tof,"HcalHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
178  // std::string hcalsubdet("HcalHits");
179  std::auto_ptr<MixCollection<PCaloHit> > colhcal(new MixCollection<PCaloHit>(cf_calohitHcal.product()));
181 
182  for (cfihcal=colhcal->begin(); cfihcal!=colhcal->end();cfihcal++) {
183  if (cfihcal.getTrigger()) tofhcalhist_sig->Fill(cfihcal->time());
184  else tofhcalhist->Fill(cfihcal->time());
185  }
186 }
187 
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: TestSuite.cc:73
virtual void endJob()
Definition: TestSuite.cc:65
int maxbunch_
Definition: TestSuite.h:52
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:2118
~TestSuite()
Definition: TestSuite.cc:50
TestSuite(const edm::ParameterSet &)
Definition: TestSuite.cc:41
int minbunch_
Definition: TestSuite.h:51
int iEvent
Definition: GenABIO.cc:243
DQMStore * dbe_
Definition: TestSuite.h:53
edm::InputTag cfVertexTag_
Definition: TestSuite.h:56
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
DQMStore * dbe_
std::string filename_
Definition: TestSuite.h:49
tuple cout
Definition: gather_cfg.py:121
edm::InputTag cfTrackTag_
Definition: TestSuite.h:55
void showDirStructure(void) const
Definition: DQMStore.cc:2766
virtual void beginJob()
Definition: TestSuite.cc:57
int bunchcr_
Definition: TestSuite.h:50
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434