New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simulation of the readout and digitization for the MIP timing detector barrel #23584
Changes from all commits
ed2cc03
9a16d27
2f2ced6
8a8ade8
5ea3a3f
dd4a442
fbce40a
ec1f280
c255a88
c49289d
b1890cd
b9fdf3f
b318081
403e6c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#ifndef RecoLocalFastTime_FTLCommonAlgos_MTDRecHitAlgoBase_HH | ||
#define RecoLocalFastTime_FTLCommonAlgos_MTDRecHitAlgoBase_HH | ||
|
||
/** \class MTDRecHitAlgoBase | ||
* Template algorithm to make rechits from uncalibrated rechits | ||
* | ||
* \author Lindsey Gray | ||
*/ | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
|
||
#include "DataFormats/FTLRecHit/interface/FTLRecHit.h" | ||
#include "DataFormats/FTLRecHit/interface/FTLUncalibratedRecHit.h" | ||
|
||
namespace edm { | ||
class Event; | ||
class EventSetup; | ||
} | ||
|
||
class MTDRecHitAlgoBase { | ||
public: | ||
|
||
/// Constructor | ||
MTDRecHitAlgoBase(const edm::ParameterSet& conf, | ||
edm::ConsumesCollector& sumes): | ||
name_( conf.getParameter<std::string>("algoName") ){ }; | ||
|
||
/// Destructor | ||
virtual ~MTDRecHitAlgoBase() { }; | ||
|
||
/// get event and eventsetup information | ||
virtual void getEvent(const edm::Event&) = 0; | ||
virtual void getEventSetup(const edm::EventSetup&) = 0; | ||
|
||
/// make rechits from dataframes | ||
virtual FTLRecHit makeRecHit(const FTLUncalibratedRecHit& uRecHit, uint32_t& flags) const = 0; | ||
|
||
const std::string& name() const { return name_; } | ||
|
||
private: | ||
std::string name_; | ||
|
||
}; | ||
|
||
#include "FWCore/PluginManager/interface/PluginFactory.h" | ||
typedef edmplugin::PluginFactory< MTDRecHitAlgoBase* (const edm::ParameterSet&, edm::ConsumesCollector&) > MTDRecHitAlgoFactory; | ||
|
||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDRecHitAlgoBase.h" | ||
|
||
class MTDRecHitAlgo : public MTDRecHitAlgoBase { | ||
public: | ||
/// Constructor | ||
MTDRecHitAlgo( const edm::ParameterSet& conf, | ||
edm::ConsumesCollector& sumes ) : | ||
MTDRecHitAlgoBase( conf, sumes ), | ||
thresholdToKeep_( conf.getParameter<double>("thresholdToKeep") ), | ||
calibration_( conf.getParameter<double>("calibrationConstant") ) { } | ||
|
||
/// Destructor | ||
~MTDRecHitAlgo() override { } | ||
|
||
/// get event and eventsetup information | ||
void getEvent(const edm::Event&) final {} | ||
void getEventSetup(const edm::EventSetup&) final {} | ||
|
||
/// make the rec hit | ||
FTLRecHit makeRecHit(const FTLUncalibratedRecHit& uRecHit, uint32_t& flags ) const final; | ||
|
||
private: | ||
double thresholdToKeep_, calibration_; | ||
}; | ||
|
||
|
||
FTLRecHit | ||
MTDRecHitAlgo::makeRecHit(const FTLUncalibratedRecHit& uRecHit, uint32_t& flags) const { | ||
|
||
float energy = uRecHit.amplitude() * calibration_; | ||
float time = uRecHit.time(); | ||
float timeError = uRecHit.timeError(); | ||
|
||
FTLRecHit rh( uRecHit.id(), energy, time, timeError ); | ||
|
||
// Now fill flags | ||
// all rechits from the digitizer are "good" at present | ||
if( energy > thresholdToKeep_ ) { | ||
flags = FTLRecHit::kGood; | ||
rh.setFlag(flags); | ||
} else { | ||
flags = FTLRecHit::kKilled; | ||
rh.setFlag(flags); | ||
} | ||
|
||
return rh; | ||
} | ||
|
||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
DEFINE_EDM_PLUGIN( MTDRecHitAlgoFactory, MTDRecHitAlgo, "MTDRecHitAlgo" ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDRecHitAlgoBase.h" | ||
|
||
EDM_REGISTER_PLUGINFACTORY(MTDRecHitAlgoFactory,"MTDRecHitAlgoFactory"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/FTLDigi/interface/FTLDigiCollections.h" | ||
#include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h" | ||
|
||
#include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDRecHitAlgoBase.h" | ||
|
||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
class MTDRecHitProducer : public edm::stream::EDProducer<> { | ||
|
||
public: | ||
explicit MTDRecHitProducer(const edm::ParameterSet& ps); | ||
~MTDRecHitProducer() override; | ||
void produce(edm::Event& evt, const edm::EventSetup& es) override; | ||
|
||
private: | ||
|
||
const edm::EDGetTokenT<FTLUncalibratedRecHitCollection> ftlbURecHits_; // collection of barrel digis | ||
const edm::EDGetTokenT<FTLUncalibratedRecHitCollection> ftleURecHits_; // collection of endcap digis | ||
|
||
const std::string ftlbInstance_; // instance name of barrel hits | ||
const std::string ftleInstance_; // instance name of endcap hits | ||
|
||
std::unique_ptr<MTDRecHitAlgoBase> barrel_,endcap_; | ||
}; | ||
|
||
MTDRecHitProducer::MTDRecHitProducer(const edm::ParameterSet& ps) : | ||
ftlbURecHits_( consumes<FTLUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("barrelUncalibratedRecHits") ) ), | ||
ftleURecHits_( consumes<FTLUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("endcapUncalibratedRecHits") ) ), | ||
ftlbInstance_( ps.getParameter<std::string>("BarrelHitsName") ), | ||
ftleInstance_( ps.getParameter<std::string>("EndcapHitsName") ) | ||
{ | ||
|
||
produces< FTLRecHitCollection >(ftlbInstance_); | ||
produces< FTLRecHitCollection >(ftleInstance_); | ||
|
||
auto sumes = consumesCollector(); | ||
|
||
const edm::ParameterSet& barrel = ps.getParameterSet("barrel"); | ||
const std::string& barrelAlgo = barrel.getParameter<std::string>("algoName"); | ||
barrel_.reset( MTDRecHitAlgoFactory::get()->create(barrelAlgo, barrel, sumes) ); | ||
|
||
const edm::ParameterSet& endcap = ps.getParameterSet("endcap"); | ||
const std::string& endcapAlgo = endcap.getParameter<std::string>("algoName"); | ||
endcap_.reset( MTDRecHitAlgoFactory::get()->create(endcapAlgo, endcap, sumes) ); | ||
|
||
} | ||
|
||
MTDRecHitProducer::~MTDRecHitProducer() { | ||
} | ||
|
||
void | ||
MTDRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) { | ||
|
||
|
||
// tranparently get things from event setup | ||
barrel_->getEventSetup(es); | ||
endcap_->getEventSetup(es); | ||
|
||
barrel_->getEvent(evt); | ||
endcap_->getEvent(evt); | ||
|
||
// prepare output | ||
auto barrelRechits = std::make_unique<FTLRecHitCollection>(); | ||
auto endcapRechits = std::make_unique<FTLRecHitCollection>(); | ||
|
||
edm::Handle< FTLUncalibratedRecHitCollection > hBarrel; | ||
evt.getByToken( ftlbURecHits_, hBarrel ); | ||
barrelRechits->reserve(hBarrel->size()/2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why only reserve half the size? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a cut in energy and not all UncalibratedRecHits are converted to RecHits. I think that reserving the all size would use more memory than needed. |
||
for(const auto& uhit : *hBarrel) { | ||
uint32_t flags = FTLRecHit::kGood; | ||
auto rechit = std::move( barrel_->makeRecHit(uhit, flags) ); | ||
if( flags == FTLRecHit::kGood ) barrelRechits->push_back( std::move(rechit) ); | ||
} | ||
|
||
edm::Handle< FTLUncalibratedRecHitCollection > hEndcap; | ||
evt.getByToken( ftleURecHits_, hEndcap ); | ||
endcapRechits->reserve(hEndcap->size()/2); | ||
for(const auto& uhit : *hEndcap) { | ||
uint32_t flags = FTLRecHit::kGood; | ||
auto rechit = std::move( endcap_->makeRecHit(uhit, flags) ); | ||
if( flags == FTLRecHit::kGood ) endcapRechits->push_back( std::move(rechit) ); | ||
} | ||
|
||
// put the collection of recunstructed hits in the event | ||
evt.put(std::move(barrelRechits), ftlbInstance_); | ||
evt.put(std::move(endcapRechits), ftleInstance_); | ||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
DEFINE_FWK_MODULE( MTDRecHitProducer ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
_barrelAlgo = cms.PSet( | ||
algoName = cms.string("MTDRecHitAlgo"), | ||
thresholdToKeep = cms.double(1.), # MeV | ||
calibrationConstant = cms.double(0.026041667), # MeV/pC | ||
) | ||
|
||
|
||
_endcapAlgo = cms.PSet( | ||
algoName = cms.string("MTDRecHitAlgo"), | ||
thresholdToKeep = cms.double(0.5), # MIPs | ||
calibrationConstant = cms.double(1.), | ||
) | ||
|
||
|
||
mtdRecHits = cms.EDProducer( | ||
"MTDRecHitProducer", | ||
barrel = _barrelAlgo, | ||
endcap = _endcapAlgo, | ||
barrelUncalibratedRecHits = cms.InputTag('mtdUncalibratedRecHits:FTLBarrel'), | ||
endcapUncalibratedRecHits = cms.InputTag('mtdUncalibratedRecHits:FTLEndcap'), | ||
BarrelHitsName = cms.string('FTLBarrel'), | ||
EndcapHitsName = cms.string('FTLEndcap'), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A similar simplification could be done here, though there's more information to pass (
sample.data()
,sample.toa()
,dataFrame.id()
,adcLSB
,toaLSBToNS
,timeError
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would leave two distinct methods: makeRecHit(const BTLDataFrame& dataFrame ) and makeRecHit(const ETLDataFrame& dataFrame ). For the time being they are implemented in the same way, but they refer to two different detectors, built with different technologies, and
soon (~a couple of weeks) will have different impementations.