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 token_(consumes<
edm::
HepMCProduct> (iConfig.getParameter<
edm::InputTag>(
"generatorLabel"))),
106 trEvToken_(consumes<
trigger::TriggerEvent>(
edm::InputTag(
"hltTriggerSummaryAOD"))),
108 dEdxTrackToken_(consumes<
edm::ValueMap<
reco::DeDxData> >(
edm::InputTag(
"dedxHarmonic2"))),
110 triggerResultsToken_(consumes<
edm::TriggerResults>(
edm::InputTag(
"TriggerResults",
"",
"HLT"))),
111 particleIds_ (iConfig.getParameter<
std::vector<
int> >(
"particleIds")),
112 particleStatus_ (iConfig.getUntrackedParameter<
int>(
"particleStatus",1)),
116 EBDigiCollectionToken_ (consumes<
EBDigiCollection>(iConfig.getParameter<
edm::InputTag>(
"EBDigiCollection"))),
117 EEDigiCollectionToken_ (consumes<
EEDigiCollection>(iConfig.getParameter<
edm::InputTag>(
"EEDigiCollection")))
123 particlePHist_ = fileService->
make<TH1F>(
"particleP",
"Momentum of gen particle",500,0,2000);
124 particlePtHist_ = fileService->
make<TH1F>(
"particlePt",
"P_{T} of gen particle",500,0,2000);
130 h_genhscp_met = fileService->
make<TH1F>(
"hscp_met" ,
"missing E_{T} hscp" , 100, 0., 1500. );
147 dedxVsp = fileService->
make<TH2F>(
"dedxvsp",
"dedxvsp",100,0,1000,100,0,10);
149 hltmet = fileService->
make<TH1F>(
"HLT_MET",
"MET",3,-1,2);
150 hltjet = fileService->
make<TH1F>(
"HLT_JET",
"JET",3,-1,2);
151 hltmu = fileService->
make<TH1F>(
"HLT_Mu",
"Mu",3,-1,2);
157 simHitsEcalTimeHistEB_ = fileService->
make<TH1F>(
"ecalTimingOfSimHitsEB",
"HSCP SimTrack-matching SimHit time EB [ns]",115,-15,100);
158 simHitsEcalTimeHistEE_ = fileService->
make<TH1F>(
"ecalTimingOfSimHitsEE",
"HSCP SimTrack-matching SimHit time EE [ns]",115,-15,100);
159 simHitsEcalNumHistEB_ = fileService->
make<TH1F>(
"ecalNumberOfSimHitsEB",
"Number of HSCP SimTrack-matching EB sim hits in event",100,0,200);
160 simHitsEcalNumHistEE_ = fileService->
make<TH1F>(
"ecalNumberOfSimHitsEE",
"Number of HSCP SimTrack-matching EE sim hits in event",100,0,200);
161 simHitsEcalEnergyVsTimeHistEB_ = fileService->
make<TH2F>(
"ecalEnergyVsTimeOfSimHitsEB",
"Energy vs. time of HSCP SimTrack-matching EB sim hits in event",115,-15,100,125,-1,4);
162 simHitsEcalEnergyVsTimeHistEE_ = fileService->
make<TH2F>(
"ecalEnergyVsTimeOfSimHitsEE",
"Energy vs. time of HSCP SimTrack-matching EE sim hits in event",115,-15,100,125,-1,4);
171 digisEcalNumHistEB_ = fileService->
make<TH1F>(
"ecalDigisNumberEB",
"Number of EB digis matching simhits in event",200,0,1000);
172 digisEcalNumHistEE_ = fileService->
make<TH1F>(
"ecalDigisNumberEE",
"Number of EE digis matching simhits in event",200,0,1000);
173 digiOccupancyMapEB_ = fileService->
make<TH2F>(
"ecalDigiOccupancyMapEB",
"Occupancy of simhit-matching digis EB;i#phi;i#eta",360,1,361,171,-85,86);
174 digiOccupancyMapEEP_ = fileService->
make<TH2F>(
"ecalDigiOccupancyMapEEM",
"Occupancy of simhit-matching digis EEM;ix;iy",100,1,100,100,1,100);
175 digiOccupancyMapEEM_ = fileService->
make<TH2F>(
"ecalDigiOccupancyMapEEP",
"Occupancy of simhit-matching digis EEP;ix;iy",100,1,100,100,1,100);
183 rpcTimeOfFlightBarrel_[2] = fileService->
make<TH1F>(
"RPCToFLayer3",
"RPC HSCP Time Of Flight Layer 3",50,5,100);
184 rpcTimeOfFlightBarrel_[3] = fileService->
make<TH1F>(
"RPCToFLayer4",
"RPC HSCP Time Of Flight Layer 4",50,5,100);
185 rpcTimeOfFlightBarrel_[4] = fileService->
make<TH1F>(
"RPCToFLayer5",
"RPC HSCP Time Of Flight Layer 5",50,5,100);
186 rpcTimeOfFlightBarrel_[5] = fileService->
make<TH1F>(
"RPCToFLayer6",
"RPC HSCP Time Of Flight Layer 6",50,5,100);
187 rpcBXBarrel_[0] = fileService->
make<TH1F>(
"RPCBXLayer1",
"RPC HSCP BX Layer 1",5,-0.5,4.5);
188 rpcBXBarrel_[1] = fileService->
make<TH1F>(
"RPCBXLayer2",
"RPC HSCP BX Layer 2",5,-0.5,4.5);
189 rpcBXBarrel_[2] = fileService->
make<TH1F>(
"RPCBXLayer3",
"RPC HSCP BX Layer 3",5,-0.5,4.5);
190 rpcBXBarrel_[3] = fileService->
make<TH1F>(
"RPCBXLayer4",
"RPC HSCP BX Layer 4",5,-0.5,4.5);
191 rpcBXBarrel_[4] = fileService->
make<TH1F>(
"RPCBXLayer5",
"RPC HSCP BX Layer 5",5,-0.5,4.5);
192 rpcBXBarrel_[5] = fileService->
make<TH1F>(
"RPCBXLayer6",
"RPC HSCP BX Layer 6",5,-0.5,4.5);
195 rpcTimeOfFlightEndCap_[2]= fileService->
make<TH1F>(
"RPCToFDisk3",
"RPC HSCP Time Of Flight Disk 3",50,5,100);
196 rpcBXEndCap_[0] = fileService->
make<TH1F>(
"RPCBXDisk1",
"RPC HSCP BX Disk 1",5,-0.5,4.5);
197 rpcBXEndCap_[1] = fileService->
make<TH1F>(
"RPCBXDisk2",
"RPC HSCP BX Disk 2",5,-0.5,4.5);
198 rpcBXEndCap_[2] = fileService->
make<TH1F>(
"RPCBXDisk3",
"RPC HSCP BX Disk 3",5,-0.5,4.5);
262 frequencies+=
"PDG ID: ";
264 frequencies+=
" Frequency: ";
268 std::cout <<
"Found PDGIds: " <<
"\n\n" << frequencies << std::endl;
279 double missingpx_nohscp=0;
280 double missingpy_nohscp=0;
282 double scalorEt_nohscp=0;
288 HepMC::GenEvent * myGenEvent =
new HepMC::GenEvent(*(evt->
GetEvent()));
289 for(HepMC::GenEvent::particle_iterator
p = myGenEvent->particles_begin();
290 p != myGenEvent->particles_end(); ++
p )
296 if(
abs((*p)->pdg_id())!=12 &&
abs((*p)->pdg_id())!=14 &&
abs((*p)->pdg_id())!=16){
297 missingpx-=(*p)->momentum().px();
298 missingpy-=(*p)->momentum().py();
299 scalorEt+=(*p)->momentum().perp();
307 if(
abs((*p)->pdg_id())!=12 &&
abs((*p)->pdg_id())!=14 &&
abs((*p)->pdg_id())!=16){
308 missingpx_nohscp-=(*p)->momentum().px();
309 missingpy_nohscp-=(*p)->momentum().py();
310 scalorEt_nohscp+=(*p)->momentum().perp();
317 std::pair<std::map<int,int>::iterator,
bool> pair =
particleIdsFoundMap_.insert(std::make_pair<int,int>((*p)->pdg_id(),1));
320 ++(pair.first->second);
323 double mag =
sqrt(
pow((*p)->momentum().px(),2) +
pow((*p)->momentum().py(),2) +
pow((*p)->momentum().pz(),2) );
329 float particleP =
mag;
330 float particleM = (*p)->generated_mass();
351 {
using namespace edm;
357 SimTrackContainer::const_iterator
simTrack;
359 for (simTrack = simTracks.begin(); simTrack != simTracks.end(); ++
simTrack){
391 std::cout<<
"Trigger Results not available"<<std::endl;
399 unsigned int TrIndex_Unknown = tr.
size();
405 else {
hltmu->Fill(0);}
412 printf(
"BUG with HLT_Mu\n");
414 for(
unsigned int i=0;
i<tr.
size();
i++){
423 if(TrIndex_Unknown != tr.
triggerIndex(
"HLT_PFMHT150_v3")){
427 if(TrIndex_Unknown != tr.
triggerIndex(
"HLT_PFMHT150_v2")){
432 printf(
"BUG with HLT_MET\n");
439 if(TrIndex_Unknown != tr.
triggerIndex(
"HLT_Jet370_v1")){
455 printf(
"BUG with HLT_Jet\n");
477 std::cout <<
"Cannot get EBSimHits from event!" << std::endl;
485 std::cout <<
"Cannot get EESimHits from event!" << std::endl;
493 std::cout <<
"Cannot get SimTracks from event!" << std::endl;
501 std::cout <<
"Cannot get EBDigis from event!" << std::endl;
509 std::cout <<
"Cannot get EEDigis from event!" << std::endl;
517 int numMatchedSimHitsEventEB = 0;
518 int numMatchedDigisEventEB = 0;
529 std::vector<EBDataFrame> myDigisEB;
533 PCaloHitContainer::const_iterator simHitItr = phitsEB->begin();
534 while(simHitItr != phitsEB->end())
536 if(simHitItr->geantTrackId()==trackId)
537 mySimHitsEB.push_back(*simHitItr);
540 if(mySimHitsEB.size()==0)
542 std::cout <<
"Could not find matching EB PCaloHits for SimTrack id: " << trackId <<
". Skipping this SimTrack" << std::endl;
547 for(simHitItr = mySimHitsEB.begin(); simHitItr != mySimHitsEB.end(); ++simHitItr)
553 std::cout <<
"SimHit DetId found: " << simHitId <<
" for PDGid: " <<
simTrack->type() << std::endl;
555 std::cout <<
"SimHit energy: " << simHitItr->energy() <<
" time: " << simHitItr->time() << std::endl;
556 ++numMatchedSimHitsEventEB;
559 while(digiItr != ebDigis->
end() && (digiItr->id() != simHitId))
561 if(digiItr==ebDigis->
end())
564 std::cout <<
"Could not find simHit detId: " << simHitId <<
"in EBDigiCollection!" << std::endl;
567 std::vector<EBDataFrame>::const_iterator myDigiItr = myDigisEB.begin();
568 while(myDigiItr != myDigisEB.end() && (digiItr->id() != myDigiItr->id()))
570 if(myDigiItr!=myDigisEB.end())
573 ++numMatchedDigisEventEB;
575 myDigisEB.push_back(df);
577 for(
int i=0;
i<10;++
i)
580 for(
int i=0;
i < df.
size(); ++
i)
598 int numMatchedSimHitsEventEE = 0;
599 int numMatchedDigisEventEE = 0;
610 std::vector<EEDataFrame> myDigisEE;
614 PCaloHitContainer::const_iterator simHitItr = phitsEE->begin();
615 while(simHitItr != phitsEE->end())
617 if(simHitItr->geantTrackId()==trackId)
618 mySimHitsEE.push_back(*simHitItr);
621 if(mySimHitsEE.size()==0)
623 std::cout <<
"Could not find matching EE PCaloHits for SimTrack id: " << trackId <<
". Skipping this SimTrack" << std::endl;
628 for(simHitItr = mySimHitsEE.begin(); simHitItr != mySimHitsEE.end(); ++simHitItr)
634 std::cout <<
"SimHit DetId found: " << simHitId <<
" for PDGid: " <<
simTrack->type() << std::endl;
636 std::cout <<
"SimHit energy: " << simHitItr->energy() <<
" time: " << simHitItr->time() << std::endl;
637 ++numMatchedSimHitsEventEE;
640 while(digiItr != eeDigis->
end() && (digiItr->id() != simHitId))
642 if(digiItr==eeDigis->
end())
645 std::cout <<
"Could not find simHit detId: " << simHitId <<
"in EEDigiCollection!" << std::endl;
648 std::vector<EEDataFrame>::const_iterator myDigiItr = myDigisEE.begin();
649 while(myDigiItr != myDigisEE.end() && (digiItr->id() != myDigiItr->id()))
651 if(myDigiItr!=myDigisEE.end())
654 ++numMatchedDigisEventEE;
656 myDigisEE.push_back(df);
658 for(
int i=0;
i<10;++
i)
661 for(
int i=0;
i < df.
size(); ++
i)
684 using namespace reco;
697 for(
size_t i=0;
i<tkTracks->size();
i++){
701 if(trkRef->pt()<5 || trkRef->normalizedChi2()>10)
continue;
704 double hscpgenPt =-1;
706 HepMC::GenEvent * myGenEvent =
new HepMC::GenEvent(*(evt->
GetEvent()));
707 for(HepMC::GenEvent::particle_iterator
p = myGenEvent->particles_begin();
708 p != myGenEvent->particles_end(); ++
p )
718 double distance =
pow((*p)->momentum().eta()-trkRef->eta(),2)+
pow((*p)->momentum().phi()-trkRef->phi(),2);
719 distance =
sqrt(distance);
722 hscpgenPt= (*p)->momentum().perp();
729 double dedx = dEdxTrack[trkRef].dEdx();
730 dedxVsp->Fill( trkRef->p(),dedx);
742 std::vector<Handle<edm::PSimHitContainer> > theSimHitContainers;
750 std::vector<PSimHit> theSimHits;
752 for (
int i = 0;
i <
int(theSimHitContainers.size());
i++){
753 theSimHits.insert(theSimHits.end(),theSimHitContainers.at(
i)->begin(),theSimHitContainers.at(
i)->end());
757 for (std::vector<PSimHit>::const_iterator iHit = theSimHits.begin(); iHit != theSimHits.end(); iHit++){
763 DetId theDetUnitId((*iHit).detUnitId());
778 GlobalPoint SimHitInGlobal = RPCSurface.toGlobal((*iHit).localPosition());
780 std::cout<<
"\t\t We have an RPC Sim Hit! in t="<<(*iHit).timeOfFlight()<<
"ns "<<rpcsrv.
name()<<
" Global postition="<<SimHitInGlobal<<std::endl;
785 else if(rollId.
station()==1&&rollId.
layer()==2) layer = 2;
786 else if(rollId.
station()==2&&rollId.
layer()==1) layer = 3;
787 else if(rollId.
station()==2&&rollId.
layer()==2) layer = 4;
788 else if(rollId.
station()==3) layer = 5;
789 else if(rollId.
station()==4) layer = 6;
797 std::cout<<
"\t\t r="<<SimHitInGlobal.
mag()<<
" phi="<<SimHitInGlobal.
phi()<<
" eta="<<SimHitInGlobal.
eta()<<std::endl;
801 float minres = 3000.;
803 std::cout<<
"\t \t \t \t Getting RecHits in Roll Asociated"<<std::endl;
805 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
806 rangeRecHits recHitCollection = rpcRecHits->get(rollId);
811 for(recHit = recHitCollection.first; recHit != recHitCollection.second ; recHit++){
813 float res=(*iHit).localPosition().x()- recHitPos.
x();
814 if(fabs(res)<fabs(minres)){
816 cluSize = recHit->clusterSize();
818 std::cout<<
"\t New Min Res "<<res<<
"cm."<<std::endl;
837 ostringstream myStream;
838 myStream << num << flush;
839 return(myStream.str());
849 unsigned int filterIndex = trEv.
filterIndex(InputPath);
855 const int nI(VIDS.size());
856 const int nK(KEYS.size());
862 if(!averageThreshold){
863 int NObjectAboveThresholdObserved = 0;
864 for (
int i=0;
i!=
n; ++
i) {
865 if(TOC[KEYS[
i]].
pt()> NewThreshold && fabs(TOC[KEYS[
i]].
eta())<
etaCut) NObjectAboveThresholdObserved++;
868 if(NObjectAboveThresholdObserved>=NObjectAboveThreshold)
return true;
871 std::vector<double> ObjPt;
873 for (
int i=0;
i!=
n; ++
i) {
874 ObjPt.push_back(TOC[KEYS[
i]].
pt());
877 if((
int)(ObjPt.size())<NObjectAboveThreshold)
return false;
878 std::sort(ObjPt.begin(), ObjPt.end());
881 for(
int i=0;
i<NObjectAboveThreshold;
i++){
882 Average+= ObjPt[ObjPt.size()-1-
i];
883 }Average/=NObjectAboveThreshold;
886 if(Average>NewThreshold)
return true;
void getManyByType(std::vector< Handle< PROD > > &results) const
TH2F * simHitsEcalDigiMatchEnergyVsTimeHistEE_
TH1F * rpcTimeOfFlightBarrel_[6]
edm::EDGetTokenT< EEDigiCollection > EEDigiCollectionToken_
TH1F * rpcTimeOfFlightEndCap_[3]
std::vector< PCaloHit > PCaloHitContainer
TH1F * simHitsEcalTimeHistEE_
edm::EDGetTokenT< EBDigiCollection > EBDigiCollectionToken_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
edm::EDGetTokenT< edm::PCaloHitContainer > eeSimHitToken_
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 &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TH2F * simHitsEcalEnergyVsTimeHistEB_
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
std::vector< std::string >::size_type size() const
TH1F * simHitsEcalEnergyHistEE_
TH1F * h_genhscp_met_nohscp
edm::EDGetTokenT< edm::PCaloHitContainer > ebSimHitToken_
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
std::string const & triggerName(unsigned i) const
unsigned triggerIndex(std::string const &pathName) const
T * make(const Args &...args) const
make new ROOT object
bool IncreasedTreshold(const trigger::TriggerEvent &trEv, const edm::InputTag &InputPath, double NewThreshold, double etaCut, int NObjectAboveThreshold, bool averageThreshold)
const_iterator begin() const
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_
edm::EDGetTokenT< edm::SimTrackContainer > simTracksToken_
virtual TriggerResultsByName triggerResultsByName(edm::TriggerResults const &triggerResults) const
TH1F * simHitsEcalNumHistEE_
const Vids & filterIds(trigger::size_type index) const
TH2F * digiOccupancyMapEEP_
virtual std::string name()
TH1F * h_genhscp_scaloret
const TriggerObjectCollection & getObjects() const
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
simTrack
per collection params
TH2F * digiOccupancyMapEB_
TH1F * efficiencyRPCRecHitSimDigis_
TH2F * simHitsEcalDigiMatchEnergyVsTimeHistEB_
TH1F * simHitsEcalDigiMatchEnergyHistEE_
TH1F * h_genhscp_scaloret_nohscp
edm::EDGetTokenT< edm::HepMCProduct > token_
Abs< T >::type abs(const T &t)
TH1F * simHitsEcalDigiMatchTimeHistEE_
std::string intToString(int num)
void makeSimDigiPlotsECAL(const edm::Event &iEvent)
static std::string const triggerResults
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken_
edm::EDGetTokenT< RPCRecHitCollection > rpcRecHitsToken_
TH2F * simHitsEcalEnergyVsTimeHistEE_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
TH1F * residualsRPCRecHitSimDigis_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
TH1F * simHitsEcalDigiMatchIEtaHist_
TH1F * simHitsEcalNumHistEB_
const HepMC::GenEvent * GetEvent() const
T const * product() const
void makeGenPlots(const edm::Event &iEvent)
edm::Service< TFileService > fileService
edm::EDGetTokenT< trigger::TriggerEvent > trEvToken_
TH1F * digisEcalNumHistEB_
TH1F * simTrackParticleEtaHist_
TH1F * simHitsEcalDigiMatchIPhiHist_
std::vector< size_type > Keys
TH1F * simHitsEcalDigiMatchEnergyHistEB_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
TH1F * particleStatusHist_
const_iterator end() const
edm::ESHandle< RPCGeometry > rpcGeo
TH1F * simTrackParticlePhiHist_
void makeSimDigiPlotsRPC(const edm::Event &iEvent)
edm::EDGetTokenT< reco::TrackCollection > tkTracksToken_
void makeHLTPlots(const edm::Event &iEvent)
TH1F * simTrackParticleBetaHist_
edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > dEdxTrackToken_
std::vector< SimTrack > SimTrackContainer
TH1F * simHitsEcalEnergyHistEB_
Power< A, B >::type pow(const A &a, const B &b)
TH1F * simTrackParticlePHist_
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
TH1F * particleBetaInverseHist_
int adc() const
get the ADC sample (12 bits)
TH1F * simHitsEcalTimeHistEB_
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.