Skip to content

Commit

Permalink
Merge pull request #192 from gem-sw/CSC-Trigger-Upgrade-GEM-RPC-forSL…
Browse files Browse the repository at this point in the history
…HC13_patch2

Csc trigger upgrade gem rpc for slhc13 patch2
  • Loading branch information
jshlee committed May 6, 2014
2 parents ba45973 + b2b854b commit 30c24e7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 22 deletions.
1 change: 1 addition & 0 deletions L1Trigger/CSCTriggerPrimitives/BuildFile.xml
Expand Up @@ -10,6 +10,7 @@
<use name="L1Trigger/CSCCommonTrigger"/>
<use name="Geometry/GEMGeometry"/>
<use name="Geometry/RPCGeometry"/>
<use name="boost"/>
<export>
<lib name="1"/>
</export>
Expand Up @@ -530,6 +530,7 @@
correctLCTtimingWithGEM = cms.bool(False),
promoteALCTGEMpattern = cms.bool(True),
promoteALCTGEMquality = cms.bool(True),
promoteCLCTGEMquality = cms.bool(True),

## rate reduction
doGemMatching = cms.bool(True),
Expand Down
100 changes: 80 additions & 20 deletions L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME21GEM.cc
Expand Up @@ -6,6 +6,7 @@
#include <Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h>
#include <DataFormats/Math/interface/deltaPhi.h>
#include <iomanip>
#include "boost/container/flat_set.hpp"

const double CSCMotherboardME21GEM::lut_wg_eta_odd[112][2] = {
{ 0,2.441},{ 1,2.435},{ 2,2.425},{ 3,2.414},{ 4,2.404},{ 5,2.394},{ 6,2.384},{ 7,2.374},
Expand Down Expand Up @@ -151,6 +152,7 @@ CSCMotherboardME21GEM::CSCMotherboardME21GEM(unsigned endcap, unsigned station,

// promote ALCT-GEM quality
promoteALCTGEMquality_ = me21tmbParams.getParameter<bool>("promoteALCTGEMquality");
promoteCLCTGEMquality_ = me21tmbParams.getParameter<bool>("promoteCLCTGEMquality");
}

CSCMotherboardME21GEM::~CSCMotherboardME21GEM()
Expand Down Expand Up @@ -459,9 +461,57 @@ CSCMotherboardME21GEM::run(const CSCWireDigiCollection* wiredc,
<< "; match window: [" << bx_clct_start << "; " << bx_clct_stop << "]" << std::endl;
}
}
// at this point we have invalid ALCTs --> try GEM pad matching
else{
auto coPads(coPadsLong_[bx_alct]);
if (runME21ILT_ and coPads.size() and buildLCTfromCLCTandGEM_) {
const int bx_clct_start(bx_alct - match_trig_window_size/2);
const int bx_clct_stop(bx_alct + match_trig_window_size/2);

if (debug_gem_matching){
std::cout << "========================================================================" << std::endl;
std::cout << "GEM-CLCT matching in ME2/1 chamber: " << cscChamber->id() << " in bx range: [" << bx_clct_start << "," << bx_clct_stop << "]" << std::endl;
std::cout << "------------------------------------------------------------------------" << std::endl;
}
// GEM-to-CLCT
int nSuccesFulMatches = 0;
for (int bx_clct = bx_clct_start; bx_clct <= bx_clct_stop; bx_clct++)
{
if (bx_clct < 0 or bx_clct >= CSCCathodeLCTProcessor::MAX_CLCT_BINS) continue;
if (drop_used_clcts and used_clct_mask[bx_clct]) continue;
if (clct->bestCLCT[bx_clct].isValid())
{
const int quality(clct->bestCLCT[bx_clct].getQuality());
// only use high-Q stubs for the time being
if (quality < 4) continue;

++nSuccesFulMatches;

int mbx = bx_clct-bx_clct_start;

correlateLCTsGEM(clct->bestCLCT[bx_clct], clct->secondCLCT[bx_clct], *(coPads[0].second), GEMDetId(coPads[0].first).roll(),
allLCTs[bx_alct][mbx][0], allLCTs[bx_alct][mbx][1]);
if (debug_gem_matching) {
// if (infoV > 1) LogTrace("CSCMotherboard")
std::cout << "Successful GEM-CLCT match in ME21: bx_alct = " << bx_alct
<< "; match window: [" << bx_clct_start << "; " << bx_clct_stop
<< "]; bx_clct = " << bx_clct << std::endl;
std::cout << "+++ Best CLCT Details: ";
clct->bestCLCT[bx_clct].print();
std::cout << "+++ Second CLCT Details: ";
clct->secondCLCT[bx_clct].print();
}
if (allLCTs[bx_alct][mbx][0].isValid()) {
used_clct_mask[bx_clct] += 1;
if (match_earliest_clct_me21_only) break;
}
}
}
}
}
}

// possibly use some discrimination from GEMs
// Possibly use some discrimination from GEMs
if (gemGeometryAvailable and runME21ILT_ and do_gem_matching) matchGEMPads();

// reduction of nLCTs per each BX
Expand Down Expand Up @@ -651,10 +701,10 @@ void CSCMotherboardME21GEM::correlateLCTsGEM(CSCALCTDigi bestALCT,


void CSCMotherboardME21GEM::correlateLCTsGEM(CSCCLCTDigi bestCLCT,
CSCCLCTDigi secondCLCT,
GEMCSCPadDigi gemPad,
CSCCorrelatedLCTDigi& lct1,
CSCCorrelatedLCTDigi& lct2)
CSCCLCTDigi secondCLCT,
GEMCSCPadDigi gemPad, int roll,
CSCCorrelatedLCTDigi& lct1,
CSCCorrelatedLCTDigi& lct2)
{
bool cathodeBestValid = bestCLCT.isValid();
bool cathodeSecondValid = secondCLCT.isValid();
Expand All @@ -665,14 +715,14 @@ void CSCMotherboardME21GEM::correlateLCTsGEM(CSCCLCTDigi bestCLCT,
if ((clct_trig_enable and bestCLCT.isValid()) or
(match_trig_enable and bestCLCT.isValid()))
{
lct1 = constructLCTsGEM(bestCLCT, gemPad, useOldLCTDataFormatALCTGEM_);
lct1 = constructLCTsGEM(bestCLCT, gemPad, roll, useOldLCTDataFormatALCTGEM_);
lct1.setTrknmb(1);
}

if ((clct_trig_enable and secondCLCT.isValid()) or
(match_trig_enable and secondCLCT.isValid() and secondCLCT != bestCLCT))
{
lct2 = constructLCTsGEM(secondCLCT, gemPad, useOldLCTDataFormatALCTGEM_);
lct2 = constructLCTsGEM(secondCLCT, gemPad, roll, useOldLCTDataFormatALCTGEM_);
lct2.setTrknmb(2);
}
}
Expand Down Expand Up @@ -724,25 +774,24 @@ CSCCorrelatedLCTDigi CSCMotherboardME21GEM::constructLCTsGEM(const CSCALCTDigi&
}

CSCCorrelatedLCTDigi CSCMotherboardME21GEM::constructLCTsGEM(const CSCCLCTDigi& clct,
const GEMCSCPadDigi& gem,
const GEMCSCPadDigi& gem, int roll,
bool oldDataFormat)
{
// auto mymap(ME==ME1A ? gemPadToCscHsME1a_ : gemPadToCscHsME1b_);
if (oldDataFormat){
// CLCT pattern number - no pattern
unsigned int pattern = 0; //encodePatternGEM(clct.getPattern(), clct.getStripType());
// CLCT pattern number - for the time being, do not include GEMs in the pattern
unsigned int pattern = encodePattern(clct.getPattern(), clct.getStripType());

// LCT quality number - dummy quality
unsigned int quality = 5;//findQualityGEM(alct, gem);
unsigned int quality = promoteCLCTGEMquality_ ? 14 : 11;

// Bunch crossing: get it from cathode LCT if anode LCT is not there.
int bx = gem.bx() + lct_central_bx;;
// Bunch crossing: pick GEM bx
int bx = gem.bx() + lct_central_bx;

// pick a random WG
int wg();
// pick a random WG in the roll range
int wg(getRandomWGForGEMRoll(roll));

// construct correlated LCT; temporarily assign track number of 0.
return CSCCorrelatedLCTDigi(0, 1, quality, 0, 0, pattern, 0, bx, 0, 0, 0, theTrigChamber);
return CSCCorrelatedLCTDigi(0, 1, quality, wg, clct.getKeyStrip(), pattern, clct.getBend(), bx, 0, 0, 0, theTrigChamber);
}
else {
// CLCT pattern number - no pattern
Expand All @@ -755,10 +804,10 @@ CSCCorrelatedLCTDigi CSCMotherboardME21GEM::constructLCTsGEM(const CSCCLCTDigi&
int bx = gem.bx() + lct_central_bx;;

// ALCT WG
int wg();
int wg(0);

// construct correlated LCT; temporarily assign track number of 0.
return CSCCorrelatedLCTDigi(0, 1, quality, 0, 0, pattern, 0, bx, 0, 0, 0, theTrigChamber);
return CSCCorrelatedLCTDigi(0, 1, quality, wg, 0, pattern, 0, bx, 0, 0, 0, theTrigChamber);
}
}

Expand Down Expand Up @@ -1276,3 +1325,14 @@ std::vector<GEMCSCCoPadDigi> CSCMotherboardME21GEM::readoutCoPads()
{
return gemCoPadV;
}


int CSCMotherboardME21GEM::getRandomWGForGEMRoll(int roll)
{
boost::container::flat_set<int> wgs;
for (auto p: cscWgToGemRollLong_)
if (p.first == roll)
wgs.insert(p.first);
// return a random one
return *(wgs.begin() + rand() % wgs.size());
}
6 changes: 4 additions & 2 deletions L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME21GEM.h
Expand Up @@ -57,6 +57,7 @@ class CSCMotherboardME21GEM : public CSCMotherboard
int assignGEMRoll(double eta);
int deltaRoll(int wg, int roll);
int deltaPad(int hs, int pad);
int getRandomWGForGEMRoll(int roll);

void printGEMTriggerPads(int minBX, int maxBx, bool isShort, bool iscopad = false);

Expand All @@ -82,7 +83,7 @@ class CSCMotherboardME21GEM : public CSCMotherboard
CSCCorrelatedLCTDigi& lct1, CSCCorrelatedLCTDigi& lct2);

void correlateLCTsGEM(CSCCLCTDigi bestCLCT, CSCCLCTDigi secondCLCT,
GEMCSCPadDigi gemPad,
GEMCSCPadDigi gemPad, int roll,
CSCCorrelatedLCTDigi& lct1, CSCCorrelatedLCTDigi& lct2);

void correlateLCTsGEM(CSCALCTDigi bestALCT, CSCALCTDigi secondALCT,
Expand All @@ -92,7 +93,7 @@ class CSCMotherboardME21GEM : public CSCMotherboard

CSCCorrelatedLCTDigi constructLCTsGEM(const CSCALCTDigi& alct, const GEMCSCPadDigi& gem,
bool oldDataFormat = false);
CSCCorrelatedLCTDigi constructLCTsGEM(const CSCCLCTDigi& clct, const GEMCSCPadDigi& gem,
CSCCorrelatedLCTDigi constructLCTsGEM(const CSCCLCTDigi& clct, const GEMCSCPadDigi& gem, int roll,
bool oldDataFormat = true);
CSCCorrelatedLCTDigi constructLCTsGEM(const CSCALCTDigi& alct, const CSCCLCTDigi& clct,
bool hasPad, bool hasCoPad);
Expand Down Expand Up @@ -196,6 +197,7 @@ class CSCMotherboardME21GEM : public CSCMotherboard

// promote ALCT-GEM quality
bool promoteALCTGEMquality_;
bool promoteCLCTGEMquality_;

std::map<int,std::pair<double,double> > gemRollToEtaLimitsShort_;
std::map<int,std::pair<double,double> > gemRollToEtaLimitsLong_;
Expand Down

0 comments on commit 30c24e7

Please sign in to comment.