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

Primitive RPC trigger #26967

Merged
merged 11 commits into from
Jul 9, 2019
37 changes: 37 additions & 0 deletions L1Trigger/RPCTriggerPrimitives/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<export>
<lib name="1"/>
</export>

<use name="root"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

@maseguracern @rekovic is this dependency on root really needed here? Where is it used? @smuzaffar FYI


<use name="FWCore/Concurrency"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/Utilities"/>

<use name="DataFormats/Common"/>
<use name="DataFormats/DetId"/>
<use name="DataFormats/MuonDetId"/>
<use name="DataFormats/L1TMuon"/>
<use name="DataFormats/RPCDigi"/>
<use name="DataFormats/RPCRecHit"/>
<use name="DataFormats/DTRecHit"/>
<use name="DataFormats/CSCRecHit"/>
<use name="DataFormats/TrackingRecHit"/>

<use name="CondFormats/RPCObjects"/>
<use name="CondFormats/DataRecord"/>

<use name="L1Trigger/L1TMuon"/>
<use name="L1Trigger/L1TMuonEndCap"/>

<use name="Geometry/RPCGeometry"/>
<use name="Geometry/DTGeometry"/>
<use name="Geometry/CSCGeometry"/>
<use name="Geometry/Records"/>


<use name="TrackingTools/TrackRefitter"/>

61 changes: 61 additions & 0 deletions L1Trigger/RPCTriggerPrimitives/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# RPCTriggerPrimitives

This is the first version of the RPCTriggerPrimitives for the RPC detector. Which uses as an input the RPCDigis as an input and the RPCRecHits (New collection) as an output. The output of this module is an edm branch named RPCPrimitivesDigis, following the RPCRecHit format already committed in CMSSW_10_6_0. We apply the cluster size cut and emulate max two clusters per link board. The module can be tuned by the parameters LinkBoardCut and ClusterSizeCut for phaseII.

# Out of the box instructions

```
ssh -XY username@lxplus7.cern.ch
SCRAM_ARCH=slc7_amd64_gcc700; export SCRAM_ARCH (in .bashrc file)
scram list CMSSW_10_6_0
cmsrel CMSSW_10_6_0
cd CMSSW_10_6_0/src
cmsenv
```

```
You need to do a fork from your githut repository to cmssw-offline repository. The url is:
https://github.com/cms-sw/cmssw
```


```
git cms-init
git cms-addpkg L1Trigger/L1TMuonEndCap
git cms-addpkg CondTools/RPC

cd CondTools/RPC
cp /eos/cms/store/group/dpg_rpc/comm_rpc/Run-II/cppf_payloads/RPCLinkMap.db data
for analyser in test/RPC*LinkMapPopConAnalyzer_cfg.py; do
cmsRun $analyser
done; # <- this produces RPCLinkMap.db sqlite file yourself
cd -

git remote add YourGitHubName git@github.com:YourGitHubName/cmssw.git
git fetch YourGitHubName
git checkout -b PrimitiveTrigger
scram b -j6

```

## Set your environment with my branch

```
git remote add maseguracern git@github.com:maseguracern/cmssw.git
git cms-merge-topic -u maseguracern:PrimitiveTrigger
scram b -j6
```

# Run test producer
```
cd test
cmsRun rpcprimitive_MC.py
```

## Modifying files
```
git add <Modified files>
git commit -m "Commit message"
git push my-cmssw YourBranchName
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef L1Trigger_PrimitiveAlgoFactory_H
#define L1Trigger_PrimitiveAlgoFactory_H

#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "RecoLocalMuon/RPCRecHit/interface/RPCRecHitBaseAlgo.h"

typedef edmplugin::PluginFactory<RPCRecHitBaseAlgo *(const edm::ParameterSet &)> PrimitiveAlgoFactory;

#endif
78 changes: 78 additions & 0 deletions L1Trigger/RPCTriggerPrimitives/interface/PrimitivePreprocess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#ifndef L1Trigger_RPCTriggerPrimitives_PrimitivePreprocess_h
#define L1Trigger_RPCTriggerPrimitives_PrimitivePreprocess_h

#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHit.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/RPCObjects/interface/RPCMaskedStrips.h"
#include "CondFormats/RPCObjects/interface/RPCDeadStrips.h"
#include "CondFormats/DataRecord/interface/RPCMaskedStripsRcd.h"
#include "CondFormats/DataRecord/interface/RPCDeadStripsRcd.h"

#include "Geometry/RPCGeometry/interface/RPCRoll.h"
#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include "RecoLocalMuon/RPCRecHit/interface/RPCRecHitBaseAlgo.h"


#include "L1Trigger/RPCTriggerPrimitives/interface/PrimitiveAlgoFactory.h"
#include "L1Trigger/RPCTriggerPrimitives/interface/RPCProcessor.h"


#include <string>
#include <fstream>
#include <memory>

class PrimitivePreprocess{

public:
explicit PrimitivePreprocess(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iConsumes);

~PrimitivePreprocess();

void beginRun(const edm::EventSetup& );

void Preprocess(const edm::Event& iEvent, const edm::EventSetup& iSetup, RPCRecHitCollection& primitivedigi);


private:

const edm::EDGetTokenT<RPCDigiCollection> rpcToken_;
std::array<RPCProcessor, 1> processorvector_;

edm::FileInPath Mapsource_;
bool ApplyLinkBoardCut_;
int LinkBoardCut_;
int ClusterSizeCut_;

std::vector<RPCProcessor::Map_structure> Final_MapVector;

//masking from rpcrechit module

std::vector<RPCMaskedStrips::MaskItem> MaskVec;
std::vector<RPCDeadStrips::DeadItem> DeadVec;


std::unique_ptr<RPCMaskedStrips> theRPCMaskedStripsObj;
// Object with mask-strips-vector for all the RPC Detectors

std::unique_ptr<RPCDeadStrips> theRPCDeadStripsObj;
// Object with dead-strips-vector for all the RPC Detectors

// The reconstruction algorithm
std::unique_ptr<RPCRecHitBaseAlgo> theAlgorithm;

enum class MaskSource { File, EventSetup } maskSource_, deadSource_;
};
#endif

88 changes: 88 additions & 0 deletions L1Trigger/RPCTriggerPrimitives/interface/RPCProcessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#ifndef L1Trigger_RPCTriggerPrimitives_RPCProcessor_h
#define L1Trigger_RPCTriggerPrimitives_RPCProcessor_h

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHit.h"

#include "DataFormats/RPCRecHit/interface/RPCRecHit.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"

#include "Geometry/RPCGeometry/interface/RPCRoll.h"
#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include "RecoLocalMuon/RPCRecHit/interface/RPCRecHitAlgoFactory.h"

#include "CondFormats/DataRecord/interface/RPCMaskedStripsRcd.h"
#include "CondFormats/DataRecord/interface/RPCDeadStripsRcd.h"
#include "CondFormats/RPCObjects/interface/RPCMaskedStrips.h"
#include "CondFormats/RPCObjects/interface/RPCDeadStrips.h"
#include "CondFormats/Serialization/interface/Serializable.h"


#include <algorithm>
#include <iostream>
#include <fstream>
#include <map>
#include <memory>
#include <string>
#include <sstream>
#include <utility>
#include <vector>
#include <boost/cstdint.hpp>

class RPCProcessor{

public:

explicit RPCProcessor();
~RPCProcessor();

struct Map_structure {

std::string linkboard_;
std::string linkboard_ID;
std::string chamber1_;
std::string chamber2_;
COND_SERIALIZABLE;
};

void Process(const edm::Event& iEvent,
const edm::EventSetup& iSetup,
const edm::EDGetToken& RPCDigiToken,
RPCRecHitCollection& primitivedigi,
std::unique_ptr<RPCMaskedStrips>& theRPCMaskedStripsObj,
std::unique_ptr<RPCDeadStrips>& theRPCDeadStripsObj,
std::unique_ptr<RPCRecHitBaseAlgo>& theAlgo,
std::map<std::string, std::string> LBName_ChamberID_Map_1,
std::map<std::string, std::string> LBID_ChamberID_Map_1,
std::map<std::string, std::string> LBName_ChamberID_Map_2,
std::map<std::string, std::string> LBID_ChamberID_Map_2,
bool ApplyLinkBoardCut_,
int LinkboardCut,
int ClusterSizeCut ) const;

static edm::OwnVector<RPCRecHit> ApplyClusterSizeCut(const edm::OwnVector<RPCRecHit> recHits_, int ClusterSizeCut_);
static bool ApplyLinkBoardCut(int NClusters, int LinkboardCut);

std::vector<Map_structure> const & GetMapVector() const {return MapVec;}
std::vector<Map_structure> MapVec;

std::string GetStringBarrel(const int ring_, const int station_, const int sector_, const int layer_, const int subsector_, const int roll_) const;
std::string GetStringEndCap(const int station_, const int ring_, const int chamberID_) const;


COND_SERIALIZABLE;

private:

};
#endif


5 changes: 5 additions & 0 deletions L1Trigger/RPCTriggerPrimitives/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library file="*.cc" name="L1TriggerRPCTriggerPrimitivesPlugins">
<use name="L1Trigger/RPCTriggerPrimitives"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

this line is causing a warning message:

****WARNING: Invalid tool L1Trigger/RPCTriggerPrimitives. Please fix src/L1Trigger/RPCTriggerPrimitives/plugins/BuildFile.xml file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed...

<flags EDM_PLUGIN="1"/>
</library>

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// RPCTriggerPrimitives producer for RPPRecHits in L1T Level
// Author Alejandro Segura -- Universidad de los Andes

#include "L1TMuonRPCTriggerPrimitivesProducer.h"

L1TMuonRPCTriggerPrimitivesProducer::L1TMuonRPCTriggerPrimitivesProducer(const edm::ParameterSet& iConfig):
preprocess_pointer_(std::make_unique<PrimitivePreprocess>(iConfig, consumesCollector())){

produces<RPCRecHitCollection>();

}

L1TMuonRPCTriggerPrimitivesProducer::~L1TMuonRPCTriggerPrimitivesProducer(){
}

void L1TMuonRPCTriggerPrimitivesProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){

// Create pointers to the collections which will store the new primitive digis
auto Tprimitive_digis = std::make_unique<RPCRecHitCollection>();


preprocess_pointer_->beginRun(iSetup);
preprocess_pointer_->Preprocess(iEvent, iSetup, *Tprimitive_digis);
// Fill the output collections
iEvent.put(std::move(Tprimitive_digis));

}

void L1TMuonRPCTriggerPrimitivesProducer::beginStream(edm::StreamID iID){
}

void L1TMuonRPCTriggerPrimitivesProducer::endStream(){
}

// Define this as a plug-in
DEFINE_FWK_MODULE(L1TMuonRPCTriggerPrimitivesProducer);

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef L1Trigger_RPCTriggerPrimitives_L1TMuonRPCTriggerPrimitivesProducer_h
#define L1Trigger_RPCTriggerPrimitives_L1TMuonRPCTriggerPrimitivesProducer_h

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"

#include "DataFormats/RPCRecHit/interface/RPCRecHit.h"
#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"

#include "TVector3.h"

#include "L1Trigger/RPCTriggerPrimitives/interface/PrimitivePreprocess.h"

// Class declaration

class L1TMuonRPCTriggerPrimitivesProducer : public edm::stream::EDProducer<>{

public:
explicit L1TMuonRPCTriggerPrimitivesProducer(const edm::ParameterSet&);
~L1TMuonRPCTriggerPrimitivesProducer() override;

private:
void beginStream(edm::StreamID) override;
void endStream() override;
void produce(edm::Event& event, const edm::EventSetup& setup) override;

std::unique_ptr<PrimitivePreprocess> preprocess_pointer_;

};

#endif /* #define L1Trigger_RPCTriggerPrimitives_L1TMuonRPCTriggerPrimitivesProducer_h */

19 changes: 19 additions & 0 deletions L1Trigger/RPCTriggerPrimitives/python/primitiveRPCProducer_cfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import FWCore.ParameterSet.Config as cms

primitiveRPCProducer = cms.EDProducer("L1TMuonRPCTriggerPrimitivesProducer",
Primitiverechitlabel = cms.InputTag("rpcdigis"),
Mapsource = cms.string('L1Trigger/L1TMuon/data/rpc/Linkboard_rpc_roll_mapping_lb_chamber2.txt'),
ApplyLinkBoardCut = cms.bool(True),
LinkBoardCut = cms.int32(2), # Number of clusters per linkboard greater than (default >2) are rejected
ClusterSizeCut = cms.int32(3), # Clustersize greater than (default >3) is rejected
maskSource = cms.string('File'),
maskvecfile = cms.FileInPath('RecoLocalMuon/RPCRecHit/data/RPCMaskVec.dat'),
deadSource = cms.string('File'),
deadvecfile = cms.FileInPath('RecoLocalMuon/RPCRecHit/data/RPCDeadVec.dat'),
recAlgoConfig = cms.PSet(),
recAlgo = cms.string('RPCRecHitStandardAlgo')
Copy link
Contributor

Choose a reason for hiding this comment

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

The plugin named RPCRecHitStandardAlgo is not in CMSSW and is causing large number of workflows in the integration builds to fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

It actually does exist, but is associated to a different plugin factory.

)

from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon
phase2_muon.toModify(primitiveRPCProducer, ApplyLinkBoardCut = cms.bool(False))
phase2_muon.toModify(primitiveRPCProducer, ClusterSizeCut = cms.int32(4))
4 changes: 4 additions & 0 deletions L1Trigger/RPCTriggerPrimitives/src/PrimitiveAlgoFactory.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "FWCore/PluginManager/interface/PluginFactory.h"
#include "L1Trigger/RPCTriggerPrimitives/interface/PrimitiveAlgoFactory.h"

EDM_REGISTER_PLUGINFACTORY(PrimitiveAlgoFactory,"PrimitiveAlgoFactory");