Skip to content

Commit

Permalink
Code checks and format
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimeleonh committed Mar 8, 2022
1 parent 0de6e94 commit cb3e65f
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 170 deletions.
31 changes: 15 additions & 16 deletions L1Trigger/DTTriggerPhase2/interface/MPCleanHitsFilter.h
Expand Up @@ -15,35 +15,34 @@
// ===============================================================================

class MPCleanHitsFilter : public MPFilter {
public:
public:
// Constructors and destructor
MPCleanHitsFilter(const edm::ParameterSet& pset);
~MPCleanHitsFilter() override;

// Main methods
void initialise(const edm::EventSetup& iEventSetup) override {};
void run(edm::Event &iEvent,
const edm::EventSetup &iEventSetup,
std::vector<cmsdt::metaPrimitive> &inMPath,
std::vector<cmsdt::metaPrimitive> &outMPath) override {};
void initialise(const edm::EventSetup& iEventSetup) override{};
void run(edm::Event& iEvent,
const edm::EventSetup& iEventSetup,
std::vector<cmsdt::metaPrimitive>& inMPath,
std::vector<cmsdt::metaPrimitive>& outMPath) override{};

void run(edm::Event& iEvent,
const edm::EventSetup& iEventSetup,
MuonPathPtrs& inMPath,
MuonPathPtrs& outMPath) override;
const edm::EventSetup& iEventSetup,
MuonPathPtrs& inMPath,
MuonPathPtrs& outMPath) override;

void finish() override {};
void finish() override{};

// Other public methods
void removeOutliers(MuonPathPtr &mpath);

double getMeanTime(MuonPathPtr &mpath);
void removeOutliers(MuonPathPtr& mpath);

void setTimeTolerance(int time) { timeTolerance_ = time; }
int getTimeTolerance() { return timeTolerance_; }
double getMeanTime(MuonPathPtr& mpath);

void setTimeTolerance(int time) { timeTolerance_ = time; }
int getTimeTolerance() { return timeTolerance_; }

private:
private:
// Private attributes
bool debug_;
int timeTolerance_;
Expand Down
10 changes: 6 additions & 4 deletions L1Trigger/DTTriggerPhase2/interface/MuonPathAnalyzerInChamber.h
Expand Up @@ -7,8 +7,7 @@
// Previous definitions and declarations
// ===============================================================================
namespace {
constexpr int NLayers = 8;
typedef std::array<cmsdt::LATERAL_CASES, NLayers> TLateralities;
typedef std::array<cmsdt::LATERAL_CASES, cmsdt::NUM_LAYERS_2SL> TLateralities;
} // namespace
// ===============================================================================
// Class declarations
Expand Down Expand Up @@ -65,7 +64,10 @@ class MuonPathAnalyzerInChamber : public MuonPathAnalyzer {
void buildLateralities(MuonPathPtr &mpath);
void setLateralitiesInMP(MuonPathPtr &mpath, TLateralities lat);
void setWirePosAndTimeInMP(MuonPathPtr &mpath);
void calculateFitParameters(MuonPathPtr &mpath, TLateralities lat, int present_layer[NLayers], int &lat_added);
void calculateFitParameters(MuonPathPtr &mpath,
TLateralities lat,
int present_layer[cmsdt::NUM_LAYERS_2SL],
int &lat_added);

void evaluateQuality(MuonPathPtr &mPath);
int totalNumValLateralities_;
Expand All @@ -79,7 +81,7 @@ class MuonPathAnalyzerInChamber : public MuonPathAnalyzer {
cmsdt::MP_QUALITY minQuality_;
float chiSquareThreshold_;
short minHits4Fit_;
int cellLayout_[NLayers];
int cellLayout_[cmsdt::NUM_LAYERS_2SL];
bool splitPathPerSL_;

// global coordinates
Expand Down
23 changes: 10 additions & 13 deletions L1Trigger/DTTriggerPhase2/plugins/DTTrigPhase2Prod.cc
Expand Up @@ -131,7 +131,6 @@ class DTTrigPhase2Prod : public edm::stream::EDProducer<> {
edm::EDGetTokenT<DTDigiCollection> dtDigisToken_;
edm::EDGetTokenT<RPCRecHitCollection> rpcRecHitsLabel_;


// Grouping attributes and methods
int algo_; // Grouping code
std::unique_ptr<MotherGrouping> grouping_obj_;
Expand Down Expand Up @@ -171,7 +170,7 @@ namespace {
} // namespace

DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset)
: qmap_({{8, 8}, {7, 7}, {6, 6}, {4, 4}, {3, 3}, {2, 2}, {1, 1}}) {
: qmap_({{8, 8}, {7, 7}, {6, 6}, {4, 4}, {3, 3}, {2, 2}, {1, 1}}) {
produces<L1Phase2MuDTPhContainer>();
produces<L1Phase2MuDTThContainer>();
produces<L1Phase2MuDTExtPhContainer>();
Expand All @@ -195,8 +194,8 @@ DTTrigPhase2Prod::DTTrigPhase2Prod(const ParameterSet& pset)
algo_ = pset.getParameter<int>("algo");

// Local to global coordinates approach
// geometry_tag_ =
// dtGeomToken_ = consumes<>(pset.getUntrackedParameter<std::string>("geometry_tag", ""));
// geometry_tag_ =
// dtGeomToken_ = consumes<>(pset.getUntrackedParameter<std::string>("geometry_tag", ""));

edm::ConsumesCollector consumesColl(consumesCollector());
globalcoordsobtainer_ = std::make_shared<GlobalCoordsObtainer>(pset);
Expand Down Expand Up @@ -248,16 +247,15 @@ void DTTrigPhase2Prod::beginRun(edm::Run const& iRun, const edm::EventSetup& iEv
if (debug_)
LogDebug("DTTrigPhase2Prod") << "beginRun: getting DT geometry";

grouping_obj_->initialise(iEventSetup); // Grouping object initialisation
mpathanalyzer_->initialise(iEventSetup); // Analyzer object initialisation
mpathqualityenhancer_->initialise(iEventSetup); // Filter object initialisation
mpathredundantfilter_->initialise(iEventSetup); // Filter object initialisation
grouping_obj_->initialise(iEventSetup); // Grouping object initialisation
mpathanalyzer_->initialise(iEventSetup); // Analyzer object initialisation
mpathqualityenhancer_->initialise(iEventSetup); // Filter object initialisation
mpathredundantfilter_->initialise(iEventSetup); // Filter object initialisation
mpathqualityenhancerbayes_->initialise(iEventSetup); // Filter object initialisation
mpathhitsfilter_->initialise(iEventSetup);
mpathassociator_->initialise(iEventSetup); // Associator object initialisation
mpathassociator_->initialise(iEventSetup); // Associator object initialisation


if (auto geom = iEventSetup.getHandle(dtGeomH)){
if (auto geom = iEventSetup.getHandle(dtGeomH)) {
dtGeo_ = &(*geom);
}
}
Expand Down Expand Up @@ -362,8 +360,7 @@ void DTTrigPhase2Prod::produce(Event& iEvent, const EventSetup& iEventSetup) {
MuonPathPtrs filteredmuonpaths;
if (algo_ == Standard) {
mpathredundantfilter_->run(iEvent, iEventSetup, muonpaths, filteredmuonpaths);
}
else {
} else {
mpathhitsfilter_->run(iEvent, iEventSetup, muonpaths, filteredmuonpaths);
}

Expand Down
56 changes: 27 additions & 29 deletions L1Trigger/DTTriggerPhase2/src/MPCleanHitsFilter.cc
Expand Up @@ -6,53 +6,51 @@ using namespace std;
// ============================================================================
// Constructors and destructor
// ============================================================================
MPCleanHitsFilter::MPCleanHitsFilter(const ParameterSet& pset) : MPFilter(pset) {
MPCleanHitsFilter::MPCleanHitsFilter(const ParameterSet &pset) : MPFilter(pset) {
// Obtention of parameters
debug_ = pset.getUntrackedParameter<bool>("debug");

timeTolerance_ = pset.exists("timeTolerance") ? pset.getParameter<int>("timeTolerance") : 999999;
// probably something close to the max time drift (400ns/2) is a reasonable value
// probably something close to the max time drift (400ns/2) is a reasonable value
}
void MPCleanHitsFilter::run(edm::Event &iEvent,
const edm::EventSetup &iEventSetup,
MuonPathPtrs &inMPaths,
MuonPathPtrs &outMPaths) {

const edm::EventSetup &iEventSetup,
MuonPathPtrs &inMPaths,
MuonPathPtrs &outMPaths) {
int counter = 0;
for (const auto& mpath : inMPaths) {
for (const auto &mpath : inMPaths) {
++counter;
auto mpAux = std::make_shared<MuonPath>(*mpath);
removeOutliers(mpAux); // remove hits that are more than 1 bX from the meantime.
auto mpAux = std::make_shared<MuonPath>(*mpath);
removeOutliers(mpAux); // remove hits that are more than 1 bX from the meantime.

outMPaths.emplace_back(mpAux);
}
outMPaths.emplace_back(mpAux);
}
}

void MPCleanHitsFilter::removeOutliers(MuonPathPtr &mpath){

void MPCleanHitsFilter::removeOutliers(MuonPathPtr &mpath) {
int MeanTime = getMeanTime(mpath);
for (int i=0; i<mpath->nprimitives(); i++){
if (!mpath->primitive(i)->isValidTime()) continue;
for (int i = 0; i < mpath->nprimitives(); i++) {
if (!mpath->primitive(i)->isValidTime())
continue;
if (std::abs(mpath->primitive(i)->tdcTimeStamp() - MeanTime) > timeTolerance_) {
mpath->primitive(i)->setTDCTimeStamp(-1); //invalidate hit
mpath->primitive(i)->setChannelId(-1); //invalidate hit
mpath->primitive(i)->setTDCTimeStamp(-1); //invalidate hit
mpath->primitive(i)->setChannelId(-1); //invalidate hit
}
}

}

double MPCleanHitsFilter::getMeanTime(MuonPathPtr &mpath){

float meantime = 0.;
float count = 0.;
for (int i=0; i<mpath->nprimitives(); i++){
if ( mpath->primitive(i) == nullptr ) continue;
if (!mpath->primitive(i)->isValidTime()) continue;
meantime += mpath->primitive(i)->tdcTimeStamp();
count++;
double MPCleanHitsFilter::getMeanTime(MuonPathPtr &mpath) {
float meantime = 0.;
float count = 0.;
for (int i = 0; i < mpath->nprimitives(); i++) {
if (mpath->primitive(i) == nullptr)
continue;
if (!mpath->primitive(i)->isValidTime())
continue;
meantime += mpath->primitive(i)->tdcTimeStamp();
count++;
}
return meantime/count;

return meantime / count;
}

MPCleanHitsFilter::~MPCleanHitsFilter() {}

0 comments on commit cb3e65f

Please sign in to comment.