Skip to content

Commit

Permalink
code cleanup and review
Browse files Browse the repository at this point in the history
  • Loading branch information
bendavid committed Jan 17, 2019
1 parent b770cf6 commit f777755
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 72 deletions.
26 changes: 12 additions & 14 deletions CommonTools/RecoAlgos/plugins/TOFPIDProducer.cc
Expand Up @@ -9,32 +9,30 @@
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "CLHEP/Units/GlobalPhysicalConstants.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"

using namespace std;
using namespace edm;

class TOFPIDProducer : public edm::stream::EDProducer<> {
public:

TOFPIDProducer(const ParameterSet& pset);

void produce(edm::Event& ev, const edm::EventSetup& es) final;



class TOFPIDProducer : public edm::stream::EDProducer<> {
private:
static constexpr char t0Name[] = "t0";
static constexpr char sigmat0Name[] = "sigmat0";
static constexpr char t0safeName[] = "t0safe";
static constexpr char sigmat0safeName[] = "sigmat0safe";
static constexpr char probPiName[] = "probPi";
static constexpr char probKName[] = "probK";
static constexpr char probPName[] = "probP";
public:

TOFPIDProducer(const ParameterSet& pset);

void produce(edm::Event& ev, const edm::EventSetup& es) final;

private:
edm::EDGetTokenT<reco::TrackCollection> tracksToken_;
edm::EDGetTokenT<edm::ValueMap<float> > t0Token_;
edm::EDGetTokenT<edm::ValueMap<float> > tmtdToken_;
Expand Down Expand Up @@ -80,7 +78,8 @@ void TOFPIDProducer::produce( edm::Event& ev,

constexpr double m_k = 0.493677; //[GeV]
constexpr double m_p = 0.9382720813; //[GeV]
constexpr double c = 2.99792458e1; //[cm/ns]
constexpr double c_cm_ns = CLHEP::c_light*CLHEP::ns/CLHEP::cm; //[cm/ns]
constexpr double c_inv = 1.0/c_cm_ns;

edm::Handle<reco::TrackCollection> tracksH;
ev.getByToken(tracksToken_,tracksH);
Expand Down Expand Up @@ -212,7 +211,6 @@ void TOFPIDProducer::produce( edm::Event& ev,

//recompute t0 for alternate mass hypotheses
double t0_best = t0;
double t0_pi = t0;

//reliable match, revert to raw mtd time uncertainty
if (dtsignom < maxDtSignificance_) {
Expand All @@ -225,11 +223,11 @@ void TOFPIDProducer::produce( edm::Event& ev,

double gammasq_k = 1. + magp*magp/m_k/m_k;
double beta_k = std::sqrt(1.-1./gammasq_k);
double t0_k = tmtd - pathlength/beta_k/c;
double t0_k = tmtd - pathlength/beta_k*c_inv;

double gammasq_p = 1. + magp*magp/m_p/m_p;
double beta_p = std::sqrt(1.-1./gammasq_p);
double t0_p = tmtd - pathlength/beta_p/c;
double t0_p = tmtd - pathlength/beta_p*c_inv;

double chisqmin = chisqnom;

Expand Down
2 changes: 1 addition & 1 deletion CommonTools/RecoAlgos/python/TOFPIDProducer_cfi.py
@@ -1,6 +1,6 @@
import FWCore.ParameterSet.Config as cms

TOFPIDProducer = cms.EDProducer( "TOFPIDProducer",
tofPID = cms.EDProducer( "TOFPIDProducer",
tracksSrc = cms.InputTag("generalTracks"),
t0Src = cms.InputTag("trackExtenderWithMTD:generalTrackt0"),
tmtdSrc = cms.InputTag("trackExtenderWithMTD:generalTracktmtd"),
Expand Down
28 changes: 15 additions & 13 deletions RecoMTD/TrackExtender/plugins/TrackExtenderWithMTD.cc
Expand Up @@ -50,7 +50,8 @@

#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "CLHEP/Units/GlobalPhysicalConstants.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"

using namespace std;
using namespace edm;
Expand All @@ -60,16 +61,6 @@ using namespace edm;

template<class TrackCollection>
class TrackExtenderWithMTDT : public edm::stream::EDProducer<> {
static constexpr char pathLengthName[] = "pathLength";
static constexpr char tmtdName[] = "tmtd";
static constexpr char sigmatmtdName[] = "sigmatmtd";
static constexpr char pOrigTrkName[] = "generalTrackp";
static constexpr char betaOrigTrkName[] = "generalTrackBeta";
static constexpr char t0OrigTrkName[] = "generalTrackt0";
static constexpr char sigmat0OrigTrkName[] = "generalTracksigmat0";
static constexpr char pathLengthOrigTrkName[] = "generalTrackPathLength";
static constexpr char tmtdOrigTrkName[] = "generalTracktmtd";
static constexpr char sigmatmtdOrigTrkName[] = "generalTracksigmatmtd";
public:
typedef typename TrackCollection:: value_type TrackType;
typedef edm::View<TrackType> InputCollection;
Expand Down Expand Up @@ -115,6 +106,17 @@ class TrackExtenderWithMTDT : public edm::stream::EDProducer<> {
string dumpLayer(const DetLayer* layer) const;

private:
static constexpr char pathLengthName[] = "pathLength";
static constexpr char tmtdName[] = "tmtd";
static constexpr char sigmatmtdName[] = "sigmatmtd";
static constexpr char pOrigTrkName[] = "generalTrackp";
static constexpr char betaOrigTrkName[] = "generalTrackBeta";
static constexpr char t0OrigTrkName[] = "generalTrackt0";
static constexpr char sigmat0OrigTrkName[] = "generalTracksigmat0";
static constexpr char pathLengthOrigTrkName[] = "generalTrackPathLength";
static constexpr char tmtdOrigTrkName[] = "generalTracktmtd";
static constexpr char sigmatmtdOrigTrkName[] = "generalTracksigmatmtd";

edm::EDGetTokenT<InputCollection> tracksToken_;
edm::EDGetTokenT<MTDTrackingDetSetVector> hitsToken_;
edm::EDGetTokenT<reco::BeamSpot> bsToken_;
Expand Down Expand Up @@ -320,7 +322,7 @@ void TrackExtenderWithMTDT<TrackCollection>::produce( edm::Event& ev,
tmtdMap = tmtd;
sigmatmtdMap = sigmatmtd;
auto& backtrack = output->back();
pMap = backtrack.p();
pMap = backtrack.p();
betaMap = backtrack.beta();
t0Map = backtrack.t0();
sigmat0Map = std::copysign(std::sqrt(std::abs(backtrack.covt0t0())),backtrack.covt0t0());
Expand Down Expand Up @@ -504,7 +506,7 @@ reco::Track TrackExtenderWithMTDT<TrackCollection>::buildTrack(const reco::Track
constexpr double m_pi_inv2 = 1.0/m_pi/m_pi;
constexpr double m_p = 0.9382720813;
constexpr double m_p_inv2 = 1.0/m_p/m_p;
constexpr double c_cm_ns = 2.99792458e1; //[cm/ns]
constexpr double c_cm_ns = CLHEP::c_light*CLHEP::ns/CLHEP::cm; //[cm/ns]
constexpr double c_inv = 1.0/c_cm_ns;

const FreeTrajectoryState & stateForProjectionToBeamLine=*stateForProjectionToBeamLineOnSurface.freeState();
Expand Down
11 changes: 7 additions & 4 deletions RecoParticleFlow/PFProducer/python/particleFlowBlock_cfi.py
Expand Up @@ -179,10 +179,13 @@ def _findIndicesByModule(name):
from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing
_addTiming = particleFlowBlock.elementImporters.copy()
_addTiming.append( cms.PSet( importerName = cms.string("TrackTimingImporter"),
timeValueMap = cms.InputTag("TOFPIDProducer:t0"),
timeErrorMap = cms.InputTag("TOFPIDProducer:sigmat0"),
timeValueMapGsf = cms.InputTag("TOFPIDProducer:t0"), #this will cause no time to be set for gsf tracks (since this is not available for the fullsim/reconstruction yet) *TODO* update when gsf times are available
timeErrorMapGsf = cms.InputTag("TOFPIDProducer:sigmat0")
timeValueMap = cms.InputTag("tofPID:t0"),
timeErrorMap = cms.InputTag("tofPID:sigmat0"),
#this will cause no time to be set for gsf tracks
#(since this is not available for the fullsim/reconstruction yet)
#*TODO* update when gsf times are available
timeValueMapGsf = cms.InputTag("tofPID:t0"),
timeErrorMapGsf = cms.InputTag("tofPID:sigmat0")
)
)

Expand Down
11 changes: 7 additions & 4 deletions RecoParticleFlow/PFProducer/python/simPFProducer_cfi.py
Expand Up @@ -19,10 +19,13 @@
from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing
phase2_timing.toModify(
simPFProducer,
trackTimeValueMap = cms.InputTag("TOFPIDProducer:t0"),
trackTimeErrorMap = cms.InputTag("TOFPIDProducer:sigmat0"),
gsfTrackTimeValueMap = cms.InputTag("TOFPIDProducer:t0"), #this will cause no time to be set for gsf tracks (since this is not available for the fullsim/reconstruction yet) *TODO* update when gsf times are available
gsfTrackTimeErrorMap = cms.InputTag("TOFPIDProducer:sigmat0"),
trackTimeValueMap = cms.InputTag("tofPID:t0"),
trackTimeErrorMap = cms.InputTag("tofPID:sigmat0"),
#this will cause no time to be set for gsf tracks
#(since this is not available for the fullsim/reconstruction yet)
#*TODO* update when gsf times are available
gsfTrackTimeValueMap = cms.InputTag("tofPID:t0"),
gsfTrackTimeErrorMap = cms.InputTag("tofPID:sigmat0"),
)

from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2
Expand Down
Expand Up @@ -34,7 +34,7 @@
'keep *_offlinePrimaryVertices4DnoPIDWithBS__*',
'keep *_offlinePrimaryVertices4Dfastsim__*',
'keep *_offlinePrimaryVertices4DfastsimWithBS__*',
'keep *_TOFPIDProducer_*_*',
'keep *_tofPID_*_*',
'keep *_trackTimeValueMapProducer_*_*' ]

def _phase2_tktiming_AddNewContent(mod):
Expand Down

0 comments on commit f777755

Please sign in to comment.