Skip to content

Commit

Permalink
seedingDeepCore modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
vberta committed Nov 20, 2020
1 parent a687fee commit 1182693
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,25 @@ def condition_(self, fragment, stepList, key, hasHarvest):
'--procModifiers': 'trackingMkFit'
}

#DeepCore seeding for JetCore iteration workflow
class UpgradeWorkflow_seedingDeepCore(UpgradeWorkflowTracking):
def setup_(self, step, stepName, stepDict, k, properties):
if 'Reco' in step: stepDict[stepName][k] = merge([self.step3, stepDict[step][k]])
def condition_(self, fragment, stepList, key, hasHarvest):
return '2021' in key or '2024' in key
upgradeWFs['seedingDeepCore'] = UpgradeWorkflow_seedingDeepCore(
steps = [
'Reco',
'RecoGlobal',
],
PU = [],
suffix = '_seedingDeepCore',
offset = 0.13,
)
upgradeWFs['seedingDeepCore'].step3 = {
'--procModifiers': 'seedingDeepCore'
}

# Vector Hits workflows
class UpgradeWorkflow_vectorHits(UpgradeWorkflow):
def setup_(self, step, stepName, stepDict, k, properties):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@

from Configuration.ProcessModifiers.egamma_lowPt_exclusive_cff import egamma_lowPt_exclusive
egamma_lowPt_exclusive.toModify(trackerDrivenElectronSeeds,MinPt = 1.0)

from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
seedingDeepCore.toModify(trackerDrivenElectronSeeds, MaxPt = 50 )
46 changes: 28 additions & 18 deletions RecoTracker/IterativeTracking/python/JetCoreRegionalStep_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@
# QUALITY CUTS DURING TRACK BUILDING
import TrackingTools.TrajectoryFiltering.TrajectoryFilter_cff
jetCoreRegionalStepTrajectoryFilter = TrackingTools.TrajectoryFiltering.TrajectoryFilter_cff.CkfBaseTrajectoryFilter_block.clone(
minPt = 0.1,
minimumNumberOfHits = 4,
seedPairPenalty = 0,
minPt = 0.1
)

from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
seedingDeepCore.toModify(jetCoreRegionalStepTrajectoryFilter,
maxCCCLostHits = cms.int32(9999),
maxConsecLostHits = cms.int32(2),
maxLostHits = cms.int32(999),
Expand All @@ -99,10 +105,8 @@
minimumNumberOfHits = cms.int32(2),
pixelSeedExtension = cms.bool(False),
seedExtension = cms.int32(0),
seedPairPenalty = cms.int32(0),
strictSeedExtension = cms.bool(False)

)
)

from Configuration.Eras.Modifier_pp_on_XeXe_2017_cff import pp_on_XeXe_2017
from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
Expand All @@ -126,15 +130,17 @@
maxCand = 50,
estimator = 'jetCoreRegionalStepChi2Est',
maxDPhiForLooperReconstruction = cms.double(2.0),
maxPtForLooperReconstruction = cms.double(0.7)
)
seedingDeepCore.toModify(jetCoreRegionalStepTrajectoryBuilder,
maxPtForLooperReconstruction = cms.double(0),
keepOriginalIfRebuildFails = True,
lockHits = False,
requireSeedHitsInRebuild = False,
trajectoryFilter = cms.PSet(refToPSet_ = cms.string('CkfBaseTrajectoryFilter_blockLoose'))
)

)


#customized cleaner
#customized cleaner for DeepCore
trajectoryCleanerBySharedHits_JetCore = cms.ESProducer("TrajectoryCleanerESProducer",
ComponentName = cms.string('jetCoreTrajectoryCleanerBySharedHits'),
ComponentType = cms.string('TrajectoryCleanerBySharedHits'),
Expand All @@ -144,6 +150,7 @@
fractionShared = cms.double(0.45)
)

#DeepCore filter
CkfBaseTrajectoryFilter_blockLoose = cms.PSet(
ComponentType = cms.string('CkfBaseTrajectoryFilter'),
chargeSignificance = cms.double(-1.0),
Expand All @@ -170,28 +177,31 @@
)


import RecoTracker.TkSeedGenerator.jetCoreDirectSeedGenerator_cfi
import RecoTracker.TkSeedGenerator.jetCorePerfectSeedGenerator_cfi
jetCoreRegionalStepSeeds = RecoTracker.TkSeedGenerator.jetCoreDirectSeedGenerator_cfi.jetCoreDirectSeedGenerator.clone(
# jetCoreSeeds = RecoTracker.TkSeedGenerator.jetCoreDirectSeedGenerator_cfi.jetCoreDirectSeedGenerator.clone(
# jetCoreSeeds = RecoTracker.TkSeedGenerator.jetCorePerfectSeedGenerator_cfi.JetCorePerfectSeedGenerator.clone(
import RecoTracker.TkSeedGenerator.DeepCoreSeedGenerator_cfi
import RecoTracker.TkSeedGenerator.JetCoreMCtruthSeedGenerator_cfi
jetCoreRegionalStepSeeds = RecoTracker.TkSeedGenerator.DeepCoreSeedGenerator_cfi.DeepCoreSeedGenerator.clone(
# jetCoreSeeds = RecoTracker.TkSeedGenerator.DeepCoreSeedGenerator_cfi.DeepCoreSeedGenerator.clone(
# jetCoreSeeds = RecoTracker.TkSeedGenerator.JetCoreMCtruthSeedGenerator_cfi.JetCoreMCtruthSeedGenerator.clone(
vertices="firstStepPrimaryVertices"
)

# MAKING OF TRACK CANDIDATES
import RecoTracker.CkfPattern.CkfTrackCandidates_cfi
jetCoreRegionalStepTrackCandidates = RecoTracker.CkfPattern.CkfTrackCandidates_cfi.ckfTrackCandidates.clone(
# src = 'jetCoreSeeds',
src = 'jetCoreRegionalStepSeeds',
maxSeedsBeforeCleaning = 10000,
TrajectoryBuilderPSet = cms.PSet( refToPSet_ = cms.string('jetCoreRegionalStepTrajectoryBuilder')),
TrajectoryCleaner = 'jetCoreTrajectoryCleanerBySharedHits',
NavigationSchool = 'SimpleNavigationSchool',
doSeedingRegionRebuilding = True,
### these two parameters are relevant only for the CachingSeedCleanerBySharedInput
#numHitsForSeedCleaner = cms.int32(50),
#onlyPixelHitsForSeedCleaner = cms.bool(True),
)
seedingDeepCore.toModify(jetCoreRegionalStepTrackCandidates,
TrajectoryCleaner = 'jetCoreTrajectoryCleanerBySharedHits',
doSeedingRegionRebuilding = True,
# src = 'jetCoreSeeds',

)


# TRACK FITTING
Expand Down Expand Up @@ -270,7 +280,7 @@


# Final sequence
JetCoreRegionalStepTask = cms.Task(jetsForCoreTracking,
JetCoreRegionalStepTask = cms.Task(jetsForCoreTracking,
firstStepGoodPrimaryVertices,
#jetCoreRegionalStepClusters,
jetCoreRegionalStepSeedLayers,
Expand All @@ -283,6 +293,6 @@
# jetCoreRegionalStepClassifier1,jetCoreRegionalStepClassifier2,
jetCoreRegionalStep)
JetCoreRegionalStep = cms.Sequence(JetCoreRegionalStepTask)
fastSim.toReplaceWith(JetCoreRegionalStepTask,
fastSim.toReplaceWith(JetCoreRegionalStepTask,
cms.Task(jetCoreRegionalStepTracks,
jetCoreRegionalStep))
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// -*- C++ -*-
//
// Package: trackJet/JetCoreDirectSeedGenerator
// Class: JetCoreDirectSeedGenerator
// Package: trackJet/DeepCoreSeedGenerator
// Class: DeepCoreSeedGenerator
//
/**\class JetCoreDirectSeedGenerator JetCoreDirectSeedGenerator.cc trackJet/JetCoreDirectSeedGenerator/plugins/JetCoreDirectSeedGenerator.cc
/**\class DeepCoreSeedGenerator DeepCoreSeedGenerator.cc trackJet/DeepCoreSeedGenerator/plugins/DeepCoreSeedGenerator.cc
Description: [one line class summary]
Expand All @@ -25,7 +25,7 @@
#define Nover 3
#define Npar 5

#include "JetCoreDirectSeedGenerator.h"
#include "DeepCoreSeedGenerator.h"

#include <memory>

Expand Down Expand Up @@ -109,7 +109,7 @@



JetCoreDirectSeedGenerator::JetCoreDirectSeedGenerator(const edm::ParameterSet& iConfig) :
DeepCoreSeedGenerator::DeepCoreSeedGenerator(const edm::ParameterSet& iConfig) :

vertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
pixelClusters_(consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("pixelClusters"))),
Expand All @@ -135,10 +135,10 @@ JetCoreDirectSeedGenerator::JetCoreDirectSeedGenerator(const edm::ParameterSet&

// edm::Service<TFileService> fileService;
//
// JetCoreDirectSeedGeneratorTree= fileService->make<TTree>("JetCoreDirectSeedGeneratorTree","JetCoreDirectSeedGeneratorTree");
// JetCoreDirectSeedGeneratorTree->Branch("cluster_measured",clusterMeas,"cluster_measured[30][30][4]/D");
// JetCoreDirectSeedGeneratorTree->Branch("jet_eta",&jet_eta);
// JetCoreDirectSeedGeneratorTree->Branch("jet_pt",&jet_pt);
// DeepCoreSeedGeneratorTree= fileService->make<TTree>("DeepCoreSeedGeneratorTree","DeepCoreSeedGeneratorTree");
// DeepCoreSeedGeneratorTree->Branch("cluster_measured",clusterMeas,"cluster_measured[30][30][4]/D");
// DeepCoreSeedGeneratorTree->Branch("jet_eta",&jet_eta);
// DeepCoreSeedGeneratorTree->Branch("jet_pt",&jet_pt);


// for(int i=0; i<Nlayer; i++){ //NOFLAG
Expand All @@ -154,15 +154,15 @@ JetCoreDirectSeedGenerator::JetCoreDirectSeedGenerator(const edm::ParameterSet&
}


JetCoreDirectSeedGenerator::~JetCoreDirectSeedGenerator()
DeepCoreSeedGenerator::~DeepCoreSeedGenerator()
{

}

#define foreach BOOST_FOREACH


void JetCoreDirectSeedGenerator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
void DeepCoreSeedGenerator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
evt_counter++;
// std::cout << "NEW EVENT, event number" << evt_counter <<std::endl;
Expand Down Expand Up @@ -355,11 +355,11 @@ int jet_number = 0;
} //cluster
} //detset

// JetCoreDirectSeedGeneratorTree->Fill();
// DeepCoreSeedGeneratorTree->Fill();

//HERE SOMEHOW THE NN PRODUCE THE SEED FROM THE FILLED INPUT
// std::cout << "Filling complete" << std::endl;
std::pair<double[jetDimX][jetDimY][Nover][Npar],double[jetDimX][jetDimY][Nover]> seedParamNN = JetCoreDirectSeedGenerator::SeedEvaluation(input_tensors);
std::pair<double[jetDimX][jetDimY][Nover][Npar],double[jetDimX][jetDimY][Nover]> seedParamNN = DeepCoreSeedGenerator::SeedEvaluation(input_tensors);

for(int i=0; i<jetDimX; i++){
for(int j=0; j<jetDimY; j++){
Expand Down Expand Up @@ -472,7 +472,7 @@ iEvent.put(std::move(resultTracks));



std::pair<bool, Basic3DVector<float>> JetCoreDirectSeedGenerator::findIntersection(const GlobalVector & dir,const reco::Candidate::Point & vertex, const GeomDet* det){
std::pair<bool, Basic3DVector<float>> DeepCoreSeedGenerator::findIntersection(const GlobalVector & dir,const reco::Candidate::Point & vertex, const GeomDet* det){
StraightLinePlaneCrossing vertexPlane(Basic3DVector<float>(vertex.x(),vertex.y(),vertex.z()), Basic3DVector<float>(dir.x(),dir.y(),dir.z()));

std::pair<bool, Basic3DVector<float>> pos = vertexPlane.position(det->specificSurface());
Expand All @@ -481,22 +481,22 @@ std::pair<bool, Basic3DVector<float>> JetCoreDirectSeedGenerator::findIntersecti
}


std::pair<int,int> JetCoreDirectSeedGenerator::local2Pixel(double locX, double locY, const GeomDet* det){
std::pair<int,int> DeepCoreSeedGenerator::local2Pixel(double locX, double locY, const GeomDet* det){
LocalPoint locXY(locX,locY);
float pixX=(dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().pixel(locXY).first;
float pixY=(dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().pixel(locXY).second;
std::pair<int, int> out(pixX,pixY);
return out;
}

LocalPoint JetCoreDirectSeedGenerator::pixel2Local(int pixX, int pixY, const GeomDet* det){
LocalPoint DeepCoreSeedGenerator::pixel2Local(int pixX, int pixY, const GeomDet* det){
float locX=(dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().localX(pixX);
float locY=(dynamic_cast<const PixelGeomDetUnit*>(det))->specificTopology().localY(pixY);
LocalPoint locXY(locX,locY);
return locXY;
}

int JetCoreDirectSeedGenerator::pixelFlipper(const GeomDet* det){
int DeepCoreSeedGenerator::pixelFlipper(const GeomDet* det){
int out =1;
LocalVector locZdir(0,0,1);
GlobalVector globZdir = det->specificSurface().toGlobal(locZdir);
Expand All @@ -510,7 +510,7 @@ LocalPoint JetCoreDirectSeedGenerator::pixel2Local(int pixX, int pixY, const Geo



void JetCoreDirectSeedGenerator::fillPixelMatrix(const SiPixelCluster & cluster, int layer, auto inter, const GeomDet* det, tensorflow::NamedTensorList input_tensors ){//tensorflow::NamedTensorList input_tensors){
void DeepCoreSeedGenerator::fillPixelMatrix(const SiPixelCluster & cluster, int layer, auto inter, const GeomDet* det, tensorflow::NamedTensorList input_tensors ){//tensorflow::NamedTensorList input_tensors){

int flip = pixelFlipper(det); // 1=not flip, -1=flip

Expand Down Expand Up @@ -544,7 +544,7 @@ void JetCoreDirectSeedGenerator::fillPixelMatrix(const SiPixelCluster & cluster,

}

std::pair<double[jetDimX][jetDimY][Nover][Npar],double[jetDimX][jetDimY][Nover]> JetCoreDirectSeedGenerator::SeedEvaluation(tensorflow::NamedTensorList input_tensors){
std::pair<double[jetDimX][jetDimY][Nover][Npar],double[jetDimX][jetDimY][Nover]> DeepCoreSeedGenerator::SeedEvaluation(tensorflow::NamedTensorList input_tensors){

// tensorflow::TensorShape input_size_cluster {1,jetDimX,jetDimY,Nlayer} ;
// tensorflow::TensorShape input_size_pt {1} ;
Expand Down Expand Up @@ -618,7 +618,7 @@ std::pair<double[jetDimX][jetDimY][Nover][Npar],double[jetDimX][jetDimY][Nover]>
}


const GeomDet* JetCoreDirectSeedGenerator::DetectorSelector(int llay, const reco::Candidate& jet, GlobalVector jetDir, const reco::Vertex& jetVertex, const TrackerTopology* const tTopo){
const GeomDet* DeepCoreSeedGenerator::DetectorSelector(int llay, const reco::Candidate& jet, GlobalVector jetDir, const reco::Vertex& jetVertex, const TrackerTopology* const tTopo){

struct trkNumCompare {
bool operator()(std::pair<int,const GeomDet*> x, std::pair<int,const GeomDet*> y) const
Expand Down Expand Up @@ -658,7 +658,7 @@ const GeomDet* JetCoreDirectSeedGenerator::DetectorSelector(int llay, const reco
// std::cout << "OK DET= layer =" << llay << " selected det=" << output->gdetIndex() << std::endl;
return output;
}
std::vector<GlobalVector> JetCoreDirectSeedGenerator::splittedClusterDirections(const reco::Candidate& jet, const TrackerTopology* const tTopo, auto pp, const reco::Vertex& jetVertex , int layer){
std::vector<GlobalVector> DeepCoreSeedGenerator::splittedClusterDirections(const reco::Candidate& jet, const TrackerTopology* const tTopo, auto pp, const reco::Vertex& jetVertex , int layer){
std::vector<GlobalVector> clustDirs;

edmNew::DetSetVector<SiPixelCluster>::const_iterator detIt_int = inputPixelClusters->begin();
Expand Down Expand Up @@ -716,7 +716,7 @@ std::vector<GlobalVector> JetCoreDirectSeedGenerator::splittedClusterDirections(
}


std::vector<GlobalVector> JetCoreDirectSeedGenerator::splittedClusterDirectionsOld(const reco::Candidate& jet, const TrackerTopology* const tTopo, auto pp, const reco::Vertex& jetVertex ){
std::vector<GlobalVector> DeepCoreSeedGenerator::splittedClusterDirectionsOld(const reco::Candidate& jet, const TrackerTopology* const tTopo, auto pp, const reco::Vertex& jetVertex ){
std::vector<GlobalVector> clustDirs;

edmNew::DetSetVector<SiPixelCluster>::const_iterator detIt_int = inputPixelClusters->begin();
Expand Down Expand Up @@ -768,19 +768,19 @@ std::vector<GlobalVector> JetCoreDirectSeedGenerator::splittedClusterDirectionsO

// ------------ method called once each job just before starting event loop ------------
void
JetCoreDirectSeedGenerator::beginJob()
DeepCoreSeedGenerator::beginJob()
{
}

// ------------ method called once each job just after ending the event loop ------------
void
JetCoreDirectSeedGenerator::endJob()
DeepCoreSeedGenerator::endJob()
{
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
JetCoreDirectSeedGenerator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
DeepCoreSeedGenerator::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
Expand All @@ -789,4 +789,4 @@ JetCoreDirectSeedGenerator::fillDescriptions(edm::ConfigurationDescriptions& des
}

//define this as a plug-in
// DEFINE_FWK_MODULE(JetCoreDirectSeedGenerator);
// DEFINE_FWK_MODULE(DeepCoreSeedGenerator);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RecoTracker_TkSeedGenerator_JetCoreDirectSeedGenerator_H
#define RecoTracker_TkSeedGenerator_JetCoreDirectSeedGenerator_H
#ifndef RecoTracker_TkSeedGenerator_DeepCoreSeedGenerator_H
#define RecoTracker_TkSeedGenerator_DeepCoreSeedGenerator_H

#define jetDimX 30
#define jetDimY 30
Expand Down Expand Up @@ -81,10 +81,10 @@
namespace edm { class Event; class EventSetup; }


class JetCoreDirectSeedGenerator : public edm::one::EDProducer<edm::one::SharedResources> {
class DeepCoreSeedGenerator : public edm::one::EDProducer<edm::one::SharedResources> {
public:
explicit JetCoreDirectSeedGenerator(const edm::ParameterSet&);
~JetCoreDirectSeedGenerator();
explicit DeepCoreSeedGenerator(const edm::ParameterSet&);
~DeepCoreSeedGenerator();

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
// A pointer to a cluster and a list of tracks on it
Expand All @@ -109,8 +109,8 @@ class JetCoreDirectSeedGenerator : public edm::one::EDProducer<edm::one::SharedR

typedef boost::sub_range<std::vector<SiPixelClusterWithTracks> > SiPixelClustersWithTracks;

TFile* JetCoreDirectSeedGenerator_out;
TTree* JetCoreDirectSeedGeneratorTree;
TFile* DeepCoreSeedGenerator_out;
TTree* DeepCoreSeedGeneratorTree;
// static const int jetDimX =30;
// static const int jetDimY =30;
// static const int Nlayer =4;
Expand Down
Loading

0 comments on commit 1182693

Please sign in to comment.