Skip to content

Commit

Permalink
Fully plugged in on the right now
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrothman committed Oct 21, 2021
1 parent 047e688 commit a9ea4a8
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 26 deletions.
Binary file modified Progression/EGM_DRN/data/models/EGM_DRN/1/model.pt
Binary file not shown.
35 changes: 31 additions & 4 deletions Progression/EGM_DRN/plugins/DRNCorrector.cc
Expand Up @@ -124,6 +124,34 @@ void DRNCorrector::setEvent(const edm::Event& event) {
}
}

void DRNCorrector::dummyrun(TritonInputMap &iInput) const{
auto& input1 = iInput.at("x__0");
input1.setShape(0, 1);
auto data1 = input1.allocate<float>();
auto& vdata1 = (*data1)[0];

auto& input2 = iInput.at("batch__1");
input2.setShape(0, 1);
auto data2 = input2.allocate<int64_t>();
auto& vdata2 = (*data2)[0];

auto& input3 = iInput.at("graphx__2");
input3.setShape(0, 2);
auto data3 = input3.allocate<float>();
auto& vdata3 = (*data3)[0];

vdata1.push_back(1.0);
vdata2.push_back(0);
vdata3.push_back(1.0);
vdata3.push_back(1.0);

input1.toServer(data1);
input2.toServer(data2);
input3.toServer(data3);

edm::LogPrint("DEBUG") << "Sending fake input to server...";
}

void DRNCorrector::make_input(const edm::Event& iEvent, TritonInputMap& iInput, const reco::SuperClusterCollection& inputSCs ) const {
//get event-based seed for RNG
unsigned int runNum_uint = static_cast<unsigned int>(iEvent.id().run());
Expand All @@ -142,8 +170,10 @@ void DRNCorrector::make_input(const edm::Event& iEvent, TritonInputMap& iInput,
nHits.push_back(n);
}

if(nHits.size() ==0)
if(nHits.size() ==0){
dummyrun(iInput);
return;
}

int nnodes = randint1(rng);

Expand All @@ -169,9 +199,6 @@ void DRNCorrector::make_input(const edm::Event& iEvent, TritonInputMap& iInput,
vdata1.push_back(randx(rng));
}

//for (unsigned i = 0; i < input2.sizeShape(); ++i) {
// vdata2.push_back(0);
//}
unsigned k=0;
for(unsigned sc=0; sc<nHits.size(); ++sc){
for(unsigned i=0; i< nHits[sc]; ++i){
Expand Down
3 changes: 3 additions & 0 deletions Progression/EGM_DRN/plugins/DRNCorrector.h
Expand Up @@ -71,6 +71,9 @@ class DRNCorrector {
std::vector<float> getRegData(const reco::SuperCluster& sc) const;

private:

void dummyrun(TritonInputMap &iInput) const;

const CaloTopology* caloTopo_;
const CaloGeometry* caloGeom_;
edm::ESGetToken<CaloTopology, CaloTopologyRecord> caloTopoToken_;
Expand Down
41 changes: 23 additions & 18 deletions Progression/EGM_DRN/plugins/DRNProducer.cc
Expand Up @@ -60,10 +60,6 @@ void DRNProducer::acquire(edm::Event const& iEvent, edm::EventSetup const& iSetu
edm::LogPrint(debugName_) << std::endl;
edm::LogPrint(debugName_) << "acquiring..." << std::endl;
auto inputSCs = iEvent.get(inputSCToken_);
if(inputSCs.size() ==0){
edm::LogPrint(debugName_) << "skipped acquire for empty event" << std::endl;
return;
}
energyCorrector_.setEvent(iEvent);
energyCorrector_.make_input(iEvent, iInput, inputSCs);
edm::LogPrint(debugName_) << "acquired" << std::endl;
Expand All @@ -72,28 +68,37 @@ void DRNProducer::acquire(edm::Event const& iEvent, edm::EventSetup const& iSetu
void DRNProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup, Output const& iOutput){
edm::LogPrint(debugName_) << "producing..." << std::endl;
auto inputSCs = iEvent.get(inputSCToken_);

const auto& output1 = iOutput.begin()->second;
const auto& serverout = output1.fromServer<float>();
edm::LogPrint("test") << "output shape: " << output1.shape()[0] << "," << output1.shape()[1] << std::endl;
// const auto& serverout = energyCorrector_.get_output(iOutput);
edm::LogPrint(debugName_) << "got from server" << std::endl;

if(inputSCs.size() ==0){
edm::LogPrint(debugName_) << "skipped produce for empty event" << std::endl;
edm::LogPrint(debugName_) << "produced" << std::endl;
return;
}

const auto& serverout = energyCorrector_.get_output(iOutput);
edm::LogPrint(debugName_) << "got from server" << std::endl;

//assert(inputSCs.size() == serverout.shape()[0]);

//auto inputSCs = iEvent.get(inputSCToken_);
auto corrSCs = std::make_unique<reco::SuperClusterCollection>();
unsigned i=0;
for (const auto& inputSC : inputSCs) {
edm::LogPrint(debugName_) << "doing a supercluster" << std::endl;
corrSCs->push_back(inputSC);
corrSCs->back().setEnergy(serverout[i][0]);
corrSCs->back().setCorrectedEnergy(serverout[i][0]);
corrSCs->back().setCorrectedEnergyUncertainty(serverout[i][1]);
//energyCorrector_.modifyObject(corrSCs->back());
++i;
}
auto corrSCs = std::make_unique<reco::SuperClusterCollection>();
unsigned i=0;
for (const auto& inputSC : inputSCs) {
edm::LogPrint(debugName_) << "doing a supercluster" << std::endl;
corrSCs->push_back(inputSC);
edm::LogPrint(debugName_) << "pushed back" << std::endl;
corrSCs->back().setEnergy(serverout[0][0+6*i]);
edm::LogPrint(debugName_) << "set energy" << std::endl;
corrSCs->back().setCorrectedEnergy(serverout[0][0+6*i]);
edm::LogPrint(debugName_) << "set corrected energy" << std::endl;
corrSCs->back().setCorrectedEnergyUncertainty(serverout[0][1+6*i]);
edm::LogPrint(debugName_) << "set corrected energy uncertainty" << std::endl;
//energyCorrector_.modifyObject(corrSCs->back());
++i;
}

edm::LogPrint(debugName_) << "putting into event" << std::endl;

Expand Down
15 changes: 12 additions & 3 deletions Progression/EGM_DRN/test/Electron_RecHit_AOD_cfg.py
Expand Up @@ -11,6 +11,9 @@
process.load("Configuration.StandardSequences.GeometryRecoDB_cff")

process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) )
process.options.numberOfThreads = cms.untracked.uint32(1)
process.options.numberOfStreams = cms.untracked.uint32(1)
process.options.SkipEvent = cms.untracked.vstring('ProductNotFound')

process.TritonService.verbose = True
process.TritonService.fallback.verbose = True
Expand All @@ -36,7 +39,8 @@
process.source = cms.Source("PoolSource",
# replace 'myfile.root' with the source file you want to use
fileNames = cms.untracked.vstring(
'root://cms-xrd-global.cern.ch///store/mc/RunIISummer19UL18RECO/DYJetsToEE_M-50_TuneCP5_13TeV-madgraphMLM-pythia8/AODSIM/NoPUECAL4BX25_106X_upgrade2018_realistic_v11_Ecal4-v2/20000/D2F029DD-CACC-AA48-BC51-D1987DD92E26.root'
#'root://cms-xrd-global.cern.ch///store/mc/RunIISummer19UL18RECO/DYJetsToEE_M-50_TuneCP5_13TeV-madgraphMLM-pythia8/AODSIM/NoPUECAL4BX25_106X_upgrade2018_realistic_v11_Ecal4-v2/20000/D2F029DD-CACC-AA48-BC51-D1987DD92E26.root'
"file:testfile.root"
)
)

Expand Down Expand Up @@ -127,7 +131,7 @@
useSharedMemory = cms.untracked.bool(True),
compression = cms.untracked.string(""),
),

# generateConcurrently = cms.untracked.bool(False),
)


Expand Down Expand Up @@ -171,6 +175,7 @@
compression = cms.untracked.string(""),
),

# generateConcurrently = cms.untracked.bool(False),
)

from PhysicsTools.SelectorUtils.tools.vid_id_tools import *
Expand All @@ -195,7 +200,8 @@
eleMediumIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-medium"),
eleTightIdMap = cms.InputTag("egmGsfElectronIDs:cutBasedElectronID-Fall17-94X-V2-tight"),

tracks = cms.InputTag("globalTracks")
tracks = cms.InputTag("globalTracks"),
SkipEvent = cms.untracked.vstring('ProductNotFound')
)


Expand All @@ -204,4 +210,7 @@
closeFileFast = cms.untracked.bool(True)
)


#process.p = cms.Path(process.DRNProducerEB*process.egmGsfElectronIDSequence*process.nTuplelize)

process.p = cms.Path(process.DRNProducerEB*process.DRNProducerEE*process.egmGsfElectronIDSequence*process.nTuplelize)
Expand Up @@ -204,7 +204,7 @@ Electron_RecHit_NTuplizer::Electron_RecHit_NTuplizer(const edm::ParameterSet& iC
recHitCollectionEEToken_(consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"))),
recHitCollectionESToken_(consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsES"))),
_EBSuperClustersToken(consumes<reco::SuperClusterCollection>(edm::InputTag("DRNProducerEB"))),
_EESuperClustersToken(consumes<reco::SuperClusterCollection>(edm::InputTag("DRNProducerEE"))),
_EESuperClustersToken(consumes<reco::SuperClusterCollection>(edm::InputTag("DRNProducerEB"))),
eleLooseIdMapToken_(consumes<edm::ValueMap<bool> >(iConfig.getParameter<edm::InputTag>("eleLooseIdMap"))),
eleMediumIdMapToken_(consumes<edm::ValueMap<bool> >(iConfig.getParameter<edm::InputTag>("eleMediumIdMap"))),
eleTightIdMapToken_(consumes<edm::ValueMap<bool> >(iConfig.getParameter<edm::InputTag>("eleTightIdMap")))
Expand Down

0 comments on commit a9ea4a8

Please sign in to comment.