Skip to content

Commit

Permalink
Merge pull request cms-sw#9 from kdlong/pepr_candProducer
Browse files Browse the repository at this point in the history
Pepr cand producer
  • Loading branch information
jkiesele authored Sep 30, 2020
2 parents 0116ccc + 6cd8bdc commit cd54bad
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
22 changes: 21 additions & 1 deletion RecoHGCal/GraphReco/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ Once the GSD events are produced, we can run the reconstruction step:
cmsRun RECO_pf.py inputFiles="file://1_GSD.root" outputFile="file:1_RECO.root" outputFileDQM="file:1_DQM.root" maxEvents=5
```
A dedicated **EDProducer module**, the `peprCandidateFromHitProducer` located
in the [RecoHGCAL/GraphReco](https://github.com/gvonsem/cmssw/tree/pepr_CMSSW_11_1_0_pre7_peprCandDev/RecoHGCal/GraphReco) package,
in the [RecoHGCAL/GraphReco](.) package,
produces PF candidates straight from rechit information, in this example via the [Object Condensation](https://arxiv.org/abs/2002.03605) method.

The inference of trained graph neural network models is done by sending the rechit information per endcap to a custom Triton server, evaluating the model,
and retrieving the regressed energy and position of clustered particle candidates.
These candidates are subsequently turned into a PFcandidate collection named `recoPFCandidates_peprCandidateFromHitProducer__RECO`. Particle and charge identification as well as track-cluster matching are work in progress and not included yet.
Expand All @@ -70,4 +71,23 @@ The **sequence** of the producer module is as follows:
* The inference itself is done on the Triton server via the trained model that is stored there, and the results are passed back to the module where a collection of reconstructed particle candidates is created.
* The Triton client is automatically closed in the destructor of the producer

### Adding the peprCandidateFromHitProducer to your favorite RECO config

The `peprCandidateFromHitProducer` can be loaded from the [config fragment](python/peprCandidateFromHitProducer_cfi.py) and added to a RECO sequence in the usual way. Add the following line to your python config

```
process.load("RecoHGCal/GraphReco/python/peprCandidateFromHitProducer_cfi")
```

this adds the producer to the process, you should then schedule it by adding it to a scheduled sequence, for example:

```
process.reconstruction_step += process.peprCandidateFromHitProducer
```

It's not expected that you would need to change arguments from their default values, but
this can be done as for other EDProducer modules, for example

```
process.peprCandidateFromHitProducer.tracks = "globalMuons" # Not a very good idea, but possible
```
7 changes: 4 additions & 3 deletions RecoHGCal/GraphReco/plugins/peprCandidateFromHitProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
Expand Down Expand Up @@ -73,7 +74,7 @@ class peprCandidateFromHitProducer: public edm::stream::EDProducer<> {
std::vector<edm::EDGetTokenT<HGCRecHitCollection> > recHitTokens_;
edm::EDGetTokenT<edm::View<reco::Track>> tracksToken_;

std::string tritonPath_;
std::string tritonScript_;
std::string inpipeName_;
std::string outpipeName_;
std::string containerPIDName_;
Expand All @@ -97,7 +98,7 @@ class peprCandidateFromHitProducer: public edm::stream::EDProducer<> {
peprCandidateFromHitProducer::peprCandidateFromHitProducer(const edm::ParameterSet& config) :
recHitCollections_(config.getParameter<std::vector<edm::InputTag> >("recHitCollections")),
tracksToken_(consumes<edm::View<reco::Track>>(config.getParameter<edm::InputTag>("tracks"))),
tritonPath_(config.getParameter<std::string>("tritonPath")),
tritonScript_(config.getParameter<edm::FileInPath>("tritonScript").fullPath()),
inpipeName_(config.getParameter<std::string>("inpipeName")),
outpipeName_(config.getParameter<std::string>("outpipeName")),
//FIXME: actually these are all not needed if windows are created in the constructor!
Expand Down Expand Up @@ -136,7 +137,7 @@ peprCandidateFromHitProducer::peprCandidateFromHitProducer(const edm::ParameterS
//https://github.com/cms-pepr/HGCalML/tree/master/triton

//within the client script, the container is also started in the background and its process ID is stored for later kill command in destructor
std::string clientcommand = tritonPath_ + "cmssw_oc_forward_client.sh " + inpipeName_ + " " + containerPIDName_ + " &";
std::string clientcommand = tritonScript_ + " " + inpipeName_ + " " + containerPIDName_ + " &";
system(clientcommand.data());
//std::cout << " Forward client command executed" << std::endl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
cms.InputTag("HGCalRecHit", "HGCHEBRecHits"),
),
tracks = cms.InputTag("generalTracks"),
#tritonPath=cms.string("/afs/cern.ch/work/g/gvonsem/public/HGCAL/ML/HGCalML/triton/"),
tritonPath=cms.string("RecoHGCal/GraphReco/test/"),
tritonScript=cms.FileInPath("RecoHGCal/GraphReco/test/cmssw_oc_forward_client.sh"),
inpipeName=cms.string("arrayspipe"),
outpipeName=cms.string("arrayspipe_pred"),
minEta=cms.double(1.6),
Expand Down
6 changes: 1 addition & 5 deletions RecoHGCal/GraphReco/test/RECO_pf.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@


# pepr PF candidate producer
test_dir = os.path.expandvars("$CMSSW_BASE/src/RecoHGCal/GraphReco/test/")
from RecoHGCal.GraphReco.peprCandidateFromHitProducer_cfi import peprCandidateFromHitProducer
process.peprCandidateFromHitProducer = peprCandidateFromHitProducer.clone(
tritonPath=cms.string(test_dir),
)
process.load("RecoHGCal.GraphReco.peprCandidateFromHitProducer_cfi")
process.reconstruction_step += process.peprCandidateFromHitProducer


Expand Down

0 comments on commit cd54bad

Please sign in to comment.