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 edm::EDConsumerBase

Public Member Functions

 TestMixedSource (const edm::ParameterSet &)
 
 ~TestMixedSource ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
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_
 
std::ofstream outputFile
 
TH1I * tofhist_
 
TH1I * tofhist_sig_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 45 of file TestMixedSource.h.

Constructor & Destructor Documentation

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

Definition at line 55 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_.

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

References gather_cfg::cout.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 97 of file TestMixedSource.cc.

References a, b, MixCollection< T >::MixItr::bunch(), trackerHits::c, cuy::col, gather_cfg::cout, alignCSCRings::e, 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(), AlCaHLTBitMon_QueryRunRegistry::string, tofhist_, and tofhist_sig_.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 276 of file TestMixedSource.cc.

References gather_cfg::cout, and outputFile.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 288 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, lumiQTWidget::t, tofhist_, and tofhist_sig_.

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

Member Data Documentation

int edm::TestMixedSource::bunchcr_
private

Definition at line 59 of file TestMixedSource.h.

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

Definition at line 58 of file TestMixedSource.h.

Referenced by endJob().

TFile* edm::TestMixedSource::histFile_
private

Definition at line 73 of file TestMixedSource.h.

Referenced by endJob().

TH1I* edm::TestMixedSource::histHepMCProduct_bunch_
private

Definition at line 72 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histPCaloHit_bunch_
private

Definition at line 65 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histPSimHit_bunchPileups_MuonCSCHits_
private

Definition at line 71 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histPSimHit_bunchPileups_TrackerHitsTECHighTof_
private

Definition at line 67 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histPSimHit_bunchSignal_MuonCSCHits_
private

Definition at line 70 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histPSimHit_bunchSignal_TrackerHitsTECHighTof_
private

Definition at line 66 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histTrack_bunchPileups_
private

Definition at line 62 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histTrack_bunchSignal_
private

Definition at line 63 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::histVertex_bunch_
private

Definition at line 64 of file TestMixedSource.h.

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

int edm::TestMixedSource::maxbunch_
private

Definition at line 61 of file TestMixedSource.h.

Referenced by TestMixedSource().

int edm::TestMixedSource::minbunch_
private

Definition at line 60 of file TestMixedSource.h.

Referenced by TestMixedSource().

std::ofstream edm::TestMixedSource::outputFile
private

Definition at line 57 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::tofhist_
private

Definition at line 68 of file TestMixedSource.h.

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

TH1I* edm::TestMixedSource::tofhist_sig_
private

Definition at line 69 of file TestMixedSource.h.

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