Skip to content

Commit

Permalink
integrated, associatorchi2 and looseHits, perfectseed
Browse files Browse the repository at this point in the history
  • Loading branch information
vberta committed Nov 5, 2020
1 parent a25da25 commit 51fffb4
Show file tree
Hide file tree
Showing 12 changed files with 922 additions and 5 deletions.
Expand Up @@ -335,6 +335,7 @@ void LowPtGsfElectronSeedProducer::loop(const edm::Handle<std::vector<T> >& hand
if (!passThrough_ && (trackRef->pt() < minPtThreshold_)) {
continue;
}
if(trackRef->algo() == 11) continue; //Skip jetcore tracks because the seeds are hitless

// Create ElectronSeed
reco::ElectronSeed seed(*(trackRef->seedRef()));
Expand Down
Binary file not shown.
675 changes: 675 additions & 0 deletions RecoTracker/TkSeedGenerator/plugins/JetCorePerfectSeedGenerator.cc

Large diffs are not rendered by default.

191 changes: 191 additions & 0 deletions RecoTracker/TkSeedGenerator/plugins/JetCorePerfectSeedGenerator.h
@@ -0,0 +1,191 @@
#ifndef RecoTracker_TkSeedGenerator_JetCorePerfectSeedGenerator_H
#define RecoTracker_TkSeedGenerator_JetCorePerfectSeedGenerator_H

#define jetDimX 30
#define jetDimY 30
#define Nlayer 4
#define Nover 3
#define Npar 5


#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/Common/interface/DetSet.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/GeometryVector/interface/VectorUtil.h"
#include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/Candidate/interface/Candidate.h"


#include "RecoLocalTracker/ClusterParameterEstimator/interface/PixelClusterParameterEstimator.h"
#include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h"

#include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h"

#include "TrackingTools/GeomPropagators/interface/StraightLinePlaneCrossing.h"
#include "TrackingTools/GeomPropagators/interface/Propagator.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"

#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"



#include <boost/range.hpp>
#include <boost/foreach.hpp>
#include "boost/multi_array.hpp"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

// #include "SimG4Core/Application/interface/G4SimTrack.h"
#include "SimDataFormats/Track/interface/SimTrack.h"

#include "SimDataFormats/Vertex/interface/SimVertex.h"


#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"

#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"

#include "SimDataFormats/TrackingHit/interface/PSimHit.h"


#include "TTree.h"
#include "PhysicsTools/TensorFlow/interface/TensorFlow.h"


namespace edm { class Event; class EventSetup; }


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

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
// A pointer to a cluster and a list of tracks on it
struct TrackAndState
{
TrackAndState(const reco::Track *aTrack, TrajectoryStateOnSurface aState) :
track(aTrack), state(aState) {}
const reco::Track* track;
TrajectoryStateOnSurface state;
};


template<typename Cluster>
struct ClusterWithTracks
{
ClusterWithTracks(const Cluster &c) : cluster(&c) {}
const Cluster* cluster;
std::vector<TrackAndState> tracks;
};

typedef ClusterWithTracks<SiPixelCluster> SiPixelClusterWithTracks;

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

TFile* JetCorePerfectSeedGenerator_out;
TTree* JetCorePerfectSeedGeneratorTree;
// static const int jetDimX =30;
// static const int jetDimY =30;
// static const int Nlayer =4;
// static const int Nover = 3;
// static const int Npar = 4;

// double clusterMeas[jetDimX][jetDimY][Nlayer];
double jet_pt;
double jet_eta;
double pitchX = 0.01;
double pitchY = 0.015;
bool print = false;
int evt_counter =0;
bool inclusiveConeSeed = true; //true= fill tracks in a cone of deltaR_, false=fill tracks which produce SimHit on globDet


private:
virtual void beginJob() override;
virtual void produce( edm::Event&, const edm::EventSetup&) override;
virtual void endJob() override;


// ----------member data ---------------------------
std::string propagatorName_;
edm::ESHandle<MagneticField> magfield_;
edm::ESHandle<GlobalTrackingGeometry> geometry_;
edm::ESHandle<Propagator> propagator_;

edm::EDGetTokenT<std::vector<reco::Vertex> > vertices_;
edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > pixelClusters_;
std::vector<SiPixelClusterWithTracks> allSiPixelClusters;
std::map<uint32_t, SiPixelClustersWithTracks> siPixelDetsWithClusters;
edm::Handle< edm::DetSetVector<PixelDigiSimLink> > pixeldigisimlink;
edm::Handle<edmNew::DetSetVector<SiPixelCluster> > inputPixelClusters;
edm::EDGetTokenT< edm::DetSetVector<PixelDigiSimLink> > pixeldigisimlinkToken;
edm::EDGetTokenT<edm::View<reco::Candidate> > cores_;
edm::EDGetTokenT<std::vector<SimTrack> > simtracksToken;
edm::EDGetTokenT<std::vector<SimVertex> > simvertexToken;
edm::EDGetTokenT<std::vector<PSimHit> > PSimHitToken;
edm::Handle<std::vector<PSimHit> > simhits;

double ptMin_;
double deltaR_;
double chargeFracMin_;
double centralMIPCharge_;

std::string pixelCPE_;

tensorflow::GraphDef* graph_;
tensorflow::Session* session_;



std::pair<bool, Basic3DVector<float>> findIntersection(const GlobalVector & , const reco::Candidate::Point & ,const GeomDet*);

void fillPixelMatrix(const SiPixelCluster &, int, auto, const GeomDet*, tensorflow::NamedTensorList);

std::pair<int,int> local2Pixel(double, double, const GeomDet*);

LocalPoint pixel2Local(int, int, const GeomDet*);

int pixelFlipper(const GeomDet*);

const GeomDet* DetectorSelector(int ,const reco::Candidate& jet, GlobalVector, const reco::Vertex& jetVertex, const TrackerTopology* const);

std::vector<GlobalVector> splittedClusterDirections(const reco::Candidate&, const TrackerTopology* const, auto pp, const reco::Vertex& jetVertex, int );

std::vector<PSimHit> coreHitsFilling(auto,const GeomDet*,GlobalVector,const reco::Vertex&);
std::pair<std::vector<SimTrack>,std::vector<SimVertex>> coreTracksFilling(std::vector<PSimHit>, const auto &, const auto &);

std::vector<std::array<double,5>> seedParFilling(std::pair<std::vector<SimTrack>,std::vector<SimVertex>>,const GeomDet*);

std::pair<std::vector<SimTrack>,std::vector<SimVertex>> coreTracksFillingDeltaR( const auto &, const auto &,const GeomDet* , const reco::Candidate& );


};
#endif
3 changes: 3 additions & 0 deletions RecoTracker/TkSeedGenerator/plugins/SealModules.cc
Expand Up @@ -42,3 +42,6 @@ DEFINE_FWK_MODULE(SeedCreatorFromRegionConsecutiveHitsTripletOnlyEDProducer);

#include "RecoTracker/TkSeedGenerator/plugins/JetCoreDirectSeedGenerator.h"
DEFINE_FWK_MODULE(JetCoreDirectSeedGenerator);

#include "RecoTracker/TkSeedGenerator/plugins/JetCorePerfectSeedGenerator.h"
DEFINE_FWK_MODULE(JetCorePerfectSeedGenerator);
@@ -0,0 +1,12 @@
import FWCore.ParameterSet.Config as cms

JetCorePerfectSeedGenerator = cms.EDProducer("JetCorePerfectSeedGenerator",
vertices= cms.InputTag("offlinePrimaryVertices"),
pixelClusters= cms.InputTag("siPixelClustersPreSplitting"),
cores= cms.InputTag("jetsForCoreTracking"),
ptMin= cms.double(300),
deltaR= cms.double(0.1),
chargeFractionMin= cms.double(18000.0),
centralMIPCharge= cms.double(2),
pixelCPE= cms.string( "PixelCPEGeneric" )
)
Expand Up @@ -14,4 +14,3 @@
assoc2GsfTracks.label_tr = 'electronGsfTracks'
assocOutInConversionTracks.label_tr = 'ckfOutInTracksFromConversions'
assocInOutConversionTracks.label_tr = 'ckfInOutTracksFromConversions'

Expand Up @@ -2,11 +2,11 @@

trackingParticleRecoTrackAsssociation = cms.EDProducer("TrackAssociatorEDProducer",
associator = cms.InputTag('quickTrackAssociatorByHits'),
# associator = cms.InputTag('trackAssociatorByChi2'),
label_tp = cms.InputTag("mix","MergedTrackTruth"),
label_tr = cms.InputTag("generalTracks"),
ignoremissingtrackcollection=cms.untracked.bool(False)
)

from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2
premix_stage2.toModify(trackingParticleRecoTrackAsssociation, label_tp = "mixData:MergedTrackTruth")

Expand Up @@ -2,7 +2,7 @@
#define TrackAssociatorByChi2Impl_h

/** \class TrackAssociatorByChi2Impl
* Class that performs the association of reco::Tracks and TrackingParticles evaluating the chi2 of reco tracks parameters and sim tracks parameters. The cut can be tuned from the config file: see data/TrackAssociatorByChi2.cfi. Note that the Association Map is filled with -ch2 and not chi2 because it is ordered using std::greater: the track with the lowest association chi2 will be the first in the output map.It is possible to use only diagonal terms (associator by pulls) seeting onlyDiagonal = true in the PSet
* Class that performs the association of reco::Tracks and TrackingParticles evaluating the chi2 of reco tracks parameters and sim tracks parameters. The cut can be tuned from the config file: see data/TrackAssociatorByChi2.cfi. Note that the Association Map is filled with -ch2 and not chi2 because it is ordered using std::greater: the track with the lowest association chi2 will be the first in the output map.It is possible to use only diagonal terms (associator by pulls) seeting onlyDiagonal = true in the PSet
*
* \author cerati, magni
*/
Expand Down Expand Up @@ -47,10 +47,10 @@ class TrackAssociatorByChi2Impl : public reco::TrackToTrackingParticleAssociator
chi2cut(conf.getParameter<double>("chi2cut")),
onlyDiagonal(conf.getParameter<bool>("onlyDiagonal")),
bsSrc(conf.getParameter<edm::InputTag>("beamSpot")) {
theMF=mF;
theMF=mF;
if (onlyDiagonal)
edm::LogInfo("TrackAssociator") << " ---- Using Off Diagonal Covariance Terms = 0 ---- " << "\n";
else
else
edm::LogInfo("TrackAssociator") << " ---- Using Off Diagonal Covariance Terms != 0 ---- " << "\n";
}
*/
Expand Down
1 change: 1 addition & 0 deletions Validation/RecoTrack/python/MultiTrackValidator_cfi.py
Expand Up @@ -31,6 +31,7 @@
# if False, the src's above should specify the TP-RecoTrack association
# if True, the src's above should specify the associator
UseAssociators = cms.bool(False),
# UseAssociators = cms.bool(True),

### sim input configuration ###
label_tp_effic = cms.InputTag("mix","MergedTrackTruth"),
Expand Down
30 changes: 30 additions & 0 deletions Validation/RecoTrack/python/TrackValidation_cff.py
Expand Up @@ -365,6 +365,34 @@ def _getMVASelectors(postfix):
# Select B-hadron TPs
trackingParticlesBHadron = _trackingParticleBHadronRefSelector.clone()

# MTVtrackAssociatorByChi2 = SimTracker.TrackAssociatorProducers.trackAssociatorByChi2_cfi.trackAssociatorByChi2.clone() #maybe modification needed

MTVTrackAssociationByChi2 = trackingParticleRecoTrackAsssociation.clone(
associator = cms.InputTag('trackAssociatorByChi2'),
# UseAssociators = cms.bool(True)
)

# associatorByHitLoose = SimTracker.TrackAssociatorProducers.quickTrackAssociatorByHits_cfi.quickTrackAssociatorByHits.clone(
associatorByHitLoose = quickTrackAssociatorByHits.clone(
# AbsoluteNumberOfHits = cms.bool(False),
Cut_RecoToSim = cms.double(0.5),
# SimToRecoDenominator = cms.string('reco'), # either "sim" or "reco"
Quality_SimToReco = cms.double(0.3),
Purity_SimToReco = cms.double(0.5),
# ThreeHitTracksAreSpecial = cms.bool(True),
# PixelHitWeight = cms.double(1.0),
# useClusterTPAssociation = cms.bool(True),
# cluster2TPSrc = cms.InputTag("tpClusterProducer")
usePixels = cms.bool(False)
)


MTVTrackAssociationByHitsLoose = trackingParticleRecoTrackAsssociation.clone(
associator = cms.InputTag('associatorByHitLoose'),
# UseAssociators = cms.bool(True)
)


## MTV instances
trackValidator = Validation.RecoTrack.MultiTrackValidator_cfi.multiTrackValidator.clone(
useLogPt = cms.untracked.bool(True),
Expand Down Expand Up @@ -660,6 +688,8 @@ def _uniqueFirstLayers(layerList):
tpClusterProducerPreSplitting,
# trackAssociatorByChi2, #uncomment for byChi2 assoc. for jetcore studies (4/5)
# MTVTrackAssociationByChi2, #uncomment for byChi2 assoc. for jetcore studies (5/5)
associatorByHitLoose,
MTVTrackAssociationByHitsLoose,
quickTrackAssociatorByHits,
quickTrackAssociatorByHitsPreSplitting,
trackingParticleRecoTrackAsssociation,
Expand Down
5 changes: 5 additions & 0 deletions Validation/RecoTrack/python/associators_cff.py
Expand Up @@ -19,6 +19,11 @@
hltTrackAssociatorByHits.UseSplitting = cms.bool( False )
hltTrackAssociatorByHits.ThreeHitTracksAreSpecial = cms.bool( False )

#NOT BY HIT NOW!!! uncomment lines 16-20 to do byhits
# hltTrackAssociatorByHits = SimTracker.TrackAssociatorProducers.trackAssociatorByChi2_cfi.trackAssociatorByChi2.clone()



hltTrackAssociatorByDeltaR = SimTracker.TrackAssociatorProducers.trackAssociatorByPosition_cfi.trackAssociatorByPosition.clone()
hltTrackAssociatorByDeltaR.method = cms.string('momdr')
hltTrackAssociatorByDeltaR.QCut = cms.double(0.5)
Expand Down

0 comments on commit 51fffb4

Please sign in to comment.