47 level_(iConfig.getUntrackedParameter<int>(
"PrintLevel"))
88 bool gotTracks = iEvent.
getByLabel(
"mix",
"g4SimHits",cf_simtrack);
89 if (!gotTracks)
std::cout<<
" Could not read SimTracks!!!!"<<std::endl;
104 const std::string subdet(
"g4SimHitsTrackerHitsTECHighTof");
106 got = iEvent.
getByLabel(
"mix",subdet,cf_simhit);
107 if (!got)
std::cout<<
" Could not read SimHits with label "<<subdet<<
"!!!!"<<std::endl;
109 std::cout<<
"\n\n=================== Starting SimHit access, subdet "<<subdet<<
" ==================="<<std::endl;
111 std::auto_ptr<MixCollection<PSimHit> > col(
new MixCollection<PSimHit>(cf_simhit.product(),std::pair<int,int>(-1,1)));
114 for (cfi=col->begin(); cfi!=col->end();cfi++) {
115 std::cout<<
" Hit "<<
count<<
" 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;
122 const std::string subdetcalo(
"g4SimHitsEcalHitsEB");
124 got = iEvent.
getByLabel(
"mix",subdetcalo,cf_calo);
125 if (!got)
std::cout<<
" Could not read CaloHits with label "<<subdetcalo<<
"!!!!"<<std::endl;
127 std::cout<<
"\n\n=================== Starting CaloHit access, subdet "<<subdetcalo<<
" ==================="<<std::endl;
128 std::auto_ptr<MixCollection<PCaloHit> > colcalo(
new MixCollection<PCaloHit>(cf_calo.product(), std::pair<int,int>(-1,1)));
132 for (cficalo=colcalo->begin(); cficalo!=colcalo->end();cficalo++) {
133 std::cout<<
" CaloHit "<<
count<<
" has tof "<<cficalo->time()<<
" trackid "<<cficalo->geantTrackId() <<
" bunchcr "<<cficalo.bunch()<<
" trigger "<<cficalo.getTrigger()<<
", from EncodedEventId: "<<cficalo->eventId().bunchCrossing()<<
" " <<cficalo->eventId().event() <<std::endl;
141 std::cout<<
"\n=================== Starting SimTrack access ==================="<<std::endl;
147 std::cout <<
" \nWe got "<<col2->sizeSignal()<<
" signal tracks and "<<col2->sizePileup()<<
" pileup tracks, total: "<<col2->size()<<std::endl;
148 for (cfi2=col2->begin(); cfi2!=col2->end();cfi2++) {
149 std::cout<<
" SimTrack "<<count2<<
" has genpart index "<<cfi2->genpartIndex()<<
" vertex Index "<<cfi2->vertIndex() <<
" bunchcr "<<cfi2.
bunch()<<
" trigger "<<cfi2.
getTrigger()<<
", from EncodedEventId: "<<cfi2->eventId().bunchCrossing() <<
" "<<cfi2->eventId().event() <<std::endl;
156 got = iEvent.
getByLabel(
"mix",
"g4SimHits",cf_simvtx);
157 if (!got)
std::cout<<
" Could not read Simvertices !!!!"<<std::endl;
159 std::cout<<
"\n=================== Starting SimVertex access ==================="<<std::endl;
163 std::cout <<
" \nWe got "<<col3->sizeSignal()<<
" signal vertices and "<<col3->sizePileup()<<
" pileup vertices, total: "<<col3->size()<<std::endl;
164 for (cfi3=col3->begin(); cfi3!=col3->end();cfi3++) {
165 std::cout<<
" SimVertex "<<count3<<
" has parent index "<<cfi3->parentIndex()<<
" bunchcr "<<cfi3.
bunch()<<
" trigger "<<cfi3.
getTrigger()<<
", from EncodedEventId: "<<cfi3->eventId().bunchCrossing() <<
" "<<cfi3->eventId().event() <<std::endl;
173 bool got1,got2=
false;
174 std::auto_ptr<MixCollection<PSimHit> > all_trackhits;
175 std::auto_ptr<MixCollection<PSimHit> > all_trackhits2;
176 std::cout<<
"\n=================== Starting test for coll of several ROU-s ==================="<<std::endl;
178 std::vector<const CrossingFrame<PSimHit> *> cfvec;
182 std::cout<<
"\n=================== Starting test for coll of several ROU-s ==================="<<std::endl;
183 cfvec.push_back(cf_simhit.product());
184 std::cout <<
" \nFirst container "<<
track_containers_[0]<<
" Nr signals "<<cf_simhit->getNrSignals() <<
", Nr pileups "<<cf_simhit->getNrPileups() <<std::endl;
187 cfvec.push_back(cf_simhit.product());
188 std::cout <<
" \nSecond container "<<
track_containers_[1]<<
" Nr signals "<<cf_simhit->getNrSignals() <<
", Nr pileups "<<cf_simhit->getNrPileups() <<std::endl;
191 std::cout <<
" \nFor all containers we got "<<all_trackhits->sizeSignal()<<
" signal hits and "<<all_trackhits->sizePileup()<<
" pileup hits, total: "<<all_trackhits->size()<<std::endl;
195 for (it=all_trackhits->
begin(); it!= all_trackhits->
end();it++) {
196 std::cout<<
" Hit "<<ii<<
" of all hits has tof "<<it->timeOfFlight()<<
" trackid "<<it->trackId() <<
" bunchcr "<<it.bunch()<<
" trigger "<<it.getTrigger()<<
", from EncodedEventId: "<<it->eventId().bunchCrossing() <<
" "<<it->eventId().event()<<std::endl;
205 std::vector<const CrossingFrame<PSimHit> *> cfvec2;
209 cfvec2.push_back(cf_simhit.product());
212 cfvec2.push_back(cf_simhit.product());
214 std::cout <<
" \nSame containers, different order: we got "<<all_trackhits2->sizeSignal()<<
" signal hits and "<<all_trackhits2->sizePileup()<<
" pileup hits, total: "<<all_trackhits2->size()<<std::endl;
215 for (it2=all_trackhits2->begin(); it2!= all_trackhits2->end();it2++) {
216 std::cout<<
" Hit "<<ii2<<
" of all hits has tof "<<it2->timeOfFlight()<<
" trackid "<<it2->trackId() <<
" bunchcr "<<it2.bunch()<<
" trigger "<<it2.getTrigger()<<
", bcr from Id: "<<it2->eventId().bunchCrossing() <<
" evtnr in id "<<it2->eventId().event()<<std::endl;
227 got = iEvent.
getByLabel(
"mix",
"generator",cf_hepmc);
228 if (!got)
std::cout<<
" Could not read HepMCProducts!!!!"<<std::endl;
233 std::cout <<
" \nWe got "<<colhepmc->sizeSignal()<<
" signal hepmc products and "<<colhepmc->sizePileup()<<
" pileup hepmcs, total: "<<colhepmc->size()<<std::endl;
234 for (cfihepmc=colhepmc->begin(); cfihepmc!=colhepmc->end();cfihepmc++) {
235 std::cout<<
" edm::HepMCProduct "<<counthepmc<<
" 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;
237 std::cout<<
"same with getObject:hepmc product "<<counthepmc<<
" has event number "<<myprod.
GetEvent()->event_number()<<
", "<<myprod.
GetEvent()->particles_size()<<
" particles and "<<myprod.
GetEvent()->vertices_size()<<
" vertices"<<std::endl;
248 for (it2=all_trackhits2->begin(); it2!= all_trackhits2->end();it2++) ii3++;
249 if (ii3!=ii2)
std::cout<<
" Problem when re-using iterator!!"<<std::endl;
250 else std::cout<<
" \nNo problem when re-using iterator."<<std::endl;
256 std::cout<<
"\n=================== Starting tests for abnormal conditions ==================="<<std::endl;
260 std::cout<<
"\n[ Testing abnormal conditions case 0]Should be all ok: registry: "<<all_trackhits->inRegistry()<<
" size: "<<all_trackhits->size()<<std::endl;
263 std::cout<<
"\n[ Testing abnormal conditions case 1] Should throw an exception " <<std::endl;
int event() const
get the contents of the subdetector field (should be protected?)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< std::string > track_containers2_
int bunchCrossing() const
get the detector field from this detid
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const HepMC::GenEvent * GetEvent() const
std::vector< std::string > track_containers_
EncodedEventId eventId() const
int getSourceType() const
TestMix(const edm::ParameterSet &)