CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::TestMixedSource Class Reference

#include <TestMixedSource.h>

Inheritance diagram for edm::TestMixedSource:
edm::EDAnalyzer

Public Member Functions

 TestMixedSource (const edm::ParameterSet &)
 
 ~TestMixedSource ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 

Private Attributes

int bunchcr_
 
std::string fileName_
 
TFile * histFile_
 
TH1I * histHepMCProduct_bunch_
 
TH1I * histPCaloHit_bunch_
 
TH1I * histPSimHit_bunchPileups_MuonCSCHits_
 
TH1I * histPSimHit_bunchPileups_TrackerHitsTECHighTof_
 
TH1I * histPSimHit_bunchSignal_MuonCSCHits_
 
TH1I * histPSimHit_bunchSignal_TrackerHitsTECHighTof_
 
TH1I * histTrack_bunchPileups_
 
TH1I * histTrack_bunchSignal_
 
TH1I * histVertex_bunch_
 
int maxbunch_
 
int minbunch_
 
ofstream outputFile
 
TH1I * tofhist_
 
TH1I * tofhist_sig_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 46 of file TestMixedSource.h.

Constructor & Destructor Documentation

TestMixedSource::TestMixedSource ( const edm::ParameterSet iConfig)
explicit

Definition at line 56 of file TestMixedSource.cc.

References histHepMCProduct_bunch_, histPCaloHit_bunch_, histPSimHit_bunchPileups_MuonCSCHits_, histPSimHit_bunchPileups_TrackerHitsTECHighTof_, histPSimHit_bunchSignal_MuonCSCHits_, histPSimHit_bunchSignal_TrackerHitsTECHighTof_, histTrack_bunchPileups_, histTrack_bunchSignal_, histVertex_bunch_, maxbunch_, minbunch_, tofhist_, and tofhist_sig_.

57 : fileName_(iConfig.getParameter<std::string>("fileName")), minbunch_(iConfig.getParameter<int>("minBunch")),maxbunch_(iConfig.getParameter<int>("maxBunch"))
58 {
59 
60  histTrack_bunchSignal_ = new TH1I("histoTrackSignal","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
61  histTrack_bunchPileups_ = new TH1I("histoTrackPileups","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
62 
63  // Vertex
64  histVertex_bunch_ = new TH1I("histoVertex","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
65 
66  // PCaloHit
67  histPCaloHit_bunch_ = new TH1I("histoPCaloHit","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
68 
69  // PSimHit
70  histPSimHit_bunchSignal_TrackerHitsTECHighTof_ = new TH1I("histoPSimHitTrackerHitsTECHighTofSignal","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
71  histPSimHit_bunchPileups_TrackerHitsTECHighTof_ = new TH1I("histoPSimHitTrackerHitsTECHighTofPileups","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
72  histPSimHit_bunchSignal_MuonCSCHits_ = new TH1I("histoPSimHitMuonCSCHitsSignal","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
73  histPSimHit_bunchPileups_MuonCSCHits_ = new TH1I("histoPSimHitMuonCSCHitsPileups","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
74 
75  int bsp = 25;//bunchspace
76  tofhist_ = new TH1I ("TrackerHit_Tof_bcr","TrackerHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
77  tofhist_sig_ = new TH1I("SignalTrackerHit_Tof_bcr","TrackerHit_ToF",100,float(bsp*minbunch_),float(bsp*maxbunch_)+50.);
78 
79 
80  // HepMCProduct
81  histHepMCProduct_bunch_ = new TH1I("histoHepMCProduct","Bunchcrossings",maxbunch_-minbunch_+1,minbunch_,maxbunch_+1);
82 
83 }
T getParameter(std::string const &) const
TH1I * histPSimHit_bunchPileups_TrackerHitsTECHighTof_
TH1I * histPSimHit_bunchSignal_MuonCSCHits_
TH1I * histPSimHit_bunchPileups_MuonCSCHits_
TH1I * histPSimHit_bunchSignal_TrackerHitsTECHighTof_
TestMixedSource::~TestMixedSource ( )

Definition at line 86 of file TestMixedSource.cc.

References gather_cfg::cout.

87 { std::cout << " Destructor TestMixed" << std::endl;
88 
89 }
tuple cout
Definition: gather_cfg.py:41

Member Function Documentation

void TestMixedSource::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 98 of file TestMixedSource.cc.

References a, b, MixCollection< T >::begin(), MixCollection< T >::MixItr::bunch(), trackerHits::c, gather_cfg::cout, MixCollection< T >::end(), edm::Event::getByLabel(), MixCollection< T >::MixItr::getTrigger(), histHepMCProduct_bunch_, histPCaloHit_bunch_, histPSimHit_bunchPileups_MuonCSCHits_, histPSimHit_bunchPileups_TrackerHitsTECHighTof_, histPSimHit_bunchSignal_MuonCSCHits_, histPSimHit_bunchSignal_TrackerHitsTECHighTof_, histTrack_bunchPileups_, histTrack_bunchSignal_, histVertex_bunch_, outputFile, edm::Handle< T >::product(), tofhist_, and tofhist_sig_.

99 {
100  // test SimTracks
101  //----------------------
103  bool gotTracks = iEvent.getByLabel("mix","g4SimHits",cf_simtrack);
104  if (!gotTracks) outputFile<<" Could not read SimTracks!!!!"
105  << " Please, check if the object SimTracks has been declared in the"
106  << " MixingModule configuration file."<<std::endl;
107 
108  if (gotTracks) {
109  outputFile<<"\n=================== Starting SimTrack access ==================="<<std::endl;
110 
111  std::auto_ptr<MixCollection<SimTrack> > col1(new MixCollection<SimTrack>(cf_simtrack.product()));
113  int count1=0;
114  std::cout <<" \nWe got "<<col1->sizeSignal()<<" signal tracks and "<<col1->sizePileup()<<" pileup tracks, total: "<<col1->size()<<std::endl;
115  for (cfi1=col1->begin(); cfi1!=col1->end();cfi1++) {
116  //std::cout << " BUNCH cfi1.bunch() = " << cfi1.bunch() << std::endl;
117  if (cfi1.getTrigger()==0){
118  histTrack_bunchPileups_->Fill(cfi1.bunch());
119  }
120 
121  if (cfi1.getTrigger()==1){
122  histTrack_bunchSignal_->Fill(cfi1.bunch());
123  }
124 
125 
126  int a = count1%4;
127  if (a==3){
128  outputFile<<" SimTrack "<<count1<<" has genpart index "<<cfi1->genpartIndex()<<" vertex Index "<<cfi1->vertIndex() <<" bunchcr "<<cfi1.bunch()<<" trigger "<<cfi1.getTrigger()<<", from EncodedEventId: "<<cfi1->eventId().bunchCrossing() <<" "<<cfi1->eventId().event() <<std::endl;
129  }
130  count1++;
131  }
132  }
133 
134 
135  // test SimVertices
136  //---------------------
138  bool gotSimVertex = iEvent.getByLabel("mix","g4SimHits",cf_simvtx);
139  if (!gotSimVertex) outputFile<<" Could not read Simvertices !!!!"<<std::endl;
140  else {
141  outputFile<<"\n=================== Starting SimVertex access ==================="<<std::endl;
142  std::auto_ptr<MixCollection<SimVertex> > col2(new MixCollection<SimVertex>(cf_simvtx.product()));
144  int count2=0;
145  outputFile <<" \nWe got "<<col2->sizeSignal()<<" signal vertices and "<<col2->sizePileup()<<" pileup vertices, total: "<<col2->size()<<std::endl;
146  for (cfi2=col2->begin(); cfi2!=col2->end();cfi2++) {
147  histVertex_bunch_->Fill(cfi2.bunch());
148  int b = count2%4;
149  if (count2 == 0 || b==3){
150  //outputFile<<" SimVertex "<<count2<<" has parent index "<<cfi2->parentIndex()<<" bunchcr "<<cfi2.bunch()<<" trigger "<<cfi2.getTrigger()<<", from EncodedEventId: "<<cfi2->eventId().bunchCrossing() <<" "<<cfi2->eventId().event() <<std::endl;
151  }
152  SimVertex myvtx=(*cfi2);
153  //outputFile<<"Same with op*: "<<count2<<" has parent index "<<myvtx.parentIndex()<<" bunchcr "<<cfi2.bunch()<<" trigger "<<cfi2.getTrigger()<<", from EncodedEventId: "<<myvtx.eventId().bunchCrossing() <<" "<<myvtx.eventId().event() <<std::endl;
154  count2++;
155  }
156  }
157 
158 
159  //test HepMCProducts
160  //------------------------------------
162  bool gotHepMCP = iEvent.getByLabel("mix","generator",cf_hepmc);
163  if (!gotHepMCP) std::cout<<" Could not read HepMCProducts!!!!"<<std::endl;
164  else {
165  outputFile<<"\n=================== Starting HepMCProduct access ==================="<<std::endl;
166  std::auto_ptr<MixCollection<edm::HepMCProduct> > colhepmc(new MixCollection<edm::HepMCProduct>(cf_hepmc.product()));
168 
169  int count3=0;
170  outputFile <<" \nWe got "<<colhepmc->sizeSignal()<<" signal hepmc products and "<<colhepmc->sizePileup()<<" pileup hepmcs, total: "<<colhepmc->size()<<std::endl;
171  for (cfihepmc=colhepmc->begin(); cfihepmc!=colhepmc->end();cfihepmc++) {
172  histHepMCProduct_bunch_->Fill(cfihepmc.bunch());
173  int c = count3%4;
174  if (count3==0 || c==3){
175  //outputFile<<" edm::HepMCProduct "<<count3<<" has event number "<<cfihepmc->GetEvent()->event_number()<<", "<< cfihepmc->GetEvent()->particles_size()<<" particles and "<<cfihepmc->GetEvent()->vertices_size()<<" vertices, bunchcr= "<<cfihepmc.bunch()<<" trigger= "<<cfihepmc.getTrigger() <<" sourcetype= "<<cfihepmc.getSourceType()<<std::endl;
176  }
177  HepMCProduct myprod=colhepmc->getObject(count3);
178  //outputFile<<"same with getObject:hepmc product "<<count3<<" has event number "<<myprod.GetEvent()->event_number()<<", "<<myprod.GetEvent()->particles_size()<<" particles and "<<myprod.GetEvent()->vertices_size()<<" vertices"<<std::endl;
179  count3++;
180  }
181  }
182 
183 
184  // test CaloHits
185  //--------------------------
186  const std::string subdetcalo("g4SimHitsEcalHitsEB");
188  bool gotPCaloHit = iEvent.getByLabel("mix",subdetcalo,cf_calo);
189  if (!gotPCaloHit) outputFile<<" Could not read CaloHits with label "<<subdetcalo<<"!!!!"<<std::endl;
190  else {
191  outputFile<<"\n\n=================== Starting CaloHit access, subdet "<<subdetcalo<<" ==================="<<std::endl;
192  std::auto_ptr<MixCollection<PCaloHit> > colcalo(new MixCollection<PCaloHit>(cf_calo.product()));
193  //outputFile<<*(colcalo.get())<<std::endl;
195  int count4=0;
196  for (cficalo=colcalo->begin(); cficalo!=colcalo->end();cficalo++) {
197  histPCaloHit_bunch_->Fill(cficalo.bunch());
198  int d = count4%4;
199  if (count4==0 || d==3){
200  //outputFile<<" CaloHit "<<count4<<" has tof "<<cficalo->time()<<" trackid "<<cficalo->geantTrackId() <<" bunchcr "<<cficalo.bunch()<<" trigger "<<cficalo.getTrigger()<<", from EncodedEventId: "<<cficalo->eventId().bunchCrossing()<<" " <<cficalo->eventId().event() <<std::endl;
201  }
202  count4++;
203  }
204  }
205 
206 
207  // test PSimHit for one particular subdet
208  //---------------------------------------
209 
210 
211  const std::string subdet("g4SimHitsTrackerHitsTECHighTof");
213  bool gotPSimHit = iEvent.getByLabel("mix",subdet,cf_simhit);
214  if (!gotPSimHit) outputFile<<" Could not read SimHits with label "<<subdet<<"!!!!"<<std::endl;
215  else {
216  outputFile<<"\n\n=================== Starting SimHit access, subdet "<<subdet<<" ==================="<<std::endl;
217 
218  std::auto_ptr<MixCollection<PSimHit> > col(new MixCollection<PSimHit>(cf_simhit.product()));
219  //outputFile<<*(col.get())<<std::endl;
221  int count5=0;
222  for (cfi=col->begin(); cfi!=col->end();cfi++) {
223 
224  // Signal
225  if (cfi.getTrigger()==1){
227  tofhist_sig_->Fill(cfi->timeOfFlight());
228  }
229 
230  // Pileups
231  if (cfi.getTrigger()==0){
233  std::cout << " cfi->timeOfFlight() = " << cfi->timeOfFlight() << std::endl;
234  tofhist_->Fill(cfi->timeOfFlight());
235  }
236 
237  int e = count5%4;
238  if (e==3){
239  outputFile<<" Hit "<<count5<<" has tof "<<cfi->timeOfFlight()<<" trackid "<<cfi->trackId() <<" bunchcr "<<cfi.bunch()<<" trigger "<<cfi.getTrigger()<<", from EncodedEventId: "<<cfi->eventId().bunchCrossing()<<" " <<cfi->eventId().event() <<" bcr from MixCol "<<cfi.bunch()<<std::endl;
240  }
241  count5++;
242  }
243  }
244 
245  const std::string subdet1("g4SimHitsMuonCSCHits");
247  bool gotPSimHit1 = iEvent.getByLabel("mix",subdet1,cf_simhit1);
248  if (!gotPSimHit1) outputFile<<" Could not read SimHits with label "<<subdet1<<"!!!!"<<std::endl;
249  else {
250  outputFile<<"\n\n=================== Starting SimHit access, subdet "<<subdet1<<" ==================="<<std::endl;
251 
252  std::auto_ptr<MixCollection<PSimHit> > col(new MixCollection<PSimHit>(cf_simhit1.product()));
253  //outputFile<<*(col.get())<<std::endl;
255  int count5=0;
256  for (cfi=col->begin(); cfi!=col->end();cfi++) {
257 
258  if (cfi.getTrigger()==1) histPSimHit_bunchSignal_MuonCSCHits_->Fill(cfi.bunch());
259 
260  if (cfi.getTrigger()==0) histPSimHit_bunchPileups_MuonCSCHits_->Fill(cfi.bunch());
261 
262  int e = count5%4;
263  if (e==3){
264  outputFile<<" Hit "<<count5<<" has tof "<<cfi->timeOfFlight()<<" trackid "<<cfi->trackId() <<" bunchcr "<<cfi.bunch()<<" trigger "<<cfi.getTrigger()<<", from EncodedEventId: "<<cfi->eventId().bunchCrossing()<<" " <<cfi->eventId().event() <<" bcr from MixCol "<<cfi.bunch()<<std::endl;
265  }
266  count5++;
267  }
268  }
269 
270 
271 
272 }
TH1I * histPSimHit_bunchPileups_TrackerHitsTECHighTof_
TH1I * histPSimHit_bunchSignal_MuonCSCHits_
TH1I * histPSimHit_bunchPileups_MuonCSCHits_
TH1I * histPSimHit_bunchSignal_TrackerHitsTECHighTof_
bool getTrigger() const
Definition: MixCollection.h:89
iterator end()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
iterator begin()
double b
Definition: hdecay.h:120
T const * product() const
Definition: Handle.h:74
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:41
void TestMixedSource::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 277 of file TestMixedSource.cc.

References gather_cfg::cout, and outputFile.

278 {
279  outputFile.open("test.log");
280  if (!outputFile.is_open())
281  {
282  std::cout << "Unable to open file!" << std::endl;
283  }
284 
285 }
tuple cout
Definition: gather_cfg.py:41
void TestMixedSource::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 289 of file TestMixedSource.cc.

References gather_cfg::cout, fileName_, histFile_, histHepMCProduct_bunch_, histPCaloHit_bunch_, histPSimHit_bunchPileups_MuonCSCHits_, histPSimHit_bunchPileups_TrackerHitsTECHighTof_, histPSimHit_bunchSignal_MuonCSCHits_, histPSimHit_bunchSignal_TrackerHitsTECHighTof_, histTrack_bunchPileups_, histTrack_bunchSignal_, histVertex_bunch_, outputFile, matplotRender::t, tofhist_, and tofhist_sig_.

289  {
290 
291  outputFile.close();
292 
293  char t[30];
294  sprintf(t,"%s",fileName_.c_str());
295  std::cout << " fileName = " << t << std::endl;
296  histFile_=new TFile(t,"RECREATE");
297  histTrack_bunchPileups_->Write();
298  histTrack_bunchSignal_->Write();
299  histVertex_bunch_->Write();
300  histPCaloHit_bunch_->Write();
303  tofhist_sig_->Write();
304  tofhist_->Write();
307  histHepMCProduct_bunch_->Write();
308  histFile_->Write();
309  histFile_->Close();
310 
311 }
TH1I * histPSimHit_bunchPileups_TrackerHitsTECHighTof_
TH1I * histPSimHit_bunchSignal_MuonCSCHits_
TH1I * histPSimHit_bunchPileups_MuonCSCHits_
TH1I * histPSimHit_bunchSignal_TrackerHitsTECHighTof_
tuple cout
Definition: gather_cfg.py:41

Member Data Documentation

int edm::TestMixedSource::bunchcr_
private

Definition at line 60 of file TestMixedSource.h.

std::string edm::TestMixedSource::fileName_
private

Definition at line 59 of file TestMixedSource.h.

Referenced by endJob().

TFile* edm::TestMixedSource::histFile_
private

Definition at line 74 of file TestMixedSource.h.

Referenced by endJob().

TH1I* edm::TestMixedSource::histHepMCProduct_bunch_
private

Definition at line 73 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histPCaloHit_bunch_
private

Definition at line 66 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histPSimHit_bunchPileups_MuonCSCHits_
private

Definition at line 72 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histPSimHit_bunchPileups_TrackerHitsTECHighTof_
private

Definition at line 68 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histPSimHit_bunchSignal_MuonCSCHits_
private

Definition at line 71 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histPSimHit_bunchSignal_TrackerHitsTECHighTof_
private

Definition at line 67 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histTrack_bunchPileups_
private

Definition at line 63 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histTrack_bunchSignal_
private

Definition at line 64 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::histVertex_bunch_
private

Definition at line 65 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

int edm::TestMixedSource::maxbunch_
private

Definition at line 62 of file TestMixedSource.h.

Referenced by TestMixedSource().

int edm::TestMixedSource::minbunch_
private

Definition at line 61 of file TestMixedSource.h.

Referenced by TestMixedSource().

ofstream edm::TestMixedSource::outputFile
private

Definition at line 58 of file TestMixedSource.h.

Referenced by analyze(), beginJob(), and endJob().

TH1I* edm::TestMixedSource::tofhist_
private

Definition at line 69 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().

TH1I* edm::TestMixedSource::tofhist_sig_
private

Definition at line 70 of file TestMixedSource.h.

Referenced by analyze(), endJob(), and TestMixedSource().