forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 2
Add Hcal reco producer with FACILE algorithm #1
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
Open
jeffkrupa
wants to merge
20
commits into
fastmachinelearning:master
Choose a base branch
from
jeffkrupa:hcalreco-facile
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f74748e
first FACILE commit
ec5a06c
second FACILE commit
959b7dd
output debug
cbd1cd7
outputs working
0a2f08d
outputs working
ce16d3e
cleanup 1
430893d
cleanup 1
eb114c2
sonic hlt config
2934857
sonic hlt config
363aeab
sonic hlt config
93c3b69
sonic hlt config
9edea12
sonic hlt config
34ef691
cleanup
bf01cb1
cleanup header
4e974f7
cleanup BuildFile
b789f7e
code review changes
33d6a5b
esConsumes
ace95e2
remove cout
81910ec
small fix
b2e10d3
use ietaAbs() in HcalDetId
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
| import os,sys | ||
|
|
||
| sys.path = sys.path + [os.path.expandvars("$CMSSW_BASE/src/HLTrigger/Configuration/test/"), os.path.expandvars("$CMSSW_RELEASE_BASE/src/HLTrigger/Configuration/test/")] | ||
|
|
||
| from OnLine_HLT_GRun import process | ||
|
|
||
| process.hltHbherecopre = process.hltHbhereco.clone( | ||
| makeRecHits = cms.bool(False), | ||
| saveInfos = cms.bool(True), | ||
| ) | ||
|
|
||
| process.hltHbhereco = cms.EDProducer("HcalReconstructor", | ||
| Client = cms.PSet( | ||
| batchSize = cms.untracked.uint32(16000), | ||
| address = cms.untracked.string("ailab01.fnal.gov"), | ||
| port = cms.untracked.uint32(8001), | ||
| timeout = cms.untracked.uint32(300), | ||
| modelName = cms.string("facile_all_v2"), | ||
| mode = cms.string("Async"), | ||
| modelVersion = cms.int32(-1), | ||
| verbose = cms.untracked.bool(False), | ||
| allowedTries = cms.untracked.uint32(5), | ||
| outputs = cms.untracked.vstring("output/BiasAdd"), | ||
| ), | ||
| ChannelInfoName = cms.InputTag("hltHbherecopre") | ||
| ) | ||
|
|
||
| process.HLTDoLocalHcalSequence = cms.Sequence( process.hltHcalDigis + process.hltHbherecopre + process.hltHbhereco + process.hltHfprereco + process.hltHfreco + process.hltHoreco ) | ||
| process.HLTStoppedHSCPLocalHcalReco = cms.Sequence( process.hltHcalDigis + process.hltHbherecopre + process.hltHbhereco) | ||
|
|
||
| process.source.fileNames = cms.untracked.vstring("file:RelVal_Raw_GRun_MC.root") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
RecoLocalCalo/HcalRecProducers/src/HcalReconstructor.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| #include "FWCore/Framework/interface/Event.h" | ||
| #include "FWCore/Framework/interface/ESHandle.h" | ||
| #include "FWCore/Utilities/interface/InputTag.h" | ||
| #include "DataFormats/Common/interface/Handle.h" | ||
| #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" | ||
| #include "HeterogeneousCore/SonicTriton/interface/TritonClient.h" | ||
| #include "HeterogeneousCore/SonicCore/interface/SonicEDProducer.h" | ||
| #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| #include "DataFormats/HcalRecHit/interface/HBHERecHit.h" | ||
|
|
||
| class HcalReconstructor : public SonicEDProducer<TritonClient> | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| public: | ||
| explicit HcalReconstructor(edm::ParameterSet const& cfg) : | ||
| SonicEDProducer<TritonClient>(cfg), | ||
| fChannelInfoName_(cfg.getParameter<edm::InputTag>("ChannelInfoName")), | ||
| fTokChannelInfo_(this->consumes<HBHEChannelInfoCollection>(fChannelInfoName_)) | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| { | ||
| this->produces<HBHERecHitCollection>(); | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this->setDebugName("HcalReconstructor"); | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| void acquire(edm::Event const& iEvent, edm::EventSetup const& iSetup, Input& iInput) override { | ||
|
|
||
| const HBHEChannelInfoCollection *channelInfo = 0; | ||
| edm::Handle<HBHEChannelInfoCollection> hChannelInfo; | ||
| iEvent.getByToken(fTokChannelInfo_, hChannelInfo); | ||
| channelInfo = hChannelInfo.product(); | ||
|
|
||
| auto& input1 = iInput.begin()->second; | ||
| auto data1 = std::make_shared<TritonInput<float>>(); | ||
| data1->reserve(std::distance(channelInfo->begin(), channelInfo->end())); | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| hcalIds_.clear(); | ||
|
|
||
| for(HBHEChannelInfoCollection::const_iterator itC = channelInfo->begin(); itC != channelInfo->end(); itC++){ | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| std::vector<float> input; | ||
| const HBHEChannelInfo& pChannel(*itC); | ||
| const HcalDetId pDetId = pChannel.id(); | ||
| hcalIds_.push_back(pDetId); | ||
|
|
||
| //FACILE uses iphi as a continuous variable | ||
| input.push_back((float)pDetId.iphi()); | ||
| input.push_back((float)pChannel.tsGain(0.)); | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (unsigned int itTS=0; itTS < pChannel.nSamples(); ++itTS) { | ||
| input.push_back((float)pChannel.tsRawCharge(itTS)); | ||
| } | ||
|
|
||
| //FACILE considers 7 Hcal depths as binary variables | ||
| for (int itDepth=1; itDepth < 8; itDepth++){ | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (pDetId.depth() == itDepth) input.push_back(1.f); | ||
| else input.push_back(0.f); | ||
| } | ||
|
|
||
| //ieta is also encoded as a binary variable | ||
| for (int itIeta = 0; itIeta < 30; itIeta++){ | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (std::abs(pDetId.ieta()) == itIeta) input.push_back(1.f); | ||
| else input.push_back(0.f); | ||
| } | ||
|
|
||
| data1->push_back(input); | ||
| } | ||
|
|
||
| //set batch at maximum RHcollsize; pad the remainder | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| unsigned last = std::distance(channelInfo->begin(), channelInfo->end()); | ||
| if(last < input1.batchSize()){ | ||
| std::vector<float> pad(47,0.f); | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for(unsigned int iP = last; iP != input1.batchSize(); iP++){ | ||
| data1->push_back(pad); | ||
| } | ||
| } | ||
|
|
||
| input1.toServer(data1); | ||
| } | ||
|
|
||
| void produce(edm::Event& iEvent, edm::EventSetup const& iSetup, Output const& iOutput) override { | ||
| std::unique_ptr<HBHERecHitCollection> out; | ||
| out = std::make_unique<HBHERecHitCollection>(); | ||
| out->reserve(hcalIds_.size()); | ||
|
|
||
| const auto& output1 = iOutput.begin()->second; | ||
| const auto& outputs = output1.fromServer<float>(); | ||
|
|
||
| for(std::size_t iB = 0; iB < hcalIds_.size(); iB++){ | ||
|
|
||
| float rhE = outputs[iB][0]; | ||
| if(rhE < 0.) rhE = 0.;//shouldn't be necessary, relu activation function | ||
jeffkrupa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| //exception? | ||
| if(std::isnan(rhE)) rhE = 0; | ||
| if(std::isinf(rhE)) rhE = 0; | ||
|
|
||
| //FACILE does no time reco | ||
| HBHERecHit rh = HBHERecHit(hcalIds_[iB],rhE,0.f,0.f); | ||
| out->push_back(rh); | ||
| } | ||
| iEvent.put(std::move(out)); | ||
| } | ||
|
|
||
| /*static void fillDescriptions(edm::ConfigurationDescriptions & descriptions) { | ||
|
||
| edm::ParameterSetDescription desc; | ||
| TritonClient::fillPSetDescription(desc); | ||
| //add producer-specific parameters | ||
| desc.add<edm::InputTag>("ChannelInfoName","hbheprereco"); | ||
| descriptions.add("HcalPhase1Reconstructor_FACILE",desc); | ||
| }*/ | ||
|
|
||
|
|
||
| private: | ||
| edm::InputTag fChannelInfoName_; | ||
| edm::EDGetTokenT<HBHEChannelInfoCollection> fTokChannelInfo_; | ||
| std::vector<HcalDetId> hcalIds_; | ||
| }; | ||
|
|
||
| DEFINE_FWK_MODULE(HcalReconstructor); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.