Skip to content

Commit

Permalink
Move module loop to setup (#175)
Browse files Browse the repository at this point in the history
* Move module loop to setup

* Import functions from trackerTFP

* Ian's 2nd comment

* Code-format

Co-authored-by: Jack Li <[email protected]>
  • Loading branch information
2 people authored and Daniel Ally committed Nov 2, 2022
1 parent 56994c4 commit 6b204c8
Show file tree
Hide file tree
Showing 19 changed files with 201 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
#include "Geometry/CommonTopologies/interface/PixelGeomDetUnit.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "L1Trigger/TrackTrigger/interface/HitPatternHelperRcd.h"
#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelperRcd.h"
#include "L1Trigger/TrackTrigger/interface/Setup.h"
#include "L1Trigger/TrackerTFP/interface/DataFormats.h"
#include "L1Trigger/TrackerTFP/interface/LayerEncoding.h"

#include <bitset>
#include <iostream>
Expand All @@ -43,27 +45,42 @@ namespace hph {
//Class that stores configuration for HitPatternHelper
class Setup {
public:
Setup() {}
Setup(const edm::ParameterSet& iConfig, const tt::Setup& setupTT);
Setup(const edm::ParameterSet& iConfig,
const tt::Setup& setupTT,
const trackerTFP::DataFormats& dataFormats,
const trackerTFP::LayerEncoding& layerEncoding);
~Setup() {}

bool hphDebug() const { return iConfig_.getParameter<bool>("hphDebug"); }
bool useNewKF() const { return iConfig_.getParameter<bool>("useNewKF"); }
double deltaTanL() const { return iConfig_.getParameter<double>("deltaTanL"); }
double chosenRofZ() const { return setupTT_.chosenRofZ(); }
std::vector<double> etaRegions() const { return setupTT_.boundarieEta(); }
std::vector<tt::SensorModule> sensorModules() const { return setupTT_.sensorModules(); }
bool hphDebug() const { return hphDebug_; }
bool useNewKF() const { return useNewKF_; }
double chosenRofZ() const { return chosenRofZ_; }
std::vector<double> etaRegions() const { return etaRegions_; }
std::map<int, std::map<int, std::vector<int>>> layermap() const { return layermap_; }
int nKalmanLayers() const { return nKalmanLayers_; }
static auto smallerID(std::pair<int, bool> lhs, std::pair<int, bool> rhs) { return lhs.first < rhs.first; }
static auto equalID(std::pair<int, bool> lhs, std::pair<int, bool> rhs) { return lhs.first == rhs.first; }
int etaRegion(double z0, double cot, bool useNewKF) const;
int digiCot(double cot, int binEta) const;
int digiZT(double z0, double cot, int binEta) const;
const std::vector<int>& layerEncoding(int binEta, int binZT, int binCot) const {
return layerEncoding_.layerEncoding(binEta, binZT, binCot);
}
const std::map<int, const tt::SensorModule*>& layerEncodingMap(int binEta, int binZT, int binCot) const {
return layerEncoding_.layerEncodingMap(binEta, binZT, binCot);
}

private:
edm::ParameterSet iConfig_;
edm::ParameterSet oldKFPSet_;
const tt::Setup setupTT_; // Helper class to store TrackTrigger configuration
std::vector<std::pair<int, bool>>
layerIds_; // layer IDs (1~6->L1~L6;11~15->D1~D5) and whether or not they are from tracker barrel
// Only needed by Old KF
const trackerTFP::DataFormats dataFormats_;
const trackerTFP::DataFormat dfcot_;
const trackerTFP::DataFormat dfzT_;
const trackerTFP::LayerEncoding layerEncoding_;
bool hphDebug_;
bool useNewKF_;
double chosenRofZNewKF_;
std::vector<double> etaRegionsNewKF_;
double chosenRofZ_;
std::vector<double> etaRegions_;
std::map<int, std::map<int, std::vector<int>>> layermap_; // Hard-coded layermap in Old KF
int nEtaRegions_; // # of eta regions
int nKalmanLayers_; // # of maximum KF layers allowed
Expand All @@ -72,7 +89,6 @@ namespace hph {
//Class that returns decoded information from hitpattern
class HitPatternHelper {
public:
HitPatternHelper() {}
HitPatternHelper(const Setup* setup, int hitpattern, double cot, double z0);
~HitPatternHelper() {}

Expand All @@ -95,36 +111,36 @@ namespace hph {
return numMissingInterior2_;
} //The number of missing interior layers (using hitpattern, layermap from Old KF and sensor modules)
std::vector<int> binary() { return binary_; } //11-bit hitmask needed by TrackQuality.cc (0~5->L1~L6;6~10->D1~D5)
static auto smallerID(tt::SensorModule lhs, tt::SensorModule rhs) { return lhs.layerId() < rhs.layerId(); }
static auto equalID(tt::SensorModule lhs, tt::SensorModule rhs) { return lhs.layerId() == rhs.layerId(); }
std::vector<float> bonusFeatures() { return bonusFeatures_; } //bonus features for track quality

int ReducedId(
int reducedId(
int layerId); //Converts layer ID (1~6->L1~L6;11~15->D1~D5) to reduced layer ID (0~5->L1~L6;6~10->D1~D5)
int findLayer(int layerId); //Search for a layer ID from sensor modules

private:
int etaSector_;
int hitpattern_;
const Setup* setup_;
bool hphDebug_;
bool useNewKF_;
std::vector<double> etaRegions_;
std::map<int, std::map<int, std::vector<int>>> layermap_;
int nKalmanLayers_;
int etaBin_;
int cotBin_;
int zTBin_;
std::vector<int> layerEncoding_;
std::map<int, const tt::SensorModule*> layerEncodingMap_;
int numExpLayer_;
int hitpattern_;
int etaSector_;
int numMissingLayer_;
int numMissingPS_;
int numMissing2S_;
int numPS_;
int num2S_;
int numMissingInterior1_;
int numMissingInterior2_;
double cot_;
double z0_;
const Setup* setup_;
std::vector<tt::SensorModule> layers_; //Sensor modules that particles are expected to hit
std::vector<int> binary_;
bool hphDebug_;
bool useNewKF_;
float chosenRofZ_;
float deltaTanL_; // Uncertainty added to tanL (cot) when layermap in new KF is determined
std::vector<double> etaRegions_;
int nKalmanLayers_;
std::map<int, std::map<int, std::vector<int>>> layermap_;
std::vector<float> bonusFeatures_;
};

} // namespace hph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
#define L1Trigger_TrackTrigger_interface_HitPatternHelperRcd_h

#include "FWCore/Framework/interface/DependentRecordImplementation.h"

#include "L1Trigger/TrackTrigger/interface/SetupRcd.h"

#include "L1Trigger/TrackerTFP/interface/DataFormatsRcd.h"
#include "L1Trigger/TrackerTFP/interface/LayerEncodingRcd.h"
#include "FWCore/Utilities/interface/mplVector.h"

namespace hph {

typedef edm::mpl::Vector<tt::SetupRcd> Rcds;
typedef edm::mpl::Vector<tt::SetupRcd, trackerTFP::DataFormatsRcd, trackerTFP::LayerEncodingRcd> Rcds;

// record of hph::SetupRcd
class SetupRcd : public edm::eventsetup::DependentRecordImplementation<SetupRcd, Rcds> {};
Expand Down
10 changes: 6 additions & 4 deletions L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
#include "L1Trigger/TrackFindingTracklet/interface/Residual.h"
#include "L1Trigger/TrackFindingTracklet/interface/Stub.h"
#include "L1Trigger/TrackFindingTracklet/interface/StubStreamData.h"
#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h"

////////////////
// PHYSICS TOOLS
Expand All @@ -99,7 +100,6 @@

#include "L1Trigger/TrackTrigger/interface/StubPtConsistency.h"
#include "L1Trigger/TrackTrigger/interface/L1TrackQuality.h"
#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h"

//////////////
// STD HEADERS
Expand Down Expand Up @@ -350,9 +350,6 @@ void L1FPGATrackProducer::beginRun(const edm::Run& run, const edm::EventSetup& i

setup_ = &iSetup.getData(esGetToken_);
setupHPH_ = &iSetup.getData(esGetTokenHPH_);
if (trackQuality_) {
trackQualityModel_->beginRun(setupHPH_);
}
// Tracklet pattern reco output channel info.
channelAssignment_ = &iSetup.getData(esGetTokenChannelAssignment_);
// initialize the tracklet event processing (this sets all the processing & memory modules, wiring, etc)
Expand Down Expand Up @@ -722,6 +719,11 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
trackQualityModel_->setL1TrackQuality(aTrack);
}

// hph::HitPatternHelper hph(setupHPH_, tmp_hit, tmp_tanL, tmp_z0);
// if (trackQuality_) {
// trackQualityModel_->setBonusFeatures(hph.bonusFeatures());
// }

// test track word
//aTrack.testTrackWordBits();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/Utilities/interface/ESInputTag.h"
#include "DataFormats/Provenance/interface/ParameterSetID.h"
#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h"
#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h"
#include "L1Trigger/TrackTrigger/interface/Setup.h"
#include "L1Trigger/TrackerTFP/interface/DataFormats.h"
#include "L1Trigger/TrackerTFP/interface/LayerEncoding.h"

#include <memory>

Expand All @@ -28,17 +30,23 @@ namespace hph {

private:
const ParameterSet iConfig_;
ESGetToken<tt::Setup, tt::SetupRcd> getTokenSetup_;
ESGetToken<tt::Setup, tt::SetupRcd> esGetTokenSetup_;
ESGetToken<trackerTFP::DataFormats, trackerTFP::DataFormatsRcd> esGetTokenDataFormats_;
ESGetToken<trackerTFP::LayerEncoding, trackerTFP::LayerEncodingRcd> esGetTokenLayerEncoding_;
};

ProducerHPH::ProducerHPH(const ParameterSet& iConfig) : iConfig_(iConfig) {
auto cc = setWhatProduced(this);
getTokenSetup_ = cc.consumes();
esGetTokenSetup_ = cc.consumes();
esGetTokenDataFormats_ = cc.consumes();
esGetTokenLayerEncoding_ = cc.consumes();
}

unique_ptr<Setup> ProducerHPH::produce(const SetupRcd& Rcd) {
const tt::Setup& setupTT = Rcd.get(getTokenSetup_);
return make_unique<Setup>(iConfig_, setupTT);
const tt::Setup& setupTT = Rcd.get(esGetTokenSetup_);
const trackerTFP::DataFormats& dataFormats = Rcd.get(esGetTokenDataFormats_);
const trackerTFP::LayerEncoding& layerEncoding = Rcd.get(esGetTokenLayerEncoding_);
return make_unique<Setup>(iConfig_, setupTT, dataFormats, layerEncoding);
}

} // namespace hph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from SimTracker.TrackTriggerAssociation.TrackTriggerAssociator_cff import *

from L1Trigger.TrackTrigger.ProducerHPH_cff import *
from L1Trigger.TrackFindingTracklet.ProducerHPH_cff import *

# prompt hybrid emulation
TTTrackAssociatorFromPixelDigis.TTTracks = cms.VInputTag(cms.InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks") )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import FWCore.ParameterSet.Config as cms

from L1Trigger.TrackTrigger.ProducerHPH_cfi import HitPatternHelper_params
from L1Trigger.TrackFindingTracklet.ProducerHPH_cfi import HitPatternHelper_params

HitPatternHelperSetup = cms.ESProducer("hph::ProducerHPH", HitPatternHelper_params)
12 changes: 12 additions & 0 deletions L1Trigger/TrackFindingTracklet/python/ProducerHPH_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import FWCore.ParameterSet.Config as cms
from L1Trigger.TrackFindingTMTT.TMTrackProducer_Defaults_cfi import TMTrackProducer_params

# ParameterSet used by HitPatternHelper

HitPatternHelper_params = cms.PSet (

hphDebug = cms.bool(False), # switch on/off debug statement
useNewKF = cms.bool(False), # switch between new/old KF
oldKFPSet = cms.PSet(TMTrackProducer_params.EtaSectors) # import eta sector boundries from old kf package

)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
//

#include "FWCore/Utilities/interface/typelookup.h"
#include "L1Trigger/TrackTrigger/interface/HitPatternHelper.h"
#include "L1Trigger/TrackFindingTracklet/interface/HitPatternHelper.h"

TYPELOOKUP_DATA_REG(hph::Setup);
Loading

0 comments on commit 6b204c8

Please sign in to comment.