Skip to content

Commit

Permalink
Ian L1TStub bug fix (cms-sw#160)
Browse files Browse the repository at this point in the history
* Ran second auto formatter tool

* tweak

* Fixed bug in L1TStub::isTilted function

* Update L1TrackNtupleMaker_cfg.py

Removed unnecessary line

* Update L1FPGATrackProducer.cc

Fix incorrect tiltedBarrel variable in endcap
  • Loading branch information
tomalin committed May 31, 2022
1 parent 9851ed3 commit 61bb76c
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 47 deletions.
12 changes: 7 additions & 5 deletions L1Trigger/TrackFindingTracklet/interface/L1TStub.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace trklet {
std::string stubword,
int isPSmodule,
int isFlipped,
bool tiltedBarrel,
unsigned int detId,
double x,
double y,
double z,
Expand Down Expand Up @@ -49,8 +51,6 @@ namespace trklet {
}
return disk;
}
unsigned int ladder() const { return ladder_; }
unsigned int module() const { return module_; }

double x() const { return x_; }
double y() const { return y_; }
Expand Down Expand Up @@ -94,7 +94,9 @@ namespace trklet {
unsigned int isPSmodule() const { return isPSmodule_; }
unsigned int isFlipped() const { return isFlipped_; }

bool isTilted() const;
bool isTilted() const { return tiltedBarrel_; } // Tilted barrel

unsigned int detId() const { return detId_; } // Lower sensor in module

bool tpmatch(int tp) const;
bool tpmatch2(int tp) const;
Expand All @@ -117,8 +119,6 @@ namespace trklet {
unsigned int iphi_;
unsigned int iz_;
unsigned int layer_;
unsigned int ladder_;
unsigned int module_;
unsigned int strip_;
double x_;
double y_;
Expand All @@ -131,6 +131,8 @@ namespace trklet {

unsigned int isPSmodule_;
unsigned int isFlipped_;
bool tiltedBarrel_;
unsigned int detId_;
};
}; // namespace trklet
#endif
7 changes: 6 additions & 1 deletion L1Trigger/TrackFindingTracklet/interface/SLHCEvent.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// This holds two classes: L1SimTrack (truth level simulated track), and SLHCEvent (support for maintaining standalone running)
// This class stores all the L1SimTracks (truth-level simulated track)
// & reconstructed stubs using CMSSW independent containers,
// to support standalone running.

#ifndef L1Trigger_TrackFindingTracklet_interface_SLHCEvent_h
#define L1Trigger_TrackFindingTracklet_interface_SLHCEvent_h

Expand Down Expand Up @@ -34,6 +37,8 @@ namespace trklet {
std::string stubword,
int isPSmodule,
int isFlipped,
bool tiltedBarrel,
unsigned int detId,
double x,
double y,
double z,
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/TrackFindingTracklet/interface/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ namespace trklet {
};

constexpr unsigned int N_TILTED_RINGS = 12; // # of tilted rings per half-layer in TBPS layers
constexpr std::array<unsigned int, N_PSLAYER> N_MOD_PLANK = {{7, 11, 15}}; // # of modules/plank in TBPS
constexpr std::array<unsigned int, N_PSLAYER> N_MOD_PLANK = {{7, 11, 15}}; // # of flat barrel modules/plank in TBPS

constexpr unsigned int N_TRKLSEED = 7; // # of tracklet seeds
constexpr unsigned int N_PROJ = 4; // # of projections (beyond stubs from tracklet seed)
Expand Down
54 changes: 33 additions & 21 deletions L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,26 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
// Process stubs in each region and channel within that tracking region
for (const int& region : handleDTC->tfpRegions()) {
for (const int& channel : handleDTC->tfpChannels()) {
// Get the DTC name form the channel
// Get the DTC name & ID from the channel
unsigned int atcaSlot = channel % 12;
string dtcname = settings_.slotToDTCname(atcaSlot);
if (channel % 24 >= 12)
dtcname = "neg" + dtcname;
dtcname += (channel < 24) ? "_A" : "_B"; // which detector region
int dtcId = setup_->dtcId(region, channel);

// Get the stubs from the DTC
const tt::StreamStub& streamFromDTC{handleDTC->stream(region, channel)};

// Prepare the DTC stubs for the IR
for (size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
const tt::FrameStub& stub{streamFromDTC[stubIndex]};
const TTStubRef& stubRef = stub.first;

if (stub.first.isNull()) {
if (stubRef.isNull())
continue;
}

const GlobalPoint& ttPos = setup_->stubPos(stub.first);
const GlobalPoint& ttPos = setup_->stubPos(stubRef);

//Get the 2 bits for the layercode
string layerword = stub.second.to_string().substr(61, 2);
Expand All @@ -486,18 +487,19 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe

//translation from the two bit layercode to the layer/disk number of each of the
//12 channels (dtcs)
static int layerdisktab[12][4] = {{0, 6, 8, 10},
{0, 7, 9, -1},
{1, 7, -1, -1},
{6, 8, 10, -1},
{2, 7, -1, -1},
{2, 9, -1, -1},
{3, 4, -1, -1},
{4, -1, -1, -1},
{5, -1, -1, -1},
{5, 8, -1, -1},
{6, 9, -1, -1},
{7, 10, -1, -1}};
// FIX: take this from DTC cabling map.
static const int layerdisktab[12][4] = {{0, 6, 8, 10},
{0, 7, 9, -1},
{1, 7, -1, -1},
{6, 8, 10, -1},
{2, 7, -1, -1},
{2, 9, -1, -1},
{3, 4, -1, -1},
{4, -1, -1, -1},
{5, -1, -1, -1},
{5, 8, -1, -1},
{6, 9, -1, -1},
{7, 10, -1, -1}};

int layerdisk = layerdisktab[channel % 12][layercode];
assert(layerdisk != -1);
Expand Down Expand Up @@ -551,7 +553,7 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe

for (unsigned int iClus = 0; iClus <= 1; iClus++) { // Loop over both clusters that make up stub.

const TTClusterRef& ttClusterRef = stub.first->clusterRef(iClus);
const TTClusterRef& ttClusterRef = stubRef->clusterRef(iClus);

// Now identify all TP's contributing to either cluster in stub.
if (readMoreMcTruth_) {
Expand All @@ -573,26 +575,36 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
}
}

double stubbend = stub.first->bendFE(); //stub.first->rawBend()
double stubbend = stubRef->bendFE(); //stubRef->rawBend()
if (ttPos.z() < -120) {
stubbend = -stubbend;
}

bool barrel = (layerdisk < N_LAYER);
// See https://github.com/cms-sw/cmssw/tree/master/Geometry/TrackerNumberingBuilder
enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
const TypeBarrel type = static_cast<TypeBarrel>(tTopo->tobSide(innerDetId));
bool tiltedBarrel = barrel && (type == tiltedMinus || type == tiltedPlus);

const unsigned int intDetId = innerDetId.rawId();

ev.addStub(dtcname,
region,
layerdisk,
stubwordhex,
setup_->psModule(setup_->dtcId(region, channel)),
setup_->psModule(dtcId),
isFlipped,
tiltedBarrel,
intDetId,
ttPos.x(),
ttPos.y(),
ttPos.z(),
stubbend,
stub.first->innerClusterPosition(),
stubRef->innerClusterPosition(),
assocTPs);

const trklet::L1TStub& lastStub = ev.lastStub();
stubMap[lastStub] = stub.first;
stubMap[lastStub] = stubRef;
}
}
}
Expand Down
21 changes: 5 additions & 16 deletions L1Trigger/TrackFindingTracklet/src/L1TStub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ L1TStub::L1TStub(std::string DTClink,
std::string stubword,
int isPSmodule,
int isFlipped,
bool tiltedBarrel,
unsigned int detId,
double x,
double y,
double z,
Expand All @@ -32,8 +34,6 @@ L1TStub::L1TStub(std::string DTClink,
layer_ += 1000;
}

ladder_ = -1;
module_ = -1;
strip_ = strip;
x_ = x;
y_ = y;
Expand All @@ -44,6 +44,8 @@ L1TStub::L1TStub(std::string DTClink,
bend_ = bend;
isPSmodule_ = isPSmodule;
isFlipped_ = isFlipped;
tiltedBarrel_ = tiltedBarrel;
detId_ = detId;

allstubindex_ = 999;
}
Expand All @@ -59,8 +61,7 @@ void L1TStub::write(ofstream& out) {
}

bool L1TStub::operator==(const L1TStub& other) const {
return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.ladder() == ladder_ &&
other.module() == module_);
return (other.iphi() == iphi_ && other.iz() == iz_ && other.layer() == layer_ && other.detId() == detId_);
}

void L1TStub::lorentzcor(double shift) {
Expand Down Expand Up @@ -122,15 +123,3 @@ bool L1TStub::tpmatch2(int tp) const {

return match1 && match2;
}

bool L1TStub::isTilted() const {
//here layer_ runs 0-5 for barrel, >1000 for disk
//disk modules and outer barrel modules are not tilted by construction
if (layer_ >= N_PSLAYER)
return false;

assert(layer_ < N_PSLAYER); // safety for acccessing # modules/plank
if ((module_ <= N_TILTED_RINGS) || (module_ >= N_TILTED_RINGS + N_MOD_PLANK.at(layer_)))
return true;
return false;
}
12 changes: 10 additions & 2 deletions L1Trigger/TrackFindingTracklet/src/SLHCEvent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ bool SLHCEvent::addStub(string DTClink,
string stubword,
int isPSmodule,
int isFlipped,
bool tiltedBarrel,
unsigned int detId,
double x,
double y,
double z,
double bend,
double strip,
vector<int> tps) {
L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps);
L1TStub stub(
DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, tiltedBarrel, detId, x, y, z, bend, strip, tps);

stubs_.push_back(stub);
return true;
Expand Down Expand Up @@ -92,13 +95,18 @@ SLHCEvent::SLHCEvent(istream& in) {

in >> DTClink >> region >> layerdisk >> stubword >> isPSmodule >> isFlipped >> x >> y >> z >> bend >> strip >> ntps;

// TO FIX: READ THESE FROM INPUT FILE
bool tiltedBarrel = false;
unsigned int detId = 999999; // Lower sensor in module

for (unsigned int itps = 0; itps < ntps; itps++) {
int tp;
in >> tp;
tps.push_back(tp);
}

L1TStub stub(DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, x, y, z, bend, strip, tps);
L1TStub stub(
DTClink, region, layerdisk, stubword, isPSmodule, isFlipped, tiltedBarrel, detId, x, y, z, bend, strip, tps);

in >> tmp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@

# HYBRID_NEWKF: prompt tracking or reduced
elif (L1TRKALGO == 'HYBRID_NEWKF' or L1TRKALGO == 'HYBRID_REDUCED'):
process.load("L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff")
process.load( 'L1Trigger.TrackFindingTracklet.Producer_cff' )
NHELIXPAR = 4
L1TRK_NAME = process.TrackFindingTrackletProducer_params.LabelTT.value()
Expand Down

0 comments on commit 61bb76c

Please sign in to comment.