Skip to content

Commit

Permalink
add in code for ecal cluster time assigner
Browse files Browse the repository at this point in the history
  • Loading branch information
lgray committed Sep 14, 2016
1 parent 9dac168 commit 369440a
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 9 deletions.
2 changes: 1 addition & 1 deletion RecoParticleFlow/PFSimProducer/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<library name="RecoParticleFlowPFProducerSimPlugins" file="SimPFProducer.cc,TauHadronDecayFilter.cc,PFSimParticleProducer.cc,EcalBarrelClusterFastTimer.cc,SealModuleSim.cc">
<library name="RecoParticleFlowPFProducerSimPlugins" file="SimPFProducer.cc,TauHadronDecayFilter.cc,PFSimParticleProducer.cc,EcalBarrelClusterFastTimer.cc,ResolutionModel.cc,PerfectResolutionModel.cc,ConfigurableFlatResolutionModel.cc,SealModuleSim.cc">
<use name="DataFormats/EcalDetId"/>
<use name="Geometry/HGCalGeometry"/>
<use name="TrackingTools/MaterialEffects"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "ResolutionModel.h"

class ConfigurableFlatResolutionModel : public ResolutionModel {
public:
ConfigurableFlatResolutionModel( const edm::ParameterSet& conf ) :
ResolutionModel( conf ),
reso_( conf.getParameter<double>("resolutionInNs") ) {
}

virtual float getTimeResolution(const reco::Track&) const override { return reso_; }
virtual float getTimeResolution(const reco::PFCluster&) const override { return reso_; }

private:
const float reso_;
};

DEFINE_EDM_PLUGIN(ResolutionModelFactory,
ConfigurableFlatResolutionModel,
"ConfigurableFlatResolutionModel");
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// assign a reasonable time guess

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -34,12 +34,12 @@
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"

class EcalBarrelClusterFastTimer : public edm::EDProducer {
class EcalBarrelClusterFastTimer : public edm::global::EDProducer<> {
public:
EcalBarrelClusterFastTimer(const edm::ParameterSet&);
~EcalBarrelClusterFastTimer() { }

virtual void produce(edm::Event&, const edm::EventSetup&) override;
virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;

private:
// inputs
Expand All @@ -54,8 +54,6 @@ class EcalBarrelClusterFastTimer : public edm::EDProducer {
std::pair<float, DetId> getTimeForECALPFCluster(const EcalRecHitCollection&,const reco::PFCluster&) const;
float correctTimeToVertex(const float intime, const DetId& timeDet, const reco::Vertex& vtx,
const CaloSubdetectorGeometry* ecalGeom) const;
// RNG
CLHEP::HepRandomEngine* _rng_engine;
};

DEFINE_FWK_MODULE(EcalBarrelClusterFastTimer);
Expand Down Expand Up @@ -104,10 +102,13 @@ EcalBarrelClusterFastTimer::EcalBarrelClusterFastTimer(const edm::ParameterSet&
<< "EcalBarrelClusterFastTimer::EcalBarrelClusterFastTimer() - RandomNumberGeneratorService is not present in configuration file.\n"
<< "Add the service in the configuration file or remove the modules that require it.";
}
_rng_engine = &(rng->getEngine());
}

void EcalBarrelClusterFastTimer::produce(edm::Event& evt, const edm::EventSetup& es) {
void EcalBarrelClusterFastTimer::produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const {
// get RNG engine
edm::Service<edm::RandomNumberGenerator> rng;
auto rng_engine = &(rng->getEngine(sid));

edm::Handle<std::vector<reco::PFCluster> > clustersH;
edm::Handle<EcalRecHitCollection> timehitsH;
edm::Handle<reco::VertexCollection> verticesH;
Expand Down Expand Up @@ -145,7 +146,7 @@ void EcalBarrelClusterFastTimer::produce(edm::Event& evt, const edm::EventSetup&
for( unsigned i = 0 ; i < clusters.size(); ++i ) {
const float theresolution = reso->getTimeResolution(clusters[i]);

smeared_times.emplace_back( CLHEP::RandGauss::shoot(_rng_engine, times[i].first, theresolution), times[i].second );
smeared_times.emplace_back( CLHEP::RandGauss::shoot(rng_engine, times[i].first, theresolution), times[i].second );
resolutions.push_back( theresolution );
}

Expand Down
14 changes: 14 additions & 0 deletions RecoParticleFlow/PFSimProducer/plugins/PerfectResolutionModel.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "ResolutionModel.h"

class PerfectResolutionModel : public ResolutionModel {
public:
PerfectResolutionModel( const edm::ParameterSet& conf ) : ResolutionModel( conf ) {}

virtual float getTimeResolution(const reco::Track&) const override { return 1e-6; }
virtual float getTimeResolution(const reco::PFCluster&) const override { return 1e-6; }

};

DEFINE_EDM_PLUGIN(ResolutionModelFactory,
PerfectResolutionModel,
"PerfectResolutionModel");
4 changes: 4 additions & 0 deletions RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "ResolutionModel.h"

EDM_REGISTER_PLUGINFACTORY(ResolutionModelFactory,
"ResolutionModelFactory");
33 changes: 33 additions & 0 deletions RecoParticleFlow/PFSimProducer/plugins/ResolutionModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef __RecoFTL_FastTimingKludge_ResolutionModel_h__
#define __RecoFTL_FastTimingKludge_ResolutionModel_h__

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"

#include <string>
#include <iostream>

class ResolutionModel {
public:
ResolutionModel(const edm::ParameterSet& conf):
_modelName(conf.getParameter<std::string>("modelName")) {
}
virtual ~ResolutionModel() { }
// get rid of things we should never use...
ResolutionModel(const ResolutionModel&) = delete;
ResolutionModel& operator=(const ResolutionModel&) = delete;

virtual float getTimeResolution(const reco::Track&) const { return -1.f; }
virtual float getTimeResolution(const reco::PFCluster&) const { return -1.f; }

const std::string& name() const { return _modelName; }

private:
const std::string _modelName;
};

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory< ResolutionModel* (const edm::ParameterSet&) > ResolutionModelFactory;

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import FWCore.ParameterSet.Config as cms

ecalBarrelClusterFastTimer = cms.EDProducer(
'EcalBarrelClusterFastTimer',
ebTimeHits = cms.InputTag('ecalDetailedTimeRecHit:EcalRecHitsEB'),
ebClusters = cms.InputTag('particleFlowClusterECAL'),
timedVertices = cms.InputTag('offlinePrimaryVertices4D'),
minFractionToConsider = cms.double(0.1),
minEnergyToConsider = cms.double(0.0),
ecalDepth = cms.double(7.0),
resolutionModels = cms.VPSet( cms.PSet( modelName = cms.string('PerfectResolutionModel') ) )
)

0 comments on commit 369440a

Please sign in to comment.