Skip to content

Commit

Permalink
Merge pull request #195 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 7, 2014
2 parents 42e4ac7 + 97d381d commit 72c5696
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Geometry/GEMGeometry/test/testGEMGeometry_cfg.py
Expand Up @@ -8,7 +8,7 @@
process.load('FWCore.MessageLogger.MessageLogger_cfi')

from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgrade2019', '')
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS3', '')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(1)
Expand Down
Expand Up @@ -17,6 +17,7 @@
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeometry.h"
Expand Down Expand Up @@ -52,6 +53,15 @@ CSCTriggerPrimitivesProducer::CSCTriggerPrimitivesProducer(const edm::ParameterS

lctBuilder_ = new CSCTriggerPrimitivesBuilder(conf); // pass on the conf

edm::Service<edm::RandomNumberGenerator> rng;
if (!rng.isAvailable()){
throw cms::Exception("Configuration")
<< "GEMDigiProducer::GEMDigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
<< "Add the service in the configuration file or remove the modules that require it.";
}
CLHEP::HepRandomEngine& engine = rng->getEngine();
lctBuilder_->setRandomEngine(engine);

// register what this produces
produces<CSCALCTDigiCollection>();
produces<CSCCLCTDigiCollection>();
Expand Down
Expand Up @@ -24,6 +24,8 @@
#include <FWCore/Framework/interface/Event.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include <FWCore/Utilities/interface/InputTag.h>
#include "CLHEP/Random/RandomEngine.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"

class CSCTriggerPrimitivesBuilder;

Expand Down
Expand Up @@ -18,6 +18,7 @@

# for SLHC studies we don't want bad chambers checks so far
checkBadChambers = cms.bool(False),
fractionBrokenCSCs = cms.double(0.0),

# Parameters common for all boards
commonParam = cms.PSet(
Expand Down
Expand Up @@ -19,6 +19,7 @@

# for SLHC studies we don't want bad chambers checks so far
checkBadChambers = cms.bool(False),
fractionBrokenCSCs = cms.double(0.0),

# Parameters common for all boards
commonParam = cms.PSet(
Expand Down Expand Up @@ -49,7 +50,7 @@
# run integrated local triggers
runME11ILT = cms.bool(True),
runME21ILT = cms.bool(True),
runME3141ILT = cms.bool(False),
runME3141ILT = cms.bool(True),
),

# Parameters for ALCT processors: old MC studies
Expand Down Expand Up @@ -484,11 +485,11 @@

## run in debug mode
debugLUTs = cms.bool(False),
debugMatching = cms.bool(False),
debugMatching = cms.bool(True),

## matching to digis in case LowQ CLCT
maxDeltaBXRPC = cms.int32(1),
maxDeltaStripRPC = cms.int32(1),
maxDeltaBXRPC = cms.int32(0),
maxDeltaStripRPC = cms.int32(3),

## efficiency recovery switches
dropLowQualityCLCTsNoRPCs = cms.bool(True),
Expand Down
14 changes: 6 additions & 8 deletions L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc
Expand Up @@ -100,12 +100,10 @@ CSCMotherboard::CSCMotherboard(unsigned endcap, unsigned station,
conf.getParameter<edm::ParameterSet>("me21tmbSLHCGEM"):edm::ParameterSet());
const edm::ParameterSet me3141tmbRpcParams(conf.existsAs<edm::ParameterSet>("me3141tmbSLHCRPC")?
conf.getParameter<edm::ParameterSet>("me3141tmbSLHCRPC"):edm::ParameterSet());
const bool runME11ILT(me11tmbGemParams.existsAs<bool>("runME11ILT")?
me11tmbGemParams.getParameter<bool>("runME11ILT"):false);
const bool runME21ILT(me21tmbGemParams.existsAs<bool>("runME21ILT")?
me21tmbGemParams.getParameter<bool>("runME21ILT"):false);
const bool runME3141ILT(me3141tmbRpcParams.existsAs<bool>("runME3141ILT")?
me3141tmbRpcParams.getParameter<bool>("runME3141ILT"):false);

const bool runME11ILT(commonParams.existsAs<bool>("runME11ILT")?commonParams.getParameter<bool>("runME11ILT"):false);
const bool runME21ILT(commonParams.existsAs<bool>("runME21ILT")?commonParams.getParameter<bool>("runME21ILT"):false);
const bool runME3141ILT(commonParams.existsAs<bool>("runME3141ILT")?commonParams.getParameter<bool>("runME3141ILT"):false);

// run upgrade TMBs for all MEX/1 stations
if (isSLHC and theRing == 1){
Expand All @@ -118,14 +116,14 @@ CSCMotherboard::CSCMotherboard(unsigned endcap, unsigned station,
}
}
else if (theStation == 2 and runME21ILT) {
tmbParams = me21tmbGemParams;
alctParams = conf.getParameter<edm::ParameterSet>("alctSLHCME21");
clctParams = conf.getParameter<edm::ParameterSet>("clctSLHCME21");
tmbParams = me21tmbGemParams;
}
else if ((theStation == 3 or theStation == 4) and runME3141ILT) {
tmbParams = me3141tmbRpcParams;
alctParams = conf.getParameter<edm::ParameterSet>("alctSLHCME3141");
clctParams = conf.getParameter<edm::ParameterSet>("clctSLHCME3141");
tmbParams = me3141tmbRpcParams;
}
}

Expand Down
34 changes: 18 additions & 16 deletions L1Trigger/CSCTriggerPrimitives/src/CSCMotherboardME3141RPC.cc
Expand Up @@ -145,7 +145,7 @@ CSCMotherboardME3141RPC::run(const CSCWireDigiCollection* wiredc,
alctV = alct->run(wiredc); // run anodeLCT
clctV = clct->run(compdc); // run cathodeLCT

const bool debugStubs(true);
const bool debugStubs(false);
if (debugStubs){
for (auto& p : alctV){
std::cout << "ALCT: " << p << std::endl;
Expand Down Expand Up @@ -173,9 +173,14 @@ CSCMotherboardME3141RPC::run(const CSCWireDigiCollection* wiredc,
const CSCLayerGeometry* keyLayerGeometry(keyLayer->geometry());
const int region((theEndcap == 1) ? 1: -1);
const bool isEven(csc_id%2==0);
const RPCDetId rpc_id(region,1,theStation,CSCTriggerNumbering::triggerSectorFromLabels(csc_id),1,CSCTriggerNumbering::triggerCscIdFromLabels(csc_id),0);
const int csc_trig_sect(CSCTriggerNumbering::triggerSectorFromLabels(csc_id));
const int csc_trig_id( CSCTriggerNumbering::triggerCscIdFromLabels(csc_id));
const int csc_trig_chid((3*(csc_trig_sect-1)+csc_trig_id)%18 +1);
const int rpc_trig_sect((csc_trig_chid-1)/3+1);
const int rpc_trig_subsect((csc_trig_chid-1)%3+1);
const RPCDetId rpc_id(region,1,theStation,rpc_trig_sect,1,rpc_trig_subsect,0);
const RPCChamber* rpcChamber(rpc_g->chamber(rpc_id));

if (runME3141ILT_){

// check for RE3/1-RE4/1 geometry
Expand Down Expand Up @@ -258,8 +263,6 @@ CSCMotherboardME3141RPC::run(const CSCWireDigiCollection* wiredc,
retrieveRPCDigis(rpcDigis, rpc_id.rawId());
}

return;

const bool hasRPCDigis(rpcDigis_.size()!=0);

int used_clct_mask[20];
Expand Down Expand Up @@ -298,24 +301,24 @@ CSCMotherboardME3141RPC::run(const CSCWireDigiCollection* wiredc,
// clct quality
const int quality(clct->bestCLCT[bx_clct].getQuality());
// low quality ALCT
const bool lowQualityALCT(alct->bestALCT[bx_alct].getQuality() == 4);
const bool lowQualityALCT(alct->bestALCT[bx_alct].getQuality() == 0);
// low quality ALCT or CLCT
const bool lowQuality(quality<4 or lowQualityALCT);

if (runME3141ILT_ and dropLowQualityCLCTsNoRPCs_ and lowQuality and hasRPCDigis){
int nFound(matchingDigis.size());
const bool clctInEdge(clct->bestCLCT[bx_clct].getKeyStrip() < 5 or clct->bestCLCT[bx_clct].getKeyStrip() > 155);
if (clctInEdge){
if (debug_rpc_matching_) std::cout << "\tInfo: low quality CLCT in CSC chamber edge, don't care about RPC digis" << std::endl;
if (debug_rpc_matching_) std::cout << "\tInfo: low quality CLCT in CSC chamber edge, don't care about RPC digis" << std::endl;
}
else {
if (nFound != 0){
if (debug_rpc_matching_) std::cout << "\tInfo: low quality CLCT with " << nFound << " matching RPC trigger digis" << std::endl;
}
else {
if (debug_rpc_matching_) std::cout << "\tWarning: low quality CLCT without matching RPC trigger digi" << std::endl;
continue;
}
if (nFound != 0){
if (debug_rpc_matching_) std::cout << "\tInfo: low quality CLCT with " << nFound << " matching RPC trigger digis" << std::endl;
}
else {
if (debug_rpc_matching_) std::cout << "\tWarning: low quality CLCT without matching RPC trigger digi" << std::endl;
continue;
}
}
}

Expand Down Expand Up @@ -461,7 +464,6 @@ void CSCMotherboardME3141RPC::retrieveRPCDigis(const RPCDigiCollection* rpcDigis
RPCDetId roll_id(roll->id());
auto digis_in_det = rpcDigis->get(roll_id);
for (auto digi = digis_in_det.first; digi != digis_in_det.second; ++digi) {
std::cout << roll_id << " " << &(*digi) << std::endl;
auto id_digi = std::make_pair(roll_id(), &(*digi));
const int bx_shifted(lct_central_bx + digi->bx());
for (int bx = bx_shifted - maxDeltaBXRPC_;bx <= bx_shifted + maxDeltaBXRPC_; ++bx) {
Expand All @@ -486,7 +488,7 @@ void CSCMotherboardME3141RPC::printRPCTriggerDigis(int bx_start, int bx_stop)
if (rpcDigis_.size()!=0){
for (auto digi : in_strips){
auto roll_id(RPCDetId(digi.first));
std::cout << "\tdetId " << digi.first << " " << roll_id << ", digi = " << digi.second->strip() << ", BX = " << digi.second->bx() + 6;
std::cout << "\tdetId " << digi.first << " " << roll_id << ", digi = " << digi.second->strip() << ", BX = " << digi.second->bx() + 6 << std::endl;
}
}
else
Expand Down
18 changes: 16 additions & 2 deletions L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.cc
Expand Up @@ -28,6 +28,7 @@
#include <DataFormats/MuonDetId/interface/CSCDetId.h>
#include <Geometry/GEMGeometry/interface/GEMGeometry.h>
#include <Geometry/RPCGeometry/interface/RPCGeometry.h>
#include "CLHEP/Random/RandFlat.h"

//------------------
// Static variables
Expand Down Expand Up @@ -57,6 +58,7 @@ CSCTriggerPrimitivesBuilder::CSCTriggerPrimitivesBuilder(const edm::ParameterSet
disableME42 = commonParams.getParameter<bool>("disableME42");

checkBadChambers_ = conf.getParameter<bool>("checkBadChambers");
fractionBrokenCSCs_ = conf.getParameter<double>("fractionBrokenCSCs");

runME11ILT_ = commonParams.existsAs<bool>("runME11ILT")?commonParams.getParameter<bool>("runME11ILT"):false;
runME21ILT_ = commonParams.existsAs<bool>("runME21ILT")?commonParams.getParameter<bool>("runME21ILT"):false;
Expand Down Expand Up @@ -96,7 +98,7 @@ CSCTriggerPrimitivesBuilder::CSCTriggerPrimitivesBuilder(const edm::ParameterSet
tmb_[endc-1][stat-1][sect-1][subs-1][cham-1] = new CSCMotherboardME11GEM(endc, stat, sect, subs, cham, conf);
else if (stat==2 && ring==1 && runME21ILT_)
tmb_[endc-1][stat-1][sect-1][subs-1][cham-1] = new CSCMotherboardME21GEM(endc, stat, sect, subs, cham, conf);
else if ((stat==3 || stat==4) && ring==1 && runME3141ILT_)
else if ((stat==3 || stat==4) && ring==1 && runME3141ILT_ and endc==2)
tmb_[endc-1][stat-1][sect-1][subs-1][cham-1] = new CSCMotherboardME3141RPC(endc, stat, sect, subs, cham, conf);
else
tmb_[endc-1][stat-1][sect-1][subs-1][cham-1] = new CSCMotherboard(endc, stat, sect, subs, cham, conf);
Expand Down Expand Up @@ -227,6 +229,12 @@ void CSCTriggerPrimitivesBuilder::build(const CSCBadChambers* badChambers,
// also, there's no ME1/a-1/b separation, it's whole ME1/1)
if (checkBadChambers_ && badChambers->isInBadChamber(detid)) continue;

// randomly disable X% of CSC chambers
if (flat_->fire(1) < fractionBrokenCSCs_) {
edm::LogInfo("L1CSCTrigger") << "Skipping bad chamber: " << detid << std::endl;
continue;
}

// running upgraded ME1/1 TMBs
if (stat==1 && ring==1 && smartME1aME1b && !runME11ILT_)
{
Expand Down Expand Up @@ -530,7 +538,7 @@ void CSCTriggerPrimitivesBuilder::build(const CSCBadChambers* badChambers,
}

// running upgraded ME3/1-ME4/1 TMBs
else if ((stat==3 or stat==4) && ring==1 && runME3141ILT_)
else if ((stat==3 or stat==4) && ring==1 && runME3141ILT_ and endc==2)
{
CSCMotherboardME3141RPC* tmb3141RPC = static_cast<CSCMotherboardME3141RPC*>(tmb);
tmb3141RPC->setCSCGeometry(csc_g);
Expand Down Expand Up @@ -682,3 +690,9 @@ void CSCTriggerPrimitivesBuilder::build(const CSCBadChambers* badChambers,
<< " trig id. " << itr->cscid() << ")" << "\n";
}
}


void CSCTriggerPrimitivesBuilder::setRandomEngine(CLHEP::HepRandomEngine& eng)
{
flat_ = new CLHEP::RandFlat(eng);
}
17 changes: 17 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.h
Expand Up @@ -24,6 +24,7 @@
#include "DataFormats/GEMDigi/interface/GEMCSCCoPadDigiCollection.h"
#include <DataFormats/RPCDigi/interface/RPCDigiCollection.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include "CLHEP/Random/RandomEngine.h"

class CSCDBL1TPParameters;
class CSCMotherboard;
Expand All @@ -32,6 +33,13 @@ class CSCGeometry;
class GEMGeometry;
class RPCGeometry;

namespace CLHEP
{
class HepRandomEngine;
class RandFlat;
}


class CSCTriggerPrimitivesBuilder
{
public:
Expand All @@ -52,6 +60,9 @@ class CSCTriggerPrimitivesBuilder
void setGEMGeometry(const GEMGeometry *g) { gem_g = g; }
void setRPCGeometry(const RPCGeometry *g) { rpc_g = g; }

/// random engine to disable X% of chambers
void setRandomEngine(CLHEP::HepRandomEngine&);

/** Build anode, cathode, and correlated LCTs in each chamber and fill
* them into output collections. Select up to three best correlated LCTs
* in each (sub)sector and put them into an output collection as well. */
Expand Down Expand Up @@ -89,6 +100,10 @@ class CSCTriggerPrimitivesBuilder
/// a flag whether to skip chambers from the bad chambers map
bool checkBadChambers_;

/** SLHC: randomly disable X% of CSC chambers */
double fractionBrokenCSCs_;


/** SLHC: special configuration parameters for ME11 treatment. */
bool smartME1aME1b, disableME1a;

Expand Down Expand Up @@ -116,6 +131,8 @@ class CSCTriggerPrimitivesBuilder
const CSCGeometry* csc_g;
const GEMGeometry* gem_g;
const RPCGeometry* rpc_g;

CLHEP::RandFlat* flat_;
};

#endif
7 changes: 6 additions & 1 deletion SLHCUpgradeSimulations/Configuration/python/gemCustoms.py
Expand Up @@ -46,6 +46,11 @@ def customise_L1Emulator2019(process, ptdphi):
process.simCscTriggerPrimitiveDigis.clctSLHC.clctNplanesHitPattern = 3
process.simCscTriggerPrimitiveDigis.clctSLHC.clctPidThreshPretrig = 2
process.simCscTriggerPrimitiveDigis.clctParam07.clctPidThreshPretrig = 2
## give a random number generator
process.RandomNumberGeneratorService.simCscTriggerPrimitiveDigis = cms.PSet(
initialSeed = cms.untracked.uint32(1234567),
engineName = cms.untracked.string('HepJamesRandom')
)
return process

def customise_L1Emulator2023(process, ptdphi):
Expand All @@ -59,9 +64,9 @@ def customise_L1Emulator2023(process, ptdphi):
process.simCscTriggerPrimitiveDigis.alctSLHCME21 = process.simCscTriggerPrimitiveDigis.alctSLHC.clone()
process.simCscTriggerPrimitiveDigis.clctSLHCME21 = process.simCscTriggerPrimitiveDigis.clctSLHC.clone()
process.simCscTriggerPrimitiveDigis.alctSLHCME21.alctNplanesHitPattern = 3
process.simCscTriggerPrimitiveDigis.alctSLHCME21.runME21ILT = cms.bool(True)
process.simCscTriggerPrimitiveDigis.clctSLHCME21.clctNplanesHitPattern = 3
process.simCscTriggerPrimitiveDigis.clctSLHCME21.clctPidThreshPretrig = 2
process.simCscTriggerPrimitiveDigis.clctSLHCME21.runME21ILT = cms.bool(True)
return process

def customise_DigiToRaw(process):
Expand Down
2 changes: 1 addition & 1 deletion SLHCUpgradeSimulations/Configuration/python/rpcCustoms.py
Expand Up @@ -27,9 +27,9 @@ def customise_L1Emulator(process):
process.simCscTriggerPrimitiveDigis.alctSLHCME3141 = process.simCscTriggerPrimitiveDigis.alctSLHC.clone()
process.simCscTriggerPrimitiveDigis.clctSLHCME3141 = process.simCscTriggerPrimitiveDigis.clctSLHC.clone()
process.simCscTriggerPrimitiveDigis.alctSLHCME3141.alctNplanesHitPattern = 3
process.simCscTriggerPrimitiveDigis.alctSLHCME3141.runME3141ILT = cms.bool(True)
process.simCscTriggerPrimitiveDigis.clctSLHCME3141.clctNplanesHitPattern = 3
process.simCscTriggerPrimitiveDigis.clctSLHCME3141.clctPidThreshPretrig = 2
process.simCscTriggerPrimitiveDigis.clctSLHCME21.runME3141ILT = cms.bool(True)
return process

def customise_DigiToRaw(process):
Expand Down

0 comments on commit 72c5696

Please sign in to comment.