50 #include "FastSimulation/Tracking/test/FastTrackAnalyzer.h"
99 doGenPlots_ (iConfig.getParameter<bool>(
"MakeGenPlots")),
100 doHLTPlots_ (iConfig.getParameter<bool>(
"MakeHLTPlots")),
101 doSimTrackPlots_ (iConfig.getParameter<bool>(
"MakeSimTrackPlots")),
102 doSimDigiPlots_ (iConfig.getParameter<bool>(
"MakeSimDigiPlots")),
103 doRecoPlots_ (iConfig.getParameter<bool>(
"MakeRecoPlots")),
104 label_ (iConfig.getParameter<edm::InputTag>(
"generatorLabel")),
105 particleIds_ (iConfig.getParameter< std::vector<int> >(
"particleIds")),
106 particleStatus_ (iConfig.getUntrackedParameter<int>(
"particleStatus",1)),
107 ebSimHitTag_ (iConfig.getParameter<edm::InputTag>(
"EBSimHitCollection")),
108 eeSimHitTag_ (iConfig.getParameter<edm::InputTag>(
"EESimHitCollection")),
109 simTrackTag_ (iConfig.getParameter<edm::InputTag>(
"SimTrackCollection")),
110 EBDigiCollection_ (iConfig.getParameter<edm::InputTag>(
"EBDigiCollection")),
111 EEDigiCollection_ (iConfig.getParameter<edm::InputTag>(
"EEDigiCollection")),
112 RPCRecHitTag_ (iConfig.getParameter<edm::InputTag>(
"RPCRecHitTag"))
118 particlePHist_ = fileService->
make<TH1F>(
"particleP",
"Momentum of gen particle",500,0,2000);
119 particlePtHist_ = fileService->
make<TH1F>(
"particlePt",
"P_{T} of gen particle",500,0,2000);
125 h_genhscp_met = fileService->
make<TH1F>(
"hscp_met" ,
"missing E_{T} hscp" , 100, 0., 1500. );
142 dedxVsp = fileService->
make<TH2F>(
"dedxvsp",
"dedxvsp",100,0,1000,100,0,10);
144 hltmet = fileService->
make<TH1F>(
"HLT_MET",
"MET",3,-1,2);
145 hltjet = fileService->
make<TH1F>(
"HLT_JET",
"JET",3,-1,2);
146 hltmu = fileService->
make<TH1F>(
"HLT_Mu",
"Mu",3,-1,2);
152 simHitsEcalTimeHistEB_ = fileService->
make<TH1F>(
"ecalTimingOfSimHitsEB",
"HSCP SimTrack-matching SimHit time EB [ns]",115,-15,100);
153 simHitsEcalTimeHistEE_ = fileService->
make<TH1F>(
"ecalTimingOfSimHitsEE",
"HSCP SimTrack-matching SimHit time EE [ns]",115,-15,100);
154 simHitsEcalNumHistEB_ = fileService->
make<TH1F>(
"ecalNumberOfSimHitsEB",
"Number of HSCP SimTrack-matching EB sim hits in event",100,0,200);
155 simHitsEcalNumHistEE_ = fileService->
make<TH1F>(
"ecalNumberOfSimHitsEE",
"Number of HSCP SimTrack-matching EE sim hits in event",100,0,200);
156 simHitsEcalEnergyVsTimeHistEB_ = fileService->
make<TH2F>(
"ecalEnergyVsTimeOfSimHitsEB",
"Energy vs. time of HSCP SimTrack-matching EB sim hits in event",115,-15,100,125,-1,4);
157 simHitsEcalEnergyVsTimeHistEE_ = fileService->
make<TH2F>(
"ecalEnergyVsTimeOfSimHitsEE",
"Energy vs. time of HSCP SimTrack-matching EE sim hits in event",115,-15,100,125,-1,4);
166 digisEcalNumHistEB_ = fileService->
make<TH1F>(
"ecalDigisNumberEB",
"Number of EB digis matching simhits in event",200,0,1000);
167 digisEcalNumHistEE_ = fileService->
make<TH1F>(
"ecalDigisNumberEE",
"Number of EE digis matching simhits in event",200,0,1000);
168 digiOccupancyMapEB_ = fileService->
make<TH2F>(
"ecalDigiOccupancyMapEB",
"Occupancy of simhit-matching digis EB;i#phi;i#eta",360,1,361,171,-85,86);
169 digiOccupancyMapEEP_ = fileService->
make<TH2F>(
"ecalDigiOccupancyMapEEM",
"Occupancy of simhit-matching digis EEM;ix;iy",100,1,100,100,1,100);
170 digiOccupancyMapEEM_ = fileService->
make<TH2F>(
"ecalDigiOccupancyMapEEP",
"Occupancy of simhit-matching digis EEP;ix;iy",100,1,100,100,1,100);
178 rpcTimeOfFlightBarrel_[2] = fileService->
make<TH1F>(
"RPCToFLayer3",
"RPC HSCP Time Of Flight Layer 3",50,5,100);
179 rpcTimeOfFlightBarrel_[3] = fileService->
make<TH1F>(
"RPCToFLayer4",
"RPC HSCP Time Of Flight Layer 4",50,5,100);
180 rpcTimeOfFlightBarrel_[4] = fileService->
make<TH1F>(
"RPCToFLayer5",
"RPC HSCP Time Of Flight Layer 5",50,5,100);
181 rpcTimeOfFlightBarrel_[5] = fileService->
make<TH1F>(
"RPCToFLayer6",
"RPC HSCP Time Of Flight Layer 6",50,5,100);
182 rpcBXBarrel_[0] = fileService->
make<TH1F>(
"RPCBXLayer1",
"RPC HSCP BX Layer 1",5,-0.5,4.5);
183 rpcBXBarrel_[1] = fileService->
make<TH1F>(
"RPCBXLayer2",
"RPC HSCP BX Layer 2",5,-0.5,4.5);
184 rpcBXBarrel_[2] = fileService->
make<TH1F>(
"RPCBXLayer3",
"RPC HSCP BX Layer 3",5,-0.5,4.5);
185 rpcBXBarrel_[3] = fileService->
make<TH1F>(
"RPCBXLayer4",
"RPC HSCP BX Layer 4",5,-0.5,4.5);
186 rpcBXBarrel_[4] = fileService->
make<TH1F>(
"RPCBXLayer5",
"RPC HSCP BX Layer 5",5,-0.5,4.5);
187 rpcBXBarrel_[5] = fileService->
make<TH1F>(
"RPCBXLayer6",
"RPC HSCP BX Layer 6",5,-0.5,4.5);
190 rpcTimeOfFlightEndCap_[2]= fileService->
make<TH1F>(
"RPCToFDisk3",
"RPC HSCP Time Of Flight Disk 3",50,5,100);
191 rpcBXEndCap_[0] = fileService->
make<TH1F>(
"RPCBXDisk1",
"RPC HSCP BX Disk 1",5,-0.5,4.5);
192 rpcBXEndCap_[1] = fileService->
make<TH1F>(
"RPCBXDisk2",
"RPC HSCP BX Disk 2",5,-0.5,4.5);
193 rpcBXEndCap_[2] = fileService->
make<TH1F>(
"RPCBXDisk3",
"RPC HSCP BX Disk 3",5,-0.5,4.5);
257 frequencies+=
"PDG ID: ";
259 frequencies+=
" Frequency: ";
263 std::cout <<
"Found PDGIds: " <<
"\n\n" << frequencies << std::endl;
274 double missingpx_nohscp=0;
275 double missingpy_nohscp=0;
277 double scalorEt_nohscp=0;
283 HepMC::GenEvent * myGenEvent =
new HepMC::GenEvent(*(evt->GetEvent()));
284 for(HepMC::GenEvent::particle_iterator
p = myGenEvent->particles_begin();
285 p != myGenEvent->particles_end(); ++
p )
291 if(
abs((*p)->pdg_id())!=12 &&
abs((*p)->pdg_id())!=14 &&
abs((*p)->pdg_id())!=16){
292 missingpx-=(*p)->momentum().px();
293 missingpy-=(*p)->momentum().py();
294 scalorEt+=(*p)->momentum().perp();
302 if(
abs((*p)->pdg_id())!=12 &&
abs((*p)->pdg_id())!=14 &&
abs((*p)->pdg_id())!=16){
303 missingpx_nohscp-=(*p)->momentum().px();
304 missingpy_nohscp-=(*p)->momentum().py();
305 scalorEt_nohscp+=(*p)->momentum().perp();
312 std::pair<std::map<int,int>::iterator,
bool> pair =
particleIdsFoundMap_.insert(std::make_pair<int,int>((*p)->pdg_id(),1));
315 ++(pair.first->second);
318 double mag =
sqrt(
pow((*p)->momentum().px(),2) +
pow((*p)->momentum().py(),2) +
pow((*p)->momentum().pz(),2) );
324 float particleP =
mag;
325 float particleM = (*p)->generated_mass();
346 {
using namespace edm;
349 iEvent.
getByLabel(
"g4SimHits",simTracksHandle);
352 SimTrackContainer::const_iterator simTrack;
354 for (simTrack = simTracks.begin(); simTrack != simTracks.end(); ++simTrack){
381 std::cout<<
"Tirgger Results not available"<<std::endl;
385 iEvent.
getByLabel(
"hltTriggerSummaryAOD", trEvHandle);
389 unsigned int TrIndex_Unknown = tr.size();
393 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_Mu40_v1")){
394 if(tr.accept(tr.triggerIndex(
"HLT_Mu40_v1")))
hltmu->Fill(1);
395 else {
hltmu->Fill(0);}
398 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_Mu30_v1")){
402 printf(
"BUG with HLT_Mu\n");
404 for(
unsigned int i=0;
i<tr.size();
i++){
413 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_PFMHT150_v3")){
414 if(tr.accept(tr.triggerIndex(
"HLT_PFMHT150_v3")))
hltmet->Fill(1);
417 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_PFMHT150_v2")){
418 if(tr.accept(tr.triggerIndex(
"HLT_PFMHT150_v2")))
hltmet->Fill(1);
422 printf(
"BUG with HLT_MET\n");
429 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_Jet370_v1")){
430 if(tr.accept(tr.triggerIndex(
"HLT_Jet370_v1")))
hltjet->Fill(1);
433 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_Jet100U")){
437 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_Jet70U")){
441 if(TrIndex_Unknown != tr.triggerIndex(
"HLT_Jet50U")){
445 printf(
"BUG with HLT_Jet\n");
465 if(!ebSimHits.isValid())
467 std::cout <<
"Cannot get EBSimHits from event!" << std::endl;
473 if(!eeSimHits.isValid())
475 std::cout <<
"Cannot get EESimHits from event!" << std::endl;
481 if(!simTracks.isValid())
483 std::cout <<
"Cannot get SimTracks from event!" << std::endl;
489 if(!ebDigis.isValid())
491 std::cout <<
"Cannot get EBDigis from event!" << std::endl;
497 if(!eeDigis.isValid())
499 std::cout <<
"Cannot get EEDigis from event!" << std::endl;
507 int numMatchedSimHitsEventEB = 0;
508 int numMatchedDigisEventEB = 0;
510 phitsEB = ebSimHits.product();
511 for(SimTrackContainer::const_iterator simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack)
519 std::vector<EBDataFrame> myDigisEB;
522 int trackId = simTrack->trackId();
523 PCaloHitContainer::const_iterator simHitItr = phitsEB->begin();
524 while(simHitItr != phitsEB->end())
526 if(simHitItr->geantTrackId()==trackId)
527 mySimHitsEB.push_back(*simHitItr);
530 if(mySimHitsEB.size()==0)
532 std::cout <<
"Could not find matching EB PCaloHits for SimTrack id: " << trackId <<
". Skipping this SimTrack" << std::endl;
537 for(simHitItr = mySimHitsEB.begin(); simHitItr != mySimHitsEB.end(); ++simHitItr)
543 std::cout <<
"SimHit DetId found: " << simHitId <<
" for PDGid: " << simTrack->type() << std::endl;
545 std::cout <<
"SimHit energy: " << simHitItr->energy() <<
" time: " << simHitItr->time() << std::endl;
546 ++numMatchedSimHitsEventEB;
549 while(digiItr != ebDigis->end() && (digiItr->id() != simHitId))
551 if(digiItr==ebDigis->end())
554 std::cout <<
"Could not find simHit detId: " << simHitId <<
"in EBDigiCollection!" << std::endl;
557 std::vector<EBDataFrame>::const_iterator myDigiItr = myDigisEB.begin();
558 while(myDigiItr != myDigisEB.end() && (digiItr->id() != myDigiItr->id()))
560 if(myDigiItr!=myDigisEB.end())
563 ++numMatchedDigisEventEB;
565 myDigisEB.push_back(df);
567 for(
int i=0;
i<10;++
i)
570 for(
int i=0;
i < df.
size(); ++
i)
588 int numMatchedSimHitsEventEE = 0;
589 int numMatchedDigisEventEE = 0;
591 phitsEE = eeSimHits.product();
592 for(SimTrackContainer::const_iterator simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack)
600 std::vector<EEDataFrame> myDigisEE;
603 int trackId = simTrack->trackId();
604 PCaloHitContainer::const_iterator simHitItr = phitsEE->begin();
605 while(simHitItr != phitsEE->end())
607 if(simHitItr->geantTrackId()==trackId)
608 mySimHitsEE.push_back(*simHitItr);
611 if(mySimHitsEE.size()==0)
613 std::cout <<
"Could not find matching EE PCaloHits for SimTrack id: " << trackId <<
". Skipping this SimTrack" << std::endl;
618 for(simHitItr = mySimHitsEE.begin(); simHitItr != mySimHitsEE.end(); ++simHitItr)
624 std::cout <<
"SimHit DetId found: " << simHitId <<
" for PDGid: " << simTrack->type() << std::endl;
626 std::cout <<
"SimHit energy: " << simHitItr->energy() <<
" time: " << simHitItr->time() << std::endl;
627 ++numMatchedSimHitsEventEE;
630 while(digiItr != eeDigis->end() && (digiItr->id() != simHitId))
632 if(digiItr==eeDigis->end())
635 std::cout <<
"Could not find simHit detId: " << simHitId <<
"in EEDigiCollection!" << std::endl;
638 std::vector<EEDataFrame>::const_iterator myDigiItr = myDigisEE.begin();
639 while(myDigiItr != myDigisEE.end() && (digiItr->id() != myDigiItr->id()))
641 if(myDigiItr!=myDigisEE.end())
644 ++numMatchedDigisEventEE;
646 myDigisEE.push_back(df);
648 for(
int i=0;
i<10;++
i)
651 for(
int i=0;
i < df.
size(); ++
i)
660 if(((
EEDetId)digiItr->id()).zside() > 0)
662 else if(((
EEDetId)digiItr->id()).zside() < 0)
674 using namespace reco;
684 iEvent.
getByLabel(
"dedxHarmonic2", dEdxTrackHandle);
687 for(
size_t i=0;
i<tkTracks->size();
i++){
691 if(trkRef->pt()<5 || trkRef->normalizedChi2()>10)
continue;
694 double hscpgenPt =-1;
696 HepMC::GenEvent * myGenEvent =
new HepMC::GenEvent(*(evt->GetEvent()));
697 for(HepMC::GenEvent::particle_iterator
p = myGenEvent->particles_begin();
698 p != myGenEvent->particles_end(); ++
p )
708 double distance =
pow((*p)->momentum().eta()-trkRef->eta(),2)+
pow((*p)->momentum().phi()-trkRef->phi(),2);
709 distance =
sqrt(distance);
712 hscpgenPt= (*p)->momentum().perp();
719 double dedx = dEdxTrack[trkRef].dEdx();
720 dedxVsp->Fill( trkRef->p(),dedx);
732 std::vector<Handle<edm::PSimHitContainer> > theSimHitContainers;
740 std::vector<PSimHit> theSimHits;
742 for (
int i = 0;
i < int(theSimHitContainers.size());
i++){
743 theSimHits.insert(theSimHits.end(),theSimHitContainers.at(
i)->begin(),theSimHitContainers.at(
i)->end());
747 for (std::vector<PSimHit>::const_iterator iHit = theSimHits.begin(); iHit != theSimHits.end(); iHit++){
753 DetId theDetUnitId((*iHit).detUnitId());
768 GlobalPoint SimHitInGlobal = RPCSurface.toGlobal((*iHit).localPosition());
770 std::cout<<
"\t\t We have an RPC Sim Hit! in t="<<(*iHit).timeOfFlight()<<
"ns "<<rpcsrv.
name()<<
" Global postition="<<SimHitInGlobal<<std::endl;
775 else if(rollId.
station()==1&&rollId.
layer()==2) layer = 2;
776 else if(rollId.
station()==2&&rollId.
layer()==1) layer = 3;
777 else if(rollId.
station()==2&&rollId.
layer()==2) layer = 4;
778 else if(rollId.
station()==3) layer = 5;
779 else if(rollId.
station()==4) layer = 6;
787 std::cout<<
"\t\t r="<<SimHitInGlobal.
mag()<<
" phi="<<SimHitInGlobal.
phi()<<
" eta="<<SimHitInGlobal.
eta()<<std::endl;
791 float minres = 3000.;
793 std::cout<<
"\t \t \t \t Getting RecHits in Roll Asociated"<<std::endl;
795 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
796 rangeRecHits recHitCollection =
rpcRecHits->get(rollId);
801 for(recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++){
803 float res=(*iHit).localPosition().
x()- recHitPos.
x();
804 if(fabs(res)<fabs(minres)){
806 cluSize = recHit->clusterSize();
808 std::cout<<
"\t New Min Res "<<res<<
"cm."<<std::endl;
827 ostringstream myStream;
828 myStream << num << flush;
829 return(myStream.str());
839 unsigned int filterIndex = trEv.
filterIndex(InputPath);
845 const int nI(VIDS.size());
846 const int nK(KEYS.size());
852 if(!averageThreshold){
853 int NObjectAboveThresholdObserved = 0;
854 for (
int i=0;
i!=
n; ++
i) {
855 if(TOC[KEYS[
i]].pt()> NewThreshold && fabs(TOC[KEYS[
i]].
eta())<etaCut) NObjectAboveThresholdObserved++;
858 if(NObjectAboveThresholdObserved>=NObjectAboveThreshold)
return true;
861 std::vector<double> ObjPt;
863 for (
int i=0;
i!=
n; ++
i) {
864 ObjPt.push_back(TOC[KEYS[
i]].pt());
867 if((
int)(ObjPt.size())<NObjectAboveThreshold)
return false;
871 for(
int i=0;
i<NObjectAboveThreshold;
i++){
872 Average+= ObjPt[ObjPt.size()-1-
i];
873 }Average/=NObjectAboveThreshold;
876 if(Average>NewThreshold)
return true;
void getManyByType(std::vector< Handle< PROD > > &results) const
TH2F * simHitsEcalDigiMatchEnergyVsTimeHistEE_
virtual TriggerResultsByName triggerResultsByName(std::string const &process) const
TH1F * rpcTimeOfFlightBarrel_[6]
TH1F * rpcTimeOfFlightEndCap_[3]
std::vector< PCaloHit > PCaloHitContainer
TH1F * simHitsEcalTimeHistEE_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TH2F * simHitsEcalEnergyVsTimeHistEB_
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
TH1F * simHitsEcalEnergyHistEE_
TH1F * h_genhscp_met_nohscp
TH1F * digisEcalNumHistEE_
const Keys & filterKeys(trigger::size_type index) const
Geom::Phi< T > phi() const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
std::vector< Track > TrackCollection
collection of Tracks
TH2F * digiOccupancyMapEEM_
EcalMGPASample sample(int i) const
bool IncreasedTreshold(const trigger::TriggerEvent &trEv, const edm::InputTag &InputPath, double NewThreshold, double etaCut, int NObjectAboveThreshold, bool averageThreshold)
TH1F * cluSizeDistribution_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
TH1F * simHitsEcalDigiMatchTimeHistEB_
const Plane & surface() const
The nominal surface of the GeomDet.
void makeSimTrackPlots(const edm::Event &iEvent)
HSCPValidator(const edm::ParameterSet &)
void makeRecoPlots(const edm::Event &iEvent)
std::vector< int > particleIds_
std::map< int, int > particleIdsFoundMap_
TH1F * simTrackParticlePtHist_
TH1F * simHitsEcalNumHistEE_
C::const_iterator const_iterator
constant access iterator type
const Vids & filterIds(trigger::size_type index) const
TH2F * digiOccupancyMapEEP_
virtual std::string name()
const T & max(const T &a, const T &b)
TH1F * h_genhscp_scaloret
const TriggerObjectCollection & getObjects() const
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
TH2F * digiOccupancyMapEB_
TH1F * efficiencyRPCRecHitSimDigis_
TH2F * simHitsEcalDigiMatchEnergyVsTimeHistEB_
TH1F * simHitsEcalDigiMatchEnergyHistEE_
TH1F * h_genhscp_scaloret_nohscp
edm::InputTag ebSimHitTag_
TH1F * simHitsEcalDigiMatchTimeHistEE_
std::string intToString(int num)
void makeSimDigiPlotsECAL(const edm::Event &iEvent)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
TH2F * simHitsEcalEnergyVsTimeHistEE_
edm::InputTag eeSimHitTag_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
TH1F * residualsRPCRecHitSimDigis_
TH1F * simHitsEcalDigiMatchIEtaHist_
TH1F * simHitsEcalNumHistEB_
void makeGenPlots(const edm::Event &iEvent)
edm::Service< TFileService > fileService
TH1F * digisEcalNumHistEB_
TH1F * simTrackParticleEtaHist_
TH1F * simHitsEcalDigiMatchIPhiHist_
std::vector< size_type > Keys
TH1F * simHitsEcalDigiMatchEnergyHistEB_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
TH1F * particleStatusHist_
edm::InputTag EBDigiCollection_
edm::InputTag EEDigiCollection_
edm::ESHandle< RPCGeometry > rpcGeo
TH1F * simTrackParticlePhiHist_
T * make() const
make new ROOT object
void makeSimDigiPlotsRPC(const edm::Event &iEvent)
void makeHLTPlots(const edm::Event &iEvent)
TH1F * simTrackParticleBetaHist_
std::vector< SimTrack > SimTrackContainer
edm::InputTag simTrackTag_
TH1F * simHitsEcalEnergyHistEB_
Power< A, B >::type pow(const A &a, const B &b)
TH1F * simTrackParticlePHist_
TH1F * particleBetaInverseHist_
int adc() const
get the ADC sample (12 bits)
TH1F * simHitsEcalTimeHistEB_
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.