diff --git a/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc b/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc new file mode 100644 index 0000000000000..aee60459099b8 --- /dev/null +++ b/CommonTools/RecoAlgos/plugins/ME0MuonTrackCollProducer.cc @@ -0,0 +1,95 @@ + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "DataFormats/MuonDetId/interface/DTChamberId.h" +#include "DataFormats/MuonDetId/interface/MuonSubdetId.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "RecoMuon/MuonIdentification/plugins/ME0MuonSelector.cc" +#include "FWCore/Framework/interface/ESHandle.h" + +#include + +#include +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" +#include "DataFormats/MuonReco/interface/ME0Muon.h" +#include "DataFormats/MuonReco/interface/ME0MuonCollection.h" +#include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h" +#include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" + +class ME0MuonTrackCollProducer : public edm::stream::EDProducer<> { +public: + explicit ME0MuonTrackCollProducer(const edm::ParameterSet&); + //std::vector findSimVtx(edm::Event& iEvent); + ~ME0MuonTrackCollProducer(); + +private: + virtual void produce(edm::Event&, const edm::EventSetup&) override; + edm::Handle > OurMuons; + //edm::Handle muonCollectionH; + edm::InputTag OurMuonsTag; + std::vector selectionTags; + const edm::ParameterSet parset_; + edm::EDGetTokenT OurMuonsToken_; +}; + + +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(ME0MuonTrackCollProducer); + + +ME0MuonTrackCollProducer::ME0MuonTrackCollProducer(const edm::ParameterSet& parset) : + OurMuonsTag(parset.getParameter("me0MuonTag")), + selectionTags(parset.getParameter< std::vector >("selectionTags")), + parset_(parset) +{ + produces(); + OurMuonsToken_ = consumes(OurMuonsTag); +} + +ME0MuonTrackCollProducer::~ME0MuonTrackCollProducer() { +} + +void ME0MuonTrackCollProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace reco; + using namespace edm; + Handle OurMuons; + iEvent.getByToken(OurMuonsToken_,OurMuons); + + + std::auto_ptr selectedTracks(new reco::TrackCollection); + + reco::TrackRefProd rTracks = iEvent.getRefBeforePut(); + + + + for(std::vector::const_iterator thismuon = OurMuons->begin(); + thismuon != OurMuons->end(); ++thismuon) { + + if (!muon::isGoodMuon(*thismuon, muon::Tight)) continue; + reco::TrackRef trackref; + + if (thismuon->innerTrack().isNonnull()) trackref = thismuon->innerTrack(); + + const reco::Track* trk = &(*trackref); + // pointer to old track: + //reco::Track* newTrk = new reco::Track(*trk); + + selectedTracks->push_back( *trk ); + //selectedTrackExtras->push_back( *newExtra ); + } + iEvent.put(selectedTracks); + +} diff --git a/CommonTools/RecoAlgos/python/me0Associator.py b/CommonTools/RecoAlgos/python/me0Associator.py new file mode 100644 index 0000000000000..f5de9d5d7845b --- /dev/null +++ b/CommonTools/RecoAlgos/python/me0Associator.py @@ -0,0 +1,12 @@ +import FWCore.ParameterSet.Config as cms + + +#----------ME0Muon Collection Production for association by chi2 +me0muon = cms.EDProducer("ME0MuonTrackCollProducer", + me0MuonTag = cms.InputTag("me0SegmentMatching"), + selectionTags = cms.vstring('All'), + ) +#-------------------- +me0muonColl_seq = cms.Sequence( + me0muon + ) diff --git a/DataFormats/MuonReco/BuildFile.xml b/DataFormats/MuonReco/BuildFile.xml index 3148aa0399e07..2429f58146204 100644 --- a/DataFormats/MuonReco/BuildFile.xml +++ b/DataFormats/MuonReco/BuildFile.xml @@ -4,8 +4,8 @@ + - diff --git a/DataFormats/MuonReco/interface/EmulatedME0Segment.h b/DataFormats/MuonReco/interface/EmulatedME0Segment.h new file mode 100644 index 0000000000000..9cd1f46609778 --- /dev/null +++ b/DataFormats/MuonReco/interface/EmulatedME0Segment.h @@ -0,0 +1,76 @@ +#ifndef DataFormats_MuonReco_EmulatedME0Segment_h +#define DataFormats_MuonReco_EmulatedME0Segment_h + +/** \class EmulatedME0Segment + * Describes a simulated track segment in a z-plane modeling an ME0 chamber. + * It is modeled after CSCSegment, so it is a 4-dimensional object ( origin (x,y) , direction (x,y) ) + * Formally it must be defined as a LocalPoint and LocalError but we actually use the global coordinate system. + * + * + * \author David Nash + */ + +#include + +#include + +class EmulatedME0Segment : public RecSegment { + +public: + + /// Default constructor + EmulatedME0Segment() : theOrigin(0,0,0), theLocalDirection(0,0,0), theCovMatrix(4,0),theChi2(0.) {} + + /// Constructor + EmulatedME0Segment(const LocalPoint& origin, const LocalVector& direction, const AlgebraicSymMatrix& errors, const double chi2); + + /// Destructor + virtual ~EmulatedME0Segment(); + + //--- Base class interface + EmulatedME0Segment* clone() const { return new EmulatedME0Segment(*this); } + + virtual LocalPoint localPosition() const { return theOrigin; } + LocalError localPositionError() const ; + + LocalVector localDirection() const { return theLocalDirection; } + LocalError localDirectionError() const ; + + /// Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y ) + AlgebraicVector parameters() const; + + /// Covariance matrix of parameters() + virtual AlgebraicSymMatrix parametersError() const { return theCovMatrix; } + + /// The projection matrix relates the trajectory state parameters to the segment parameters(). + AlgebraicMatrix projectionMatrix() const; + + virtual std::vector recHits() const {return std::vector (); } + + virtual std::vector recHits() {return std::vector();} + + virtual double chi2() const { return theChi2; } + + virtual int dimension() const { return 4; } + + virtual int degreesOfFreedom() const { return -1;} //Maybe change later? + + //--- Extension of the interface + + int nRecHits() const { return 0;} //theME0RecHits.size(); } + + void print() const; + + private: + + //std::vector theME0RecHits; + // CAVEAT: these "Local" paramaters will in fact be filled by global coordinates + LocalPoint theOrigin; // in chamber frame - the GeomDet local coordinate system + LocalVector theLocalDirection; // in chamber frame - the GeomDet local coordinate system + AlgebraicSymMatrix theCovMatrix; // the covariance matrix + double theChi2; +}; + +std::ostream& operator<<(std::ostream& os, const EmulatedME0Segment& seg); + +#endif // ME0RecHit_EmulatedME0Segment_h diff --git a/DataFormats/MuonReco/interface/EmulatedME0SegmentCollection.h b/DataFormats/MuonReco/interface/EmulatedME0SegmentCollection.h new file mode 100644 index 0000000000000..aa83686c3288d --- /dev/null +++ b/DataFormats/MuonReco/interface/EmulatedME0SegmentCollection.h @@ -0,0 +1,23 @@ + +#ifndef DataFormats_EmulatedME0SegmentCollection_H +#define DataFormats_EmulatedME0SegmentCollection_H + +/** \class EmulatedME0SegmentCollection + * + * The collection of EmulatedME0Segment's. See \ref EmulatedME0SegmentCollection.h for details. + * + * \author Matteo Sani + */ + +#include +#include + +/// collection of EmulatedME0Segments +typedef std::vector EmulatedME0SegmentCollection; + +/// persistent reference to a EmulatedME0Segment +typedef edm::Ref EmulatedME0SegmentRef; + +#endif + + diff --git a/DataFormats/MuonReco/interface/ME0Muon.h b/DataFormats/MuonReco/interface/ME0Muon.h new file mode 100644 index 0000000000000..f277250cd088e --- /dev/null +++ b/DataFormats/MuonReco/interface/ME0Muon.h @@ -0,0 +1,87 @@ +#ifndef MuonReco_ME0Muon_h +#define MuonReco_ME0Muon_h +/** \class reco::ME0Muon ME0Muon.h DataFormats/MuonReco/interface/ME0Muon.h + * + * \author David Nash NEU + * + * + */ +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "DataFormats/GeometryVector/interface/GlobalVector.h" +#include "DataFormats/Math/interface/AlgebraicROOTObjects.h" + +#include + +#include "DataFormats/RecoCandidate/interface/RecoCandidate.h" + +namespace reco { + + class ME0Muon : public RecoCandidate{ + public: + ME0Muon(); + //ME0Muon( const TrackRef & t, const ME0Segment & s) { innerTrack_ = t; me0Segment_ = s;} + ME0Muon( const TrackRef & t, const ME0Segment & s, const int v, const double c) { innerTrack_ = t; me0Segment_ = s; me0segid_=v; trackCharge_ = c;} + virtual ~ME0Muon(){} + + /// reference to Track reconstructed in the tracker only + TrackRef innerTrack() const { return innerTrack_; } + virtual TrackRef track() const { return innerTrack(); } + /// set reference to Track + void setInnerTrack( const TrackRef & t ) { innerTrack_ = t; } + void setTrack( const TrackRef & t ) { setInnerTrack(t); } + /// set reference to our new ME0Segment type + void setME0Segment( const ME0Segment & s ) { me0Segment_ = s; } + + const ME0Segment& me0segment() const { return me0Segment_; } + + //Added for testing + void setme0segid( const int v){me0segid_=v;} + int me0segid() const {return me0segid_;} + + + const GlobalPoint& globalTrackPosAtSurface() const { return globalTrackPosAtSurface_; } + const GlobalVector& globalTrackMomAtSurface() const { return globalTrackMomAtSurface_; } + const LocalPoint& localTrackPosAtSurface() const { return localTrackPosAtSurface_; } + const LocalVector& localTrackMomAtSurface() const { return localTrackMomAtSurface_; } + + int trackCharge() const { return trackCharge_; } + const AlgebraicSymMatrix66& globalTrackCov() const { return globalTrackCov_; } + const AlgebraicSymMatrix55& localTrackCov() const { return localTrackCov_; } + + void setGlobalTrackPosAtSurface(const GlobalPoint& globalTrackPosAtSurface) { globalTrackPosAtSurface_ = globalTrackPosAtSurface; } + void setGlobalTrackMomAtSurface(const GlobalVector& globalTrackMomAtSurface) { globalTrackMomAtSurface_ = globalTrackMomAtSurface; } + void setLocalTrackPosAtSurface(const LocalPoint& localTrackPosAtSurface) { localTrackPosAtSurface_ = localTrackPosAtSurface; } + void setLocalTrackMomAtSurface(const LocalVector& localTrackMomAtSurface) { localTrackMomAtSurface_ = localTrackMomAtSurface; } + void setTrackCharge(const int& trackCharge) { trackCharge_ = trackCharge; } + void setGlobalTrackCov(const AlgebraicSymMatrix66& trackCov) { globalTrackCov_ = trackCov; } + void setLocalTrackCov(const AlgebraicSymMatrix55& trackCov) { localTrackCov_ = trackCov; } + + private: + /// check overlap with another candidate + virtual bool overlap( const Candidate & ) const; + + /// reference to Track reconstructed in the tracker only + TrackRef innerTrack_; + ME0Segment me0Segment_; + int me0segid_; + + GlobalPoint globalTrackPosAtSurface_; + GlobalVector globalTrackMomAtSurface_; + + LocalPoint localTrackPosAtSurface_; + LocalVector localTrackMomAtSurface_; + int trackCharge_; + AlgebraicSymMatrix66 globalTrackCov_; + AlgebraicSymMatrix55 localTrackCov_; + + //double xpull_,ypull_,xdiff_,ydiff_,phidirdiff_; + }; + +} + + +#endif + + diff --git a/DataFormats/MuonReco/interface/ME0MuonCollection.h b/DataFormats/MuonReco/interface/ME0MuonCollection.h new file mode 100644 index 0000000000000..06eebc1a2ed41 --- /dev/null +++ b/DataFormats/MuonReco/interface/ME0MuonCollection.h @@ -0,0 +1,22 @@ +#ifndef DataFormats_ME0MuonCollection_H +#define DataFormats_ME0MuonCollection_H + +/** \class ME0MuonCollection + * + * The collection of ME0Muon's. See \ref ME0MuonCollection.h for details. + * + * $Date: 2010/03/12 13:08:15 $ + * \author David Nash + */ + +#include "DataFormats/MuonReco/interface/ME0Muon.h" +#include "DataFormats/Common/interface/Ref.h" + +/// collection of ME0Muons +typedef std::vector ME0MuonCollection; + +/// persistent reference to a ME0Muon +typedef edm::Ref ME0MuonRef; + + +#endif diff --git a/DataFormats/MuonReco/src/EmulatedME0Segment.cc b/DataFormats/MuonReco/src/EmulatedME0Segment.cc new file mode 100644 index 0000000000000..e03d31cfd9462 --- /dev/null +++ b/DataFormats/MuonReco/src/EmulatedME0Segment.cc @@ -0,0 +1,74 @@ +/** \file ME0Segment.cc + * + * $Date: 2013/04/22 22:41:33 $ + * \author David Nash + */ + +#include +#include + +EmulatedME0Segment::EmulatedME0Segment(const LocalPoint& origin, const LocalVector& direction, const AlgebraicSymMatrix& errors, const double chi2) : + theOrigin(origin), + theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2) { +} + +EmulatedME0Segment::~EmulatedME0Segment() {} + +LocalError EmulatedME0Segment::localPositionError() const { + return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]); +} + +LocalError EmulatedME0Segment::localDirectionError() const { + return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); +} + + +AlgebraicVector EmulatedME0Segment::parameters() const { + // For consistency with DT and what we require for the TrackingRecHit interface, + // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z) + + AlgebraicVector result(4); + + result[0] = theLocalDirection.x()/theLocalDirection.z(); + result[1] = theLocalDirection.y()/theLocalDirection.z(); + result[2] = theOrigin.x(); + result[3] = theOrigin.y(); + + return result; +} + +namespace{ + AlgebraicMatrix createStaticMatrix(){ + AlgebraicMatrix m( 4, 5, 0); + m[0][1] = 1; + m[1][2] = 1; + m[2][3] = 1; + m[3][4] = 1; + return m; + } +}; + +namespace{ + static const AlgebraicMatrix theProjectionMatrix = createStaticMatrix(); +}; + +AlgebraicMatrix EmulatedME0Segment::projectionMatrix() const { + return theProjectionMatrix; +} + + + +// +void EmulatedME0Segment::print() const { + std::cout << *this << std::endl; +} + +std::ostream& operator<<(std::ostream& os, const EmulatedME0Segment& seg) { + os << "EmulatedME0Segment: local pos = " << seg.localPosition() << + " posErr = (" << sqrt(seg.localPositionError().xx())<<","<( & c ); + return ( o != 0 && + ( checkOverlap( track(), o->track() )) + ); +} diff --git a/DataFormats/MuonReco/src/classes.h b/DataFormats/MuonReco/src/classes.h index c2b3421c83d40..c1b9bab30afdb 100755 --- a/DataFormats/MuonReco/src/classes.h +++ b/DataFormats/MuonReco/src/classes.h @@ -24,6 +24,11 @@ #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/Common/interface/AssociationMap.h" #include "DataFormats/MuonReco/interface/DYTInfo.h" +#include +#include + +#include +#include #include #include @@ -137,6 +142,22 @@ namespace DataFormats_MuonReco { edm::PtrVector pv_muon; edm::Wrapper > w_pv_muon; + //ME0 block + EmulatedME0Segment seg; + std::vector segs; + edm::Wrapper< std::vector > dwc1; + + reco::ME0Muon muon; + std::vector muons; + edm::Wrapper< std::vector > dwc2; + + ME0MuonCollection muoncol; + edm::Wrapper mcw1; + edm::Ref mcr1; + + EmulatedME0SegmentCollection segcol; + edm::Wrapper scw1; + edm::Ref scr1; }; } diff --git a/DataFormats/MuonReco/src/classes_def.xml b/DataFormats/MuonReco/src/classes_def.xml index 38611de36f191..ee72ca5d46887 100644 --- a/DataFormats/MuonReco/src/classes_def.xml +++ b/DataFormats/MuonReco/src/classes_def.xml @@ -177,5 +177,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py b/RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py index 0d5fb51fb5d45..90a75fa2747a2 100644 --- a/RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py +++ b/RecoLocalMuon/GEMRecHit/python/me0LocalReco_cff.py @@ -1,6 +1,6 @@ import FWCore.ParameterSet.Config as cms from RecoLocalMuon.GEMRecHit.me0RecHits_cfi import * -from RecoLocalMuon.GEMRecHit.me0Segments_cfi import * +from RecoLocalMuon.GEMSegment.me0Segments_cfi import * me0LocalReco = cms.Sequence(me0RecHits*me0Segments) diff --git a/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py b/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py new file mode 100644 index 0000000000000..84c8de8ae807e --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py @@ -0,0 +1,111 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: step2 -s DIGI --conditions auto:run2_mc --magField 38T_PostLS1 --datatier GEN-SIM-DIGI --geometry Extended2015MuonGEMDev,Extended2015MuonGEMDevReco --eventcontent FEVTDEBUGHLT --era Run2_25ns --customise=SimMuon/GEMDigitizer/customizeGEMDigi.customize_digi_addGEM_nocalo,SLHCUpgradeSimulations/Configuration/fixMissingUpgradeGTPayloads.fixRPCConditions,SLHCUpgradeSimulations/Configuration/me0Customs.customise -n 100 --no_exec --filein file:out_sim.root --fileout out_digi.root --python_filename SingleMuPt100_cfi_DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('DIGI',eras.Run2_25ns) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDevReco_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100) +) + +# Input source +process.source = cms.Source("PoolSource", + dropDescendantsOfDroppedBranches = cms.untracked.bool(False), + fileNames = cms.untracked.vstring('file:out_sim.root'), + inputCommands = cms.untracked.vstring('keep *', + 'drop *_genParticles_*_*', + 'drop *_genParticlesForJets_*_*', + 'drop *_kt4GenJets_*_*', + 'drop *_kt6GenJets_*_*', + 'drop *_iterativeCone5GenJets_*_*', + 'drop *_ak4GenJets_*_*', + 'drop *_ak7GenJets_*_*', + 'drop *_ak8GenJets_*_*', + 'drop *_ak4GenJetsNoNu_*_*', + 'drop *_ak8GenJetsNoNu_*_*', + 'drop *_genCandidatesForMET_*_*', + 'drop *_genParticlesForMETAllVisible_*_*', + 'drop *_genMetCalo_*_*', + 'drop *_genMetCaloAndNonPrompt_*_*', + 'drop *_genMetTrue_*_*', + 'drop *_genMetIC5GenJs_*_*'), + secondaryFileNames = cms.untracked.vstring() +) + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('step2 nevts:100'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(1048576), + fileName = cms.untracked.string('out_digi.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + +# Path and EndPath definitions +process.digitisation_step = cms.Path(process.pdigi) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.digitisation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) + +# customisation of the process. + +# Automatic addition of the customisation function from SimMuon.GEMDigitizer.customizeGEMDigi +from SimMuon.GEMDigitizer.customizeGEMDigi import customize_digi_addGEM_nocalo + +#call to customisation function customize_digi_addGEM_nocalo imported from SimMuon.GEMDigitizer.customizeGEMDigi +process = customize_digi_addGEM_nocalo(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads +from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads import fixRPCConditions + +#call to customisation function fixRPCConditions imported from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads +process = fixRPCConditions(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.me0Customs +from SLHCUpgradeSimulations.Configuration.me0Customs import customise + +#call to customisation function customise imported from SLHCUpgradeSimulations.Configuration.me0Customs +process = customise(process) + +# End of customisation functions + diff --git a/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_GEM-SIM-DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py b/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_GEM-SIM-DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py new file mode 100644 index 0000000000000..3b4235473ee78 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_GEM-SIM-DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py @@ -0,0 +1,122 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: SingleMuPt100_cfi -s GEN,SIM,DIGI --conditions auto:run2_mc --magField 38T_PostLS1 --datatier GEN-SIM-DIGI --geometry Extended2015MuonGEMDev,Extended2015MuonGEMDevReco --eventcontent FEVTDEBUGHLT --era Run2_25ns --customise=SimMuon/GEMDigitizer/customizeGEMDigi.customize_digi_addGEM_nocalo,SLHCUpgradeSimulations/Configuration/fixMissingUpgradeGTPayloads.fixRPCConditions,SLHCUpgradeSimulations/Configuration/me0Customs.customise -n 100 --no_exec --fileout out_digi.root --python_filename SingleMuPt100_cfi_GEM-SIM-DIGI_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('DIGI',eras.Run2_25ns) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDevReco_cff') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDev_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedNominalCollision2015_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('SingleMuPt100_cfi nevts:100'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(1048576), + fileName = cms.untracked.string('out_digi.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + +process.generator = cms.EDProducer("FlatRandomPtGunProducer", + AddAntiParticle = cms.bool(True), + PGunParameters = cms.PSet( + MaxEta = cms.double(2.5), + MaxPhi = cms.double(3.14159265359), + MaxPt = cms.double(100.01), + MinEta = cms.double(-2.5), + MinPhi = cms.double(-3.14159265359), + MinPt = cms.double(99.99), + PartID = cms.vint32(-13) + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('single mu pt 100') +) + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path)._seq = process.generator * getattr(process,path)._seq + +# customisation of the process. + +# Automatic addition of the customisation function from SimMuon.GEMDigitizer.customizeGEMDigi +from SimMuon.GEMDigitizer.customizeGEMDigi import customize_digi_addGEM_nocalo + +#call to customisation function customize_digi_addGEM_nocalo imported from SimMuon.GEMDigitizer.customizeGEMDigi +process = customize_digi_addGEM_nocalo(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads +from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads import fixRPCConditions + +#call to customisation function fixRPCConditions imported from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads +process = fixRPCConditions(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.me0Customs +from SLHCUpgradeSimulations.Configuration.me0Customs import customise + +#call to customisation function customise imported from SLHCUpgradeSimulations.Configuration.me0Customs +process = customise(process) + +# End of customisation functions + diff --git a/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_GEM-SIM_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py b/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_GEM-SIM_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py new file mode 100644 index 0000000000000..8121c6179b555 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/test/SingleMuPt100_cfi_GEM-SIM_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py @@ -0,0 +1,108 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: SingleMuPt100_cfi -s GEN,SIM --conditions auto:run2_mc --magField 38T_PostLS1 --datatier GEN-SIM --geometry Extended2015MuonGEMDev,Extended2015MuonGEMDevReco --eventcontent FEVTDEBUGHLT --era Run2_25ns --customise=SLHCUpgradeSimulations/Configuration/me0Customs.customise -n 100 --no_exec --fileout out_sim.root --python_filename SingleMuPt100_cfi_GEM-SIM_Extended2015MuonGEMDev_RPCGEMME0Customs_cfg.py +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('SIM',eras.Run2_25ns) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDevReco_cff') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDev_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedNominalCollision2015_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('SingleMuPt100_cfi nevts:100'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM'), + filterName = cms.untracked.string('') + ), + eventAutoFlushCompressedSize = cms.untracked.int32(1048576), + fileName = cms.untracked.string('out_sim.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + +process.generator = cms.EDProducer("FlatRandomPtGunProducer", + AddAntiParticle = cms.bool(True), + PGunParameters = cms.PSet( + MaxEta = cms.double(2.5), + MaxPhi = cms.double(3.14159265359), + MaxPt = cms.double(100.01), + MinEta = cms.double(-2.5), + MinPhi = cms.double(-3.14159265359), + MinPt = cms.double(99.99), + PartID = cms.vint32(-13) + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('single mu pt 100') +) + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path)._seq = process.generator * getattr(process,path)._seq + +# customisation of the process. + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.me0Customs +from SLHCUpgradeSimulations.Configuration.me0Customs import customise + +#call to customisation function customise imported from SLHCUpgradeSimulations.Configuration.me0Customs +process = customise(process) + +# End of customisation functions + diff --git a/RecoLocalMuon/GEMRecHit/test/runTestUpgradeGEMME0Reco_cfg.py b/RecoLocalMuon/GEMRecHit/test/runTestUpgradeGEMME0Reco_cfg.py new file mode 100644 index 0000000000000..ac74c1e5a4096 --- /dev/null +++ b/RecoLocalMuon/GEMRecHit/test/runTestUpgradeGEMME0Reco_cfg.py @@ -0,0 +1,287 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("MyMuonRECO") + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1)) + +# Process options :: +# - wantSummary helps to understand which module crashes +# - skipEvent skips event in case a product was not found +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True), + # SkipEvent = cms.untracked.vstring('ProductNotFound') + ) + + + +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDevReco_cff') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDev_cff') +process.load("Configuration.StandardSequences.MagneticField_cff") # recommended configuration +# process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') # deprecated configuration +# Be careful here ot to load Configuration.StandardSequences.Reconstruction_cff +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + + +### Try to do RecoLocalMuon on all muon detectors ### +##################################################### +process.load('RecoLocalMuon.GEMRecHit.gemRecHits_cfi') +#process.load('RecoLocalMuon.GEMRecHit.me0RecHits_cfi') +process.load('RecoLocalMuon.GEMRecHit.me0LocalReco_cff') +process.load("RecoLocalMuon.Configuration.RecoLocalMuon_cff") + +### me0Muon reco now +process.load('RecoMuon.MuonIdentification.me0MuonReco_cff') + + +### Try to add also Tracker local reco ### +########################################## +# Digi2Raw and Raw2Digi for Tracker Dets: +process.load("EventFilter.SiPixelRawToDigi.SiPixelDigiToRaw_cfi") +process.load("EventFilter.SiPixelRawToDigi.SiPixelRawToDigi_cfi") +process.load("EventFilter.SiStripRawToDigi.SiStripDigiToRaw_cfi") +process.load("EventFilter.SiStripRawToDigi.SiStripDigis_cfi") +process.siStripDigis.ProductLabel = cms.InputTag('SiStripDigiToRaw') + +# -------------------------- +# - Sources of Information - +# ----------------------------------------------------------------- +# Configuration/StandardSequences/python/Reconstruction_cff.py +# RecoTracker/Configuration/python/customiseForRunI.py +# RecoTracker/Configuration/python/RecoTrackerRunI_cff.py +# RecoTracker/IterativeTracking/python/RunI_iterativeTk_cff.py +# tgrIndex = process.globalreco.index(process.trackingGlobalReco) +# ----------------------------------------------------------------- +# Twiki pages I should consider to read: +# https://twiki.cern.ch/twiki/bin/view/CMS/AndreaBocciTracking +# https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideIterativeTracking?redirectedfrom=CMS.SWGuideIterativeTracking +# ----------------------------------------------------------------- + +# -------------------------- +# - Local Reco for Tracker - +# ----------------------------------------------------------------- +process.load("RecoLocalTracker.Configuration.RecoLocalTracker_cff") +# for Local Reco for Tracker in Run-I we need to load & redefine: +process.load("RecoLocalTracker.SiPixelClusterizer.SiPixelClusterizer_cfi") +process.load("RecoPixelVertexing.Configuration.RecoPixelVertexing_cff") +# Run-II Local Reco +# process.pixeltrackerlocalreco = cms.Sequence(process.siPixelClustersPreSplitting*process.siPixelRecHitsPreSplitting) +# process.striptrackerlocalreco = cms.Sequence(process.siStripZeroSuppression*process.siStripClusters*process.siStripMatchedRecHits) +# process.trackerlocalreco = cms.Sequence(process.pixeltrackerlocalreco*process.striptrackerlocalreco*process.clusterSummaryProducer) +# Run-I Local Reco +process.pixeltrackerlocalreco = cms.Sequence(process.siPixelClusters*process.siPixelRecHits) +process.striptrackerlocalreco = cms.Sequence(process.siStripZeroSuppression*process.siStripClusters*process.siStripMatchedRecHits) +process.trackerlocalreco = cms.Sequence(process.pixeltrackerlocalreco*process.striptrackerlocalreco*process.clusterSummaryProducerNoSplitting) +# ----------------------------------------------------------------- + + +# --------------------------- +# - Global Reco for Tracker - +# ----------------------------------------------------------------- +# Run-2 configuration ... will not work because of Calo dependencies +# process.load("RecoTracker.Configuration.RecoTracker_cff") +# Run-1 configuration ... should work stand-alone +# process.load("RecoTracker.Configuration.RecoTrackerRunI_cff") +# taking iterTracking from this file, +# removing all dEdX, EcalSeeds and trackExtrapolations for (B-)Jets +process.load("RecoTracker.IterativeTracking.RunI_iterativeTk_cff") +process.load("RecoTracker.CkfPattern.CkfTrackCandidates_cff") +process.ckftracks = cms.Sequence(process.iterTracking) +process.trackingGlobalReco = cms.Sequence(process.ckftracks) + +# Now get rid of spurious reference to JetCore step +process.earlyGeneralTracks.trackProducers = ['initialStepTracks', + 'lowPtTripletStepTracks', + 'pixelPairStepTracks', + 'detachedTripletStepTracks', + 'mixedTripletStepTracks', + 'pixelLessStepTracks', + 'tobTecStepTracks' + ] + +process.earlyGeneralTracks.inputClassifiers =["initialStepSelector", + "lowPtTripletStepSelector", + "pixelPairStepSelector", + "detachedTripletStep", + "mixedTripletStep", + "pixelLessStepSelector", + "tobTecStep" + ] + +# Now restore pixelVertices wherever was not possible with an ad-hoc RunI cfg +process.muonSeededTracksInOutClassifier.vertices = 'pixelVertices' +process.muonSeededTracksOutInClassifier.vertices = 'pixelVertices' +process.duplicateTrackClassifier.vertices = 'pixelVertices' +process.convStepSelector.vertices = 'pixelVertices' +# because of removal of dEdX, EcalSeeds and trackExtrapolations +# following processes are not called, therefore pixelVertices not restored +# process.muonSeededTracksOutInDisplacedClassifier.vertices = 'pixelVertices' +# process.duplicateDisplacedTrackClassifier.vertices = 'pixelVertices' +# process.pixelPairElectronSeeds.RegionFactoryPSet.RegionPSet.VertexCollection = 'pixelVertices' +# process.ak4CaloJetsForTrk.srcPVs = 'pixelVertices' +# process.photonConvTrajSeedFromSingleLeg.primaryVerticesTag = 'pixelVertices' + +# ... and finally turn off all possible references to CCC: this is +# done by switching off the Tight and Loose reftoPSet, rather than +# following all the places in which they are effectively used in +# release. The RunI-like tracking already uses CCCNone: this will +# be useful mainly for conversions. +process.SiStripClusterChargeCutTight.value = -1. +process.SiStripClusterChargeCutLoose.value = -1 + +# Defaults are ok here ... +# process.earlyMuons.TrackAssociatorParameters.useMuon = cms.bool(True) +# process.earlyMuons.TrackAssociatorParameters.useHO = cms.bool(False) +# process.earlyMuons.TrackAssociatorParameters.useEcal = cms.bool(False) +# process.earlyMuons.TrackAssociatorParameters.useHcal = cms.bool(False) +# process.earlyMuons.TrackAssociatorParameters.useCalo = cms.bool(False) +# process.earlyMuons.TrackAssociatorParameters.usePreShower = cms.bool(False) + +# Global Reco for Tracker, including BeamSpot, Vertices, special Muon Tracking +process.load("RecoTracker.MeasurementDet.MeasurementTrackerEventProducer_cfi") +process.load("RecoPixelVertexing.PixelLowPtUtilities.siPixelClusterShapeCache_cfi") +# necessary for Run-II +# process.siPixelClusterShapeCachePreSplitting = process.siPixelClusterShapeCache.clone( +# src = 'siPixelClustersPreSplitting' +# ) +process.load("RecoVertex.Configuration.RecoVertex_cff") +process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff") +process.load("RecoTracker.TkSeedingLayers.PixelLayerTriplets_cfi") + +# redefine the process vertexreco +# check modification in RecoVertex/Configuration/python/RecoVertex_cff.py +# the Run-II configuration has been commented out +# process.vertexreco = cms.Sequence(process.offlinePrimaryVertices*process.offlinePrimaryVerticesWithBS*process.generalV0Candidates*process.inclusiveVertexing) + +# process.vertexreco.remove(process.caloTowerForTrk) +# process.vertexreco.remove(process.ak4CaloJetsForTrk) +# process.sortedPrimaryVertices.jets = "" + + +### Can we do also Muon Global Reco? ### +######################################## +process.load("RecoMuon.Configuration.RecoMuon_cff") +# process.load("RecoVertex.Configuration.RecoVertex_cff") +# process.load("RecoPixelVertexing.Configuration.RecoPixelVertexing_cff") +# process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff") + +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + + +# Fix DT and CSC Alignment # +############################ +# does this work actually? +from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads import fixDTAlignmentConditions +process = fixDTAlignmentConditions(process) +from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads import fixCSCAlignmentConditions +process = fixCSCAlignmentConditions(process) + + +# Skip Digi2Raw and Raw2Digi steps for Al Muon detectors # +########################################################## +process.gemRecHits.gemDigiLabel = cms.InputTag("simMuonGEMDigis","","GEMDIGI") +process.rpcRecHits.rpcDigiLabel = cms.InputTag('simMuonRPCDigis') +process.csc2DRecHits.wireDigiTag = cms.InputTag("simMuonCSCDigis","MuonCSCWireDigi") +process.csc2DRecHits.stripDigiTag = cms.InputTag("simMuonCSCDigis","MuonCSCStripDigi") +process.dt1DRecHits.dtDigiLabel = cms.InputTag("simMuonDTDigis") +process.dt1DCosmicRecHits.dtDigiLabel = cms.InputTag("simMuonDTDigis") + + +# Explicit configuration of CSC for postls1 = run2 # +#################################################### +process.load("CalibMuon.CSCCalibration.CSCChannelMapper_cfi") +process.load("CalibMuon.CSCCalibration.CSCIndexer_cfi") +process.CSCIndexerESProducer.AlgoName = cms.string("CSCIndexerPostls1") +process.CSCChannelMapperESProducer.AlgoName = cms.string("CSCChannelMapperPostls1") +process.CSCGeometryESModule.useGangedStripsInME1a = False +process.csc2DRecHits.readBadChannels = cms.bool(False) +process.csc2DRecHits.CSCUseGasGainCorrections = cms.bool(False) +# process.csc2DRecHits.wireDigiTag = cms.InputTag("simMuonCSCDigis","MuonCSCWireDigi") +# process.csc2DRecHits.stripDigiTag = cms.InputTag("simMuonCSCDigis","MuonCSCStripDigi") + +process.gemRecHits = cms.EDProducer("GEMRecHitProducer", + recAlgoConfig = cms.PSet(), + recAlgo = cms.string('GEMRecHitStandardAlgo'), + gemDigiLabel = cms.InputTag("simMuonGEMDigis"), + # maskSource = cms.string('File'), + # maskvecfile = cms.FileInPath('RecoLocalMuon/GEMRecHit/data/GEMMaskVec.dat'), + # deadSource = cms.string('File'), + # deadvecfile = cms.FileInPath('RecoLocalMuon/GEMRecHit/data/GEMDeadVec.dat') +) + + + +### Input and Output Files +########################## +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring( + 'file:out_digi.root' + ) +) + +process.output = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string( + 'file:out_local_reco.root' + ), + outputCommands = cms.untracked.vstring( + 'keep *_*_*_*', + ), + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('localreco_step', 'globalreco_step') + ) +) + +### TO ACTIVATE LogTrace one NEEDS TO COMPILE IT WITH: +### ----------------------------------------------------------- +### --> scram b -j8 USER_CXXFLAGS="-DEDM_ML_DEBUG" +### Make sure that you first cleaned your CMSSW version: +### --> scram b clean +### before issuing the scram command above +### ----------------------------------------------------------- +### LogTrace output goes to cout; all other output to "junk.log" +############################################################### +# process.load("FWCore.MessageLogger.MessageLogger_cfi") +# process.MessageLogger.categories.append("MuonIdentification") +# process.MessageLogger.categories.append("TrackAssociator") +# process.MessageLogger.debugModules = cms.untracked.vstring("*") +# process.MessageLogger.destinations = cms.untracked.vstring("cout","junk") +# process.MessageLogger.cout = cms.untracked.PSet( +# threshold = cms.untracked.string("DEBUG"), +# default = cms.untracked.PSet( limit = cms.untracked.int32(0) ), +# FwkReport = cms.untracked.PSet( limit = cms.untracked.int32(-1) ), +# MuonIdentification = cms.untracked.PSet( limit = cms.untracked.int32(-1) ), +# TrackAssociator = cms.untracked.PSet( limit = cms.untracked.int32(-1) ), +# ) + + + + +### Paths and Schedules +####################### +process.digi2raw_step = cms.Path(process.siPixelRawData+process.SiStripDigiToRaw) +process.raw2digi_step = cms.Path(process.siPixelDigis+process.siStripDigis) +#process.localreco_step = cms.Path(process.muonlocalreco+process.gemRecHits+process.me0RecHits+process.trackerlocalreco) +process.localreco_step = cms.Path(process.muonlocalreco+process.gemRecHits+process.me0LocalReco+process.trackerlocalreco) + +# Run-2 Global Reco Step: +# process.globalreco_step = cms.Path(process.offlineBeamSpot*process.MeasurementTrackerEventPreSplitting*process.siPixelClusterShapeCachePreSplitting* +# process.standalonemuontracking*process.iterTracking)#process.trackingGlobalReco*process.vertexreco)#*process.muonGlobalReco) +# Run-1 Global Reco Step: (no PreSplitting before iterTracking sequence) +process.globalreco_step = cms.Path(process.offlineBeamSpot*process.MeasurementTrackerEvent*process.siPixelClusterShapeCache*process.PixelLayerTriplets*process.recopixelvertexing* + process.standalonemuontracking*process.trackingGlobalReco*process.vertexreco*process.me0MuonReco)#*process.muonGlobalReco) + +process.endjob_step = cms.Path(process.endOfProcess) +process.out_step = cms.EndPath(process.output) + +process.schedule = cms.Schedule( + process.digi2raw_step, + process.raw2digi_step, + process.localreco_step, + process.globalreco_step, + process.endjob_step, + process.out_step +) diff --git a/RecoMuon/MuonIdentification/BuildFile.xml b/RecoMuon/MuonIdentification/BuildFile.xml index abe086f5e8d7c..ac0c8b73e6791 100644 --- a/RecoMuon/MuonIdentification/BuildFile.xml +++ b/RecoMuon/MuonIdentification/BuildFile.xml @@ -26,11 +26,14 @@ + + - - + + + diff --git a/RecoMuon/MuonIdentification/interface/ME0MuonSelector.h b/RecoMuon/MuonIdentification/interface/ME0MuonSelector.h new file mode 100644 index 0000000000000..bd4ff2e82b446 --- /dev/null +++ b/RecoMuon/MuonIdentification/interface/ME0MuonSelector.h @@ -0,0 +1,37 @@ +#ifndef RecoMuon_ME0MuonSelectors_h +#define RecoMuon_ME0MuonSelectors_h +// + +#include "DataFormats/MuonReco/interface/ME0Muon.h" + +#include "FWCore/Framework/interface/ESHandle.h" + +#include + + + + +namespace muon { + /// Selector type + enum SelectionType { + All = 0, // dummy options - always true + VeryLoose = 1, // + Loose = 2, // + Tight = 3, // + }; + + /// a lightweight "map" for selection type string label and enum value + struct SelectionTypeStringToEnum { const char *label; SelectionType value; }; + SelectionType selectionTypeFromString( const std::string &label ); + + /// main GoodMuon wrapper call + bool isGoodMuon(const reco::ME0Muon& me0muon, SelectionType type ); + + + /// Specialized isGoodMuon function called from main wrapper + + bool isGoodMuon(const reco::ME0Muon& me0muon, double MaxPullX, double MaxDiffX, double MaxPullY, double MaxDiffY, double MaxDiffPhiDir ); + + +} +#endif diff --git a/RecoMuon/MuonIdentification/plugins/ME0MuonConverter.cc b/RecoMuon/MuonIdentification/plugins/ME0MuonConverter.cc new file mode 100644 index 0000000000000..bf5efd90c9187 --- /dev/null +++ b/RecoMuon/MuonIdentification/plugins/ME0MuonConverter.cc @@ -0,0 +1,128 @@ +/** \file ME0MuonConverter.cc + * + * \author David Nash + */ + + +#include +#include + +#include +#include +#include + +#include + + + +#include "DataFormats/GeometryVector/interface/GlobalVector.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "TrackingTools/GeomPropagators/interface/Propagator.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" +#include "DataFormats/TrajectorySeed/interface/PropagationDirection.h" + +#include "TLorentzVector.h" + +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" + +#include "TrackingTools/Records/interface/TrackingComponentsRecord.h" + + +#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h" +#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h" + +/** \class ME0MuonConverter + * Produces a collection of ME0Segment's in endcap muon ME0s. + * + * + * \author David Nash + */ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + + +#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h" +#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h" + + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include + + + +#include +#include + + + +class ME0MuonConverter : public edm::stream::EDProducer<> { +public: + /// Constructor + explicit ME0MuonConverter(const edm::ParameterSet&); + /// Destructor + ~ME0MuonConverter(); + /// Produce the converted collection + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + + +private: + + //edm::EDGetTokenT> OurMuonsToken_; + edm::EDGetTokenT OurMuonsToken_; +}; + + +ME0MuonConverter::ME0MuonConverter(const edm::ParameterSet& pas) { + + produces >(); + edm::InputTag OurMuonsTag ("me0SegmentMatching"); + OurMuonsToken_ = consumes(OurMuonsTag); + +} + +ME0MuonConverter::~ME0MuonConverter() {} + +void ME0MuonConverter::produce(edm::Event& ev, const edm::EventSetup& setup) { + + using namespace edm; + + using namespace reco; + + // Handle > OurMuons; + // ev.getByToken > (OurMuonsToken_, OurMuons); + + + Handle OurMuons; + ev.getByToken(OurMuonsToken_, OurMuons); + + std::auto_ptr oc( new RecoChargedCandidateCollection()); + + for (std::vector::const_iterator thisMuon = OurMuons->begin(); + thisMuon != OurMuons->end(); ++thisMuon){ + TrackRef tkRef = thisMuon->innerTrack(); + + Particle::Charge q = tkRef->charge(); + Particle::LorentzVector p4(tkRef->px(), tkRef->py(), tkRef->pz(), tkRef->p()); + Particle::Point vtx(tkRef->vx(),tkRef->vy(), tkRef->vz()); + + int pid = 0; + if(abs(q)==1) pid = q < 0 ? 13 : -13; + reco::RecoChargedCandidate cand(q, p4, vtx, pid); + cand.setTrack(thisMuon->innerTrack()); + oc->push_back(cand); + } + + ev.put(oc); +} + + + DEFINE_FWK_MODULE(ME0MuonConverter); diff --git a/RecoMuon/MuonIdentification/plugins/ME0MuonSelector.cc b/RecoMuon/MuonIdentification/plugins/ME0MuonSelector.cc new file mode 100644 index 0000000000000..c6fec57d7e061 --- /dev/null +++ b/RecoMuon/MuonIdentification/plugins/ME0MuonSelector.cc @@ -0,0 +1,91 @@ +/** + *Filter to select me0Muons based on pulls and differences w.r.t. me0Segments + * + * + */ + +#include "RecoMuon/MuonIdentification/interface/ME0MuonSelector.h" + +#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" +#include "TrackingTools/AnalyticalJacobians/interface/JacobianCartesianToLocal.h" +#include "TrackingTools/AnalyticalJacobians/interface/JacobianLocalToCartesian.h" +#include "DataFormats/Math/interface/deltaPhi.h" + + +namespace muon { +SelectionType selectionTypeFromString( const std::string &label ) +{ + const static SelectionTypeStringToEnum selectionTypeStringToEnumMap[] = { + { "All", All }, + { "VeryLoose", VeryLoose }, + { "Loose", Loose }, + { "Tight", Tight }, + { 0, (SelectionType)-1 } + }; + + SelectionType value = (SelectionType)-1; + bool found = false; + for(int i = 0; selectionTypeStringToEnumMap[i].label && (! found); ++i) + if (! strcmp(label.c_str(), selectionTypeStringToEnumMap[i].label)) { + found = true; + value = selectionTypeStringToEnumMap[i].value; + } + + // in case of unrecognized selection type + if (! found) throw cms::Exception("MuonSelectorError") << label << " is not a recognized SelectionType"; + return value; +} +} + + +bool muon::isGoodMuon(const reco::ME0Muon& me0muon, SelectionType type) +{ + switch (type) + { + case muon::All: + return true; + break; + case muon::VeryLoose: + return isGoodMuon(me0muon,3,4,20,20,3.14); + break; + case muon::Loose: + return isGoodMuon(me0muon,3,2,3,2,0.5); + break; + case muon::Tight: + return isGoodMuon(me0muon,3,2,3,2,0.15); + break; + default: + return false; + } +} + + + + +bool muon::isGoodMuon(const reco::ME0Muon& me0muon, double MaxPullX, double MaxDiffX, double MaxPullY, double MaxDiffY, double MaxDiffPhiDir ) +{ + using namespace reco; + + ME0Segment thisSegment = me0muon.me0segment(); + + + LocalPoint r3FinalReco = me0muon.localTrackPosAtSurface(); + + AlgebraicSymMatrix55 C = me0muon.localTrackCov(); + LocalPoint thisPosition(thisSegment.localPosition()); + + + double sigmax = sqrt(C[3][3]+thisSegment.localPositionError().xx() ); + double sigmay = sqrt(C[4][4]+thisSegment.localPositionError().yy() ); + + bool X_MatchFound = false, Y_MatchFound = false, Dir_MatchFound = false; + + + if ( ( (std::abs(thisPosition.x()-r3FinalReco.x())/sigmax ) < MaxPullX ) || (std::abs(thisPosition.x()-r3FinalReco.x()) < MaxDiffX ) ) X_MatchFound = true; + if ( ( (std::abs(thisPosition.y()-r3FinalReco.y())/sigmay ) < MaxPullY ) || (std::abs(thisPosition.y()-r3FinalReco.y()) < MaxDiffY ) ) Y_MatchFound = true; + if ( std::abs(reco::deltaPhi(me0muon.localTrackMomAtSurface().phi(),thisSegment.localDirection().phi())) < MaxDiffPhiDir) Dir_MatchFound = true; + + return (X_MatchFound && Y_MatchFound && Dir_MatchFound); + +} + diff --git a/RecoMuon/MuonIdentification/plugins/ME0SegmentMatcher.cc b/RecoMuon/MuonIdentification/plugins/ME0SegmentMatcher.cc new file mode 100644 index 0000000000000..48d1994168d45 --- /dev/null +++ b/RecoMuon/MuonIdentification/plugins/ME0SegmentMatcher.cc @@ -0,0 +1,363 @@ +/** \file ME0SegmentMatcher.cc + * + * \author David Nash + */ + + +#include +#include + +#include +#include + +#include + +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" + +#include "TrackingTools/Records/interface/TrackingComponentsRecord.h" + +#include "DataFormats/GeometrySurface/interface/Plane.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixStateInfo.h" +#include "DataFormats/Math/interface/deltaR.h" + + +#include "DataFormats/GeometrySurface/interface/LocalError.h" + + +#include "TLorentzVector.h" + +#include "DataFormats/TrajectoryState/interface/LocalTrajectoryParameters.h" +#include "TrackingTools/AnalyticalJacobians/interface/JacobianCartesianToLocal.h" +#include "TrackingTools/AnalyticalJacobians/interface/JacobianLocalToCartesian.h" + + +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include +#include "Geometry/GEMGeometry/interface/ME0EtaPartitionSpecs.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" +#include + + +/** \class ME0SegmentMatcher + * + * \author David Nash + */ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "DataFormats/GeometryVector/interface/GlobalVector.h" + +#include "DataFormats/Math/interface/AlgebraicROOTObjects.h" +#include "FWCore/Framework/interface/ESHandle.h" + +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include +#include +#include + +#include "FWCore/ServiceRegistry/interface/Service.h" + +#include +#include + +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "DataFormats/TrackReco/interface/Track.h" + + + + +class FreeTrajectoryState; +class MagneticField; +class ME0SegmentMatcher : public edm::stream::EDProducer<> { +public: + /// Constructor + explicit ME0SegmentMatcher(const edm::ParameterSet&); + /// Destructor + ~ME0SegmentMatcher(); + /// Produce the ME0Segment collection + virtual void produce(edm::Event&, const edm::EventSetup&) override; + + + virtual void beginRun(edm::Run const&, edm::EventSetup const&) override; + + + + FreeTrajectoryState getFTS(const GlobalVector& , const GlobalVector& , + int , const AlgebraicSymMatrix66& , + const MagneticField* ); + + FreeTrajectoryState getFTS(const GlobalVector& , const GlobalVector& , + int , const AlgebraicSymMatrix55& , + const MagneticField* ); + + void getFromFTS(const FreeTrajectoryState& , + GlobalVector& , GlobalVector& , + int& , AlgebraicSymMatrix66& ); + +private: + + + + double theX_RESIDUAL_CUT, theX_PULL_CUT, theY_RESIDUAL_CUT, theY_PULL_CUT, thePHIDIR_RESIDUAL_CUT; + edm::InputTag OurSegmentsTag, generalTracksTag; + edm::EDGetTokenT OurSegmentsToken_; + edm::EDGetTokenT generalTracksToken_; + + +}; + + +ME0SegmentMatcher::ME0SegmentMatcher(const edm::ParameterSet& pas) { + produces >(); + theX_PULL_CUT = pas.getParameter("maxPullX"); + theX_RESIDUAL_CUT = pas.getParameter("maxDiffX"); + theY_PULL_CUT = pas.getParameter("maxPullY"); + theY_RESIDUAL_CUT = pas.getParameter("maxDiffY"); + thePHIDIR_RESIDUAL_CUT = pas.getParameter("maxDiffPhiDirection"); + //Might need to replace "OurSegments" with an edm::InputTag of "OurSegments" + OurSegmentsTag = pas.getParameter("me0SegmentTag"); + generalTracksTag = pas.getParameter("tracksTag"); + OurSegmentsToken_ = consumes(OurSegmentsTag); + generalTracksToken_ = consumes(generalTracksTag); +} + +ME0SegmentMatcher::~ME0SegmentMatcher() {} + +void ME0SegmentMatcher::produce(edm::Event& ev, const edm::EventSetup& setup) { + + + //Getting the objects we'll need + using namespace edm; + + ESHandle me0Geom; + setup.get().get(me0Geom); + ESHandle bField; + setup.get().get(bField); + ESHandle ThisshProp; + setup.get().get("SteppingHelixPropagatorAlong", ThisshProp); + + using namespace reco; + + Handle OurSegments; + //ev.getByLabel("me0Segments","",OurSegments); + ev.getByToken(OurSegmentsToken_,OurSegments); + + std::auto_ptr > oc( new std::vector ); + std::vector TempStore; + + Handle generalTracks; + //ev.getByLabel ("generalTracks", generalTracks); + ev.getByToken(generalTracksToken_,generalTracks); + + + int TrackNumber = 0; + + for (std::vector::const_iterator thisTrack = generalTracks->begin(); + thisTrack != generalTracks->end(); ++thisTrack,++TrackNumber){ + //Initializing our plane + + //Remove later + if (std::abs(thisTrack->eta()) < 1.8) continue; + + float zSign = thisTrack->pz() > 0 ? 1.0f : -1.0f; + + const float zValue = 526.75 * zSign; + + Plane *plane = new Plane(Surface::PositionType(0,0,zValue),Surface::RotationType()); + + //Getting the initial variables for propagation + + int chargeReco = thisTrack->charge(); + GlobalVector p3reco, r3reco; + + p3reco = GlobalVector(thisTrack->outerPx(), thisTrack->outerPy(), thisTrack->outerPz()); + r3reco = GlobalVector(thisTrack->outerX(), thisTrack->outerY(), thisTrack->outerZ()); + + AlgebraicSymMatrix66 covReco; + //This is to fill the cov matrix correctly + AlgebraicSymMatrix55 covReco_curv; + covReco_curv = thisTrack->outerStateCovariance(); + FreeTrajectoryState initrecostate = getFTS(p3reco, r3reco, chargeReco, covReco_curv, &*bField); + getFromFTS(initrecostate, p3reco, r3reco, chargeReco, covReco); + + //Now we propagate and get the propagated variables from the propagated state + //SteppingHelixStateInfo startrecostate(initrecostate); + //SteppingHelixStateInfo lastrecostate; + TrajectoryStateOnSurface lastrecostate; + + //const SteppingHelixPropagator* ThisshProp = + //dynamic_cast(&*shProp); + + + + //lastrecostate = ThisshProp->propagate(startrecostate, *plane); + //lastrecostate = ThisshProp->propagateWithPath(startrecostate, *plane); + //ThisshProp->propagate(startrecostate, *plane,lastrecostate); + lastrecostate = ThisshProp->propagate(initrecostate,*plane); + + FreeTrajectoryState finalrecostate(*lastrecostate.freeTrajectoryState()); + //lastrecostate.getFreeState(finalrecostate); + //finalrecostate = lastrecostate.freeTrajectoryState(); + + AlgebraicSymMatrix66 covFinalReco; + GlobalVector p3FinalReco_glob, r3FinalReco_globv; + getFromFTS(finalrecostate, p3FinalReco_glob, r3FinalReco_globv, chargeReco, covFinalReco); + + + //To transform the global propagated track to local coordinates + int SegmentNumber = 0; + + reco::ME0Muon MuonCandidate; + double ClosestDelR2 = 999.; + + for (auto thisSegment = OurSegments->begin(); thisSegment != OurSegments->end(); + ++thisSegment,++SegmentNumber){ + ME0DetId id = thisSegment->me0DetId(); + + auto roll = me0Geom->etaPartition(id); + + if ( zSign * roll->toGlobal(thisSegment->localPosition()).z() < 0 ) continue; + + GlobalPoint r3FinalReco_glob(r3FinalReco_globv.x(),r3FinalReco_globv.y(),r3FinalReco_globv.z()); + + LocalPoint r3FinalReco = roll->toLocal(r3FinalReco_glob); + LocalVector p3FinalReco=roll->toLocal(p3FinalReco_glob); + + LocalPoint thisPosition(thisSegment->localPosition()); + LocalVector thisDirection(thisSegment->localDirection().x(),thisSegment->localDirection().y(),thisSegment->localDirection().z()); //FIXME + + //The same goes for the error + AlgebraicMatrix thisCov(4,4,0); + for (int i = 1; i <=4; i++){ + for (int j = 1; j <=4; j++){ + thisCov(i,j) = thisSegment->parametersError()(i,j); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////// + + + LocalTrajectoryParameters ltp(r3FinalReco,p3FinalReco,chargeReco); + JacobianCartesianToLocal jctl(roll->surface(),ltp); + AlgebraicMatrix56 jacobGlbToLoc = jctl.jacobian(); + + AlgebraicMatrix55 Ctmp = (jacobGlbToLoc * covFinalReco) * ROOT::Math::Transpose(jacobGlbToLoc); + AlgebraicSymMatrix55 C; // I couldn't find any other way, so I resort to the brute force + for(int i=0; i<5; ++i) { + for(int j=0; j<5; ++j) { + C[i][j] = Ctmp[i][j]; + + } + } + + Double_t sigmax = sqrt(C[3][3]+thisSegment->localPositionError().xx() ); + Double_t sigmay = sqrt(C[4][4]+thisSegment->localPositionError().yy() ); + + bool X_MatchFound = false, Y_MatchFound = false, Dir_MatchFound = false; + + + // if ( (std::abs(thisPosition.x()-r3FinalReco.x()) < (3.0 * sigmax)) || (std::abs(thisPosition.x()-r3FinalReco.x()) < 2.0 ) ) X_MatchFound = true; + // if ( (std::abs(thisPosition.y()-r3FinalReco.y()) < (3.0 * sigmay)) || (std::abs(thisPosition.y()-r3FinalReco.y()) < 2.0 ) ) Y_MatchFound = true; + + // if ( std::abs(p3FinalReco_glob.phi()-roll->toGlobal(thisSegment->localDirection()).phi()) < 0.15) Dir_MatchFound = true; + + + if ( (std::abs(thisPosition.x()-r3FinalReco.x()) < (theX_PULL_CUT * sigmax)) || (std::abs(thisPosition.x()-r3FinalReco.x()) < theX_RESIDUAL_CUT ) ) X_MatchFound = true; + if ( (std::abs(thisPosition.y()-r3FinalReco.y()) < (theY_PULL_CUT * sigmay)) || (std::abs(thisPosition.y()-r3FinalReco.y()) < theY_RESIDUAL_CUT ) ) Y_MatchFound = true; + + if ( std::abs(reco::deltaPhi(p3FinalReco_glob.phi(),roll->toGlobal(thisSegment->localDirection()).phi())) < thePHIDIR_RESIDUAL_CUT) Dir_MatchFound = true; + + //Check for a Match, and if there is a match, check the delR from the segment, keeping only the closest in MuonCandidate + if (X_MatchFound && Y_MatchFound && Dir_MatchFound) { + + TrackRef thisTrackRef(generalTracks,TrackNumber); + + GlobalPoint SegPos(roll->toGlobal(thisSegment->localPosition())); + GlobalPoint TkPos(r3FinalReco_globv.x(),r3FinalReco_globv.y(),r3FinalReco_globv.z()); + + double thisDelR2 = reco::deltaR2(SegPos,TkPos); + if (thisDelR2 < ClosestDelR2){ + ClosestDelR2 = thisDelR2; + MuonCandidate = reco::ME0Muon(thisTrackRef,(*thisSegment),SegmentNumber,chargeReco); + + MuonCandidate.setGlobalTrackPosAtSurface(r3FinalReco_glob); + MuonCandidate.setGlobalTrackMomAtSurface(p3FinalReco_glob); + MuonCandidate.setLocalTrackPosAtSurface(r3FinalReco); + MuonCandidate.setLocalTrackMomAtSurface(p3FinalReco); + MuonCandidate.setGlobalTrackCov(covFinalReco); + MuonCandidate.setLocalTrackCov(C); + } + } + }//End loop for (auto thisSegment = OurSegments->begin(); thisSegment != OurSegments->end(); ++thisSegment,++SegmentNumber) + + //As long as the delR of the MuonCandidate is sensible, store the track-segment pair + if (ClosestDelR2 < 500.) { + oc->push_back(MuonCandidate); + } + } + + // put collection in event + + ev.put(oc); +} + +FreeTrajectoryState +ME0SegmentMatcher::getFTS(const GlobalVector& p3, const GlobalVector& r3, + int charge, const AlgebraicSymMatrix55& cov, + const MagneticField* field){ + + GlobalVector p3GV(p3.x(), p3.y(), p3.z()); + GlobalPoint r3GP(r3.x(), r3.y(), r3.z()); + GlobalTrajectoryParameters tPars(r3GP, p3GV, charge, field); + + CurvilinearTrajectoryError tCov(cov); + + return cov.kRows == 5 ? FreeTrajectoryState(tPars, tCov) : FreeTrajectoryState(tPars) ; +} + +FreeTrajectoryState +ME0SegmentMatcher::getFTS(const GlobalVector& p3, const GlobalVector& r3, + int charge, const AlgebraicSymMatrix66& cov, + const MagneticField* field){ + + GlobalVector p3GV(p3.x(), p3.y(), p3.z()); + GlobalPoint r3GP(r3.x(), r3.y(), r3.z()); + GlobalTrajectoryParameters tPars(r3GP, p3GV, charge, field); + + CartesianTrajectoryError tCov(cov); + + return cov.kRows == 6 ? FreeTrajectoryState(tPars, tCov) : FreeTrajectoryState(tPars) ; +} + +void ME0SegmentMatcher::getFromFTS(const FreeTrajectoryState& fts, + GlobalVector& p3, GlobalVector& r3, + int& charge, AlgebraicSymMatrix66& cov){ + GlobalVector p3GV = fts.momentum(); + GlobalPoint r3GP = fts.position(); + + GlobalVector p3T(p3GV.x(), p3GV.y(), p3GV.z()); + GlobalVector r3T(r3GP.x(), r3GP.y(), r3GP.z()); + p3 = p3T; + r3 = r3T; + // p3.set(p3GV.x(), p3GV.y(), p3GV.z()); + // r3.set(r3GP.x(), r3GP.y(), r3GP.z()); + + charge = fts.charge(); + cov = fts.hasError() ? fts.cartesianError().matrix() : AlgebraicSymMatrix66(); + +} + + +void ME0SegmentMatcher::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) +{ + +} + + + DEFINE_FWK_MODULE(ME0SegmentMatcher); diff --git a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc index 9ac0505104793..9b17dba1febcd 100644 --- a/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc +++ b/RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc @@ -34,6 +34,9 @@ MuonIdProducer::MuonIdProducer(const edm::ParameterSet& iConfig): muIsoExtractorCalo_(0),muIsoExtractorTrack_(0),muIsoExtractorJet_(0) { + + LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: Constructor called"; + produces(); produces(); produces("combined"); @@ -261,15 +264,22 @@ reco::Muon MuonIdProducer::makeMuon(edm::Event& iEvent, const edm::EventSetup& i " Pt (GeV), eta: " << track.get()->eta(); reco::Muon aMuon( makeMuon( *(track.get()) ) ); + LogTrace("MuonIdentification") << "Muon created from a track "; + aMuon.setMuonTrack(type,track); aMuon.setBestTrack(type); aMuon.setTunePBestTrack(type); + LogTrace("MuonIdentification") << "Muon created from a track and setMuonBestTrack, setBestTrack and setTunePBestTrack called"; + return aMuon; } reco::CaloMuon MuonIdProducer::makeCaloMuon( const reco::Muon& muon ) { + + LogTrace("MuonIdentification") << "Creating a CaloMuon from a Muon"; + reco::CaloMuon aMuon; aMuon.setInnerTrack( muon.innerTrack() ); @@ -768,15 +778,22 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu reco::Muon& aMuon, TrackDetectorAssociator::Direction direction) { + + LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: fillMuonId"; + // perform track - detector association const reco::Track* track = 0; if ( aMuon.track().isNonnull() ) track = aMuon.track().get(); else if ( aMuon.standAloneMuon().isNonnull() ) track = aMuon.standAloneMuon().get(); else throw cms::Exception("FatalError") << "Failed to fill muon id information for a muon with undefined references to tracks"; + TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *track, parameters_, direction); + LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: fillMuonId :: fillEnergy = "< muonChamberMatches; unsigned int nubmerOfMatchesAccordingToTrackAssociator = 0; for ( const auto& chamber : info.chambers ) @@ -883,6 +901,7 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent, const edm::EventSetup& iSetu } // Fill RPC info + LogTrace("MuonIdentification") << "RecoMuon/MuonIdProducer :: fillMuonId :: fill RPC info"; if ( rpcHitHandle_.isValid() ) { for ( const auto& chamber : info.chambers ) diff --git a/RecoMuon/MuonIdentification/python/me0MuonConverter_cfi.py b/RecoMuon/MuonIdentification/python/me0MuonConverter_cfi.py new file mode 100644 index 0000000000000..83b6632c7cca0 --- /dev/null +++ b/RecoMuon/MuonIdentification/python/me0MuonConverter_cfi.py @@ -0,0 +1,4 @@ +import FWCore.ParameterSet.Config as cms + + +me0MuonConverting = cms.EDProducer("ME0MuonConverter") diff --git a/RecoMuon/MuonIdentification/python/me0MuonReco_cff.py b/RecoMuon/MuonIdentification/python/me0MuonReco_cff.py new file mode 100644 index 0000000000000..7ecc4dc2cba3f --- /dev/null +++ b/RecoMuon/MuonIdentification/python/me0MuonReco_cff.py @@ -0,0 +1,8 @@ +import FWCore.ParameterSet.Config as cms + +#from FastSimulation.Muons.me0SegmentProducer_cfi import * +from RecoMuon.MuonIdentification.me0SegmentMatcher_cfi import * +from RecoMuon.MuonIdentification.me0MuonConverter_cfi import * + +#me0MuonReco = cms.Sequence(me0SegmentProducer*me0SegmentMatcher*me0MuonConverter) +me0MuonReco = cms.Sequence(me0SegmentMatching*me0MuonConverting) diff --git a/RecoMuon/MuonIdentification/python/me0SegmentMatcher_cfi.py b/RecoMuon/MuonIdentification/python/me0SegmentMatcher_cfi.py new file mode 100644 index 0000000000000..e0d204f3950d8 --- /dev/null +++ b/RecoMuon/MuonIdentification/python/me0SegmentMatcher_cfi.py @@ -0,0 +1,12 @@ +import FWCore.ParameterSet.Config as cms + + +me0SegmentMatching = cms.EDProducer("ME0SegmentMatcher", + maxPullX = cms.double (3.0), + maxDiffX = cms.double (4.0), + maxPullY = cms.double (20.0), + maxDiffY = cms.double (20.0), + maxDiffPhiDirection = cms.double (3.14), + me0SegmentTag = cms.InputTag("me0Segments"), + tracksTag = cms.InputTag("generalTracks") + ) diff --git a/RecoMuon/MuonIdentification/test/ME0MuonAnalyzer.cc b/RecoMuon/MuonIdentification/test/ME0MuonAnalyzer.cc new file mode 100644 index 0000000000000..108392d2fd27e --- /dev/null +++ b/RecoMuon/MuonIdentification/test/ME0MuonAnalyzer.cc @@ -0,0 +1,2839 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + +#include +#include +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include +#include +#include +#include "FWCore/Utilities/interface/InputTag.h" + +#include + +#include +#include + +#include +#include +#include "DataFormats/GeometryVector/interface/GlobalVector.h" +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" +#include "TrackingTools/GeomPropagators/interface/Propagator.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" +#include "DataFormats/TrajectorySeed/interface/PropagationDirection.h" + +#include "TLorentzVector.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" + +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" + +#include "DataFormats/TrackReco/interface/Track.h" + +#include "TrackingTools/Records/interface/TrackingComponentsRecord.h" +#include "DataFormats/GeometrySurface/interface/Plane.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h" +#include "TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixStateInfo.h" + +#include "DataFormats/Math/interface/deltaR.h" +#include + +//Associator for chi2: Including header files +#include "SimTracker/TrackAssociatorProducers/plugins/TrackAssociatorByChi2Impl.h" +#include "SimTracker/TrackAssociatorProducers/plugins/TrackAssociatorByHitsImpl.h" + +//#include "SimMuon/MCTruth/interface/MuonAssociatorByHits.h" +#include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h" +#include "SimTracker/Records/interface/TrackAssociatorRecord.h" +#include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h" +#include "DataFormats/RecoCandidate/interface/TrackAssociation.h" + +#include "DataFormats/MuonReco/interface/Muon.h" + +#include "SimTracker/TrackAssociation/plugins/ParametersDefinerForTPESProducer.h" +#include "SimTracker/TrackAssociation/plugins/CosmicParametersDefinerForTPESProducer.h" + +#include "CommonTools/CandAlgos/interface/GenParticleCustomSelector.h" + +#include "RecoMuon/MuonIdentification/plugins/ME0MuonSelector.cc" + +#include "Fit/FitResult.h" +#include "TF1.h" + + +#include "TMath.h" +#include "TLorentzVector.h" + +#include "TH1.h" +#include +#include "TFile.h" +#include +#include "TStyle.h" +#include +#include +#include + +#include "Geometry/GEMGeometry/interface/ME0Geometry.h" +#include +#include +#include + + +#include "TrackingTools/AnalyticalJacobians/interface/JacobianCartesianToLocal.h" +#include "TrackingTools/AnalyticalJacobians/interface/JacobianLocalToCartesian.h" +#include "TGraph.h" + +#include +#include + +#include +#include +#include + +class ME0MuonAnalyzer : public edm::EDAnalyzer { +public: + explicit ME0MuonAnalyzer(const edm::ParameterSet&); + ~ME0MuonAnalyzer(); + FreeTrajectoryState getFTS(const GlobalVector& , const GlobalVector& , + int , const AlgebraicSymMatrix66& , + const MagneticField* ); + + FreeTrajectoryState getFTS(const GlobalVector& , const GlobalVector& , + int , const AlgebraicSymMatrix55& , + const MagneticField* ); + void getFromFTS(const FreeTrajectoryState& , + GlobalVector& , GlobalVector& , + int& , AlgebraicSymMatrix66& ); + + + virtual void analyze(const edm::Event&, const edm::EventSetup&); + void beginRun(edm::Run const&, edm::EventSetup const&); + void endRun(edm::Run const&, edm::EventSetup const&); + + //protected: + + private: + + edm::EDGetTokenT genParticlesToken_; + edm::EDGetTokenT trackingParticlesToken_; + edm::EDGetTokenT generalTracksToken_; + edm::EDGetTokenT OurMuonsToken_; + edm::EDGetTokenT OurSegmentsToken_; + std::vector > > track_Collection_Token; + + + bool UseAssociators; + bool RejectEndcapMuons; + const TrackAssociatorByChi2Impl* associatorByChi2; + + + + std::vector associators; + std::vector label; + std::vector associator; + + //Histos for plotting + TString histoFolder; + TString me0MuonSelector; + TFile* histoFile; + TH1F *Candidate_Eta; TH1F *Mass_h; + TH1F *Segment_Eta; TH1F *Segment_Phi; TH1F *Segment_R; TH2F *Segment_Pos; + TH1F *Rechit_Eta; TH1F *Rechit_Phi; TH1F *Rechit_R; TH2F *Rechit_Pos; + TH1F *GenMuon_Phi; TH1F *GenMuon_R; TH2F *GenMuon_Pos; + TH1F *Track_Eta; TH1F *Track_Pt; TH1F *ME0Muon_Eta; TH1F *ME0Muon_Pt; TH1F *CheckME0Muon_Eta; + TH1F *ME0Muon_SmallBins_Pt; TH1F *ME0Muon_VariableBins_Pt; + TH1F *ME0Muon_Cuts_Eta_5_10; TH1F *ME0Muon_Cuts_Eta_9_11; TH1F *ME0Muon_Cuts_Eta_10_50; TH1F *ME0Muon_Cuts_Eta_50_100; TH1F *ME0Muon_Cuts_Eta_100; + TH1F *UnmatchedME0Muon_Eta; TH1F *UnmatchedME0Muon_Pt; TH1F *UnmatchedME0Muon_Window_Pt; TH1F *Chi2UnmatchedME0Muon_Eta; + TH1F *Chi2UnmatchedME0Muon_Pt; TH1F *Chi2UnmatchedME0Muon_SmallBins_Pt; TH1F *Chi2UnmatchedME0Muon_VariableBins_Pt; + TH1F *UnmatchedME0Muon_SmallBins_Pt; TH1F *UnmatchedME0Muon_VariableBins_Pt; + TH1F *UnmatchedME0Muon_Cuts_Eta_5_10; TH1F *UnmatchedME0Muon_Cuts_Eta_9_11; TH1F *UnmatchedME0Muon_Cuts_Eta_10_50; TH1F *UnmatchedME0Muon_Cuts_Eta_50_100; TH1F *UnmatchedME0Muon_Cuts_Eta_100; + TH1F *TracksPerSegment_h; TH2F *TracksPerSegment_s; TProfile *TracksPerSegment_p; + TH2F *ClosestDelR_s; TProfile *ClosestDelR_p; + TH2F *PtDiff_s; TProfile *PtDiff_p; TH1F *PtDiff_h; TH1F *QOverPtDiff_h; TH1F *PtDiff_rms; TH1F *PtDiff_gaus_narrow; TH1F *PtDiff_gaus_wide; + TH2F *StandalonePtDiff_s; TProfile *StandalonePtDiff_p; TH1F *StandalonePtDiff_h; TH1F *StandaloneQOverPtDiff_h; TH1F *StandalonePtDiff_rms; TH1F *StandalonePtDiff_gaus_narrow; TH1F *StandalonePtDiff_gaus_wide; + TH1F *PtDiff_gaus_5_10; TH1F *PtDiff_gaus_10_50; TH1F *PtDiff_gaus_50_100; TH1F *PtDiff_gaus_100; + TH1F *StandalonePtDiff_gaus; + TH1F *VertexDiff_h; + TH2F *PDiff_s; TProfile *PDiff_p; TH1F *PDiff_h; + TH2F *PtDiff_s_5_10; TH2F *PtDiff_s_10_50; TH2F *PtDiff_s_50_100; TH2F *PtDiff_s_100; + TH1F *FakeTracksPerSegment_h; TH2F *FakeTracksPerSegment_s; TProfile *FakeTracksPerSegment_p; + TH1F *FakeTracksPerAssociatedSegment_h; TH2F *FakeTracksPerAssociatedSegment_s; TProfile *FakeTracksPerAssociatedSegment_p; + TH1F *GenMuon_Eta; TH1F *GenMuon_Pt; TH1F *MatchedME0Muon_Eta; TH1F *MatchedME0Muon_Pt; TH1F *Chi2MatchedME0Muon_Eta; TH1F *Chi2MatchedME0Muon_Pt; + TH1F *GenMuon_SmallBins_Pt; TH1F *MatchedME0Muon_SmallBins_Pt; TH1F *Chi2MatchedME0Muons_Pt; TH1F *Chi2MatchedME0Muon_SmallBins_Pt; + TH1F *GenMuon_VariableBins_Pt; TH1F *MatchedME0Muon_VariableBins_Pt; TH1F *Chi2MatchedME0Muon_VariableBins_Pt; + TH1F *TPMuon_Eta; TH1F *TPMuon_SmallBins_Pt; TH1F *TPMuon_Pt; TH1F *TPMuon_VariableBins_Pt; + TH1F *MatchedME0Muon_Eta_5_10; TH1F *MatchedME0Muon_Eta_9_11; TH1F *MatchedME0Muon_Eta_10_50; TH1F *MatchedME0Muon_Eta_50_100; TH1F *MatchedME0Muon_Eta_100; + TH1F *Chi2MatchedME0Muon_Eta_5_10; TH1F *Chi2MatchedME0Muon_Eta_9_11; TH1F *Chi2MatchedME0Muon_Eta_10_50; TH1F *Chi2MatchedME0Muon_Eta_50_100; TH1F *Chi2MatchedME0Muon_Eta_100; + TH1F *GenMuon_Eta_5_10; TH1F *GenMuon_Eta_9_11; TH1F *GenMuon_Eta_10_50; TH1F *GenMuon_Eta_50_100; TH1F *GenMuon_Eta_100; + TH1F *MuonRecoEff_Eta; TH1F *MuonRecoEff_Pt; TH1F *Chi2MuonRecoEff_Eta; + TH1F *MuonRecoEff_Eta_5_10; TH1F *MuonRecoEff_Eta_9_11; TH1F *MuonRecoEff_Eta_10_50; TH1F *MuonRecoEff_Eta_50_100; TH1F *MuonRecoEff_Eta_100; + TH1F *Chi2MuonRecoEff_Eta_5_10; TH1F *Chi2MuonRecoEff_Eta_9_11; TH1F *Chi2MuonRecoEff_Eta_10_50; TH1F *Chi2MuonRecoEff_Eta_50_100; TH1F *Chi2MuonRecoEff_Eta_100; + TH1F *FakeRate_Eta; TH1F *FakeRate_Pt; TH1F *FakeRate_Eta_PerEvent; TH1F *Chi2FakeRate_Eta; + + TH1F *Chi2FakeRate_WideBinning_Eta; + TH1F *Chi2FakeRate_WidestBinning_Eta; + TH1F *FakeRate_WideBinning_Eta; + TH1F *FakeRate_WidestBinning_Eta; + TH1F *UnmatchedME0Muon_Cuts_WideBinning_Eta; + TH1F *UnmatchedME0Muon_Cuts_WidestBinning_Eta; + TH1F *ME0Muon_Cuts_WideBinning_Eta; + TH1F *ME0Muon_Cuts_WidestBinning_Eta; + TH1F *Chi2UnmatchedME0Muon_WideBinning_Eta; + TH1F *Chi2UnmatchedME0Muon_WidestBinning_Eta; + TH1F *TPMuon_WideBinning_Eta; + TH1F *TPMuon_WidestBinning_Eta; + TH1F *GenMuon_WideBinning_Eta; + TH1F *GenMuon_WidestBinning_Eta; + TH1F *MatchedME0Muon_WideBinning_Eta; + TH1F *MatchedME0Muon_WidestBinning_Eta; + TH1F *Chi2MatchedME0Muon_WideBinning_Eta; + TH1F *Chi2MatchedME0Muon_WidestBinning_Eta; + TH1F *MuonRecoEff_WideBinning_Eta; + TH1F *MuonRecoEff_WidestBinning_Eta; + TH1F *Chi2MuonRecoEff_WideBinning_Eta; + TH1F *Chi2MuonRecoEff_WidestBinning_Eta; + + + TH1F *FakeRate_Eta_5_10; TH1F *FakeRate_Eta_9_11; TH1F *FakeRate_Eta_10_50; TH1F *FakeRate_Eta_50_100; TH1F *FakeRate_Eta_100; + TH1F *MuonAllTracksEff_Eta; TH1F *MuonAllTracksEff_Pt; + TH1F *MuonUnmatchedTracksEff_Eta; TH1F *MuonUnmatchedTracksEff_Pt; TH1F *FractionMatched_Eta; + + TH1F *StandaloneMuonRecoEff_Eta; TH1F *StandaloneMuonRecoEff_WideBinning_Eta; TH1F *StandaloneMuonRecoEff_WidestBinning_Eta; + TH1F *UnmatchedME0Muon_Cuts_Eta;TH1F *ME0Muon_Cuts_Eta; + TH1F *StandaloneMatchedME0Muon_Eta; TH1F *StandaloneMatchedME0Muon_WideBinning_Eta; TH1F *StandaloneMatchedME0Muon_WidestBinning_Eta; + TH1F *DelR_Segment_GenMuon; + + TH1F *SegPosDirPhiDiff_True_h; TH1F *SegPosDirEtaDiff_True_h; TH1F *SegPosDirPhiDiff_All_h; TH1F *SegPosDirEtaDiff_All_h; + TH1F *SegTrackDirPhiDiff_True_h; TH1F *SegTrackDirEtaDiff_True_h; TH1F *SegTrackDirPhiDiff_All_h; TH1F *SegTrackDirEtaDiff_All_h; TH1F *SegTrackDirPhiPull_True_h; TH1F *SegTrackDirPhiPull_All_h; + + TH1F *SegGenDirPhiDiff_True_h; TH1F *SegGenDirEtaDiff_True_h; TH1F *SegGenDirPhiDiff_All_h; TH1F *SegGenDirEtaDiff_All_h; TH1F *SegGenDirPhiPull_True_h; TH1F *SegGenDirPhiPull_All_h; + + TH1F *XDiff_h; TH1F *YDiff_h; TH1F *XPull_h; TH1F *YPull_h; + + + TH1F *DelR_Window_Under5; TH1F *Pt_Window_Under5; + TH1F *DelR_Track_Window_Under5; TH1F *Pt_Track_Window_Under5; TH1F *Pt_Track_Window; + TH1F *DelR_Track_Window_Failed_Under5; TH1F *Pt_Track_Window_Failed_Under5; TH1F *Pt_Track_Window_Failed; + + TH1F *FailedTrack_Window_XPull; TH1F *FailedTrack_Window_YPull; TH1F *FailedTrack_Window_PhiDiff; + TH1F *FailedTrack_Window_XDiff; TH1F *FailedTrack_Window_YDiff; + + TH1F *NormChi2_h; TH1F *NormChi2Prob_h; TH2F *NormChi2VsHits_h; TH2F *chi2_vs_eta_h; TH1F *AssociatedChi2_h; TH1F *AssociatedChi2_Prob_h; + + TH1F *PreMatch_TP_R; TH1F *PostMatch_TP_R; TH1F *PostMatch_BX0_TP_R; + + TH2F *UnmatchedME0Muon_ScatterPlot; + + double FakeRatePtCut, MatchingWindowDelR; + + double Nevents; + + TH1F *Nevents_h; + +}; + +ME0MuonAnalyzer::ME0MuonAnalyzer(const edm::ParameterSet& iConfig) +{ + histoFile = new TFile(iConfig.getParameter("HistoFile").c_str(), "recreate"); + histoFolder = iConfig.getParameter("HistoFolder").c_str(); + me0MuonSelector = iConfig.getParameter("ME0MuonSelectionType").c_str(); + RejectEndcapMuons = iConfig.getParameter< bool >("RejectEndcapMuons"); + UseAssociators = iConfig.getParameter< bool >("UseAssociators"); + + FakeRatePtCut = iConfig.getParameter("FakeRatePtCut"); + MatchingWindowDelR = iConfig.getParameter("MatchingWindowDelR"); + + //Associator for chi2: getting parameters + UseAssociators = iConfig.getParameter< bool >("UseAssociators"); + associators = iConfig.getParameter< std::vector >("associators"); + + label = iConfig.getParameter< std::vector >("label"); + edm::InputTag genParticlesTag ("genParticles"); + genParticlesToken_ = consumes(genParticlesTag); + edm::InputTag trackingParticlesTag ("mix","MergedTrackTruth"); + trackingParticlesToken_ = consumes(trackingParticlesTag); + edm::InputTag generalTracksTag ("generalTracks"); + generalTracksToken_ = consumes(generalTracksTag); + edm::InputTag OurMuonsTag ("me0SegmentMatching"); + OurMuonsToken_ = consumes(OurMuonsTag); + edm::InputTag OurSegmentsTag ("me0Segments"); + OurSegmentsToken_ = consumes(OurSegmentsTag); + + //Getting tokens and doing consumers for track associators + for (unsigned int www=0;www >(label[www])); + } + + if (UseAssociators) { + for (auto const& thisassociator :associators) { + consumes(edm::InputTag(thisassociator)); + } + } + + + std::cout<<"Contructor end"<Fill(1); + using namespace edm; + + + if (UseAssociators) { + edm::Handle theAssociator; + for (unsigned int w=0;w genParticles; + iEvent.getByToken(genParticlesToken_, genParticles); + const GenParticleCollection genParticlesForChi2 = *(genParticles.product()); + + unsigned int gensize=genParticles->size(); + + Handle trackingParticles; + iEvent.getByToken(trackingParticlesToken_, trackingParticles); + + + if (RejectEndcapMuons){ + //Section to turn off signal muons in the endcaps, to approximate a nu gun + for(unsigned int i=0; i 1.9 ) { + //std::cout<<"Found a signal muon outside the barrel, exiting the function"< generalTracks; + iEvent.getByToken (generalTracksToken_, generalTracks); + + Handle > OurMuons; + iEvent.getByToken (OurMuonsToken_, OurMuons); + + Handle OurSegments; + iEvent.getByToken(OurSegmentsToken_,OurSegments); + + + edm::ESHandle me0Geom; + iSetup.get().get(me0Geom); + + ESHandle bField; + iSetup.get().get(bField); + ESHandle shProp; + iSetup.get().get("SteppingHelixPropagatorAlong", shProp); + + // -----First, make a vector of bools for each ME0Muon + + std::vector IsMatched; + std::vector SegIdForMatch; + for (std::vector::const_iterator thisMuon = OurMuons->begin(); + thisMuon != OurMuons->end(); ++thisMuon){ + if (!muon::isGoodMuon(*thisMuon, muon::Tight)) continue; + IsMatched.push_back(false); + SegIdForMatch.push_back(-1); + } + + + //=====Finding ME0Muons that match gen muons, plotting the closest of those + std::vector MatchedSegIds; + + for(unsigned int i=0; i ReferenceTrackPt; + + double VertexDiff=-1,PtDiff=-1,QOverPtDiff=-1,PDiff=-1; + + for (std::vector::const_iterator thisMuon = OurMuons->begin(); + thisMuon != OurMuons->end(); ++thisMuon){ + if (!muon::isGoodMuon(*thisMuon, muon::Tight)) continue; + TrackRef tkRef = thisMuon->innerTrack(); + SegIdForMatch.push_back(thisMuon->me0segid()); + thisDelR = reco::deltaR(CurrentParticle,*tkRef); + ReferenceTrackPt.push_back(tkRef->pt()); + + + if (( tkRef->pt() > FakeRatePtCut ) ){ + if (thisDelR < MatchingWindowDelR ){ + if (tkRef->pt() < 5.0){ + DelR_Window_Under5->Fill(thisDelR); + Pt_Window_Under5->Fill(tkRef->pt()); + } + if (thisDelR < LowestDelR){ + LowestDelR = thisDelR; + //if (fabs(tkRef->pt() - CurrentParticle.pt())/CurrentParticle.pt() < 0.50) MatchedID = ME0MuonID; + MatchedID = ME0MuonID; + VertexDiff = fabs(tkRef->vz()-CurrentParticle.vz()); + QOverPtDiff = ( (tkRef->charge() /tkRef->pt()) - (CurrentParticle.charge()/CurrentParticle.pt() ) )/ (CurrentParticle.charge()/CurrentParticle.pt() ); + PtDiff = (tkRef->pt() - CurrentParticle.pt())/CurrentParticle.pt(); + PDiff = (tkRef->p() - CurrentParticle.p())/CurrentParticle.p(); + } + } + } + + ME0MuonID++; + + } + + for (std::vector::const_iterator thisTrack = generalTracks->begin(); + thisTrack != generalTracks->end();++thisTrack){ + //TrackRef tkRef = thisTrack->innerTrack(); + thisDelR = reco::deltaR(CurrentParticle,*thisTrack); + + if ((thisTrack->pt() > FakeRatePtCut ) ){ + if (thisDelR < MatchingWindowDelR ){ + if (thisTrack->pt() < 5.0){ + DelR_Track_Window_Under5->Fill(thisDelR); + Pt_Track_Window_Under5->Fill(thisTrack->pt()); + } + Pt_Track_Window->Fill(thisTrack->pt()); + } + } + } + if (MatchedID == -1){ + + for (std::vector::const_iterator thisTrack = generalTracks->begin(); + thisTrack != generalTracks->end();++thisTrack){ + //TrackRef tkRef = thisTrack->innerTrack(); + thisDelR = reco::deltaR(CurrentParticle,*thisTrack); + + + if ( (thisTrack->pt() > FakeRatePtCut ) && (TMath::Abs(thisTrack->eta()) < 2.8) && (TMath::Abs(thisTrack->eta()) > 2.0) ) { + if (thisDelR < MatchingWindowDelR ){ + if (thisTrack->pt() < 5.0){ + DelR_Track_Window_Failed_Under5->Fill(thisDelR); + Pt_Track_Window_Failed_Under5->Fill(thisTrack->pt()); + } + Pt_Track_Window_Failed->Fill(thisTrack->pt()); + } + } + } + } + + if (MatchedID != -1){ + IsMatched[MatchedID] = true; + + if ((CurrentParticle.pt() >FakeRatePtCut) ){ + MatchedME0Muon_Eta->Fill(fabs(CurrentParticle.eta())); + if ( (TMath::Abs(CurrentParticle.eta()) > 2.0) && (TMath::Abs(CurrentParticle.eta()) < 2.8) ) { + MatchedME0Muon_Pt->Fill(CurrentParticle.pt()); + MatchedME0Muon_SmallBins_Pt->Fill(CurrentParticle.pt()); + MatchedME0Muon_VariableBins_Pt->Fill(CurrentParticle.pt()); + } + + + MatchedME0Muon_WideBinning_Eta->Fill(fabs(CurrentParticle.eta())); + MatchedME0Muon_WidestBinning_Eta->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 5.0) && (CurrentParticle.pt() <= 10.0) ) MatchedME0Muon_Eta_5_10->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 9.0) && (CurrentParticle.pt() <= 11.0) ) MatchedME0Muon_Eta_9_11->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 10.0) && (CurrentParticle.pt() <= 50.0) ) MatchedME0Muon_Eta_10_50->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 50.0) && (CurrentParticle.pt() <= 100.0) ) MatchedME0Muon_Eta_50_100->Fill(fabs(CurrentParticle.eta())); + if ( CurrentParticle.pt() > 100.0) MatchedME0Muon_Eta_100->Fill(fabs(CurrentParticle.eta())); + + + + VertexDiff_h->Fill(VertexDiff); + PtDiff_h->Fill(PtDiff); + QOverPtDiff_h->Fill(QOverPtDiff); + PtDiff_s->Fill(CurrentParticle.eta(),PtDiff); + if ( (CurrentParticle.pt() > 5.0) && (CurrentParticle.pt() <= 10.0) ) PtDiff_s_5_10->Fill(CurrentParticle.eta(),PtDiff); + if ( (CurrentParticle.pt() > 10.0) && (CurrentParticle.pt() <= 50.0) ) PtDiff_s_10_50->Fill(CurrentParticle.eta(),PtDiff); + if ( (CurrentParticle.pt() > 50.0) && (CurrentParticle.pt() <= 100.0) ) PtDiff_s_50_100->Fill(CurrentParticle.eta(),PtDiff); + if ( CurrentParticle.pt() > 100.0) PtDiff_s_100->Fill(CurrentParticle.eta(),PtDiff); + PtDiff_p->Fill(CurrentParticle.eta(),PtDiff); + + PDiff_h->Fill(PDiff); + PDiff_s->Fill(CurrentParticle.eta(),PDiff); + PDiff_p->Fill(CurrentParticle.eta(),PDiff); + } + MatchedSegIds.push_back(SegIdForMatch[MatchedID]); + } + + + if ( (CurrentParticle.pt() >FakeRatePtCut) ){ + GenMuon_Eta->Fill(fabs(CurrentParticle.eta())); + GenMuon_WideBinning_Eta->Fill(fabs(CurrentParticle.eta())); + GenMuon_WidestBinning_Eta->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 5.0) && (CurrentParticle.pt() <= 10.0) ) GenMuon_Eta_5_10->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 9.0) && (CurrentParticle.pt() <= 11.0) ) GenMuon_Eta_9_11->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 10.0) && (CurrentParticle.pt() <= 50.0) ) GenMuon_Eta_10_50->Fill(fabs(CurrentParticle.eta())); + if ( (CurrentParticle.pt() > 50.0) && (CurrentParticle.pt() <= 100.0) ) GenMuon_Eta_50_100->Fill(fabs(CurrentParticle.eta())); + if ( CurrentParticle.pt() > 100.0) GenMuon_Eta_100->Fill(fabs(CurrentParticle.eta())); + GenMuon_Phi->Fill(CurrentParticle.phi()); + if ( (fabs(CurrentParticle.eta()) > 2.0) && (fabs(CurrentParticle.eta()) < 2.8) ) { + GenMuon_SmallBins_Pt->Fill(CurrentParticle.pt()); + GenMuon_VariableBins_Pt->Fill(CurrentParticle.pt()); + GenMuon_Pt->Fill(CurrentParticle.pt()); + } + } + + } + } + + + + //Del R study =========================== + for(unsigned int i=0; i::const_iterator thisMuon = OurMuons->begin(); + thisMuon != OurMuons->end(); ++thisMuon){ + if (!muon::isGoodMuon(*thisMuon, muon::Tight)) continue; + TrackRef tkRef = thisMuon->innerTrack(); + thisDelR = reco::deltaR(CurrentParticle,*tkRef); + if (thisDelR < LowestDelR) LowestDelR = thisDelR; + } + + ClosestDelR_s->Fill(CurrentParticle.eta(), LowestDelR); + ClosestDelR_p->Fill(CurrentParticle.eta(), LowestDelR); + } + } + + //==================================== + + // -----Finally, we loop over all the ME0Muons in the event + // -----Before, we plotted the gen muon pt and eta for the efficiency plot of matches + // -----Now, each time a match failed, we plot the ME0Muon pt and eta + int ME0MuonID = 0; + for (std::vector::const_iterator thisMuon = OurMuons->begin(); + thisMuon != OurMuons->end(); ++thisMuon){ + if (!muon::isGoodMuon(*thisMuon, muon::Tight)) continue; + TrackRef tkRef = thisMuon->innerTrack(); + //Moved resolution stuff here, only calculate resolutions for matched muons! + if (!IsMatched[ME0MuonID]){ + + UnmatchedME0Muon_Eta->Fill(fabs(tkRef->eta())); + + if ((tkRef->pt() > FakeRatePtCut) && (TMath::Abs(tkRef->eta()) < 2.8) ) { + if ( (tkRef->pt() > 5.0) && (tkRef->pt() <= 10.0) ) UnmatchedME0Muon_Cuts_Eta_5_10->Fill(fabs(tkRef->eta())); + if ( (tkRef->pt() > 9.0) && (tkRef->pt() <= 11.0) ) UnmatchedME0Muon_Cuts_Eta_9_11->Fill(fabs(tkRef->eta())); + if ( (tkRef->pt() > 10.0) && (tkRef->pt() <= 20.0) ) UnmatchedME0Muon_Cuts_Eta_10_50->Fill(fabs(tkRef->eta())); + if ( (tkRef->pt() > 20.0) && (tkRef->pt() <= 40.0) ) UnmatchedME0Muon_Cuts_Eta_50_100->Fill(fabs(tkRef->eta())); + if ( tkRef->pt() > 40.0) UnmatchedME0Muon_Cuts_Eta_100->Fill(fabs(tkRef->eta())); + + UnmatchedME0Muon_Cuts_Eta->Fill(fabs(tkRef->eta())); + UnmatchedME0Muon_Cuts_WideBinning_Eta->Fill(fabs(tkRef->eta())); + UnmatchedME0Muon_Cuts_WidestBinning_Eta->Fill(fabs(tkRef->eta())); + + UnmatchedME0Muon_ScatterPlot->Fill(fabs(tkRef->eta()), fabs(tkRef->phi()) ); + + for(unsigned int i=0; ieta()) < 2.8) ) UnmatchedME0Muon_Window_Pt->Fill(tkRef->pt()); + } + } + if ( (TMath::Abs(tkRef->eta()) > 2.0) && (TMath::Abs(tkRef->eta()) < 2.8) ) { + UnmatchedME0Muon_Pt->Fill(tkRef->pt()); + UnmatchedME0Muon_SmallBins_Pt->Fill(tkRef->pt()); + UnmatchedME0Muon_VariableBins_Pt->Fill(tkRef->pt()); + } + + } + } + ME0MuonID++; + } + + + + //Track Association by Chi2 or hits: + + + //Map the list of all me0muons that failed or passed delR matching to a list of only Tight me0Muons that failed or passed delR matching + std::vector SkimmedIsMatched; + int i_me0muon=0; + for (std::vector::const_iterator thisMuon = OurMuons->begin(); + thisMuon != OurMuons->end(); ++thisMuon, ++i_me0muon){ + if (!muon::isGoodMuon(*thisMuon, muon::Tight)) continue; + SkimmedIsMatched.push_back(IsMatched[i_me0muon]); + } + + //int w=0; + //std::cout<<"associators size = "< > trackCollection; + + + + unsigned int trackCollectionSize = 0; + + if(!iEvent.getByToken(track_Collection_Token[www], trackCollection)){ + recSimColl.post_insert(); + simRecColl.post_insert(); + + } + + else { + trackCollectionSize = trackCollection->size(); + recSimColl=associator[ww]->associateRecoToSim(trackCollection, + trackingParticles); + + + simRecColl=associator[ww]->associateSimToReco(trackCollection, + trackingParticles); + + + } + + for (TrackingParticleCollection::size_type i=0; isize(); i++){ + + const TrackingParticle& TPCheck=(*trackingParticles)[i]; + if (abs(TPCheck.pdgId()) != 13) continue; + + TrackingParticleRef tpr(trackingParticles, i); + TrackingParticle* tp=const_cast(tpr.get()); + TrackingParticle::Vector momentumTP; + TrackingParticle::Point vertexTP; + + if (abs(tp->pdgId()) != 13) continue; + + momentumTP = tp->momentum(); + vertexTP = tp->vertex(); + + //This section fills the denominator for the chi2 efficiency... + + + if ((tp->pt() >FakeRatePtCut) ){ + bool SignalMuon=false; + if (tp->status() !=-99){ + int motherid=-1; + if ((*tp->genParticle_begin())->numberOfMothers()>0) { + if ((*tp->genParticle_begin())->mother()->numberOfMothers()>0){ + motherid=(*tp->genParticle_begin())->mother()->mother()->pdgId(); + } + } + + std::cout<<"Mother ID = "<status()==1) && ( (*tp->genParticle_begin())->numberOfMothers()==0 ) ) || + ( (tp->status()==1) ) ) SignalMuon=true; + + //if (SignalMuon) PreMatch_TP_R->Fill( sqrt(pow(tp->vertex().x(),2) + pow(tp->vertex().y(),2)) ); + } + if (SignalMuon){ + TPMuon_Eta->Fill(fabs(tp->eta())); + TPMuon_WideBinning_Eta->Fill(fabs(tp->eta())); + TPMuon_WidestBinning_Eta->Fill(fabs(tp->eta())); + if ( (fabs(tp->eta()) > 2.0) && (fabs(tp->eta()) < 2.8) ) { + TPMuon_SmallBins_Pt->Fill(tp->pt()); + TPMuon_VariableBins_Pt->Fill(tp->pt()); + TPMuon_Pt->Fill(tp->pt()); + } + + } + + } + if ( (fabs(tp->eta()) > 2.0) && (fabs(tp->eta()) < 2.8) ) PreMatch_TP_R->Fill( sqrt(pow(tp->vertex().x(),2) + pow(tp->vertex().y(),2)) ); + }// END for (TrackingParticleCollection::size_type i=0; isize(); i++){ + + for(View::size_type i=0; i track(trackCollection, i); + + std::vector > tp; + std::vector > tpforfake; + TrackingParticleRef tpr; + TrackingParticleRef tprforfake; + + //Check if the track is associated to any gen particle + bool TrackIsEfficient = false; + //std::cout<<"About to check first collection"<first; + + double assocChi2 = -(tp.begin()->second); + + //So this track is matched to a gen particle, lets get that gen particle now + + if ( (simRecColl.find(tpr) != simRecColl.end()) ){ + std::vector, double> > rt; + if (simRecColl[tpr].size() > 0){ + rt=simRecColl[tpr]; + RefToBase bestrecotrackforeff = rt.begin()->first; + //Only fill the efficiency histo if the track found matches up to a gen particle's best choice + if ( (bestrecotrackforeff == track ) && (abs(tpr->pdgId()) == 13) ) { + TrackIsEfficient=true; + //This section fills the numerator of the efficiency calculation... + //if ( (track->pt() > FakeRatePtCut) && (TMath::Abs(track->eta()) < 2.8) ) + PostMatch_TP_R->Fill( sqrt(pow(tpr->vertex().x(),2) + pow(tpr->vertex().y(),2)) ); + if (tpr->eventId().bunchCrossing()) PostMatch_BX0_TP_R->Fill( sqrt(pow(tpr->vertex().x(),2) + pow(tpr->vertex().y(),2)) ); + + + if ( (tpr->pt() > FakeRatePtCut) ) + { + + + bool SignalMuon=false; + + if (tpr->status() !=-99){ + int motherid=-1; + if ((*tpr->genParticle_begin())->numberOfMothers()>0) { + if ((*tpr->genParticle_begin())->mother()->numberOfMothers()>0){ + motherid=(*tpr->genParticle_begin())->mother()->mother()->pdgId(); + } + } + std::cout<<"Mother ID = "<status()==1) && ( (*tpr->genParticle_begin())->numberOfMothers()==0 ) ) || + ( (tpr->status()==1) ) )SignalMuon=true; + + } + if (SignalMuon){ + Chi2MatchedME0Muon_Eta->Fill(fabs(tpr->eta())); + Chi2MatchedME0Muon_WideBinning_Eta->Fill(fabs(tpr->eta())); + Chi2MatchedME0Muon_WidestBinning_Eta->Fill(fabs(tpr->eta())); + if ( (TMath::Abs(tpr->eta()) > 2.0) && (TMath::Abs(tpr->eta()) < 2.8) ) { + Chi2MatchedME0Muon_Pt->Fill(tpr->pt()); + Chi2MatchedME0Muon_SmallBins_Pt->Fill(tpr->pt()); + Chi2MatchedME0Muon_VariableBins_Pt->Fill(tpr->pt()); + } + + if ( (track->pt() > 5.0) && (track->pt() <= 10.0) ) Chi2MatchedME0Muon_Eta_5_10->Fill(fabs(tpr->eta())); + if ( (track->pt() > 9.0) && (track->pt() <= 11.0) ) Chi2MatchedME0Muon_Eta_9_11->Fill(fabs(tpr->eta())); + if ( (track->pt() > 10.0) && (track->pt() <= 50.0) ) Chi2MatchedME0Muon_Eta_10_50->Fill(fabs(tpr->eta())); + if ( (track->pt() > 50.0) && (track->pt() <= 100.0) ) Chi2MatchedME0Muon_Eta_50_100->Fill(fabs(tpr->eta())); + if ( track->pt() > 100.0) Chi2MatchedME0Muon_Eta_100->Fill(fabs(tpr->eta())); + } + + } + //...end section + + if ( (track->pt() > FakeRatePtCut) && (TMath::Abs(track->eta()) < 2.8) )AssociatedChi2_h->Fill(assocChi2); + if ( (track->pt() > FakeRatePtCut) && (TMath::Abs(track->eta()) < 2.8) )AssociatedChi2_Prob_h->Fill(TMath::Prob((assocChi2)*5,5)); + } + } + } + + + + } + } + //A simple way of measuring fake rate: + if (!TrackIsEfficient) { + + if ((track->pt() > FakeRatePtCut) && (TMath::Abs(track->eta()) < 2.8) ) { + Chi2UnmatchedME0Muon_Eta->Fill(fabs(track->eta())); + Chi2UnmatchedME0Muon_WideBinning_Eta->Fill(fabs(track->eta())); + Chi2UnmatchedME0Muon_WidestBinning_Eta->Fill(fabs(track->eta())); + if ( (TMath::Abs(track->eta()) > 2.0) && (TMath::Abs(track->eta()) < 2.8) ) { + Chi2UnmatchedME0Muon_Pt->Fill(track->pt()); + Chi2UnmatchedME0Muon_SmallBins_Pt->Fill(track->pt()); + Chi2UnmatchedME0Muon_VariableBins_Pt->Fill(track->pt()); + } + } + + } + //End checking of Efficient muons + + //Deprecated F.R. method, only used for debugging offline. Commented out now: + + // //For Fakes -------------------------------------------- here we fill the numerator for the F.R., Chi2UnmatchedME0Muon_Eta + // //The denominator is filled elsewhere, just a histo of all the ME0Muon eta values + // //It is ME0Muon_Cuts_Eta, so named because it is all ME0Muons passing the selection (also the pT cut) + + + // //Check if finding a track associated to a gen particle fails, or if there is no track in the collection at all + + // if( (recSimColl.find(track) == recSimColl.end() ) || ( recSimColl[track].size() == 0 ) ){ + // if (SkimmedIsMatched[i]){ + // if ((track->pt() >FakeRatePtCut) ){ + // if (tp.size()!=0) std::cout<<"Found an me0muontrack failing chi2 matching: "<pt()<<", "<eta()<<", "<second< 0){ + // tpforfake = recSimColl[track]; + // tprforfake=tpforfake.begin()->first; + // //We now have the gen particle, to check + + + // //If for some crazy reason we can't find the gen particle, that means its a fake + // if ( (simRecColl.find(tprforfake) == simRecColl.end()) || (simRecColl[tprforfake].size() == 0) ) { + // //Check if this muon matched via Del-R matching + // if (SkimmedIsMatched[i]){ + // if ((track->pt() >FakeRatePtCut) ) { + // if (tp.size()!=0) std::cout<<"Found an me0muontrack failing chi2 matching: "<pt()<<", "<eta()<<", "<second< 0) { + // //We can now access the best possible track for the gen particle that this track was matched to + // std::vector, double> > rtforfake; + // rtforfake=simRecColl[tprforfake]; + + // RefToBase bestrecotrack = rtforfake.begin()->first; + // //if the best reco track is NOT the track that we're looking at, we know we have a fake, that was within the cut, but not the closest + // if (bestrecotrack != track) { + // //Check if this muon matched via Del-R matching + // if (IsMatched[i]){ + // if (tp.size()!=0) std::cout<<"Found an me0muontrack failing chi2 matching: "<pt()<<", "<eta()<<", "<second<eta()) < 2.8) CheckME0Muon_Eta->Fill(fabs(track->eta())); + + NormChi2_h->Fill(track->normalizedChi2()); + NormChi2Prob_h->Fill(TMath::Prob(track->chi2(),(int)track->ndof())); + NormChi2VsHits_h->Fill(track->numberOfValidHits(),track->normalizedChi2()); + + + chi2_vs_eta_h->Fill((track->eta()),track->normalizedChi2()); + + + }//END for(View::size_type i=0; i::const_iterator thisTrack = generalTracks->begin(); + thisTrack != generalTracks->end();++thisTrack){ + Track_Eta->Fill(fabs(thisTrack->eta())); + if ( (TMath::Abs(thisTrack->eta()) > 2.0) && (TMath::Abs(thisTrack->eta()) < 2.8) ) Track_Pt->Fill(thisTrack->pt()); + } + + + std::vector SegmentEta, SegmentPhi, SegmentR, SegmentX, SegmentY; + std::vector Ids; + std::vector Ids_NonGenMuons; + std::vector UniqueIdList; + int TrackID=0; + + int MuID = 0; + + for (std::vector::const_iterator thisMuon = OurMuons->begin(); + thisMuon != OurMuons->end(); ++thisMuon){ + if (!muon::isGoodMuon(*thisMuon, muon::Tight)) continue; + TrackRef tkRef = thisMuon->innerTrack(); + + ME0Segment Seg = thisMuon->me0segment(); + ME0DetId id =Seg.me0DetId(); + auto roll = me0Geom->etaPartition(id); + auto GlobVect(roll->toGlobal(Seg.localPosition())); + + int SegId=thisMuon->me0segid(); + + bool IsNew = true; + for (unsigned int i =0; i < Ids.size(); i++){ + if (SegId == Ids[i]) IsNew=false; + } + + if (IsNew) { + UniqueIdList.push_back(SegId); + SegmentEta.push_back(GlobVect.eta()); + SegmentPhi.push_back(GlobVect.phi()); + SegmentR.push_back(GlobVect.perp()); + SegmentX.push_back(GlobVect.x()); + SegmentY.push_back(GlobVect.y()); + } + Ids.push_back(SegId); + if (!IsMatched[TrackID]) Ids_NonGenMuons.push_back(SegId); + + ME0Muon_Eta->Fill(fabs(tkRef->eta())); + + if ((tkRef->pt() > FakeRatePtCut) && (TMath::Abs(tkRef->eta()) < 2.8)){ + ME0Muon_Cuts_Eta->Fill(fabs(tkRef->eta())); + ME0Muon_Cuts_WideBinning_Eta->Fill(fabs(tkRef->eta())); + ME0Muon_Cuts_WidestBinning_Eta->Fill(fabs(tkRef->eta())); + if ( (tkRef->pt() > 5.0) && (tkRef->pt() <= 10.0) ) ME0Muon_Cuts_Eta_5_10->Fill(fabs(tkRef->eta())); + if ( (tkRef->pt() > 9.0) && (tkRef->pt() <= 11.0) ) ME0Muon_Cuts_Eta_9_11->Fill(fabs(tkRef->eta())); + if ( (tkRef->pt() > 10.0) && (tkRef->pt() <= 20.0) ) ME0Muon_Cuts_Eta_10_50->Fill(fabs(tkRef->eta())); + if ( (tkRef->pt() > 20.0) && (tkRef->pt() <= 40.0) ) ME0Muon_Cuts_Eta_50_100->Fill(fabs(tkRef->eta())); + if ( tkRef->pt() > 40.0) ME0Muon_Cuts_Eta_100->Fill(fabs(tkRef->eta())); + + + if ( (TMath::Abs(tkRef->eta()) > 2.0) && (TMath::Abs(tkRef->eta()) < 2.8) ) { + ME0Muon_Pt->Fill(tkRef->pt()); + ME0Muon_SmallBins_Pt->Fill(tkRef->pt()); + ME0Muon_VariableBins_Pt->Fill(tkRef->pt()); + } + } + TrackID++; + MuID++; + + } //END for (std::vector::const_iterator thisMuon = OurMuons->begin(); + + + for (unsigned int i = 0; i < UniqueIdList.size(); i++){ + int Num_Total=0, Num_Fake = 0, Num_Fake_Associated = 0; + for (unsigned int j = 0; j < Ids.size(); j++){ + if (Ids[j] == UniqueIdList[i]) Num_Total++; + } + + for (unsigned int j = 0; j < Ids_NonGenMuons.size(); j++){ + if (Ids_NonGenMuons[j] == UniqueIdList[i]) Num_Fake++; + bool AssociatedWithMatchedSegment = false; + for (unsigned int isegid=0;isegid < MatchedSegIds.size();isegid++){ + if (MatchedSegIds[isegid]==Ids_NonGenMuons[j]) AssociatedWithMatchedSegment=true; + } + if (AssociatedWithMatchedSegment) Num_Fake_Associated++; + } + + TracksPerSegment_h->Fill((double)Num_Total); + TracksPerSegment_s->Fill(SegmentEta[i], (double)Num_Total); + TracksPerSegment_p->Fill(SegmentEta[i], (double)Num_Total); + + FakeTracksPerSegment_h->Fill((double)Num_Fake); + FakeTracksPerSegment_s->Fill(SegmentEta[i], (double)Num_Fake); + FakeTracksPerSegment_p->Fill(SegmentEta[i], (double)Num_Fake); + + FakeTracksPerAssociatedSegment_h->Fill((double)Num_Fake_Associated); + FakeTracksPerAssociatedSegment_s->Fill(SegmentEta[i], (double)Num_Fake_Associated); + FakeTracksPerAssociatedSegment_p->Fill(SegmentEta[i], (double)Num_Fake_Associated); + + } + + //================ For Segment Plotting + for (auto thisSegment = OurSegments->begin(); thisSegment != OurSegments->end(); + ++thisSegment){ + ME0DetId id = thisSegment->me0DetId(); + auto roll = me0Geom->etaPartition(id); + auto GlobVect(roll->toGlobal(thisSegment->localPosition())); + Segment_Eta->Fill(fabs(GlobVect.eta())); + Segment_Phi->Fill(GlobVect.phi()); + Segment_R->Fill(GlobVect.perp()); + Segment_Pos->Fill(GlobVect.x(),GlobVect.y()); + + + + auto theseRecHits = thisSegment->specificRecHits(); + + for (auto thisRecHit = theseRecHits.begin(); thisRecHit!= theseRecHits.end(); thisRecHit++){ + auto me0id = thisRecHit->me0Id(); + auto rollForRechit = me0Geom->etaPartition(me0id); + + auto thisRecHitGlobalPoint = rollForRechit->toGlobal(thisRecHit->localPosition()); + + Rechit_Eta->Fill(fabs(thisRecHitGlobalPoint.eta())); + Rechit_Phi->Fill(thisRecHitGlobalPoint.phi()); + Rechit_R->Fill(thisRecHitGlobalPoint.perp()); + Rechit_Pos->Fill(thisRecHitGlobalPoint.x(),thisRecHitGlobalPoint.y()); + + } + } + //================== + + for(unsigned int i=0; ibegin(); thisSegment != OurSegments->end(); + ++thisSegment){ + ME0DetId id = thisSegment->me0DetId(); + auto roll = me0Geom->etaPartition(id); + auto GlobVect(roll->toGlobal(thisSegment->localPosition())); + if (reco::deltaR(CurrentParticle,GlobVect) < SmallestDelR) SmallestDelR = reco::deltaR(CurrentParticle,GlobVect); + + } + if ((fabs(CurrentParticle.eta()) < 2.0 ) ||(fabs(CurrentParticle.eta()) > 2.8 )) continue; + DelR_Segment_GenMuon->Fill(SmallestDelR); + } + } +} + + +void ME0MuonAnalyzer::endRun(edm::Run const&, edm::EventSetup const&) + +{ + + //Write plots to histo root file and folder + TString cmsText = "CMS PhaseII Simulation Prelim."; + + TString lumiText = "PU 140, 14 TeV"; + float cmsTextFont = 61; // default is helvetic-bold + + + //float extraTextFont = 52; // default is helvetica-italics + float lumiTextSize = 0.05; + + float lumiTextOffset = 0.2; + float cmsTextSize = 0.05; + //float cmsTextOffset = 0.1; // only used in outOfFrame version + + // float relPosX = 0.045; + // float relPosY = 0.035; + // float relExtraDY = 1.2; + + // //ratio of "CMS" and extra text size + // float extraOverCmsTextSize = 0.76; + + + + histoFile->cd(); + + + TCanvas *c1 = new TCanvas("c1", "canvas" ); + + + gStyle->SetOptStat(0); + gStyle->SetOptTitle(0); + + //setTDRStyle(); + + gStyle->SetOptStat(1); + //XPull_h->Fit("gaus","","",-1.,1.); + XPull_h->Draw(); + XPull_h->GetXaxis()->SetTitle("Local pulls: X"); + XPull_h->GetXaxis()->SetTitleSize(0.05); + c1->Print("PullX.png"); + + //YPull_h->Fit("gaus"); + YPull_h->Draw(); + YPull_h->GetXaxis()->SetTitle("Local pulls: Y"); + YPull_h->GetXaxis()->SetTitleSize(0.05); + c1->Print("PullY.png"); + + gStyle->SetOptStat(1); + // XDiff_h->Fit("gaus","","",-1.,1.); + XDiff_h->Draw(); + XDiff_h->GetXaxis()->SetTitle("Local residuals : X"); + XDiff_h->GetXaxis()->SetTitleSize(0.05); + c1->Print("DiffX.png"); + + // YDiff_h->Fit("gaus"); + YDiff_h->Draw(); + YDiff_h->GetXaxis()->SetTitle("Local residuals : Y"); + YDiff_h->GetXaxis()->SetTitleSize(0.05); + c1->Print("DiffY.png"); + + gStyle->SetOptStat(0); + Nevents_h->Write(); + + SegPosDirPhiDiff_True_h->Write(); SegPosDirPhiDiff_True_h->Draw(); c1->Print(histoFolder+"/SegPosDirPhiDiff_True_h.png"); + SegPosDirEtaDiff_True_h->Write(); SegPosDirEtaDiff_True_h->Draw(); c1->Print(histoFolder+"/SegPosDirEtaDiff_True_h.png"); + + c1->SetLogy(); + SegPosDirPhiDiff_All_h->Write(); SegPosDirPhiDiff_All_h->Draw(); c1->Print(histoFolder+"/SegPosDirPhiDiff_All_h.png"); + c1->SetLogy(); + SegPosDirEtaDiff_All_h->Write(); SegPosDirEtaDiff_All_h->Draw(); c1->Print(histoFolder+"/SegPosDirEtaDiff_All_h.png"); + + SegTrackDirPhiDiff_True_h->Write(); SegTrackDirPhiDiff_True_h->Draw(); c1->Print(histoFolder+"/SegTrackDirPhiDiff_True_h.png"); + SegTrackDirEtaDiff_True_h->Write(); SegTrackDirEtaDiff_True_h->Draw(); c1->Print(histoFolder+"/SegTrackDirEtaDiff_True_h.png"); + + SegTrackDirPhiPull_True_h->Write(); SegTrackDirPhiPull_True_h->Draw(); c1->Print(histoFolder+"/SegTrackDirPhiPull_True_h.png"); + SegTrackDirPhiPull_All_h->Write(); SegTrackDirPhiPull_All_h->Draw(); c1->Print(histoFolder+"/SegTrackDirPhiPull_All_h.png"); + + c1->SetLogy(); + SegTrackDirPhiDiff_All_h->Write(); SegTrackDirPhiDiff_All_h->Draw(); c1->Print(histoFolder+"/SegTrackDirPhiDiff_All_h.png"); + c1->SetLogy(); + SegTrackDirEtaDiff_All_h->Write(); SegTrackDirEtaDiff_All_h->Draw(); c1->Print(histoFolder+"/SegTrackDirEtaDiff_All_h.png"); + + + SegGenDirPhiDiff_True_h->Write(); SegGenDirPhiDiff_True_h->Draw(); c1->Print(histoFolder+"/SegGenDirPhiDiff_True_h.png"); + SegGenDirEtaDiff_True_h->Write(); SegGenDirEtaDiff_True_h->Draw(); c1->Print(histoFolder+"/SegGenDirEtaDiff_True_h.png"); + + SegGenDirPhiPull_True_h->Write(); SegGenDirPhiPull_True_h->Draw(); c1->Print(histoFolder+"/SegGenDirPhiPull_True_h.png"); + SegGenDirPhiPull_All_h->Write(); SegGenDirPhiPull_All_h->Draw(); c1->Print(histoFolder+"/SegGenDirPhiPull_All_h.png"); + + c1->SetLogy(); + SegGenDirPhiDiff_All_h->Write(); SegGenDirPhiDiff_All_h->Draw(); c1->Print(histoFolder+"/SegGenDirPhiDiff_All_h.png"); + c1->SetLogy(); + SegGenDirEtaDiff_All_h->Write(); SegGenDirEtaDiff_All_h->Draw(); c1->Print(histoFolder+"/SegGenDirEtaDiff_All_h.png"); + + Candidate_Eta->Write(); Candidate_Eta->Draw(); c1->Print(histoFolder+"/Candidate_Eta.png"); + Track_Eta->Write(); Track_Eta->Draw(); c1->Print(histoFolder+"/Track_Eta.png"); + Track_Pt->Write(); Track_Pt->Draw(); c1->Print(histoFolder+"/Track_Pt.png"); + + Segment_Eta->GetXaxis()->SetTitle("me0segment |#eta|"); + Segment_Eta->GetYaxis()->SetTitle(" Num. Segments"); + Segment_Eta->Write(); Segment_Eta->Draw(); + //GenMuon_Eta->SetLineColor(2);GenMuon_Eta->Draw("SAME"); + c1->Print(histoFolder+"/Segment_Eta.png"); + + Segment_Phi->Write(); Segment_Phi->Draw(); c1->Print(histoFolder+"/Segment_Phi.png"); + Segment_R->Write(); Segment_R->Draw(); c1->Print(histoFolder+"/Segment_R.png"); + Segment_Pos->Write(); Segment_Pos->Draw(); c1->Print(histoFolder+"/Segment_Pos.png"); + + Rechit_Eta->Write(); Rechit_Eta->Draw(); c1->Print(histoFolder+"/Rechit_Eta.png"); + Rechit_Phi->Write(); Rechit_Phi->Draw(); c1->Print(histoFolder+"/Rechit_Phi.png"); + Rechit_R->Write(); Rechit_R->Draw(); c1->Print(histoFolder+"/Rechit_R.png"); + Rechit_Pos->Write(); Rechit_Pos->Draw(); c1->Print(histoFolder+"/Rechit_Pos.png"); + + ME0Muon_Eta->Write(); ME0Muon_Eta->Draw(); + ME0Muon_Eta->GetXaxis()->SetTitle("ME0Muon |#eta|"); + ME0Muon_Eta->GetXaxis()->SetTitleSize(0.05); + c1->Print(histoFolder+"/ME0Muon_Eta.png"); + + CheckME0Muon_Eta->Write(); CheckME0Muon_Eta->Draw(); + CheckME0Muon_Eta->GetXaxis()->SetTitle("CheckME0Muon |#eta|"); + CheckME0Muon_Eta->GetXaxis()->SetTitleSize(0.05); + c1->Print(histoFolder+"/CheckME0Muon_Eta.png"); + + ME0Muon_Cuts_Eta->Write(); ME0Muon_Cuts_Eta->Draw(); c1->Print(histoFolder+"/ME0Muon_Cuts_Eta.png"); + ME0Muon_Cuts_WidestBinning_Eta->Write(); ME0Muon_Cuts_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/ME0Muon_Cuts_WidestBinning_Eta.png"); + ME0Muon_Cuts_WideBinning_Eta->Write(); ME0Muon_Cuts_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/ME0Muon_Cuts_WideBinning_Eta.png"); + //c1->SetLogy(); + ME0Muon_Pt->Write(); ME0Muon_Pt->Draw(); + ME0Muon_Pt->GetXaxis()->SetTitle("ME0Muon p_{T}"); + ME0Muon_Pt->GetXaxis()->SetTitleSize(0.05); + c1->Print(histoFolder+"/ME0Muon_Pt.png"); + + ME0Muon_SmallBins_Pt->Write(); ME0Muon_SmallBins_Pt->Draw(); + ME0Muon_SmallBins_Pt->GetXaxis()->SetTitle("ME0Muon p_{T}"); + ME0Muon_SmallBins_Pt->GetXaxis()->SetTitleSize(0.05); + c1->Print(histoFolder+"/ME0Muon_SmallBins_Pt.png"); + + ME0Muon_VariableBins_Pt->Write(); ME0Muon_VariableBins_Pt->Draw(); + ME0Muon_VariableBins_Pt->GetXaxis()->SetTitle("ME0Muon p_{T}"); + ME0Muon_VariableBins_Pt->GetXaxis()->SetTitleSize(0.05); + c1->Print(histoFolder+"/ME0Muon_VariableBins_Pt.png"); + + GenMuon_Eta->Write(); GenMuon_Eta->Draw(); c1->Print(histoFolder+"/GenMuon_Eta.png"); + GenMuon_WideBinning_Eta->Write(); GenMuon_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/GenMuon_WideBinning_Eta.png"); + GenMuon_WidestBinning_Eta->Write(); GenMuon_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/GenMuon_WidestBinning_Eta.png"); + + TPMuon_Eta->Write(); TPMuon_Eta->Draw(); c1->Print(histoFolder+"/TPMuon_Eta.png"); + TPMuon_WideBinning_Eta->Write(); TPMuon_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/TPMuon_WideBinning_Eta.png"); + TPMuon_WidestBinning_Eta->Write(); TPMuon_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/TPMuon_WidestBinning_Eta.png"); + + + TPMuon_Pt->Write(); TPMuon_Pt->Draw(); c1->Print(histoFolder+"/TPMuon_Pt.png"); + TPMuon_SmallBins_Pt->Write(); TPMuon_SmallBins_Pt->Draw(); c1->Print(histoFolder+"/TPMuon_SmallBins_Pt.png"); + TPMuon_VariableBins_Pt->Write(); TPMuon_VariableBins_Pt->Draw(); c1->Print(histoFolder+"/TPMuon_VariableBins_Pt.png"); + + GenMuon_Pt->Write(); GenMuon_Pt->Draw(); c1->Print(histoFolder+"/GenMuon_Pt.png"); + GenMuon_SmallBins_Pt->Write(); GenMuon_SmallBins_Pt->Draw(); c1->Print(histoFolder+"/GenMuon_SmallBins_Pt.png"); + GenMuon_VariableBins_Pt->Write(); GenMuon_VariableBins_Pt->Draw(); c1->Print(histoFolder+"/GenMuon_VariableBins_Pt.png"); + + MatchedME0Muon_Eta->Write(); MatchedME0Muon_Eta->Draw(); c1->Print(histoFolder+"/MatchedME0Muon_Eta.png"); + MatchedME0Muon_WideBinning_Eta->Write(); MatchedME0Muon_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/MatchedME0Muon_WideBinning_Eta.png"); + MatchedME0Muon_WidestBinning_Eta->Write(); MatchedME0Muon_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/MatchedME0Muon_WidestBinning_Eta.png"); + + StandaloneMatchedME0Muon_Eta->Write(); StandaloneMatchedME0Muon_Eta->Draw(); c1->Print(histoFolder+"/StandaloneMatchedME0Muon_Eta.png"); + StandaloneMatchedME0Muon_WideBinning_Eta->Write(); StandaloneMatchedME0Muon_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/StandaloneMatchedME0Muon_WideBinning_Eta.png"); + StandaloneMatchedME0Muon_WidestBinning_Eta->Write(); StandaloneMatchedME0Muon_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/StandaloneMatchedME0Muon_WidestBinning_Eta.png"); + + Chi2MatchedME0Muon_Eta->Write(); Chi2MatchedME0Muon_Eta->Draw(); c1->Print(histoFolder+"/Chi2MatchedME0Muon_Eta.png"); + Chi2MatchedME0Muon_WideBinning_Eta->Write(); Chi2MatchedME0Muon_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/Chi2MatchedME0Muon_WideBinning_Eta.png"); + Chi2MatchedME0Muon_WidestBinning_Eta->Write(); Chi2MatchedME0Muon_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/Chi2MatchedME0Muon_WidestBinning_Eta.png"); + Chi2UnmatchedME0Muon_Eta->Write(); Chi2UnmatchedME0Muon_Eta->Draw(); c1->Print(histoFolder+"/Chi2UnmatchedME0Muon_Eta.png"); + Chi2UnmatchedME0Muon_WideBinning_Eta->Write(); Chi2UnmatchedME0Muon_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/Chi2UnmatchedME0Muon_WideBinning_Eta.png"); + Chi2UnmatchedME0Muon_WidestBinning_Eta->Write(); Chi2UnmatchedME0Muon_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/Chi2UnmatchedME0Muon_WidestBinning_Eta.png"); + + gStyle->SetOptStat(1); + MatchedME0Muon_Pt->GetXaxis()->SetTitle("ME0Muon p_{T}"); + //MatchedME0Muon_Pt->GetYaxis()->SetTitle(" \# of Se"); + + MatchedME0Muon_Pt->Write(); MatchedME0Muon_Pt->Draw(); c1->Print(histoFolder+"/MatchedME0Muon_Pt.png"); + + MatchedME0Muon_SmallBins_Pt->GetXaxis()->SetTitle("ME0Muon p_{T}"); + //MatchedME0Muon_SmallBins_Pt->GetYaxis()->SetTitle(" \# of Se"); + + MatchedME0Muon_SmallBins_Pt->Write(); MatchedME0Muon_SmallBins_Pt->Draw(); c1->Print(histoFolder+"/MatchedME0Muon_SmallBins_Pt.png"); + + MatchedME0Muon_VariableBins_Pt->GetXaxis()->SetTitle("ME0Muon p_{T}"); + //MatchedME0Muon_VariableBins_Pt->GetYaxis()->SetTitle(" \# of Se"); + + MatchedME0Muon_VariableBins_Pt->Write(); MatchedME0Muon_VariableBins_Pt->Draw(); c1->Print(histoFolder+"/MatchedME0Muon_VariableBins_Pt.png"); + gStyle->SetOptStat(0); + + UnmatchedME0Muon_Eta->Write(); UnmatchedME0Muon_Eta->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_Eta.png"); + UnmatchedME0Muon_Cuts_Eta->Write(); UnmatchedME0Muon_Cuts_Eta->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_Cuts_Eta.png"); + UnmatchedME0Muon_Cuts_WideBinning_Eta->Write(); UnmatchedME0Muon_Cuts_WideBinning_Eta->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_Cuts_WideBinning_Eta.png"); + UnmatchedME0Muon_Cuts_WidestBinning_Eta->Write(); UnmatchedME0Muon_Cuts_WidestBinning_Eta->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_Cuts_WidestBinning_Eta.png"); + + UnmatchedME0Muon_ScatterPlot->Write(); UnmatchedME0Muon_ScatterPlot->Draw(); UnmatchedME0Muon_ScatterPlot->Print(histoFolder+"/UnmatchedME0Muon_ScatterPlot.png"); + + + //gStyle->SetOptStat('oue'); + c1->SetLogy(); + UnmatchedME0Muon_Pt->Write(); UnmatchedME0Muon_Pt->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_Pt.png"); + UnmatchedME0Muon_SmallBins_Pt->Write(); UnmatchedME0Muon_SmallBins_Pt->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_SmallBins_Pt.png"); + UnmatchedME0Muon_VariableBins_Pt->Write(); UnmatchedME0Muon_VariableBins_Pt->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_VariableBins_Pt.png"); + + Chi2UnmatchedME0Muon_Pt->Write(); Chi2UnmatchedME0Muon_Pt->Draw(); c1->Print(histoFolder+"/Chi2UnmatchedME0Muon_Pt.png"); + Chi2UnmatchedME0Muon_SmallBins_Pt->Write(); Chi2UnmatchedME0Muon_SmallBins_Pt->Draw(); c1->Print(histoFolder+"/Chi2UnmatchedME0Muon_SmallBins_Pt.png"); + Chi2UnmatchedME0Muon_VariableBins_Pt->Write(); Chi2UnmatchedME0Muon_VariableBins_Pt->Draw(); c1->Print(histoFolder+"/Chi2UnmatchedME0Muon_VariableBins_Pt.png"); + + + Chi2MatchedME0Muon_Pt->Write(); Chi2MatchedME0Muon_Pt->Draw(); c1->Print(histoFolder+"/Chi2MatchedME0Muon_Pt.png"); + Chi2MatchedME0Muon_SmallBins_Pt->Write(); Chi2MatchedME0Muon_SmallBins_Pt->Draw(); c1->Print(histoFolder+"/Chi2MatchedME0Muon_SmallBins_Pt.png"); + Chi2MatchedME0Muon_VariableBins_Pt->Write(); Chi2MatchedME0Muon_VariableBins_Pt->Draw(); c1->Print(histoFolder+"/Chi2MatchedME0Muon_VariableBins_Pt.png"); + + UnmatchedME0Muon_Window_Pt->Write(); UnmatchedME0Muon_Window_Pt->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_Window_Pt.png"); + gStyle->SetOptStat(0); + + FailedTrack_Window_XPull->Write(); FailedTrack_Window_XPull->Draw(); c1->Print(histoFolder+"/FailedTrack_Window_XPull.png"); + FailedTrack_Window_YPull->Write(); FailedTrack_Window_YPull->Draw(); c1->Print(histoFolder+"/FailedTrack_Window_YPull.png"); + FailedTrack_Window_XDiff->Write(); FailedTrack_Window_XDiff->Draw(); c1->Print(histoFolder+"/FailedTrack_Window_XDiff.png"); + FailedTrack_Window_YDiff->Write(); FailedTrack_Window_YDiff->Draw(); c1->Print(histoFolder+"/FailedTrack_Window_YDiff.png"); + FailedTrack_Window_PhiDiff->Write(); FailedTrack_Window_PhiDiff->Draw(); c1->Print(histoFolder+"/FailedTrack_Window_PhiDiff.png"); + + c1->SetLogy(0); + TH1F *UnmatchedME0Muon_Cuts_Eta_PerEvent; + UnmatchedME0Muon_Cuts_Eta_PerEvent = new TH1F("UnmatchedME0Muon_Cuts_Eta_PerEvent" , "Muon |#eta|" , 4, 2.0, 2.8 ); + //UnmatchedME0Muon_Cuts_Eta_PerEvent->Sumw2(); + for (int i=1; i<=UnmatchedME0Muon_Cuts_Eta_PerEvent->GetNbinsX(); ++i){ + UnmatchedME0Muon_Cuts_Eta_PerEvent->SetBinContent(i,(UnmatchedME0Muon_Cuts_Eta->GetBinContent(i))); + } + UnmatchedME0Muon_Cuts_Eta_PerEvent->Scale(1/Nevents); + + UnmatchedME0Muon_Cuts_Eta_PerEvent->GetXaxis()->SetTitle("ME0Muon |#eta|"); + UnmatchedME0Muon_Cuts_Eta_PerEvent->GetXaxis()->SetTitleSize(0.05); + + UnmatchedME0Muon_Cuts_Eta_PerEvent->GetYaxis()->SetTitle("Average Num. ME0Muons per event"); + UnmatchedME0Muon_Cuts_Eta_PerEvent->GetYaxis()->SetTitleSize(0.05); + + UnmatchedME0Muon_Cuts_Eta_PerEvent->Write(); UnmatchedME0Muon_Cuts_Eta_PerEvent->Draw(); c1->Print(histoFolder+"/UnmatchedME0Muon_Cuts_Eta_PerEvent.png"); + + + TH1F *Chi2UnmatchedME0Muon_Eta_PerEvent; + Chi2UnmatchedME0Muon_Eta_PerEvent = new TH1F("Chi2UnmatchedME0Muon_Eta_PerEvent" , "Muon |#eta|" , 4, 2.0, 2.8 ); + //Chi2UnmatchedME0Muon_Eta_PerEvent->Sumw2(); + for (int i=1; i<=Chi2UnmatchedME0Muon_Eta_PerEvent->GetNbinsX(); ++i){ + Chi2UnmatchedME0Muon_Eta_PerEvent->SetBinContent(i,(Chi2UnmatchedME0Muon_Eta->GetBinContent(i))); + } + Chi2UnmatchedME0Muon_Eta_PerEvent->Scale(1/Nevents); + + Chi2UnmatchedME0Muon_Eta_PerEvent->GetXaxis()->SetTitle("ME0Muon |#eta|"); + Chi2UnmatchedME0Muon_Eta_PerEvent->GetXaxis()->SetTitleSize(0.05); + + Chi2UnmatchedME0Muon_Eta_PerEvent->GetYaxis()->SetTitle("Average Num. ME0Muons per event"); + Chi2UnmatchedME0Muon_Eta_PerEvent->GetYaxis()->SetTitleSize(0.05); + + Chi2UnmatchedME0Muon_Eta_PerEvent->Write(); Chi2UnmatchedME0Muon_Eta_PerEvent->Draw(); c1->Print(histoFolder+"/Chi2UnmatchedME0Muon_Eta_PerEvent.png"); + + + TH1F *ME0Muon_Cuts_Eta_PerEvent; + ME0Muon_Cuts_Eta_PerEvent = new TH1F("ME0Muon_Cuts_Eta_PerEvent" , "Muon |#eta|" , 4, 2.0, 2.8 ); + + for (int i=1; i<=ME0Muon_Cuts_Eta_PerEvent->GetNbinsX(); ++i){ + ME0Muon_Cuts_Eta_PerEvent->SetBinContent(i,(ME0Muon_Cuts_Eta->GetBinContent(i))); + } + ME0Muon_Cuts_Eta_PerEvent->Scale(1/Nevents); + + ME0Muon_Cuts_Eta_PerEvent->Write(); ME0Muon_Cuts_Eta_PerEvent->Draw(); c1->Print(histoFolder+"/ME0Muon_Cuts_Eta_PerEvent.png"); + + + + Mass_h->Write(); Mass_h->Draw(); c1->Print(histoFolder+"/Mass_h.png"); + TracksPerSegment_s->SetMarkerStyle(1); + TracksPerSegment_s->SetMarkerSize(3.0); + TracksPerSegment_s->Write(); TracksPerSegment_s->Draw(); c1->Print(histoFolder+"/TracksPerSegment_s.png"); + + TracksPerSegment_h->Write(); TracksPerSegment_h->Draw(); c1->Print(histoFolder+"/TracksPerSegment_h.png"); + + TracksPerSegment_p->GetXaxis()->SetTitle("Gen Muon #eta"); + TracksPerSegment_p->GetYaxis()->SetTitle("Average N_{Tracks} per segment"); + TracksPerSegment_p->Write(); TracksPerSegment_p->Draw(); c1->Print(histoFolder+"/TracksPerSegment_p.png"); + + ClosestDelR_s->SetMarkerStyle(1); + ClosestDelR_s->SetMarkerSize(3.0); + ClosestDelR_s->Write(); ClosestDelR_s->Draw(); c1->Print(histoFolder+"/ClosestDelR_s.png"); + + DelR_Window_Under5->Write(); DelR_Window_Under5->Draw(); c1->Print(histoFolder+"/DelR_Window_Under5.png"); + Pt_Window_Under5->Write(); Pt_Window_Under5->Draw(); c1->Print(histoFolder+"/Pt_Window_Under5.png"); + + DelR_Track_Window_Under5->Write(); DelR_Track_Window_Under5->Draw(); c1->Print(histoFolder+"/DelR_Track_Window_Under5.png"); + Pt_Track_Window_Under5->Write(); Pt_Track_Window_Under5->Draw(); c1->Print(histoFolder+"/Pt_Track_Window_Under5.png"); + c1->SetLogy(1); + Pt_Track_Window->Write(); Pt_Track_Window->Draw(); c1->Print(histoFolder+"/Pt_Track_Window.png"); + c1->SetLogy(0); + + DelR_Track_Window_Failed_Under5->Write(); DelR_Track_Window_Failed_Under5->Draw(); c1->Print(histoFolder+"/DelR_Track_Window_Failed_Under5.png"); + Pt_Track_Window_Failed_Under5->Write(); Pt_Track_Window_Failed_Under5->Draw(); c1->Print(histoFolder+"/Pt_Track_Window_Failed_Under5.png"); + c1->SetLogy(1); + Pt_Track_Window_Failed->Write(); Pt_Track_Window_Failed->Draw(); c1->Print(histoFolder+"/Pt_Track_Window_Failed.png"); + c1->SetLogy(0); + + DelR_Segment_GenMuon->Write(); DelR_Segment_GenMuon->Draw(); c1->Print(histoFolder+"/DelR_Segment_GenMuon.png"); + + ClosestDelR_p->GetXaxis()->SetTitle("Gen Muon #eta"); + ClosestDelR_p->GetYaxis()->SetTitle("Average closest #Delta R track"); + std::cout<<" ClosestDelR_p values:"<GetNbinsX(); ++i){ + std::cout<<2.4+(double)i*((4.0-2.4)/40.)<<","<GetBinContent(i)<Write(); ClosestDelR_p->Draw(); c1->Print(histoFolder+"/ClosestDelR_p.png"); + + FakeTracksPerSegment_s->SetMarkerStyle(1); + FakeTracksPerSegment_s->SetMarkerSize(3.0); + FakeTracksPerSegment_s->Write(); FakeTracksPerSegment_s->Draw(); c1->Print(histoFolder+"/FakeTracksPerSegment_s.png"); + + FakeTracksPerSegment_h->Write(); FakeTracksPerSegment_h->Draw(); c1->Print(histoFolder+"/FakeTracksPerSegment_h.png"); + + FakeTracksPerSegment_p->GetXaxis()->SetTitle("Gen Muon #eta"); + FakeTracksPerSegment_p->GetYaxis()->SetTitle("Average N_{Tracks} per segment"); + FakeTracksPerSegment_p->Write(); FakeTracksPerSegment_p->Draw(); c1->Print(histoFolder+"/FakeTracksPerSegment_p.png"); + + FakeTracksPerAssociatedSegment_s->SetMarkerStyle(1); + FakeTracksPerAssociatedSegment_s->SetMarkerSize(3.0); + FakeTracksPerAssociatedSegment_s->Write(); FakeTracksPerAssociatedSegment_s->Draw(); c1->Print(histoFolder+"/FakeTracksPerAssociatedSegment_s.png"); + + FakeTracksPerAssociatedSegment_h->Write(); FakeTracksPerAssociatedSegment_h->Draw(); c1->Print(histoFolder+"/FakeTracksPerAssociatedSegment_h.png"); + + FakeTracksPerAssociatedSegment_p->GetXaxis()->SetTitle("Gen Muon #eta"); + FakeTracksPerAssociatedSegment_p->GetYaxis()->SetTitle("Average N_{Tracks} per segment"); + FakeTracksPerAssociatedSegment_p->Write(); FakeTracksPerAssociatedSegment_p->Draw(); c1->Print(histoFolder+"/FakeTracksPerAssociatedSegment_p.png"); + + PreMatch_TP_R->Write(); PreMatch_TP_R->Draw(); c1->Print(histoFolder+"/PreMatch_TP_R.png"); + PostMatch_TP_R->Write(); PostMatch_TP_R->Draw(); c1->Print(histoFolder+"/PostMatch_TP_R.png"); + PostMatch_BX0_TP_R->Write(); PostMatch_BX0_TP_R->Draw(); c1->Print(histoFolder+"/PostMatch_BX0_TP_R.png"); + + GenMuon_Eta->Sumw2(); MatchedME0Muon_Eta->Sumw2(); Chi2MatchedME0Muon_Eta->Sumw2(); Chi2UnmatchedME0Muon_Eta->Sumw2();TPMuon_Eta->Sumw2(); + GenMuon_Pt->Sumw2(); MatchedME0Muon_Pt->Sumw2(); MatchedME0Muon_SmallBins_Pt->Sumw2(); MatchedME0Muon_VariableBins_Pt->Sumw2(); + StandaloneMatchedME0Muon_Eta->Sumw2(); + StandaloneMatchedME0Muon_WideBinning_Eta->Sumw2(); + StandaloneMatchedME0Muon_WidestBinning_Eta->Sumw2(); + + + Track_Eta->Sumw2(); ME0Muon_Eta->Sumw2(); + Track_Pt->Sumw2(); ME0Muon_Pt->Sumw2(); ME0Muon_SmallBins_Pt->Sumw2(); ME0Muon_VariableBins_Pt->Sumw2(); + + UnmatchedME0Muon_Eta->Sumw2(); + UnmatchedME0Muon_Pt->Sumw2(); + UnmatchedME0Muon_SmallBins_Pt->Sumw2(); UnmatchedME0Muon_VariableBins_Pt->Sumw2(); + + UnmatchedME0Muon_Cuts_Eta->Sumw2(); ME0Muon_Cuts_Eta->Sumw2(); + + ME0Muon_Cuts_Eta_5_10->Sumw2(); ME0Muon_Cuts_Eta_9_11->Sumw2(); ME0Muon_Cuts_Eta_10_50->Sumw2(); ME0Muon_Cuts_Eta_50_100->Sumw2(); ME0Muon_Cuts_Eta_100->Sumw2(); + UnmatchedME0Muon_Cuts_Eta_5_10->Sumw2(); UnmatchedME0Muon_Cuts_Eta_9_11->Sumw2(); UnmatchedME0Muon_Cuts_Eta_10_50->Sumw2(); UnmatchedME0Muon_Cuts_Eta_50_100->Sumw2(); UnmatchedME0Muon_Cuts_Eta_100->Sumw2(); + GenMuon_Eta_5_10->Sumw2(); GenMuon_Eta_9_11->Sumw2(); GenMuon_Eta_10_50->Sumw2(); GenMuon_Eta_50_100->Sumw2(); GenMuon_Eta_100->Sumw2(); + MatchedME0Muon_Eta_5_10->Sumw2(); MatchedME0Muon_Eta_9_11->Sumw2(); MatchedME0Muon_Eta_10_50->Sumw2(); MatchedME0Muon_Eta_50_100->Sumw2(); MatchedME0Muon_Eta_100->Sumw2(); + + Chi2MatchedME0Muon_Eta_5_10->Sumw2(); Chi2MatchedME0Muon_Eta_9_11->Sumw2(); Chi2MatchedME0Muon_Eta_10_50->Sumw2(); Chi2MatchedME0Muon_Eta_50_100->Sumw2(); Chi2MatchedME0Muon_Eta_100->Sumw2(); + + UnmatchedME0Muon_Cuts_WideBinning_Eta->Sumw2(); + UnmatchedME0Muon_Cuts_WidestBinning_Eta->Sumw2(); + GenMuon_WideBinning_Eta->Sumw2(); + GenMuon_WidestBinning_Eta->Sumw2(); + TPMuon_WideBinning_Eta->Sumw2(); + TPMuon_WidestBinning_Eta->Sumw2(); + MatchedME0Muon_WideBinning_Eta->Sumw2(); + MatchedME0Muon_WidestBinning_Eta->Sumw2(); + Chi2MatchedME0Muon_WideBinning_Eta->Sumw2(); + Chi2MatchedME0Muon_WidestBinning_Eta->Sumw2(); + ME0Muon_Cuts_WideBinning_Eta->Sumw2(); + ME0Muon_Cuts_WidestBinning_Eta->Sumw2(); + Chi2UnmatchedME0Muon_WideBinning_Eta->Sumw2(); + Chi2UnmatchedME0Muon_WidestBinning_Eta->Sumw2(); + + + //Captions/labels + std::stringstream PtCutString; + + PtCutString<<"#splitline{DY }{Reco Track p_{T} > "<SetTextAlign(12); + //txt->SetTextFont(42); + txt->SetNDC(); + //txt->SetTextSize(0.05); + txt->SetTextFont(132); + txt->SetTextSize(0.05); + + + float t = c1->GetTopMargin(); + float r = c1->GetRightMargin(); + + TLatex* latex1 = new TLatex; + latex1->SetNDC(); + latex1->SetTextAngle(0); + latex1->SetTextColor(kBlack); + + + latex1->SetTextFont(42); + latex1->SetTextAlign(31); + //latex1->SetTextSize(lumiTextSize*t); + latex1->SetTextSize(lumiTextSize); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + TLatex* latex = new TLatex; + latex->SetTextFont(cmsTextFont); + latex->SetNDC(); + latex->SetTextSize(cmsTextSize); + //latex->SetTextAlign(align_); + + //End captions/labels + std::cout<<"GenMuon_Eta = "<Integral()<GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_Eta->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_Eta->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_Eta->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_Eta->SetMinimum(MuonRecoEff_Eta->GetMinimum()-0.1); + MuonRecoEff_Eta->SetMinimum(0); + //MuonRecoEff_Eta->SetMaximum(MuonRecoEff_Eta->GetMaximum()+0.1); + MuonRecoEff_Eta->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_Eta->Write(); MuonRecoEff_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_Eta.png"); + c1->Print(histoFolder+"/MuonRecoEff_Eta.png"); + + + MuonRecoEff_WideBinning_Eta->Divide(MatchedME0Muon_WideBinning_Eta, GenMuon_WideBinning_Eta, 1, 1, "B"); + MuonRecoEff_WideBinning_Eta->GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_WideBinning_Eta->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_WideBinning_Eta->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_WideBinning_Eta->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_WideBinning_Eta->SetMinimum(MuonRecoEff_WideBinning_Eta->GetMinimum()-0.1); + MuonRecoEff_WideBinning_Eta->SetMinimum(0); + //MuonRecoEff_WideBinning_Eta->SetMaximum(MuonRecoEff_WideBinning_Eta->GetMaximum()+0.1); + MuonRecoEff_WideBinning_Eta->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_WideBinning_Eta->Write(); MuonRecoEff_WideBinning_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_WideBinning_Eta.png"); + c1->Print(histoFolder+"/MuonRecoEff_WideBinning_Eta.png"); + + + MuonRecoEff_WidestBinning_Eta->Divide(MatchedME0Muon_WidestBinning_Eta, GenMuon_WidestBinning_Eta, 1, 1, "B"); + MuonRecoEff_WidestBinning_Eta->GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_WidestBinning_Eta->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_WidestBinning_Eta->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_WidestBinning_Eta->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_WidestBinning_Eta->SetMinimum(MuonRecoEff_WidestBinning_Eta->GetMinimum()-0.1); + MuonRecoEff_WidestBinning_Eta->SetMinimum(0); + //MuonRecoEff_WidestBinning_Eta->SetMaximum(MuonRecoEff_WidestBinning_Eta->GetMaximum()+0.1); + MuonRecoEff_WidestBinning_Eta->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_WidestBinning_Eta->Write(); MuonRecoEff_WidestBinning_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_WidestBinning_Eta.png"); + c1->Print(histoFolder+"/MuonRecoEff_WidestBinning_Eta.png"); + + + StandaloneMuonRecoEff_Eta->Divide(StandaloneMatchedME0Muon_Eta, GenMuon_Eta, 1, 1, "B"); + StandaloneMuonRecoEff_Eta->GetXaxis()->SetTitle("Gen Muon |#eta|"); + StandaloneMuonRecoEff_Eta->GetXaxis()->SetTitleSize(0.05); + StandaloneMuonRecoEff_Eta->GetYaxis()->SetTitle("Standalone Muon Efficiency"); + StandaloneMuonRecoEff_Eta->GetYaxis()->SetTitleSize(0.05); + //StandaloneMuonRecoEff_Eta->SetMinimum(StandaloneMuonRecoEff_Eta->GetMinimum()-0.1); + StandaloneMuonRecoEff_Eta->SetMinimum(0); + //StandaloneMuonRecoEff_Eta->SetMaximum(StandaloneMuonRecoEff_Eta->GetMaximum()+0.1); + StandaloneMuonRecoEff_Eta->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + StandaloneMuonRecoEff_Eta->Write(); StandaloneMuonRecoEff_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestStandaloneMuonRecoEff_Eta.png"); + c1->Print(histoFolder+"/StandaloneMuonRecoEff_Eta.png"); + + + StandaloneMuonRecoEff_WideBinning_Eta->Divide(StandaloneMatchedME0Muon_WideBinning_Eta, GenMuon_WideBinning_Eta, 1, 1, "B"); + StandaloneMuonRecoEff_WideBinning_Eta->GetXaxis()->SetTitle("Gen Muon |#eta|"); + StandaloneMuonRecoEff_WideBinning_Eta->GetXaxis()->SetTitleSize(0.05); + StandaloneMuonRecoEff_WideBinning_Eta->GetYaxis()->SetTitle("Standalone Muon Efficiency"); + StandaloneMuonRecoEff_WideBinning_Eta->GetYaxis()->SetTitleSize(0.05); + //StandaloneMuonRecoEff_WideBinning_Eta->SetMinimum(StandaloneMuonRecoEff_WideBinning_Eta->GetMinimum()-0.1); + StandaloneMuonRecoEff_WideBinning_Eta->SetMinimum(0); + //StandaloneMuonRecoEff_WideBinning_Eta->SetMaximum(StandaloneMuonRecoEff_WideBinning_Eta->GetMaximum()+0.1); + StandaloneMuonRecoEff_WideBinning_Eta->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + StandaloneMuonRecoEff_WideBinning_Eta->Write(); StandaloneMuonRecoEff_WideBinning_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestStandaloneMuonRecoEff_WideBinning_Eta.png"); + c1->Print(histoFolder+"/StandaloneMuonRecoEff_WideBinning_Eta.png"); + + + StandaloneMuonRecoEff_WidestBinning_Eta->Divide(StandaloneMatchedME0Muon_WidestBinning_Eta, GenMuon_WidestBinning_Eta, 1, 1, "B"); + StandaloneMuonRecoEff_WidestBinning_Eta->GetXaxis()->SetTitle("Gen Muon |#eta|"); + StandaloneMuonRecoEff_WidestBinning_Eta->GetXaxis()->SetTitleSize(0.05); + StandaloneMuonRecoEff_WidestBinning_Eta->GetYaxis()->SetTitle("Standalone Muon Efficiency"); + StandaloneMuonRecoEff_WidestBinning_Eta->GetYaxis()->SetTitleSize(0.05); + //StandaloneMuonRecoEff_WidestBinning_Eta->SetMinimum(StandaloneMuonRecoEff_WidestBinning_Eta->GetMinimum()-0.1); + StandaloneMuonRecoEff_WidestBinning_Eta->SetMinimum(0); + //StandaloneMuonRecoEff_WidestBinning_Eta->SetMaximum(StandaloneMuonRecoEff_WidestBinning_Eta->GetMaximum()+0.1); + StandaloneMuonRecoEff_WidestBinning_Eta->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + StandaloneMuonRecoEff_WidestBinning_Eta->Write(); StandaloneMuonRecoEff_WidestBinning_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestStandaloneMuonRecoEff_WidestBinning_Eta.png"); + c1->Print(histoFolder+"/StandaloneMuonRecoEff_WidestBinning_Eta.png"); + + + MuonRecoEff_Eta_5_10->Divide(MatchedME0Muon_Eta_5_10, GenMuon_Eta_5_10, 1, 1, "B"); + MuonRecoEff_Eta_5_10->GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_Eta_5_10->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_Eta_5_10->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_Eta_5_10->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_Eta_5_10->SetMinimum(MuonRecoEff_Eta_5_10->GetMinimum()-0.1); + MuonRecoEff_Eta_5_10->SetMinimum(0); + //MuonRecoEff_Eta_5_10->SetMaximum(MuonRecoEff_Eta_5_10->GetMaximum()+0.1); + MuonRecoEff_Eta_5_10->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_Eta_5_10->Write(); MuonRecoEff_Eta_5_10->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_Eta_5_10.png"); + c1->Print(histoFolder+"/MuonRecoEff_Eta_5_10.png"); + + MuonRecoEff_Eta_9_11->Divide(MatchedME0Muon_Eta_9_11, GenMuon_Eta_9_11, 1, 1, "B"); + MuonRecoEff_Eta_9_11->GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_Eta_9_11->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_Eta_9_11->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_Eta_9_11->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_Eta_9_11->SetMinimum(MuonRecoEff_Eta_9_11->GetMinimum()-0.1); + MuonRecoEff_Eta_9_11->SetMinimum(0); + //MuonRecoEff_Eta_9_11->SetMaximum(MuonRecoEff_Eta_9_11->GetMaximum()+0.1); + MuonRecoEff_Eta_9_11->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_Eta_9_11->Write(); MuonRecoEff_Eta_9_11->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_Eta_9_11.png"); + c1->Print(histoFolder+"/MuonRecoEff_Eta_9_11.png"); + + MuonRecoEff_Eta_10_50->Divide(MatchedME0Muon_Eta_10_50, GenMuon_Eta_10_50, 1, 1, "B"); + MuonRecoEff_Eta_10_50->GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_Eta_10_50->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_Eta_10_50->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_Eta_10_50->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_Eta_10_50->SetMinimum(MuonRecoEff_Eta_10_50->GetMinimum()-0.1); + MuonRecoEff_Eta_10_50->SetMinimum(0); + //MuonRecoEff_Eta_10_50->SetMaximum(MuonRecoEff_Eta_10_50->GetMaximum()+0.1); + MuonRecoEff_Eta_10_50->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_Eta_10_50->Write(); MuonRecoEff_Eta_10_50->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_Eta_10_50.png"); + c1->Print(histoFolder+"/MuonRecoEff_Eta_10_50.png"); + + + MuonRecoEff_Eta_50_100->Divide(MatchedME0Muon_Eta_50_100, GenMuon_Eta_50_100, 1, 1, "B"); + MuonRecoEff_Eta_50_100->GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_Eta_50_100->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_Eta_50_100->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_Eta_50_100->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_Eta_50_100->SetMinimum(MuonRecoEff_Eta_50_100->GetMinimum()-0.1); + MuonRecoEff_Eta_50_100->SetMinimum(0); + //MuonRecoEff_Eta_50_100->SetMaximum(MuonRecoEff_Eta_50_100->GetMaximum()+0.1); + MuonRecoEff_Eta_50_100->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_Eta_50_100->Write(); MuonRecoEff_Eta_50_100->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_Eta_50_100.png"); + c1->Print(histoFolder+"/MuonRecoEff_Eta_50_100.png"); + + + MuonRecoEff_Eta_100->Divide(MatchedME0Muon_Eta_100, GenMuon_Eta_100, 1, 1, "B"); + MuonRecoEff_Eta_100->GetXaxis()->SetTitle("Gen Muon |#eta|"); + MuonRecoEff_Eta_100->GetXaxis()->SetTitleSize(0.05); + MuonRecoEff_Eta_100->GetYaxis()->SetTitle("ME0Muon Efficiency"); + MuonRecoEff_Eta_100->GetYaxis()->SetTitleSize(0.05); + //MuonRecoEff_Eta_100->SetMinimum(MuonRecoEff_Eta_100->GetMinimum()-0.1); + MuonRecoEff_Eta_100->SetMinimum(0); + //MuonRecoEff_Eta_100->SetMaximum(MuonRecoEff_Eta_100->GetMaximum()+0.1); + MuonRecoEff_Eta_100->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + MuonRecoEff_Eta_100->Write(); MuonRecoEff_Eta_100->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestMuonRecoEff_Eta_100.png"); + c1->Print(histoFolder+"/MuonRecoEff_Eta_100.png"); + + + + + + Chi2MuonRecoEff_Eta->Divide(Chi2MatchedME0Muon_Eta, TPMuon_Eta, 1, 1, "B"); + std::cout<<"TPMuon_Eta = "<Integral()<GetXaxis()->SetTitleSize(0.05); + + Chi2MuonRecoEff_Eta->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_Eta->GetYaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_Eta->SetMinimum(0); + Chi2MuonRecoEff_Eta->SetMaximum(1.2); + + Chi2MuonRecoEff_Eta->Write(); Chi2MuonRecoEff_Eta->Draw(); + + txt->DrawLatex(0.15,0.2,pcstr); + + + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //latex->SetTextAlign(align_); + latex->DrawLatex(0.4, 0.85, cmsText); + + c1->Print(histoFolder+"/Chi2MuonRecoEff_Eta.png"); + + Chi2MuonRecoEff_WideBinning_Eta->Divide(Chi2MatchedME0Muon_WideBinning_Eta, TPMuon_WideBinning_Eta, 1, 1, "B"); + std::cout<<"TPMuon_WideBinning_Eta = "<Integral()<GetXaxis()->SetTitleSize(0.05); + + Chi2MuonRecoEff_WideBinning_Eta->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_WideBinning_Eta->GetYaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_WideBinning_Eta->SetMinimum(0); + Chi2MuonRecoEff_WideBinning_Eta->SetMaximum(1.2); + + Chi2MuonRecoEff_WideBinning_Eta->Write(); Chi2MuonRecoEff_WideBinning_Eta->Draw(); + + txt->DrawLatex(0.15,0.2,pcstr); + + + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //latex->SetTextAlign(align_); + latex->DrawLatex(0.4, 0.85, cmsText); + + c1->Print(histoFolder+"/Chi2MuonRecoEff_WideBinning_Eta.png"); + + Chi2MuonRecoEff_WidestBinning_Eta->Divide(Chi2MatchedME0Muon_WidestBinning_Eta, TPMuon_WidestBinning_Eta, 1, 1, "B"); + std::cout<<"TPMuon_WidestBinning_Eta = "<Integral()<GetXaxis()->SetTitleSize(0.05); + + Chi2MuonRecoEff_WidestBinning_Eta->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_WidestBinning_Eta->GetYaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_WidestBinning_Eta->SetMinimum(0); + Chi2MuonRecoEff_WidestBinning_Eta->SetMaximum(1.2); + + Chi2MuonRecoEff_WidestBinning_Eta->Write(); Chi2MuonRecoEff_WidestBinning_Eta->Draw(); + + txt->DrawLatex(0.15,0.2,pcstr); + + + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //latex->SetTextAlign(align_); + latex->DrawLatex(0.4, 0.85, cmsText); + + c1->Print(histoFolder+"/Chi2MuonRecoEff_WidestBinning_Eta.png"); + + std::cout<<"Here0"<Divide(Chi2MatchedME0Muon_Eta_5_10, GenMuon_Eta_5_10, 1, 1, "B"); + std::cout<<"Here0"<GetXaxis()->SetTitle("Gen Muon |#eta|"); + Chi2MuonRecoEff_Eta_5_10->GetXaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_Eta_5_10->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_Eta_5_10->GetYaxis()->SetTitleSize(0.05); + //Chi2MuonRecoEff_Eta_5_10->SetMinimum(Chi2MuonRecoEff_Eta_5_10->GetMinimum()-0.1); + Chi2MuonRecoEff_Eta_5_10->SetMinimum(0); + //Chi2MuonRecoEff_Eta_5_10->SetMaximum(Chi2MuonRecoEff_Eta_5_10->GetMaximum()+0.1); + Chi2MuonRecoEff_Eta_5_10->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + Chi2MuonRecoEff_Eta_5_10->Write(); Chi2MuonRecoEff_Eta_5_10->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestChi2MuonRecoEff_Eta_5_10.png"); + c1->Print(histoFolder+"/Chi2MuonRecoEff_Eta_5_10.png"); + + + Chi2MuonRecoEff_Eta_9_11->Divide(Chi2MatchedME0Muon_Eta_9_11, GenMuon_Eta_9_11, 1, 1, "B"); + std::cout<<"Here0"<GetXaxis()->SetTitle("Gen Muon |#eta|"); + Chi2MuonRecoEff_Eta_9_11->GetXaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_Eta_9_11->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_Eta_9_11->GetYaxis()->SetTitleSize(0.05); + //Chi2MuonRecoEff_Eta_9_11->SetMinimum(Chi2MuonRecoEff_Eta_9_11->GetMinimum()-0.1); + Chi2MuonRecoEff_Eta_9_11->SetMinimum(0); + //Chi2MuonRecoEff_Eta_9_11->SetMaximum(Chi2MuonRecoEff_Eta_9_11->GetMaximum()+0.1); + Chi2MuonRecoEff_Eta_9_11->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + Chi2MuonRecoEff_Eta_9_11->Write(); Chi2MuonRecoEff_Eta_9_11->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestChi2MuonRecoEff_Eta_9_11.png"); + c1->Print(histoFolder+"/Chi2MuonRecoEff_Eta_9_11.png"); + + std::cout<<"Here"<Divide(Chi2MatchedME0Muon_Eta_10_50, GenMuon_Eta_10_50, 1, 1, "B"); + Chi2MuonRecoEff_Eta_10_50->GetXaxis()->SetTitle("Gen Muon |#eta|"); + Chi2MuonRecoEff_Eta_10_50->GetXaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_Eta_10_50->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_Eta_10_50->GetYaxis()->SetTitleSize(0.05); + //Chi2MuonRecoEff_Eta_10_50->SetMinimum(Chi2MuonRecoEff_Eta_10_50->GetMinimum()-0.1); + Chi2MuonRecoEff_Eta_10_50->SetMinimum(0); + //Chi2MuonRecoEff_Eta_10_50->SetMaximum(Chi2MuonRecoEff_Eta_10_50->GetMaximum()+0.1); + Chi2MuonRecoEff_Eta_10_50->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + Chi2MuonRecoEff_Eta_10_50->Write(); Chi2MuonRecoEff_Eta_10_50->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestChi2MuonRecoEff_Eta_10_50.png"); + c1->Print(histoFolder+"/Chi2MuonRecoEff_Eta_10_50.png"); + + + Chi2MuonRecoEff_Eta_50_100->Divide(Chi2MatchedME0Muon_Eta_50_100, GenMuon_Eta_50_100, 1, 1, "B"); + Chi2MuonRecoEff_Eta_50_100->GetXaxis()->SetTitle("Gen Muon |#eta|"); + Chi2MuonRecoEff_Eta_50_100->GetXaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_Eta_50_100->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_Eta_50_100->GetYaxis()->SetTitleSize(0.05); + //Chi2MuonRecoEff_Eta_50_100->SetMinimum(Chi2MuonRecoEff_Eta_50_100->GetMinimum()-0.1); + Chi2MuonRecoEff_Eta_50_100->SetMinimum(0); + //Chi2MuonRecoEff_Eta_50_100->SetMaximum(Chi2MuonRecoEff_Eta_50_100->GetMaximum()+0.1); + Chi2MuonRecoEff_Eta_50_100->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + Chi2MuonRecoEff_Eta_50_100->Write(); Chi2MuonRecoEff_Eta_50_100->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestChi2MuonRecoEff_Eta_50_100.png"); + c1->Print(histoFolder+"/Chi2MuonRecoEff_Eta_50_100.png"); + + + Chi2MuonRecoEff_Eta_100->Divide(Chi2MatchedME0Muon_Eta_100, GenMuon_Eta_100, 1, 1, "B"); + Chi2MuonRecoEff_Eta_100->GetXaxis()->SetTitle("Gen Muon |#eta|"); + Chi2MuonRecoEff_Eta_100->GetXaxis()->SetTitleSize(0.05); + Chi2MuonRecoEff_Eta_100->GetYaxis()->SetTitle("ME0Muon Efficiency"); + Chi2MuonRecoEff_Eta_100->GetYaxis()->SetTitleSize(0.05); + //Chi2MuonRecoEff_Eta_100->SetMinimum(Chi2MuonRecoEff_Eta_100->GetMinimum()-0.1); + Chi2MuonRecoEff_Eta_100->SetMinimum(0); + //Chi2MuonRecoEff_Eta_100->SetMaximum(Chi2MuonRecoEff_Eta_100->GetMaximum()+0.1); + Chi2MuonRecoEff_Eta_100->SetMaximum(1.2); + //CMS_lumi( c1, 7, 11 ); + Chi2MuonRecoEff_Eta_100->Write(); Chi2MuonRecoEff_Eta_100->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + + //c1->SaveAs("TestChi2MuonRecoEff_Eta_100.png"); + c1->Print(histoFolder+"/Chi2MuonRecoEff_Eta_100.png"); + + std::cout<<" MuonRecoEff_Eta values:"<Sumw2(); + for (int i=1; i<=MuonRecoEff_Eta->GetNbinsX(); ++i){ + std::cout<<2.4+(double)i*((4.0-2.4)/40.)<<","<GetBinContent(i)<<","<GetBinError(i)<Divide(MatchedME0Muon_Pt, GenMuon_Pt, 1, 1, "B"); + // MuonRecoEff_Pt->GetXaxis()->SetTitle("Gen Muon p_{T}"); + // MuonRecoEff_Pt->GetYaxis()->SetTitle("Matching Efficiency"); + // MuonRecoEff_Pt->SetMinimum(.85); + // MuonRecoEff_Pt->Write(); MuonRecoEff_Pt->Draw(); c1->Print(histoFolder+"/MuonRecoEff_Pt.png"); + + std::cout<<"UnmatchedME0Muon_Eta = "<Integral()<GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_Eta->GetXaxis()->SetTitleSize(0.05); + FakeRate_Eta->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_Eta->GetYaxis()->SetTitleSize(0.05); + //FakeRate_Eta->SetMinimum(FakeRate_Eta->GetMinimum()-0.1); + FakeRate_Eta->SetMinimum(0); + //FakeRate_Eta->SetMaximum(FakeRate_Eta->GetMaximum()+0.1); + FakeRate_Eta->SetMaximum(1.2); + FakeRate_Eta->Write(); FakeRate_Eta->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_Eta.png'); + c1->Print(histoFolder+"/FakeRate_Eta.png"); + + FakeRate_WideBinning_Eta->Divide(UnmatchedME0Muon_Cuts_WideBinning_Eta, ME0Muon_Cuts_WideBinning_Eta, 1, 1, "B"); + FakeRate_WideBinning_Eta->GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_WideBinning_Eta->GetXaxis()->SetTitleSize(0.05); + FakeRate_WideBinning_Eta->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_WideBinning_Eta->GetYaxis()->SetTitleSize(0.05); + //FakeRate_WideBinning_Eta->SetMinimum(FakeRate_WideBinning_Eta->GetMinimum()-0.1); + FakeRate_WideBinning_Eta->SetMinimum(0); + //FakeRate_WideBinning_Eta->SetMaximum(FakeRate_WideBinning_Eta->GetMaximum()+0.1); + FakeRate_WideBinning_Eta->SetMaximum(1.2); + FakeRate_WideBinning_Eta->Write(); FakeRate_WideBinning_Eta->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_WideBinning_Eta.png'); + c1->Print(histoFolder+"/FakeRate_WideBinning_Eta.png"); + + + FakeRate_WidestBinning_Eta->Divide(UnmatchedME0Muon_Cuts_WidestBinning_Eta, ME0Muon_Cuts_WidestBinning_Eta, 1, 1, "B"); + FakeRate_WidestBinning_Eta->GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_WidestBinning_Eta->GetXaxis()->SetTitleSize(0.05); + FakeRate_WidestBinning_Eta->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_WidestBinning_Eta->GetYaxis()->SetTitleSize(0.05); + //FakeRate_WidestBinning_Eta->SetMinimum(FakeRate_WidestBinning_Eta->GetMinimum()-0.1); + FakeRate_WidestBinning_Eta->SetMinimum(0); + //FakeRate_WidestBinning_Eta->SetMaximum(FakeRate_WidestBinning_Eta->GetMaximum()+0.1); + FakeRate_WidestBinning_Eta->SetMaximum(1.2); + FakeRate_WidestBinning_Eta->Write(); FakeRate_WidestBinning_Eta->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_WidestBinning_Eta.png'); + c1->Print(histoFolder+"/FakeRate_WidestBinning_Eta.png"); + + + FakeRate_Eta_5_10->Divide(UnmatchedME0Muon_Cuts_Eta_5_10, ME0Muon_Cuts_Eta_5_10, 1, 1, "B"); + FakeRate_Eta_5_10->GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_Eta_5_10->GetXaxis()->SetTitleSize(0.05); + FakeRate_Eta_5_10->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_Eta_5_10->GetYaxis()->SetTitleSize(0.05); + //FakeRate_Eta_5_10->SetMinimum(FakeRate_Eta_5_10->GetMinimum()-0.1); + FakeRate_Eta_5_10->SetMinimum(0); + //FakeRate_Eta_5_10->SetMaximum(FakeRate_Eta_5_10->GetMaximum()+0.1); + FakeRate_Eta_5_10->SetMaximum(1.2); + FakeRate_Eta_5_10->Write(); FakeRate_Eta_5_10->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_Eta_5_10.png'); + c1->Print(histoFolder+"/FakeRate_Eta_5_10.png"); + + + FakeRate_Eta_9_11->Divide(UnmatchedME0Muon_Cuts_Eta_9_11, ME0Muon_Cuts_Eta_9_11, 1, 1, "B"); + FakeRate_Eta_9_11->GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_Eta_9_11->GetXaxis()->SetTitleSize(0.05); + FakeRate_Eta_9_11->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_Eta_9_11->GetYaxis()->SetTitleSize(0.05); + //FakeRate_Eta_9_11->SetMinimum(FakeRate_Eta_9_11->GetMinimum()-0.1); + FakeRate_Eta_9_11->SetMinimum(0); + //FakeRate_Eta_9_11->SetMaximum(FakeRate_Eta_9_11->GetMaximum()+0.1); + FakeRate_Eta_9_11->SetMaximum(1.2); + FakeRate_Eta_9_11->Write(); FakeRate_Eta_9_11->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_Eta_9_11.png'); + c1->Print(histoFolder+"/FakeRate_Eta_9_11.png"); + + + + FakeRate_Eta_10_50->Divide(UnmatchedME0Muon_Cuts_Eta_10_50, ME0Muon_Cuts_Eta_10_50, 1, 1, "B"); + FakeRate_Eta_10_50->GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_Eta_10_50->GetXaxis()->SetTitleSize(0.05); + FakeRate_Eta_10_50->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_Eta_10_50->GetYaxis()->SetTitleSize(0.05); + //FakeRate_Eta_10_50->SetMinimum(FakeRate_Eta_10_50->GetMinimum()-0.1); + FakeRate_Eta_10_50->SetMinimum(0); + //FakeRate_Eta_10_50->SetMaximum(FakeRate_Eta_10_50->GetMaximum()+0.1); + FakeRate_Eta_10_50->SetMaximum(1.2); + FakeRate_Eta_10_50->Write(); FakeRate_Eta_10_50->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_Eta_10_50.png'); + c1->Print(histoFolder+"/FakeRate_Eta_10_50.png"); + + + + FakeRate_Eta_50_100->Divide(UnmatchedME0Muon_Cuts_Eta_50_100, ME0Muon_Cuts_Eta_50_100, 1, 1, "B"); + FakeRate_Eta_50_100->GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_Eta_50_100->GetXaxis()->SetTitleSize(0.05); + FakeRate_Eta_50_100->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_Eta_50_100->GetYaxis()->SetTitleSize(0.05); + //FakeRate_Eta_50_100->SetMinimum(FakeRate_Eta_50_100->GetMinimum()-0.1); + FakeRate_Eta_50_100->SetMinimum(0); + //FakeRate_Eta_50_100->SetMaximum(FakeRate_Eta_50_100->GetMaximum()+0.1); + FakeRate_Eta_50_100->SetMaximum(1.2); + FakeRate_Eta_50_100->Write(); FakeRate_Eta_50_100->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_Eta_50_100.png'); + c1->Print(histoFolder+"/FakeRate_Eta_50_100.png"); + + + + FakeRate_Eta_100->Divide(UnmatchedME0Muon_Cuts_Eta_100, ME0Muon_Cuts_Eta_100, 1, 1, "B"); + FakeRate_Eta_100->GetXaxis()->SetTitle("Reconstructed track |#eta|"); + FakeRate_Eta_100->GetXaxis()->SetTitleSize(0.05); + FakeRate_Eta_100->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_Eta_100->GetYaxis()->SetTitleSize(0.05); + //FakeRate_Eta_100->SetMinimum(FakeRate_Eta_100->GetMinimum()-0.1); + FakeRate_Eta_100->SetMinimum(0); + //FakeRate_Eta_100->SetMaximum(FakeRate_Eta_100->GetMaximum()+0.1); + FakeRate_Eta_100->SetMaximum(1.2); + FakeRate_Eta_100->Write(); FakeRate_Eta_100->Draw(); + + txt->DrawLatex(0.15,0.4,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_Eta_100.png'); + c1->Print(histoFolder+"/FakeRate_Eta_100.png"); + + + + Chi2FakeRate_Eta->Divide(Chi2UnmatchedME0Muon_Eta, ME0Muon_Cuts_Eta, 1, 1, "B"); + std::cout<<"Chi2UnmatchedME0Muon_Eta = "<Integral()<GetXaxis()->SetTitleSize(0.05); + Chi2FakeRate_Eta->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + Chi2FakeRate_Eta->GetYaxis()->SetTitleSize(0.05); + Chi2FakeRate_Eta->SetMinimum(0); + Chi2FakeRate_Eta->SetMaximum(1.2); + Chi2FakeRate_Eta->Write(); Chi2FakeRate_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestChi2FakeRate_Eta.png'); + c1->Print(histoFolder+"/Chi2FakeRate_Eta.png"); + + + + Chi2FakeRate_WideBinning_Eta->Divide(Chi2UnmatchedME0Muon_WideBinning_Eta, ME0Muon_Cuts_WideBinning_Eta, 1, 1, "B"); + //std::cout<<"Chi2UnmatchedME0Muon_WideBinning_Eta = "<Integral()<GetXaxis()->SetTitleSize(0.05); + Chi2FakeRate_WideBinning_Eta->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + Chi2FakeRate_WideBinning_Eta->GetYaxis()->SetTitleSize(0.05); + Chi2FakeRate_WideBinning_Eta->SetMinimum(0); + Chi2FakeRate_WideBinning_Eta->SetMaximum(1.2); + Chi2FakeRate_WideBinning_Eta->Write(); Chi2FakeRate_WideBinning_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestChi2FakeRate_WideBinning_Eta.png'); + c1->Print(histoFolder+"/Chi2FakeRate_WideBinning_Eta.png"); + + + Chi2FakeRate_WidestBinning_Eta->Divide(Chi2UnmatchedME0Muon_WidestBinning_Eta, ME0Muon_Cuts_WidestBinning_Eta, 1, 1, "B"); + //std::cout<<"Chi2UnmatchedME0Muon_WidestBinning_Eta = "<Integral()<GetXaxis()->SetTitleSize(0.05); + Chi2FakeRate_WidestBinning_Eta->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + Chi2FakeRate_WidestBinning_Eta->GetYaxis()->SetTitleSize(0.05); + Chi2FakeRate_WidestBinning_Eta->SetMinimum(0); + Chi2FakeRate_WidestBinning_Eta->SetMaximum(1.2); + Chi2FakeRate_WidestBinning_Eta->Write(); Chi2FakeRate_WidestBinning_Eta->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestChi2FakeRate_WidestBinning_Eta.png'); + c1->Print(histoFolder+"/Chi2FakeRate_WidestBinning_Eta.png"); + + + //Fake Rate per Event: + + FakeRate_Eta_PerEvent->Divide(UnmatchedME0Muon_Cuts_Eta_PerEvent, ME0Muon_Cuts_Eta_PerEvent, 1, 1, "B"); + std::cout<<"UnmatchedME0Muon_Eta_PerEvent = "<Integral()<GetXaxis()->SetTitleSize(0.05); + FakeRate_Eta_PerEvent->GetYaxis()->SetTitle("ME0 Muon Fake Rate"); + FakeRate_Eta_PerEvent->GetYaxis()->SetTitleSize(0.05); + FakeRate_Eta_PerEvent->SetMinimum(0); + FakeRate_Eta_PerEvent->SetMaximum(1.2); + FakeRate_Eta_PerEvent->Write(); FakeRate_Eta_PerEvent->Draw(); + txt->DrawLatex(0.15,0.2,pcstr); + latex->DrawLatex(0.4, 0.85, cmsText); + latex1->DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); + + //c1->SaveAs('TestFakeRate_Eta_PerEvent.png'); + c1->Print(histoFolder+"/FakeRate_Eta_PerEvent.png"); + + std::cout<<" FakeRate_Eta values:"<GetNbinsX(); ++i){ + std::cout<<2.4+(double)i*((4.0-2.4)/40.)<<","<GetBinContent(i)<Divide(MatchedME0Muon_Pt, GenMuon_Pt, 1, 1, "B"); + // FakeRate_Pt->GetXaxis()->SetTitle("Gen Muon p_{T}"); + // FakeRate_Pt->GetYaxis()->SetTitle("Matching Efficiency"); + // FakeRate_Pt->SetMinimum(.85); + // FakeRate_Pt->Write(); FakeRate_Pt->Draw(); c1->Print(histoFolder+"/FakeRate_Pt.png"); + + MuonAllTracksEff_Eta->Divide(ME0Muon_Eta, Track_Eta, 1, 1, "B"); + MuonAllTracksEff_Eta->Write(); MuonAllTracksEff_Eta->Draw(); c1->Print(histoFolder+"/MuonAllTracksEff_Eta.png"); + + // MuonAllTracksEff_Pt->Divide(ME0Muon_Pt, Track_Pt, 1, 1, "B"); + // MuonAllTracksEff_Pt->Write(); MuonAllTracksEff_Pt->Draw(); c1->Print(histoFolder+"/MuonAllTracksEff_Pt.png"); + + // MuonUnmatchedTracksEff_Eta->Divide(UnmatchedME0Muon_Eta, ME0Muon_Eta, 1, 1, "B"); + // MuonUnmatchedTracksEff_Eta->Write(); Candidate_Eta->Draw(); c1->Print(histoFolder+"/Candidate_Eta.png"); + + // MuonUnmatchedTracksEff_Pt->Divide(UnmatchedME0Muon_Pt, ME0Muon_Pt, 1, 1, "B"); + // MuonUnmatchedTracksEff_Pt->Write(); Candidate_Eta->Draw(); c1->Print(histoFolder+"/Candidate_Eta.png"); + FractionMatched_Eta->Divide(MatchedME0Muon_Eta, ME0Muon_Eta, 1, 1, "B"); + FractionMatched_Eta->GetXaxis()->SetTitle("Gen Muon |#eta|"); + FractionMatched_Eta->GetYaxis()->SetTitle("Matched/All ME0Muons"); + FractionMatched_Eta->Write(); FractionMatched_Eta->Draw(); c1->Print(histoFolder+"/FractionMatched_Eta.png"); + + gStyle->SetOptStat(1); + PtDiff_h->GetXaxis()->SetTitle("(pt track-ptgen)/ptgen"); + PtDiff_h->Write(); PtDiff_h->Draw(); c1->Print(histoFolder+"/PtDiff_h.png"); + + QOverPtDiff_h->GetXaxis()->SetTitle("(q/pt track-q/ptgen)/(q/ptgen)"); + QOverPtDiff_h->Write(); QOverPtDiff_h->Draw(); c1->Print(histoFolder+"/QOverPtDiff_h.png"); + + gStyle->SetOptStat(0); + PtDiff_s->SetMarkerStyle(1); + PtDiff_s->SetMarkerSize(3.0); + PtDiff_s->GetXaxis()->SetTitle("Gen Muon #eta"); + PtDiff_s->GetYaxis()->SetTitle("|(pt track-ptgen)/ptgen|"); + PtDiff_s->Write(); PtDiff_s->Draw(); c1->Print(histoFolder+"/PtDiff_s.png"); + + for(int i=1; i<=PtDiff_p->GetNbinsX(); ++i) { + PtDiff_rms->SetBinContent(i, PtDiff_p->GetBinError(i)); + std::cout<<"Pt_rms = "<GetBinError(i)<Integral()<GetNbinsX(); ++i) { + + + std::stringstream tempstore; + tempstore<Draw(); + + + PtDiff_s->ProjectionY("test",i,i,""); + std::cout<<"Bin = "<GetBinContent(i)<Fit(gaus_narrow,"R"); + + // Double_t n0 = gaus_narrow->GetParameter(0); + // Double_t n1 = gaus_narrow->GetParameter(1); + // Double_t n2 = gaus_narrow->GetParameter(2); + + // //Double_t e_n0 = gaus_narrow->GetParameterError(0); + // //Double_t e_n1 = gaus_narrow->GetParameterError(1); + // Double_t e_n2 = gaus_narrow->GetParError(2); + + // std::cout<Fit(gaus_wide,"R"); + + std::cout<<"Getting values"<GetParameter(2); + + Double_t e_w2 = gaus_wide->GetParError(2); + + std::cout<<"Got values"<SetBinContent(i, n2); + // PtDiff_gaus_narrow->SetBinError(i, e_n2); + PtDiff_gaus_wide->SetBinContent(i, w2); + PtDiff_gaus_wide->SetBinError(i, e_w2); + + test->Write(); + TString FileName = "Bin"+thistemp+"Fit.png"; + c1->Print(histoFolder+"/"+FileName); + + //test->Draw(); + //delete test; + + //continue; + + + delete test; + test= new TH1D("test" , "pt resolution" , 200, -1.0, 1.0 ); + test->Draw(); + // Redoing for pt 5 to 10 + std::cout<<"About to project"<ProjectionY("test",i,i,""); + std::cout<<"About to check, "<Integral()<Integral() < 1.0) continue; + + std::cout<<"Running the 5-10 fit"<Fit(gaus_5_10,"R"); + + w2 = gaus_5_10->GetParameter(2); + e_w2 = gaus_5_10->GetParError(2); + + PtDiff_gaus_5_10->SetBinContent(i, w2); + PtDiff_gaus_5_10->SetBinError(i, e_w2); + + test->Draw(); + FileName = "Bin"+thistemp+"Fit_5_10.png"; + c1->Print(histoFolder+"/"+FileName); + + delete test; + test= new TH1D("test" , "pt resolution" , 200, -1.0, 1.0 ); + test->Draw(); + // Redoing for pt 10 to 20 + PtDiff_s_10_50->ProjectionY("test",i,i,""); + if (test->Integral() < 1.0) continue; + + TF1 *gaus_10_50 = new TF1("gaus_10_50","gaus",-.2,.2); + test->Fit(gaus_10_50,"R"); + + w2 = gaus_10_50->GetParameter(2); + e_w2 = gaus_10_50->GetParError(2); + + PtDiff_gaus_10_50->SetBinContent(i, w2); + PtDiff_gaus_10_50->SetBinError(i, e_w2); + + test->Draw(); + FileName = "Bin"+thistemp+"Fit_10_50.png"; + c1->Print(histoFolder+"/"+FileName); + + delete test; + + test= new TH1D("test" , "pt resolution" , 200, -1.0, 1.0 ); + test->Draw(); + // Redoing for pt 20 to 40 + PtDiff_s_50_100->ProjectionY("test",i,i,""); + if (test->Integral() < 1.0) continue; + + TF1 *gaus_50_100 = new TF1("gaus_50_100","gaus",-.2,.2); + test->Fit(gaus_50_100,"R"); + + w2 = gaus_50_100->GetParameter(2); + e_w2 = gaus_50_100->GetParError(2); + + PtDiff_gaus_50_100->SetBinContent(i, w2); + PtDiff_gaus_50_100->SetBinError(i, e_w2); + + test->Draw(); + FileName = "Bin"+thistemp+"Fit_50_100.png"; + c1->Print(histoFolder+"/"+FileName); + + delete test; + + test= new TH1D("test" , "pt resolution" , 200, -1.0, 1.0 ); + test->Draw(); + // Redoing for pt 40+ + PtDiff_s_100->ProjectionY("test",i,i,""); + if (test->Integral() < 1.0) continue; + + TF1 *gaus_100 = new TF1("gaus_100","gaus",-.2,.2); + test->Fit(gaus_100,"R"); + + w2 = gaus_100->GetParameter(2); + e_w2 = gaus_100->GetParError(2); + + PtDiff_gaus_100->SetBinContent(i, w2); + PtDiff_gaus_100->SetBinError(i, e_w2); + + test->Draw(); + FileName = "Bin"+thistemp+"Fit_100.png"; + c1->Print(histoFolder+"/"+FileName); + + delete test; + + test= new TH1D("test" , "pt resolution" , 200, -1.0, 1.0 ); + test->Draw(); + // Redoing for pt 40+ + StandalonePtDiff_s->ProjectionY("test",i,i,""); + if (test->Integral() < 1.0) continue; + + TF1 *Standalonegaus = new TF1("Standalonegaus","gaus",-.2,.2); + test->Fit(Standalonegaus,"R"); + + w2 = gaus_100->GetParameter(2); + e_w2 = gaus_100->GetParError(2); + + StandalonePtDiff_gaus->SetBinContent(i, w2); + StandalonePtDiff_gaus->SetBinError(i, e_w2); + + test->Draw(); + FileName = "Bin"+thistemp+"StandaloneFit.png"; + c1->Print(histoFolder+"/"+FileName); + + delete test; + //test->Clear(); + } + // PtDiff_gaus_narrow->SetMarkerStyle(22); + // PtDiff_gaus_narrow->SetMarkerSize(1.2); + // PtDiff_gaus_narrow->SetMarkerColor(kRed); + // //PtDiff_gaus_narrow->SetLineColor(kRed); + + // //PtDiff_gaus_narrow->Draw("PL"); + + // PtDiff_gaus_narrow->GetXaxis()->SetTitle("Gen Muon #eta"); + // PtDiff_gaus_narrow->GetYaxis()->SetTitle("Gaussian width of (pt track-ptgen)/ptgen"); + // PtDiff_gaus_narrow->Write(); PtDiff_gaus_narrow->Draw("PE"); + + PtDiff_gaus_wide->SetMarkerStyle(22); + PtDiff_gaus_wide->SetMarkerSize(1.2); + PtDiff_gaus_wide->SetMarkerColor(kBlue); + //PtDiff_gaus_wide->SetLineColor(kRed); + + //PtDiff_gaus_wide->Draw("PL"); + + PtDiff_gaus_wide->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PtDiff_gaus_wide->GetYaxis()->SetTitle("Gaussian width of (pt track-ptgen)/ptgen"); + PtDiff_gaus_wide->GetYaxis()->SetTitleSize(.04); + PtDiff_gaus_wide->Write(); PtDiff_gaus_wide->Draw("PE"); c1->Print(histoFolder+"/PtDiff_gaus.png"); + + PtDiff_gaus_5_10->SetMarkerStyle(22); + PtDiff_gaus_5_10->SetMarkerSize(1.2); + PtDiff_gaus_5_10->SetMarkerColor(kBlue); + //PtDiff_gaus_5_10->SetLineColor(kRed); + + //PtDiff_gaus_5_10->Draw("PL"); + + PtDiff_gaus_5_10->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PtDiff_gaus_5_10->GetYaxis()->SetTitle("Gaussian width of (pt track-ptgen)/ptgen"); + PtDiff_gaus_5_10->Write(); PtDiff_gaus_5_10->Draw("PE"); c1->Print(histoFolder+"/PtDiff_gaus_5_10.png"); + + PtDiff_gaus_10_50->SetMarkerStyle(22); + PtDiff_gaus_10_50->SetMarkerSize(1.2); + PtDiff_gaus_10_50->SetMarkerColor(kBlue); + //PtDiff_gaus_10_50->SetLineColor(kRed); + + //PtDiff_gaus_10_50->Draw("PL"); + + PtDiff_gaus_10_50->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PtDiff_gaus_10_50->GetYaxis()->SetTitle("Gaussian width of (pt track-ptgen)/ptgen"); + PtDiff_gaus_10_50->Write(); PtDiff_gaus_10_50->Draw("PE"); c1->Print(histoFolder+"/PtDiff_gaus_10_50.png"); + + PtDiff_gaus_50_100->SetMarkerStyle(22); + PtDiff_gaus_50_100->SetMarkerSize(1.2); + PtDiff_gaus_50_100->SetMarkerColor(kBlue); + //PtDiff_gaus_50_100->SetLineColor(kRed); + + //PtDiff_gaus_50_100->Draw("PL"); + + PtDiff_gaus_50_100->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PtDiff_gaus_50_100->GetYaxis()->SetTitle("Gaussian width of (pt track-ptgen)/ptgen"); + PtDiff_gaus_50_100->Write(); PtDiff_gaus_50_100->Draw("PE"); c1->Print(histoFolder+"/PtDiff_gaus_50_100.png"); + + PtDiff_gaus_100->SetMarkerStyle(22); + PtDiff_gaus_100->SetMarkerSize(1.2); + PtDiff_gaus_100->SetMarkerColor(kBlue); + //PtDiff_gaus_100->SetLineColor(kRed); + + //PtDiff_gaus_100->Draw("PL"); + + PtDiff_gaus_100->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PtDiff_gaus_100->GetYaxis()->SetTitle("Gaussian width of (pt track-ptgen)/ptgen"); + PtDiff_gaus_100->Write(); PtDiff_gaus_100->Draw("PE"); c1->Print(histoFolder+"/PtDiff_gaus_100.png"); + + StandalonePtDiff_gaus->SetMarkerStyle(22); + StandalonePtDiff_gaus->SetMarkerSize(1.2); + StandalonePtDiff_gaus->SetMarkerColor(kBlue); + //StandalonePtDiff_gaus->SetLineColor(kRed); + + //StandalonePtDiff_gaus->Draw("PL"); + + StandalonePtDiff_gaus->GetXaxis()->SetTitle("Gen Muon |#eta|"); + StandalonePtDiff_gaus->GetYaxis()->SetTitle("Gaussian width of (pt track-ptgen)/ptgen"); + StandalonePtDiff_gaus->Write(); StandalonePtDiff_gaus->Draw("PE"); c1->Print(histoFolder+"/StandalonePtDiff_gaus.png"); + + + PtDiff_p->SetMarkerStyle(1); + PtDiff_p->SetMarkerSize(3.0); + PtDiff_p->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PtDiff_p->GetYaxis()->SetTitle("Average (pt track-ptgen)/ptgen"); + PtDiff_p->Write(); PtDiff_p->Draw(); c1->Print(histoFolder+"/PtDiff_p.png"); + + //PtDiff_rms->SetMarkerStyle(1); + //PtDiff_rms->SetMarkerSize(3.0); + + PtDiff_rms->SetMarkerStyle(22); + PtDiff_rms->SetMarkerSize(1.2); + PtDiff_rms->SetMarkerColor(kBlue); + //PtDiff_rms->SetLineColor(kRed); + + //PtDiff_rms->Draw("PL"); + + PtDiff_rms->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PtDiff_rms->GetYaxis()->SetTitle("RMS of (pt track-ptgen)/ptgen"); + PtDiff_rms->Write(); PtDiff_rms->Draw("P"); c1->Print(histoFolder+"/PtDiff_rms.png"); + + PDiff_h->GetXaxis()->SetTitle("|(p track-pgen)/pgen|"); + PDiff_h->Write(); PDiff_h->Draw(); c1->Print(histoFolder+"/PDiff_h.png"); + + PDiff_s->SetMarkerStyle(1); + PDiff_s->SetMarkerSize(3.0); + PDiff_s->GetXaxis()->SetTitle("Gen Muon |#eta|"); + PDiff_s->GetYaxis()->SetTitle("|(p track-pgen)/pgen|"); + PDiff_s->Write(); PDiff_s->Draw(); c1->Print(histoFolder+"/PDiff_s.png"); + + PDiff_p->SetMarkerStyle(1); + PDiff_p->SetMarkerSize(3.0); + PDiff_p->GetXaxis()->SetTitle("Gen Muon #eta"); + PDiff_p->GetYaxis()->SetTitle("Average |(p track-pgen)/pgen|"); + PDiff_p->Write(); PDiff_p->Draw(); c1->Print(histoFolder+"/PDiff_p.png"); + + VertexDiff_h->Write(); VertexDiff_h->Draw(); c1->Print(histoFolder+"/VertexDiff_h.png"); + + + + NormChi2_h->Write(); NormChi2_h->Draw(); c1->Print(histoFolder+"/NormChi2_h.png"); + NormChi2Prob_h->Write(); NormChi2Prob_h->Draw(); c1->Print(histoFolder+"/NormChi2Prob_h.png"); + NormChi2VsHits_h->Write(); NormChi2VsHits_h->Draw(); c1->Print(histoFolder+"/NormChi2VsHits_h.png"); + chi2_vs_eta_h->Write(); chi2_vs_eta_h->Draw(); c1->Print(histoFolder+"/chi2_vs_eta_h.png"); + + c1->SetLogy(0); + AssociatedChi2_h->Write(); AssociatedChi2_h->Draw(); c1->Print(histoFolder+"/AssociatedChi2_h.png"); + AssociatedChi2_Prob_h->Write(); AssociatedChi2_Prob_h->Draw(); c1->Print(histoFolder+"/AssociatedChi2_Prob_h.png"); + + //Printing needing values to an output log file + using namespace std; + ofstream logout; + logout.open (histoFolder+"/Log.txt"); + + logout<<"Chi 2 Efficiencies and errors:\n"; + for (int i=1; i<=Chi2MuonRecoEff_Eta->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Efficiencies and errors:\n"; + for (int i=1; i<=MuonRecoEff_Eta->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Fake Rate:\n"; + for (int i=1; i<=FakeRate_Eta->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Resolution vs eta:\n"; + for (int i=1; i<=PtDiff_gaus_wide->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Efficiencies and errors 5_10:\n"; + for (int i=1; i<=MuonRecoEff_Eta_5_10->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Efficiencies and errors 9_11:\n"; + for (int i=1; i<=MuonRecoEff_Eta_9_11->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Chi 2 Efficiencies and errors 5_10:\n"; + for (int i=1; i<=Chi2MuonRecoEff_Eta_5_10->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Fake Rate 5_10:\n"; + for (int i=1; i<=FakeRate_Eta_5_10->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Resolution vs eta 5_10:\n"; + for (int i=1; i<=PtDiff_gaus_5_10->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Efficiencies and errors 10_50:\n"; + for (int i=1; i<=MuonRecoEff_Eta_10_50->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Chi 2 Efficiencies and errors 10_50:\n"; + for (int i=1; i<=Chi2MuonRecoEff_Eta_10_50->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Fake Rate 10_50:\n"; + for (int i=1; i<=FakeRate_Eta_10_50->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Resolution vs eta 10_50:\n"; + for (int i=1; i<=PtDiff_gaus_10_50->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Efficiencies and errors 50_100:\n"; + for (int i=1; i<=MuonRecoEff_Eta_50_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Chi 2 Efficiencies and errors 50_100:\n"; + for (int i=1; i<=Chi2MuonRecoEff_Eta_50_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Fake Rate 50_100:\n"; + for (int i=1; i<=FakeRate_Eta_50_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Resolution vs eta 50_100:\n"; + for (int i=1; i<=PtDiff_gaus_50_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Efficiencies and errors 40:\n"; + for (int i=1; i<=MuonRecoEff_Eta_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Chi 2 Efficiencies and errors 40:\n"; + for (int i=1; i<=Chi2MuonRecoEff_Eta_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Fake Rate 40:\n"; + for (int i=1; i<=FakeRate_Eta_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + logout<<"Resolution vs eta 40:\n"; + for (int i=1; i<=PtDiff_gaus_100->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + logout<<"Background yield:\n"; + for (int i=1; i<=UnmatchedME0Muon_Cuts_Eta_PerEvent->GetNbinsX(); ++i){ + logout<GetBinContent(i)<<","<GetBinError(i)<<"\n"; + } + + + //logout << "Writing this to a file.\n"; + logout.close(); + + delete histoFile; histoFile = 0; +} + + + +FreeTrajectoryState +ME0MuonAnalyzer::getFTS(const GlobalVector& p3, const GlobalVector& r3, + int charge, const AlgebraicSymMatrix55& cov, + const MagneticField* field){ + + GlobalVector p3GV(p3.x(), p3.y(), p3.z()); + GlobalPoint r3GP(r3.x(), r3.y(), r3.z()); + GlobalTrajectoryParameters tPars(r3GP, p3GV, charge, field); + + CurvilinearTrajectoryError tCov(cov); + + return cov.kRows == 5 ? FreeTrajectoryState(tPars, tCov) : FreeTrajectoryState(tPars) ; +} + +FreeTrajectoryState +ME0MuonAnalyzer::getFTS(const GlobalVector& p3, const GlobalVector& r3, + int charge, const AlgebraicSymMatrix66& cov, + const MagneticField* field){ + + GlobalVector p3GV(p3.x(), p3.y(), p3.z()); + GlobalPoint r3GP(r3.x(), r3.y(), r3.z()); + GlobalTrajectoryParameters tPars(r3GP, p3GV, charge, field); + + CartesianTrajectoryError tCov(cov); + + return cov.kRows == 6 ? FreeTrajectoryState(tPars, tCov) : FreeTrajectoryState(tPars) ; +} + +void ME0MuonAnalyzer::getFromFTS(const FreeTrajectoryState& fts, + GlobalVector& p3, GlobalVector& r3, + int& charge, AlgebraicSymMatrix66& cov){ + GlobalVector p3GV = fts.momentum(); + GlobalPoint r3GP = fts.position(); + + GlobalVector p3T(p3GV.x(), p3GV.y(), p3GV.z()); + GlobalVector r3T(r3GP.x(), r3GP.y(), r3GP.z()); + p3 = p3T; + r3 = r3T; //Yikes, was setting this to p3T instead of r3T!?! + // p3.set(p3GV.x(), p3GV.y(), p3GV.z()); + // r3.set(r3GP.x(), r3GP.y(), r3GP.z()); + + charge = fts.charge(); + cov = fts.hasError() ? fts.cartesianError().matrix() : AlgebraicSymMatrix66(); + +} + +DEFINE_FWK_MODULE(ME0MuonAnalyzer); diff --git a/RecoMuon/MuonIdentification/test/runME0MuonReco_Example.py b/RecoMuon/MuonIdentification/test/runME0MuonReco_Example.py new file mode 100644 index 0000000000000..b0c4f31834559 --- /dev/null +++ b/RecoMuon/MuonIdentification/test/runME0MuonReco_Example.py @@ -0,0 +1,84 @@ +import FWCore.ParameterSet.Config as cms +process = cms.Process("ME0SegmentMatchingLocalTest") + + +## Standard sequence +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') + +#process.load('Configuration.Geometry.GeometryExtended2023MuonReco_cff') +#process.load('Configuration.Geometry.GeometryExtended2023Muon_cff') + +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDevReco_cff') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDev_cff') + +#process.load('Configuration.Geometry.GeometryExtended2023SHCalNoTaperReco_cff') +#process.load('Configuration.Geometry.GeometryExtended2023SHCalNoTaper_cff') + +process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') +#process.load('Configuration.StandardSequences.MagneticField_38T_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +## TrackingComponentsRecord required for matchers +process.load('TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi') +process.load('TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi') + +## global tag for 2019 upgrade studies +from Configuration.AlCa.GlobalTag import GlobalTag +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgrade2019', '') +#process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '') + +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '') + + + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.combinedCustoms +#from SLHCUpgradeSimulations.Configuration.combinedCustoms import cust_2023SHCal +#from SLHCUpgradeSimulations.Configuration.combinedCustoms import cust_2023Muon + +#call to customisation function cust_2023SHCal imported from SLHCUpgradeSimulations.Configuration.combinedCustoms +#process = cust_2023SHCal(process) +#process = cust_2023Muon(process) + + + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.me0Customs +from SLHCUpgradeSimulations.Configuration.me0Customs import customise +process = customise(process) + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:///somewhere/simevent.root') ##/somewhere/simevent.root" } +) + + +#process.load('RecoLocalMuon.GEMRecHit.me0RecHits_cfi') +#process.load('RecoLocalMuon.GEMSegments.me0Segments_cfi') +process.load('RecoMuon.MuonIdentification.me0MuonReco_cff') + +#process.p = cms.Path(process.me0RecHits*process.me0Segments*process.me0MuonReco) +process.p = cms.Path(process.me0MuonReco) +#process.p = cms.Path(process.me0RecHits*process.me0Segments) + +process.PoolSource.fileNames = [ + + 'file:out_local_reco_me0segment.root' +] + + +process.o1 = cms.OutputModule("PoolOutputModule", + outputCommands = cms.untracked.vstring( + 'keep *', + 'drop *_me0SegmentMatcher_*_*' + #'drop *', + ##'keep *_me0SegmentMatching_*_*', + #'keep *_me0MuonConverting_*_*', + ), + fileName = cms.untracked.string('out_me0Reco.root') + ) + +process.outpath = cms.EndPath(process.o1) diff --git a/RecoMuon/MuonIdentification/test/testME0MuonAnalyzer_Example.py b/RecoMuon/MuonIdentification/test/testME0MuonAnalyzer_Example.py new file mode 100644 index 0000000000000..c652d1c0f31bd --- /dev/null +++ b/RecoMuon/MuonIdentification/test/testME0MuonAnalyzer_Example.py @@ -0,0 +1,94 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("Test") + + +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDevReco_cff') +process.load('Configuration.Geometry.GeometryExtended2015MuonGEMDev_cff') + + +process.load('Configuration.StandardSequences.MagneticField_38T_PostLS1_cff') + +process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi") + +process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi") + +process.load("TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAny_cfi") + +process.load( "DQMServices/Core/DQMStore_cfg" ) + + + +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') +from Configuration.AlCa.GlobalTag import GlobalTag + +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgrade2019', '') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) + + + +process.source = cms.Source("PoolSource", + fileNames = cms.untracked.vstring('file:///somewhere/simevent.root') ##/somewhere/simevent.root" } + + +) + +# Configurations for MuonTrackValidators + + +# Configurations for RecoMuonValidators + +#import SimGeneral.MixingModule.mixNoPU_cfi +#process.TrackAssociatorByChi2ESProducer = Validation.RecoMuon.associators_cff.TrackAssociatorByChi2ESProducer.clone(chi2cut = 100.0,ComponentName = 'TrackAssociatorByChi2') + + +import SimMuon.MCTruth.muonAssociatorByHitsHelper_cfi + +process.muonAssociatorByHits = SimMuon.MCTruth.muonAssociatorByHitsHelper_cfi.muonAssociatorByHitsHelper.clone(#ComponentName = "muonAssociatorByHits", + #tpTag = 'mix:MergedTrackTruth', + UseTracker = True, + UseMuon = False, + EfficiencyCut_track = cms.double(0.0), + PurityCut_track = cms.double(0.0) + ) + + +from CommonTools.RecoAlgos.me0Associator import * + +#process.me0MuonSel = cms.Sequence( +# me0muonColl_seq +# ) + +process.me0MuonSel = me0muon + +process.Test = cms.EDAnalyzer("ME0MuonAnalyzer", + + + HistoFolder = cms.string('OUTPUTTEMPLATE'), + HistoFile = cms.string('OUTPUTTEMPLATE.root'), + + ME0MuonSelectionType = cms.string('Loose'), + FakeRatePtCut = cms.double(3.0), + MatchingWindowDelR = cms.double (.15), + RejectEndcapMuons = cms.bool(False), + UseAssociators = cms.bool(False), + + associators = cms.vstring('muonAssociatorByHits'), + + label = cms.VInputTag('me0muon'), + + +) + +process.p = cms.Path(process.me0MuonSel*process.Test) + + + +process.PoolSource.fileNames = [ + +'file:/afs/cern.ch/work/d/dnash/ME0Segments/ForRealSegmentsOnly/ReCommit75X/CMSSW_7_5_X_2015-06-29-2300/src/out_digi_test.root' + +] diff --git a/SLHCUpgradeSimulations/Configuration/python/combinedCustoms.py b/SLHCUpgradeSimulations/Configuration/python/combinedCustoms.py index 03b6d6d9e634a..571872e17a3fc 100644 --- a/SLHCUpgradeSimulations/Configuration/python/combinedCustoms.py +++ b/SLHCUpgradeSimulations/Configuration/python/combinedCustoms.py @@ -4,21 +4,35 @@ from SLHCUpgradeSimulations.Configuration.phase1TkCustoms import customise as customisePhase1Tk from SLHCUpgradeSimulations.Configuration.HCalCustoms import customise_HcalPhase1, customise_HcalPhase0 -import SLHCUpgradeSimulations.Configuration.aging as aging +from SLHCUpgradeSimulations.Configuration.gemCustoms import customise2019 as customise_gem2019 +from SLHCUpgradeSimulations.Configuration.gemCustoms import customise2023 as customise_gem2023 +from SLHCUpgradeSimulations.Configuration.me0Customs import customise as customise_me0 +from SLHCUpgradeSimulations.Configuration.rpcCustoms import customise as customise_rpc +from SLHCUpgradeSimulations.Configuration.fixMissingUpgradeGTPayloads import fixRPCConditions +import SLHCUpgradeSimulations.Configuration.aging as aging def cust_2017(process): process=customisePostLS1(process) process=customisePhase1Tk(process) #process=customise_HcalPhase0(process) - #process=fixRPCConditions(process) return process def cust_2019(process): process=customisePostLS1(process) process=customisePhase1Tk(process) process=customise_HcalPhase1(process) - #process=fixRPCConditions(process) + return process + +def cust_2019WithGem(process): + process=cust_2019(process) + process=customise_gem2019(process) + return process + +def cust_2023MuonOnly(process): + process=customise_gem2023(process) + process=customise_rpc(process) + process=fixRPCConditions(process) return process def noCrossing(process): diff --git a/SLHCUpgradeSimulations/Configuration/python/gemCustoms.py b/SLHCUpgradeSimulations/Configuration/python/gemCustoms.py index 44aa28a73e4dd..2bbad25b9662b 100644 --- a/SLHCUpgradeSimulations/Configuration/python/gemCustoms.py +++ b/SLHCUpgradeSimulations/Configuration/python/gemCustoms.py @@ -1,33 +1,149 @@ import FWCore.ParameterSet.Config as cms + +def customise2019(process): + if hasattr(process,'digitisation_step'): + process=customise_Digi(process) + if hasattr(process,'L1simulation_step'): + process=customise_L1Emulator2019(process,'pt0') + if hasattr(process,'DigiToRaw'): + process=customise_DigiToRaw(process) + if hasattr(process,'RawToDigi'): + process=customise_RawToDigi(process) + if hasattr(process,'reconstruction'): + process=customise_Reco(process) + if hasattr(process,'dqmoffline_step'): + process=customise_DQM(process) + if hasattr(process,'dqmHarvesting'): + process=customise_harvesting(process) + if hasattr(process,'validation_step'): + process=customise_Validation(process) + if hasattr(process,'HLTSchedule'): + process=customise_gem_hlt(process) + return process + def customise2023(process): - if hasattr(process,'digitisation_step') : - process=customise_digitization(process) - if hasattr(process,'dqmHarvesting'): - process=customise_harvesting(process) - if hasattr(process,'validation_step'): - process=customise_Validation(process) - return process -def customise_digitization(process): - from SimMuon.GEMDigitizer.customizeGEMDigi import customize_digi_addGEM_muon_only - process = customize_digi_addGEM_muon_only(process) - process.simMuonGEMDigis.mixLabel = cms.string("mix") - # process.simMuonME0Digis.mixLabel = cms.string("mix") - # process.digitisation_step.remove(process.simMuonRPCDigis) - # process.simMuonRPCDigis.digiModel = cms.string('RPCSimParam') - process.simMuonRPCDigis.digiModel = cms.string('RPCSimAverageNoiseEff') - return process + process = customise2019(process) + if hasattr(process,'L1simulation_step'): + process=customise_L1Emulator2023(process,'pt0') + return process + +def customise_Digi(process): + # original from SLHC: + # ---------------------------- + # process.RandomNumberGeneratorService.simMuonGEMDigis = cms.PSet( + # initialSeed = cms.untracked.uint32(1234567), + # engineName = cms.untracked.string('HepJamesRandom') + # ) + process.mix.mixObjects.mixSH.crossingFrames.append('MuonGEMHits') + process.mix.mixObjects.mixSH.input.append(cms.InputTag("g4SimHits","MuonGEMHits")) + process.mix.mixObjects.mixSH.subdets.append('MuonGEMHits') + process.load('SimMuon.GEMDigitizer.muonGEMDigi_cff') + process.muonDigi += process.muonGEMDigi + # process.load('SimCalorimetry.Configuration.SimCalorimetry_cff') + # process.digitisation_step.remove(process.calDigi) + # process.load('SimCalorimetry.Configuration.ecalDigiSequence_cff') + # process.load('SimCalorimetry.Configuration.hcalDigiSequence_cff') + # process.load('SimCalorimetry.Configuration.castorDigiSequence_cff') + # process.digitisation_step.remove(process.ecalDigiSequence) + # process.digitisation_step.remove(process.hcalDigiSequence) + # process.digitisation_step.remove(process.castorDigiSequence) + process=outputCustoms(process) + # ---------------------------- + + # original from 75X: + # ---------------------------- + # from SimMuon.GEMDigitizer.customizeGEMDigi import customize_digi_addGEM_muon_only + # process = customize_digi_addGEM_muon_only(process) + # process.simMuonGEMDigis.mixLabel = cms.string("mix") + # process.simMuonRPCDigis.digiModel = cms.string('RPCSimAverageNoiseEff') + # ---------------------------- + return process + +# +# Here come the L1 Trigger Customizations, below comes from 620 SLHC +# ------------------------------------------------------------------ +# def customise_L1Emulator2019(process, ptdphi): +# from L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigisPostLS2_cfi import cscTriggerPrimitiveDigisPostLS2 +# process.simCscTriggerPrimitiveDigis = cscTriggerPrimitiveDigisPostLS2 +# process.simCscTriggerPrimitiveDigis.clctSLHC.clctNplanesHitPattern = 3 +# process.simCscTriggerPrimitiveDigis.clctSLHC.clctPidThreshPretrig = 2 +# process.simCscTriggerPrimitiveDigis.clctParam07.clctPidThreshPretrig = 2 +# ## give a random number generator +# process.RandomNumberGeneratorService.simCscTriggerPrimitiveDigis = cms.PSet( +# initialSeed = cms.untracked.uint32(1234567), +# engineName = cms.untracked.string('HepJamesRandom') +# ) +# return process + +# def customise_L1Emulator2023(process, ptdphi): +# from L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigisPostLS3_cfi import cscTriggerPrimitiveDigisPostLS3 +# process.simCscTriggerPrimitiveDigis = cscTriggerPrimitiveDigisPostLS3 +# process.simCscTriggerPrimitiveDigis.clctSLHC.clctNplanesHitPattern = 3 +# process.simCscTriggerPrimitiveDigis.clctSLHC.clctPidThreshPretrig = 2 +# process.simCscTriggerPrimitiveDigis.clctParam07.clctPidThreshPretrig = 2 +# ## ME21 has its own SLHC processors +# process.simCscTriggerPrimitiveDigis.alctSLHCME21 = process.simCscTriggerPrimitiveDigis.alctSLHC.clone() +# process.simCscTriggerPrimitiveDigis.clctSLHCME21 = process.simCscTriggerPrimitiveDigis.clctSLHC.clone() +# process.simCscTriggerPrimitiveDigis.alctSLHCME21.alctNplanesHitPattern = 3 +# process.simCscTriggerPrimitiveDigis.alctSLHCME21.runME21ILT = cms.bool(True) +# process.simCscTriggerPrimitiveDigis.clctSLHCME21.clctNplanesHitPattern = 3 +# process.simCscTriggerPrimitiveDigis.clctSLHCME21.clctPidThreshPretrig = 2 +# return process +# ------------------------------------------------------------------ + +def customise_DigiToRaw(process): + return process + +def customise_RawToDigi(process): + return process + +def customise_Reco(process): + process.load('RecoLocalMuon.GEMRecHit.gemRecHits_cfi') + process.muonlocalreco += process.gemRecHits + process.standAloneMuons.STATrajBuilderParameters.EnableGEMMeasurement = cms.bool(True) + process.standAloneMuons.STATrajBuilderParameters.BWFilterParameters.EnableGEMMeasurement = cms.bool(True) + process.refittedStandAloneMuons.STATrajBuilderParameters.EnableGEMMeasurement = cms.bool(True) + process.refittedStandAloneMuons.STATrajBuilderParameters.BWFilterParameters.EnableGEMMeasurement = cms.bool(True) + process=outputCustoms(process) + return process + +def customise_DQM(process): + return process def customise_Validation(process): - #process.load('Validation.MuonGEMHits.MuonGEMHits_cfi') - process.load('Validation.MuonGEMHits.gemSimValid_cff') - process.load('Validation.MuonGEMDigis.MuonGEMDigis_cfi') - process.genvalid_all += process.gemSimValid - process.genvalid_all += process.gemDigiValidation - return process + process.load('Validation.Configuration.gemSimValid_cff') + process.load('Validation.MuonGEMDigis.MuonGEMDigis_cfi') + process.genvalid_all += process.gemSimValid + process.genvalid_all += process.gemDigiValidation + # Additional in SLHC: 2B checked whether needed / necessary + # --------------------------------------------------------- + process.load('Validation.RecoMuon.MuonTrackValidator_cfi') + process.load('SimMuon.MCTruth.MuonAssociatorByHits_cfi') + process.muonAssociatorByHitsCommonParameters.useGEMs = cms.bool(True) + process.muonTrackValidator.useGEMs = cms.bool(True) + # --------------------------------------------------------- + return process def customise_harvesting(process): - #process.load('Validation.MuonGEMHits.MuonGEMHits_cfi') - process.load('Validation.MuonGEMHits.gemPostValidation_cff') - process.genHarvesting += process.gemPostValidation - return process + process.load('Validation.Configuration.gemPostValidation_cff') + process.genHarvesting += process.gemPostValidation + return process + +def outputCustoms(process): + alist=['AODSIM','RECOSIM','FEVTSIM','FEVTDEBUG','FEVTDEBUGHLT','RECODEBUG','RAWRECOSIMHLT','RAWRECODEBUGHLT'] + for a in alist: + b=a+'output' + if hasattr(process,b): + getattr(process,b).outputCommands.append('keep *_simMuonGEMDigis_*_*') + getattr(process,b).outputCommands.append('keep *_simMuonGEMCSCPadDigis_*_*') + getattr(process,b).outputCommands.append('keep *_gemRecHits_*_*') + return process + + +def customise_gem_hlt(process): + process.hltL2OfflineMuonSeeds.EnableGEMMeasurement = cms.bool( True ) + process.hltL2Muons.L2TrajBuilderParameters.EnableGEMMeasurement = cms.bool( True ) + process.hltL2Muons.BWFilterParameters.EnableGEMMeasurement = cms.bool( True ) + return process + diff --git a/SLHCUpgradeSimulations/Configuration/python/me0Customs.py b/SLHCUpgradeSimulations/Configuration/python/me0Customs.py index 242d28e1fabe6..2bab6354dac45 100644 --- a/SLHCUpgradeSimulations/Configuration/python/me0Customs.py +++ b/SLHCUpgradeSimulations/Configuration/python/me0Customs.py @@ -31,6 +31,8 @@ def customise_Digi(process): process.mix.mixObjects.mixSH.subdets.append('MuonME0Hits') process.load('SimMuon.GEMDigitizer.muonME0DigisPreReco_cfi') process.muonDigi += process.simMuonME0Digis + # process.load('SimCalorimetry.Configuration.SimCalorimetry_cff') + # process.digitisation_step.remove(calDigi) process=outputCustoms(process) return process @@ -57,14 +59,14 @@ def customise_GlobalRecoInclude(process): def customise_GlobalRecoFast(process): customise_GlobalRecoInclude(process) - process.load('RecoMuon.MuonIdentification.me0MuonReco_cff') - process.reconstructionWithFamos += process.me0MuonReco + # process.load('RecoMuon.MuonIdentification.me0MuonReco_cff') + # process.reconstructionWithFamos += process.me0MuonReco return process def customise_GlobalRecoFull(process): customise_GlobalRecoInclude(process) - process.load('RecoMuon.MuonIdentification.me0MuonReco_cff') - process.muonGlobalReco += process.me0MuonReco + # process.load('RecoMuon.MuonIdentification.me0MuonReco_cff') + # process.muonGlobalReco += process.me0MuonReco return process def customise_RecoFast(process): diff --git a/SLHCUpgradeSimulations/Configuration/python/rpcCustoms.py b/SLHCUpgradeSimulations/Configuration/python/rpcCustoms.py new file mode 100644 index 0000000000000..07c68c6091c8e --- /dev/null +++ b/SLHCUpgradeSimulations/Configuration/python/rpcCustoms.py @@ -0,0 +1,51 @@ +import FWCore.ParameterSet.Config as cms + +def customise(process): + if hasattr(process,'digitisation_step'): + process=customise_Digi(process) + if hasattr(process,'L1simulation_step'): + process=customise_L1Emulator(process) + if hasattr(process,'DigiToRaw'): + process=customise_DigiToRaw(process) + if hasattr(process,'RawToDigi'): + process=customise_RawToDigi(process) + if hasattr(process,'reconstruction'): + process=customise_Reco(process) + if hasattr(process,'dqmoffline_step'): + process=customise_DQM(process) + if hasattr(process,'dqmHarvesting'): + process=customise_harvesting(process) + if hasattr(process,'validation_step'): + process=customise_Validation(process) + return process + +def customise_Digi(process): + return process + +def customise_L1Emulator(process): + ## this comes after GE2/1 in gemCustoms.py + process.simCscTriggerPrimitiveDigis.alctSLHCME3141 = process.simCscTriggerPrimitiveDigis.alctSLHC.clone() + process.simCscTriggerPrimitiveDigis.clctSLHCME3141 = process.simCscTriggerPrimitiveDigis.clctSLHC.clone() + process.simCscTriggerPrimitiveDigis.alctSLHCME3141.alctNplanesHitPattern = 3 + process.simCscTriggerPrimitiveDigis.alctSLHCME3141.runME3141ILT = cms.bool(True) + process.simCscTriggerPrimitiveDigis.clctSLHCME3141.clctNplanesHitPattern = 3 + process.simCscTriggerPrimitiveDigis.clctSLHCME3141.clctPidThreshPretrig = 2 + return process + +def customise_DigiToRaw(process): + return process + +def customise_RawToDigi(process): + return process + +def customise_Reco(process): + return process + +def customise_DQM(process): + return process + +def customise_Validation(process): + return process + +def customise_harvesting(process): + return (process) diff --git a/SimMuon/GEMDigitizer/python/customizeGEMDigi.py b/SimMuon/GEMDigitizer/python/customizeGEMDigi.py index f9a46b957ab78..089c577d1ada8 100644 --- a/SimMuon/GEMDigitizer/python/customizeGEMDigi.py +++ b/SimMuon/GEMDigitizer/python/customizeGEMDigi.py @@ -1,5 +1,11 @@ import FWCore.ParameterSet.Config as cms +from SimGeneral.MixingModule.aliases_cfi import * +# from SimGeneral.MixingModule.mixObjects_cfi import * +# from SimGeneral.MixingModule.digitizers_cfi import * +from SimGeneral.MixingModule.pixelDigitizer_cfi import * +from SimGeneral.MixingModule.stripDigitizer_cfi import * +# from SimGeneral.MixingModule.trackingTruthProducer_cfi import * # PSet of mixObjects that only keeps muon collections (and SimTracks with SimVertices) mixObjects_dt_csc_rpc = cms.PSet( @@ -23,17 +29,54 @@ crossingFrames = cms.untracked.vstring( 'MuonCSCHits', 'MuonDTHits', - 'MuonRPCHits' + 'MuonRPCHits', + 'TrackerHitsPixelBarrelHighTof', + 'TrackerHitsPixelBarrelLowTof', + 'TrackerHitsPixelEndcapHighTof', + 'TrackerHitsPixelEndcapLowTof', + 'TrackerHitsTECHighTof', + 'TrackerHitsTECLowTof', + 'TrackerHitsTIBHighTof', + 'TrackerHitsTIBLowTof', + 'TrackerHitsTIDHighTof', + 'TrackerHitsTIDLowTof', + 'TrackerHitsTOBHighTof', + 'TrackerHitsTOBLowTof' ), input = cms.VInputTag( cms.InputTag("g4SimHits","MuonCSCHits"), cms.InputTag("g4SimHits","MuonDTHits"), - cms.InputTag("g4SimHits","MuonRPCHits")), + cms.InputTag("g4SimHits","MuonRPCHits"), + cms.InputTag("g4SimHits","TrackerHitsPixelBarrelHighTof"), + cms.InputTag("g4SimHits","TrackerHitsPixelBarrelLowTof"), + cms.InputTag("g4SimHits","TrackerHitsPixelEndcapHighTof"), + cms.InputTag("g4SimHits","TrackerHitsPixelEndcapLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTECHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTECLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTIBHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTIBLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTIDHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTIDLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTOBHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTOBLowTof"), + ), type = cms.string('PSimHit'), subdets = cms.vstring( 'MuonCSCHits', 'MuonDTHits', - 'MuonRPCHits' + 'MuonRPCHits', + 'TrackerHitsPixelBarrelHighTof', + 'TrackerHitsPixelBarrelLowTof', + 'TrackerHitsPixelEndcapHighTof', + 'TrackerHitsPixelEndcapLowTof', + 'TrackerHitsTECHighTof', + 'TrackerHitsTECLowTof', + 'TrackerHitsTIBHighTof', + 'TrackerHitsTIBLowTof', + 'TrackerHitsTIDHighTof', + 'TrackerHitsTIDLowTof', + 'TrackerHitsTOBHighTof', + 'TrackerHitsTOBLowTof' ) ), mixTracks = cms.PSet( @@ -43,6 +86,85 @@ ) ) +# PSet of mixObjects that only keep muon and tracker collections (and SimTracks with SimVertices) +mixObjects_dt_csc_rpc_trk = cms.PSet( + mixCH = cms.PSet( + crossingFrames = cms.untracked.vstring(), + input = cms.VInputTag(), + type = cms.string('PCaloHit'), + subdets = cms.vstring() + ), + mixHepMC = cms.PSet( + input = cms.VInputTag(cms.InputTag("generator")), + makeCrossingFrame = cms.untracked.bool(True), + type = cms.string('HepMCProduct') + ), + mixVertices = cms.PSet( + input = cms.VInputTag(cms.InputTag("g4SimHits")), + makeCrossingFrame = cms.untracked.bool(True), + type = cms.string('SimVertex') + ), + mixSH = cms.PSet( + crossingFrames = cms.untracked.vstring( + 'MuonCSCHits', + 'MuonDTHits', + 'MuonRPCHits', + 'TrackerHitsPixelBarrelHighTof', + 'TrackerHitsPixelBarrelLowTof', + 'TrackerHitsPixelEndcapHighTof', + 'TrackerHitsPixelEndcapLowTof', + 'TrackerHitsTECHighTof', + 'TrackerHitsTECLowTof', + 'TrackerHitsTIBHighTof', + 'TrackerHitsTIBLowTof', + 'TrackerHitsTIDHighTof', + 'TrackerHitsTIDLowTof', + 'TrackerHitsTOBHighTof', + 'TrackerHitsTOBLowTof' + ), + input = cms.VInputTag( + cms.InputTag("g4SimHits","MuonCSCHits"), + cms.InputTag("g4SimHits","MuonDTHits"), + cms.InputTag("g4SimHits","MuonRPCHits"), + cms.InputTag("g4SimHits","TrackerHitsPixelBarrelHighTof"), + cms.InputTag("g4SimHits","TrackerHitsPixelBarrelLowTof"), + cms.InputTag("g4SimHits","TrackerHitsPixelEndcapHighTof"), + cms.InputTag("g4SimHits","TrackerHitsPixelEndcapLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTECHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTECLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTIBHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTIBLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTIDHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTIDLowTof"), + cms.InputTag("g4SimHits","TrackerHitsTOBHighTof"), + cms.InputTag("g4SimHits","TrackerHitsTOBLowTof"), + ), + type = cms.string('PSimHit'), + subdets = cms.vstring( + 'MuonCSCHits', + 'MuonDTHits', + 'MuonRPCHits', + 'TrackerHitsPixelBarrelHighTof', + 'TrackerHitsPixelBarrelLowTof', + 'TrackerHitsPixelEndcapHighTof', + 'TrackerHitsPixelEndcapLowTof', + 'TrackerHitsTECHighTof', + 'TrackerHitsTECLowTof', + 'TrackerHitsTIBHighTof', + 'TrackerHitsTIBLowTof', + 'TrackerHitsTIDHighTof', + 'TrackerHitsTIDLowTof', + 'TrackerHitsTOBHighTof', + 'TrackerHitsTOBLowTof' + ) + ), + mixTracks = cms.PSet( + input = cms.VInputTag(cms.InputTag("g4SimHits")), + makeCrossingFrame = cms.untracked.bool(True), + type = cms.string('SimTrack') + ), +) + # Customize process.mix to be used for running muon (DT, CSC, RPC) digi only. # - remove non-muon digitizers that are now run as part of mixing process @@ -55,6 +177,101 @@ def customize_mix_muon_only(process): process.mix.mixObjects = mixObjects_dt_csc_rpc return process +# Customize process.mix to be used for running muon and tracker digi only. +# - remove calo digitizers that are now run as part of mixing process +# - delete all the digitizers' aliases apart of pixel and strip aliasses. +# - reset the simCastorDigis, simEcalUnsuppressedDigis +# and simHcalUnsuppressedDigis +# - drop unnecessary mixObjects +def customize_mix_nocalo(process): + process.mix.digitizers = digitizers = cms.PSet( + pixel = cms.PSet( + pixelDigitizer + ), + strip = cms.PSet( + stripDigitizer + ), + ) + process.mix.theDigitizersValid = cms.PSet( + pixel = cms.PSet( + pixelDigitizer + ), + strip = cms.PSet( + stripDigitizer + ) + ) + # delete some contents of SimGeneral/MixingModule/python/aliases_cfi.py + # i was not able to delete these processes in a different way + process.simCastorDigis = cms.EDAlias() + process.simEcalUnsuppressedDigis = cms.EDAlias() + process.simHcalUnsuppressedDigis = cms.EDAlias() + # delete all digitizer aliasses apart of pixel and strip aliases + digi_aliases = filter(lambda n: 'Digi' in n, process.aliases.keys()) + print("digi aliases before clean up: ") + for a in digi_aliases: + print(a) + if ('Strip' not in a) and ('Pixel' not in a): + process.__delattr__(a) + process.mix.mixObjects = mixObjects_dt_csc_rpc_trk + return process + +# Customize process.mix to be used for running muon (DT, CSC, RPC + GEM) digi only. +# - first do such customization for (DT, CSC, RPC) +# - append GEM SimHit collection definitions to mix.mixObjects.mixSH +def customize_mix_addGEM_muon_only(process): + process = customize_mix_muon_only(process) + process = customize_mix_addGEM(process) + return process + +def customize_mix_addGEM_nocalo(process): + process = customize_mix_nocalo(process) + process = customize_mix_addGEM(process) + return process + +# customize the digitization sequence pdigi to only digitize DT+CSC+RPC+GEM +def customize_digi_addGEM_muon_only(process): + process = load_GEM_digitizers(process) + process = customize_random_GEMDigi(process) + process = customize_mix_addGEM_muon_only(process) + process.muonDigi = cms.Sequence( + process.simMuonCSCDigis + + process.simMuonDTDigis + + process.simMuonRPCDigis + + process.simMuonGEMDigis + + process.simMuonGEMPadDigis + ) + process.pdigi = cms.Sequence( + cms.SequencePlaceholder("randomEngineStateProducer")* + cms.SequencePlaceholder("mix")* + process.muonDigi + ) + process = append_GEMDigi_event(process) + return process + +# customize the digitization sequence pdigi to only digitize DT+CSC+RPC+GEM +def customize_digi_addGEM_nocalo(process): + process = load_GEM_digitizers(process) + process = customize_random_GEMDigi(process) + process = customize_mix_addGEM_nocalo(process) + process.muonDigi = cms.Sequence( + process.simMuonCSCDigis + + process.simMuonDTDigis + + process.simMuonRPCDigis + + process.simMuonGEMDigis + + process.simMuonGEMPadDigis + ) + process.pdigi = cms.Sequence( + cms.SequencePlaceholder("randomEngineStateProducer")* + cms.SequencePlaceholder("mix")* + process.muonDigi + ) + # process.pdigi.remove(simCastorDigis) + process = append_GEMDigi_event(process) + return process + + + + # customize process.mix by appending GEM SimHit collection definitions to mix.mixObjects.mixSH def customize_mix_addGEM(process): @@ -75,17 +292,14 @@ def customize_mix_addME0(process): # Customize process.mix to be used for running muon (DT, CSC, RPC + GEM) digi only. # - first do such customization for (DT, CSC, RPC) # - append GEM SimHit collection definitions to mix.mixObjects.mixSH -def customize_mix_addGEM_muon_only(process): +def customize_mix_addGEM_addME0_muon_only(process): process = customize_mix_muon_only(process) process = customize_mix_addGEM(process) + process = customize_mix_addME0(process) return process - -# Customize process.mix to be used for running muon (DT, CSC, RPC + GEM) digi only. -# - first do such customization for (DT, CSC, RPC) -# - append GEM SimHit collection definitions to mix.mixObjects.mixSH -def customize_mix_addGEM_addME0_muon_only(process): - process = customize_mix_muon_only(process) +def customize_mix_addGEM_addME0_nocalo(process): + process = customize_mix_nocalo(process) process = customize_mix_addGEM(process) process = customize_mix_addME0(process) return process @@ -140,27 +354,6 @@ def customize_digi_addGEM(process): return process -# customize the digitization sequence pdigi to only digitize DT+CSC+RPC+GEM -def customize_digi_addGEM_muon_only(process): - process = load_GEM_digitizers(process) - process = customize_random_GEMDigi(process) - process = customize_mix_addGEM_muon_only(process) - process.muonDigi = cms.Sequence( - process.simMuonCSCDigis + - process.simMuonDTDigis + - process.simMuonRPCDigis + - process.simMuonGEMDigis + - process.simMuonGEMPadDigis - ) - process.pdigi = cms.Sequence( - cms.SequencePlaceholder("randomEngineStateProducer")* - cms.SequencePlaceholder("mix")* - process.muonDigi - ) - process = append_GEMDigi_event(process) - return process - - # customize the digitization sequence pdigi to only digitize GEM def customize_digi_addGEM_gem_only(process): process = load_GEM_digitizers(process) @@ -254,7 +447,18 @@ def append_GEMDigi_event(process): for a in alist: b=a+'output' if hasattr(process,b): - getattr(process,b).outputCommands.append('keep *_simMuonGEMDigis_*_*') - getattr(process,b).outputCommands.append('keep *_simMuonGEMPadDigis_*_*') - getattr(process,b).outputCommands.append('keep *_simMuonME0Digis_*_*') + getattr(process,b).outputCommands.append('drop *') + # getattr(process,b).outputCommands.append('keep *_mix_*_*') + getattr(process,b).outputCommands.append('keep *_g4SimHits__*') + getattr(process,b).outputCommands.append('keep *_g4SimHits_Muon*_*') + getattr(process,b).outputCommands.append('keep *_g4SimHits_Tracker*_*') + getattr(process,b).outputCommands.append('keep *_generator_*_*') + getattr(process,b).outputCommands.append('keep *_genParticles_*_*') + getattr(process,b).outputCommands.append('keep *_*Muon*_*_*') + getattr(process,b).outputCommands.append('keep *_*Strip*_*_*') + getattr(process,b).outputCommands.append('keep *_*Pixel*_*_*') + # getattr(process,b).outputCommands.append('keep *_*_*_*') + # getattr(process,b).outputCommands.append('keep *_simSiPixelDigis_*_*') + # getattr(process,b).outputCommands.append('keep *_simSiStripDigis_*_*') + return process