Skip to content
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

MTD RECO code update #24241

Merged
merged 2 commits into from Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,13 +1,6 @@
#ifndef RecoLocalFastTime_FTLCommonAlgos_MTDUncalibratedRecHitRecAlgoBase_HH
#define RecoLocalFastTime_FTLCommonAlgos_MTDUncalibratedRecHitRecAlgoBase_HH

/** \class MTDUncalibRecHitRecAlgoBase
* Template used by Ecal to compute amplitude, pedestal, time jitter, chi2 of a pulse
* using a weights method
*
* \author
*/

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

Expand All @@ -19,6 +12,7 @@ namespace edm {
class EventSetup;
}

template <typename DataFrame>
class MTDUncalibratedRecHitAlgoBase {
public:
/// Constructor
Expand All @@ -33,9 +27,7 @@ class MTDUncalibratedRecHitAlgoBase {
virtual void getEventSetup(const edm::EventSetup&) = 0;

/// make the rec hit

virtual FTLUncalibratedRecHit makeRecHit(const BTLDataFrame& dataFrame ) const = 0;
virtual FTLUncalibratedRecHit makeRecHit(const ETLDataFrame& dataFrame ) const = 0;
virtual FTLUncalibratedRecHit makeRecHit(const DataFrame& dataFrame ) const = 0;

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

Expand All @@ -44,8 +36,13 @@ class MTDUncalibratedRecHitAlgoBase {

};

#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory< MTDUncalibratedRecHitAlgoBase* (const edm::ParameterSet&, edm::ConsumesCollector&) > MTDUncalibratedRecHitAlgoFactory;

typedef MTDUncalibratedRecHitAlgoBase<BTLDataFrame> BTLUncalibratedRecHitAlgoBase;
typedef MTDUncalibratedRecHitAlgoBase<ETLDataFrame> ETLUncalibratedRecHitAlgoBase;


#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory< BTLUncalibratedRecHitAlgoBase* (const edm::ParameterSet&, edm::ConsumesCollector&) > BTLUncalibratedRecHitAlgoFactory;
typedef edmplugin::PluginFactory< ETLUncalibratedRecHitAlgoBase* (const edm::ParameterSet&, edm::ConsumesCollector&) > ETLUncalibratedRecHitAlgoFactory;

#endif
67 changes: 67 additions & 0 deletions RecoLocalFastTime/FTLCommonAlgos/plugins/BTLUncalibRecHitAlgo.cc
@@ -0,0 +1,67 @@
#include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDUncalibratedRecHitAlgoBase.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

class BTLUncalibRecHitAlgo : public BTLUncalibratedRecHitAlgoBase {
public:
/// Constructor
BTLUncalibRecHitAlgo( const edm::ParameterSet& conf,
edm::ConsumesCollector& sumes ) :
MTDUncalibratedRecHitAlgoBase<BTLDataFrame>( conf, sumes ),
adcNBits_( conf.getParameter<uint32_t>("adcNbits") ),
adcSaturation_( conf.getParameter<double>("adcSaturation") ),
adcLSB_( adcSaturation_/(1<<adcNBits_) ),
toaLSBToNS_( conf.getParameter<double>("toaLSB_ns") ),
timeError_( conf.getParameter<double>("timeResolutionInNs") ),
timeCorr_p0_( conf.getParameter<double>("timeCorr_p0") ),
timeCorr_p1_( conf.getParameter<double>("timeCorr_p1") ),
timeCorr_p2_( conf.getParameter<double>("timeCorr_p2") )
{ }

/// Destructor
~BTLUncalibRecHitAlgo() override { }

/// get event and eventsetup information
void getEvent(const edm::Event&) final {}
void getEventSetup(const edm::EventSetup&) final {}

/// make the rec hit
FTLUncalibratedRecHit makeRecHit(const BTLDataFrame& dataFrame ) const final;

private:

const uint32_t adcNBits_;
const double adcSaturation_;
const double adcLSB_;
const double toaLSBToNS_;
const double timeError_;
const double timeCorr_p0_;
const double timeCorr_p1_;
const double timeCorr_p2_;

};

FTLUncalibratedRecHit
BTLUncalibRecHitAlgo::makeRecHit(const BTLDataFrame& dataFrame ) const {
constexpr int iSample=2; //only in-time sample
const auto& sample = dataFrame.sample(iSample);

double amplitude = double(sample.data()) * adcLSB_;
double time = double(sample.toa()) * toaLSBToNS_;

// --- Correct the time for the time-walk and the constant delays
if ( amplitude > 0. )
time -= timeCorr_p0_*pow(amplitude,timeCorr_p1_) + timeCorr_p2_;

unsigned char flag = 0;

LogDebug("BTLUncalibRecHit") << "ADC+: set the charge to: " << amplitude << ' ' << sample.data()
<< ' ' << adcLSB_ << ' ' << std::endl;
LogDebug("BTLUncalibRecHit") << "ADC+: set the time to: " << time << ' ' << sample.toa()
<< ' ' << toaLSBToNS_ << ' ' << std::endl;
LogDebug("BTLUncalibRecHit") << "Final uncalibrated amplitude : " << amplitude << std::endl;

return FTLUncalibratedRecHit( dataFrame.id(), amplitude, time, timeError_, flag);
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_EDM_PLUGIN( BTLUncalibratedRecHitAlgoFactory, BTLUncalibRecHitAlgo, "BTLUncalibRecHitAlgo" );
58 changes: 58 additions & 0 deletions RecoLocalFastTime/FTLCommonAlgos/plugins/ETLUncalibRecHitAlgo.cc
@@ -0,0 +1,58 @@
#include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDUncalibratedRecHitAlgoBase.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

class ETLUncalibRecHitAlgo : public ETLUncalibratedRecHitAlgoBase {
public:
/// Constructor
ETLUncalibRecHitAlgo( const edm::ParameterSet& conf,
edm::ConsumesCollector& sumes ) :
MTDUncalibratedRecHitAlgoBase<ETLDataFrame>( conf, sumes ),
adcNBits_( conf.getParameter<uint32_t>("adcNbits") ),
adcSaturation_( conf.getParameter<double>("adcSaturation") ),
adcLSB_( adcSaturation_/(1<<adcNBits_) ),
toaLSBToNS_( conf.getParameter<double>("toaLSB_ns") ),
tofDelay_( conf.getParameter<double>("tofDelay") ),
timeError_( conf.getParameter<double>("timeResolutionInNs") )
{ }

/// Destructor
~ETLUncalibRecHitAlgo() override { }

/// get event and eventsetup information
void getEvent(const edm::Event&) final {}
void getEventSetup(const edm::EventSetup&) final {}

/// make the rec hit
FTLUncalibratedRecHit makeRecHit(const ETLDataFrame& dataFrame ) const final;

private:

const uint32_t adcNBits_;
const double adcSaturation_;
const double adcLSB_;
const double toaLSBToNS_;
const double tofDelay_;
const double timeError_;

};

FTLUncalibratedRecHit
ETLUncalibRecHitAlgo::makeRecHit(const ETLDataFrame& dataFrame ) const {
constexpr int iSample=2; //only in-time sample
const auto& sample = dataFrame.sample(iSample);

double amplitude = double(sample.data()) * adcLSB_;
double time = double(sample.toa()) * toaLSBToNS_ - tofDelay_;
unsigned char flag = 0;

LogDebug("ETLUncalibRecHit") << "ADC+: set the charge to: " << amplitude << ' ' << sample.data()
<< ' ' << adcLSB_ << ' ' << std::endl;
LogDebug("ETLUncalibRecHit") << "ADC+: set the time to: " << time << ' ' << sample.toa()
<< ' ' << toaLSBToNS_ << ' ' << std::endl;
LogDebug("ETLUncalibRecHit") << "Final uncalibrated amplitude : " << amplitude << std::endl;

return FTLUncalibratedRecHit( dataFrame.id(), amplitude, time, timeError_, flag);
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_EDM_PLUGIN( ETLUncalibratedRecHitAlgoFactory, ETLUncalibRecHitAlgo, "ETLUncalibRecHitAlgo" );
76 changes: 0 additions & 76 deletions RecoLocalFastTime/FTLCommonAlgos/plugins/MTDUncalibRecHitAlgo.cc

This file was deleted.

This file was deleted.

@@ -1,4 +1,4 @@
#include "RecoLocalFastTime/FTLCommonAlgos/interface/MTDUncalibratedRecHitAlgoBase.h"

EDM_REGISTER_PLUGINFACTORY(MTDUncalibratedRecHitAlgoFactory,
"MTDUncalibratedRecHitAlgoFactory");
EDM_REGISTER_PLUGINFACTORY(BTLUncalibratedRecHitAlgoFactory, "BTLUncalibratedRecHitAlgoFactory");
EDM_REGISTER_PLUGINFACTORY(ETLUncalibratedRecHitAlgoFactory, "ETLUncalibratedRecHitAlgoFactory");
Expand Up @@ -26,7 +26,8 @@ class MTDUncalibratedRecHitProducer : public edm::stream::EDProducer<> {
const std::string ftlbInstance_; // instance name of barrel hits
const std::string ftleInstance_; // instance name of endcap hits

std::unique_ptr<MTDUncalibratedRecHitAlgoBase> barrel_,endcap_;
std::unique_ptr<BTLUncalibratedRecHitAlgoBase> barrel_;
std::unique_ptr<ETLUncalibratedRecHitAlgoBase> endcap_;
};

MTDUncalibratedRecHitProducer::MTDUncalibratedRecHitProducer(const edm::ParameterSet& ps) :
Expand All @@ -42,11 +43,11 @@ MTDUncalibratedRecHitProducer::MTDUncalibratedRecHitProducer(const edm::Paramete

const edm::ParameterSet& barrel = ps.getParameterSet("barrel");
const std::string& barrelAlgo = barrel.getParameter<std::string>("algoName");
barrel_.reset( MTDUncalibratedRecHitAlgoFactory::get()->create(barrelAlgo, barrel, sumes) );
barrel_.reset( BTLUncalibratedRecHitAlgoFactory::get()->create(barrelAlgo, barrel, sumes) );

const edm::ParameterSet& endcap = ps.getParameterSet("endcap");
const std::string& endcapAlgo = endcap.getParameter<std::string>("algoName");
endcap_.reset( MTDUncalibratedRecHitAlgoFactory::get()->create(endcapAlgo, endcap, sumes) );
endcap_.reset( ETLUncalibratedRecHitAlgoFactory::get()->create(endcapAlgo, endcap, sumes) );
}

MTDUncalibratedRecHitProducer::~MTDUncalibratedRecHitProducer() {
Expand Down
4 changes: 2 additions & 2 deletions RecoLocalFastTime/FTLRecProducers/python/mtdRecHits_cfi.py
Expand Up @@ -9,8 +9,8 @@

_endcapAlgo = cms.PSet(
algoName = cms.string("MTDRecHitAlgo"),
thresholdToKeep = cms.double(0.5), # MIPs
calibrationConstant = cms.double(1.),
thresholdToKeep = cms.double(0.0425), # MeV
calibrationConstant = cms.double(0.085), # MeV/MIP
)


Expand Down
@@ -1,17 +1,30 @@
import FWCore.ParameterSet.Config as cms

from RecoLocalFastTime.FTLCommonAlgos.mtdUncalibRecHitAlgo_cff import mtdUncalibRecHitAlgo

from SimFastTiming.FastTimingCommon.mtdDigitizer_cfi import mtdDigitizer

_barrelAlgo = mtdUncalibRecHitAlgo.clone()
_barrelAlgo.adcNbits = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.adcNbits
_barrelAlgo.adcSaturation = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.adcSaturation_MIP
_barrelAlgo.toaLSB_ns = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.toaLSB_ns
_endcapAlgo = mtdUncalibRecHitAlgo.clone()
_endcapAlgo.adcNbits = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.adcNbits
_endcapAlgo.adcSaturation = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.adcSaturation_MIP
_endcapAlgo.toaLSB_ns = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.toaLSB_ns

_barrelAlgo = cms.PSet(
algoName = cms.string("BTLUncalibRecHitAlgo"),
adcNbits = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.adcNbits,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may be better to define these parameters in a common place and pick them up from that one place by the digitizer and reco.

What is the plan to put all these calibration constants in the DB?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan is to put all the calibration constants in the DB. For what concerns the hardware specs, like the number of ADC bits, TDC bits, there range and so on, once the hardware is defined, I think I will follow the example of the other systems .

adcSaturation = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.adcSaturation_MIP,
toaLSB_ns = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.toaLSB_ns,
timeResolutionInNs = cms.double(0.025),
timeCorr_p0 = cms.double(24.8997),
timeCorr_p1 = cms.double(-0.911385),
#timeCorr_p2 = cms.double( 4.19755)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this commented out code needed?
Please remove or add comments inline in the code why the commented out block is relevant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it isn't, that was an oversight. I've removed the line. Thanks.

timeCorr_p2 = cms.double( 3.3744717)
)


_endcapAlgo = cms.PSet(
algoName = cms.string("ETLUncalibRecHitAlgo"),
adcNbits = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.adcNbits,
adcSaturation = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.adcSaturation_MIP,
toaLSB_ns = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.toaLSB_ns,
tofDelay = mtdDigitizer.endcapDigitizer.DeviceSimulation.tofDelay,
timeResolutionInNs = cms.double(0.025)
)


mtdUncalibratedRecHits = cms.EDProducer(
"MTDUncalibratedRecHitProducer",
Expand Down