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

Bugfixes in simtrack to GEM/CSC digi and stub matching #30608

Merged
merged 8 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DataFormats/GEMDigi/interface/GEMDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class GEMDigi {
public:
explicit GEMDigi(int strip, int bx);
explicit GEMDigi(uint16_t strip, int16_t bx);
GEMDigi();

bool operator==(const GEMDigi& digi) const;
Expand All @@ -23,8 +23,8 @@ class GEMDigi {
bool isValid() const;

// return the strip number. counts from 0.
int strip() const { return strip_; }
int bx() const { return bx_; }
uint16_t strip() const { return strip_; }
int16_t bx() const { return bx_; }

void print() const;

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/GEMDigi/src/GEMDigi.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "DataFormats/GEMDigi/interface/GEMDigi.h"
#include <iostream>

GEMDigi::GEMDigi(int strip, int bx) : strip_(strip), bx_(bx) {}
GEMDigi::GEMDigi(uint16_t strip, int16_t bx) : strip_(strip), bx_(bx) {}

GEMDigi::GEMDigi() : strip_(65535), bx_(-99) {}

Expand Down
2 changes: 1 addition & 1 deletion SimDataFormats/GEMDigiSimLink/interface/GEMDigiSimLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GEMDigiSimLink {
~GEMDigiSimLink() { ; }

unsigned int getStrip() const { return _digi.first; }
unsigned int getBx() const { return _digi.second; }
int getBx() const { return _digi.second; }
Local3DPoint getEntryPoint() const { return _entryPoint; }
LocalVector getMomentumAtEntry() const { return _momentumAtEntry; }
float getTimeOfFlight() const { return _timeOfFlight; }
Expand Down
10 changes: 0 additions & 10 deletions Validation/MuonCSCDigis/src/CSCDigiMatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ void CSCDigiMatcher::match(const SimTrack& t, const SimVertex& v) {
}

void CSCDigiMatcher::matchComparatorsToSimTrack(const CSCComparatorDigiCollection& comparators) {
for (auto detUnitIt = comparators.begin(); detUnitIt != comparators.end(); ++detUnitIt) {
const CSCDetId& id = (*detUnitIt).first;
const auto& range = (*detUnitIt).second;
for (auto digiIt = range.first; digiIt != range.second; ++digiIt) {
if (id.station() == 1 and (id.ring() == 1 or id.ring() == 4))
if (verboseComparator_)
cout << "CSCid " << id << " Comparator digi (comparator, comparator, Tbin ) " << (*digiIt) << endl;
}
}

const auto& det_ids = muonSimHitMatcher_->detIds(0);
for (const auto& id : det_ids) {
CSCDetId layer_id(id);
Expand Down
61 changes: 45 additions & 16 deletions Validation/MuonCSCDigis/src/CSCStubMatcher.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "Validation/MuonCSCDigis/interface/CSCStubMatcher.h"
#include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h"

#include <algorithm>

using namespace std;
Expand Down Expand Up @@ -87,12 +86,9 @@ void CSCStubMatcher::matchCLCTsToSimTrack(const CSCCLCTDigiCollection& clcts) {
}

int ring = ch_id.ring();
if (ring == 4)
ring = 1; //use ME1b id to get CLCTs
CSCDetId ch_id2(ch_id.endcap(), ch_id.station(), ring, ch_id.chamber(), 0);

// do not consider CSCs with too few hits
if (cscDigiMatcher_->nLayersWithStripInChamber(ch_id2) < minNHitsChamberCLCT_)
if (cscDigiMatcher_->nLayersWithStripInChamber(ch_id) < minNHitsChamberCLCT_)
continue;

// get the comparator digis in this chamber
Expand All @@ -104,7 +100,7 @@ void CSCStubMatcher::matchCLCTsToSimTrack(const CSCCLCTDigiCollection& clcts) {

// print out the digis
if (verboseCLCT_) {
cout << "clct: digi_strips " << ch_id2 << endl;
cout << "clct: comparators " << ch_id << endl;
int layer = 0;
for (const auto& p : comps) {
layer++;
Expand All @@ -115,6 +111,12 @@ void CSCStubMatcher::matchCLCTsToSimTrack(const CSCCLCTDigiCollection& clcts) {
}
}

//use ME1b id to get CLCTs
const bool isME1a(ch_id.station() == 1 and ch_id.ring() == 4);
if (isME1a)
ring = 1;
CSCDetId ch_id2(ch_id.endcap(), ch_id.station(), ring, ch_id.chamber(), 0);

const auto& clcts_in_det = clcts.get(ch_id2);

for (auto c = clcts_in_det.first; c != clcts_in_det.second; ++c) {
Expand All @@ -137,15 +139,28 @@ void CSCStubMatcher::matchCLCTsToSimTrack(const CSCCLCTDigiCollection& clcts) {
for (const auto& p : comps) {
layer++;
for (const auto& q : p) {
if (verboseCLCT_)
cout << "L" << layer << " " << q << " " << q.getHalfStrip() << " " << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed, use messagelogger

for (const auto& clctComp : (*c).getHits()[layer - 1]) {
if (q.getHalfStrip() == clctComp) {
if (clctComp == 65535)
continue;
if (verboseCLCT_) {
std::cout << "\t" << clctComp << " " << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

}
if (q.getHalfStrip() == clctComp or (isME1a and q.getHalfStrip() + 128 == clctComp)) {
nMatches++;
if (verboseCLCT_) {
cout << "\t\tnMatches " << nMatches << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

}
}
}
}
if (verboseCLCT_) {
cout << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

}
}

// require at least 3 good half-strip matches
// require at least 3 good matches
if (nMatches < 3)
continue;

Expand Down Expand Up @@ -257,19 +272,23 @@ void CSCStubMatcher::matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection& l
for (const auto& lct : lcts_tmp) {
iLct++;

bool lct_matched(false);
bool lct_clct_match(false);
bool lct_alct_match(false);
bool lct_gem1_match(false);
bool lct_gem2_match(false);

if (verboseLCT_)
cout << "in LCT, getCLCT " << lct.getCLCT() << " getALCT " << lct.getALCT() << endl;

if (verboseLCT_) {
cout << ch_id << " " << ch_id2 << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

cout << lct << endl;
cout << "getCLCT " << lct.getCLCT() << "\ngetALCT " << lct.getALCT() << "\ngetGEM1 " << lct.getGEM1()
<< "\ngetGEM2 " << lct.getGEM2() << endl;
}
// Check if matched to an CLCT
for (const auto& p : clctsInChamber(id)) {
if (p == lct.getCLCT()) {
lct_clct_match = true;
if (verboseLCT_)
cout << "\t...lct_clct_match" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

break;
}
}
Expand All @@ -278,6 +297,8 @@ void CSCStubMatcher::matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection& l
for (const auto& p : alctsInChamber(id)) {
if (p == lct.getALCT()) {
lct_alct_match = true;
if (verboseLCT_)
cout << "\t...lct_alct_match" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

break;
}
}
Expand All @@ -289,6 +310,8 @@ void CSCStubMatcher::matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection& l
for (const auto& p : gemDigiMatcher_->padsInChamber(gemDetIdL1.rawId())) {
if (p == lct.getGEM1()) {
lct_gem1_match = true;
if (verboseLCT_)
cout << "\t...lct_gem1_match" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

break;
}
}
Expand All @@ -298,17 +321,24 @@ void CSCStubMatcher::matchLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection& l
for (const auto& p : gemDigiMatcher_->padsInChamber(gemDetIdL2.rawId())) {
if (p == lct.getGEM2()) {
lct_gem2_match = true;
if (verboseLCT_)
cout << "\t...lct_gem2_match" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

break;
}
}
}

lct_matched = ((lct_clct_match and lct_alct_match) or (lct_alct_match and lct_gem1_match and lct_gem2_match) or
(lct_clct_match and lct_gem1_match and lct_gem2_match));
const bool alct_clct = lct_clct_match and lct_alct_match;
const bool alct_gem = lct_alct_match and lct_gem1_match and lct_gem2_match;
const bool clct_gem = lct_clct_match and lct_gem1_match and lct_gem2_match;

bool lct_tight_matched = alct_clct or alct_gem or clct_gem;
bool lct_loose_matched = lct_clct_match or lct_alct_match;
bool lct_matched = lct_loose_matched or lct_tight_matched;

if (lct_matched) {
if (verboseLCT_)
cout << "this LCT matched to simtrack in chamber " << ch_id << endl;
cout << "...was matched" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

cout is not allowed

if (std::find(chamber_to_lcts_[id].begin(), chamber_to_lcts_[id].end(), lct) == chamber_to_lcts_[id].end()) {
chamber_to_lcts_[id].emplace_back(lct);
}
Expand All @@ -331,7 +361,6 @@ void CSCStubMatcher::matchMPLCTsToSimTrack(const CSCCorrelatedLCTDigiCollection&
if (!lct->isValid())
continue;

// std::cout << "MPC Stub ALL " << *lct << std::endl;
chamber_to_mplcts_all_[id].emplace_back(*lct);

// check if this stub corresponds with a previously matched stub
Expand Down
1 change: 1 addition & 0 deletions Validation/MuonGEMDigis/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<use name="rootcore"/>
<use name="Validation/MuonHits"/>
<use name="DataFormats/GEMDigi"/>
<use name="SimDataFormats/GEMDigiSimLink"/>
<export>
<lib name="1"/>
</export>
18 changes: 18 additions & 0 deletions Validation/MuonGEMDigis/interface/GEMDigiMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@

#include "Validation/MuonHits/interface/GEMSimHitMatcher.h"
#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "SimDataFormats/GEMDigiSimLink/interface/GEMDigiSimLink.h"
#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
#include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h"
#include "DataFormats/GEMDigi/interface/GEMPadDigiClusterCollection.h"
#include "DataFormats/GEMDigi/interface/GEMCoPadDigiCollection.h"
#include "DataFormats/Common/interface/DetSetVector.h"

#include <vector>
#include <map>
#include <set>
#include <unordered_set>

typedef std::vector<GEMDigiSimLink> GEMDigiSimLinkContainer;
typedef std::vector<GEMDigi> GEMDigiContainer;
typedef std::vector<GEMPadDigi> GEMPadDigiContainer;
typedef std::vector<GEMPadDigiCluster> GEMPadDigiClusterContainer;
Expand All @@ -39,6 +42,8 @@ class GEMDigiMatcher {
// do the matching
void match(const SimTrack& t, const SimVertex& v);

std::set<unsigned int> detIdsSimLink(int gem_type = MuonHitHelper::GEM_ALL) const;

// partition GEM detIds with digis
std::set<unsigned int> detIdsDigi(int gem_type = MuonHitHelper::GEM_ALL) const;
std::set<unsigned int> detIdsPad(int gem_type = MuonHitHelper::GEM_ALL) const;
Expand All @@ -55,6 +60,8 @@ class GEMDigiMatcher {
std::set<unsigned int> superChamberIdsCluster(int gem_type = MuonHitHelper::GEM_ALL) const;
std::set<unsigned int> superChamberIdsCoPad(int gem_type = MuonHitHelper::GEM_ALL) const;

const GEMDigiSimLinkContainer& simLinksInDetId(unsigned int) const;

// GEM digis from a particular partition, chamber or superchamber
const GEMDigiContainer& digisInDetId(unsigned int) const;
const GEMDigiContainer& digisInChamber(unsigned int) const;
Expand All @@ -78,6 +85,7 @@ class GEMDigiMatcher {
// #layers with digis from this simtrack
int nLayersWithDigisInSuperChamber(unsigned int) const;
int nLayersWithPadsInSuperChamber(unsigned int) const;
int nLayersWithClustersInSuperChamber(unsigned int) const;

/// How many pads in GEM did this simtrack get in total?
int nPads() const;
Expand All @@ -102,18 +110,21 @@ class GEMDigiMatcher {
std::shared_ptr<GEMSimHitMatcher> muonSimHitMatcher() { return muonSimHitMatcher_; }

private:
void matchDigisSLToSimTrack(const edm::DetSetVector<GEMDigiSimLink>&);
void matchDigisToSimTrack(const GEMDigiCollection&);
void matchPadsToSimTrack(const GEMPadDigiCollection&);
void matchClustersToSimTrack(const GEMPadDigiClusterCollection&);
void matchCoPadsToSimTrack(const GEMCoPadDigiCollection&);

void clear();

edm::EDGetTokenT<edm::DetSetVector<GEMDigiSimLink>> gemSimLinkToken_;
edm::EDGetTokenT<GEMDigiCollection> gemDigiToken_;
edm::EDGetTokenT<GEMPadDigiCollection> gemPadToken_;
edm::EDGetTokenT<GEMPadDigiClusterCollection> gemClusterToken_;
edm::EDGetTokenT<GEMCoPadDigiCollection> gemCoPadToken_;

edm::Handle<edm::DetSetVector<GEMDigiSimLink>> gemDigisSLH_;
edm::Handle<GEMDigiCollection> gemDigisH_;
edm::Handle<GEMPadDigiCollection> gemPadsH_;
edm::Handle<GEMPadDigiClusterCollection> gemClustersH_;
Expand All @@ -127,18 +138,24 @@ class GEMDigiMatcher {
template <class T>
std::set<unsigned int> selectDetIds(const T&, int) const;

bool simMuOnly_;
bool discardEleHits_;

int minBXDigi_, maxBXDigi_;
int minBXPad_, maxBXPad_;
int minBXCluster_, maxBXCluster_;
int minBXCoPad_, maxBXCoPad_;

int matchDeltaStrip_;

bool verboseSimLink_;
bool verboseDigi_;
bool verbosePad_;
bool verboseCluster_;
bool verboseCoPad_;

std::map<unsigned int, GEMDigiSimLinkContainer> detid_to_simLinks_;

std::map<unsigned int, GEMDigiContainer> detid_to_digis_;
std::map<unsigned int, GEMDigiContainer> chamber_to_digis_;
std::map<unsigned int, GEMDigiContainer> superchamber_to_digis_;
Expand All @@ -153,6 +170,7 @@ class GEMDigiMatcher {

std::map<unsigned int, GEMCoPadDigiContainer> superchamber_to_copads_;

GEMDigiSimLinkContainer no_gem_simLinks_;
GEMDigiContainer no_gem_digis_;
GEMPadDigiContainer no_gem_pads_;
GEMPadDigiClusterContainer no_gem_clusters_;
Expand Down
10 changes: 8 additions & 2 deletions Validation/MuonGEMDigis/python/muonGEMDigiPSet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import FWCore.ParameterSet.Config as cms

muonGEMDigiPSet = cms.PSet(
gemSimLink = cms.PSet(
verbose = cms.int32(0),
inputTag = cms.InputTag("simMuonGEMDigis","GEM"),
simMuOnly = cms.bool(True),
discardEleHits = cms.bool(True),
),
gemStripDigi = cms.PSet(
verbose = cms.int32(0),
inputTag = cms.InputTag("simMuonGEMDigis"),
Expand Down Expand Up @@ -30,7 +36,7 @@
gemCoPadDigi = cms.PSet(
verbose = cms.int32(0),
inputTag = cms.InputTag("simCscTriggerPrimitiveDigis"),
minBX = cms.int32(-1),
maxBX = cms.int32(1),
minBX = cms.int32(0),
maxBX = cms.int32(0),
),
)
Loading