Skip to content
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

Updated CommonTools/RecoUtils also for 7XY #3928

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CommonTools/RecoUtils/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<use name="DataFormats/Candidate"/>
<use name="DataFormats/Common"/>
<use name="DataFormats/EgammaCandidates"/>
<use name="DataFormats/L1GlobalTrigger"/>
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/RecoUtils/interface/PFCand_AssoMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//
// Original Author: Matthias Geisler
// Created: Wed Apr 18 14:48:37 CEST 2012
// $Id: PFCand_AssoMap.h,v 1.7 2012/10/10 11:45:01 mgeisler Exp $
// $Id: PFCand_AssoMap.h,v 1.8 2012/11/21 09:39:33 mgeisler Exp $
//
//

Expand Down
9 changes: 6 additions & 3 deletions CommonTools/RecoUtils/interface/PFCand_AssoMapAlgos.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
//
// Original Author: Matthias Geisler,32 4-B20,+41227676487,
// $Id$
// $Id: PFCand_AssoMapAlgos.h,v 1.1 2012/11/21 09:46:43 mgeisler Exp $
//
//
#include "CommonTools/RecoUtils/interface/PF_PU_AssoMapAlgos.h"
Expand Down Expand Up @@ -39,7 +39,10 @@ class PFCand_AssoMapAlgos : public PF_PU_AssoMapAlgos {
PFCand_AssoMapAlgos(const edm::ParameterSet&);

//get all needed collections at the beginning
void GetInputCollections(edm::Event&, const edm::EventSetup&);
void GetPFCandInputCollections(edm::Event&, const edm::EventSetup&);

//get all needed collections at the beginning
void SetMotherPointer(edm::Handle<reco::PFCandidateCollection>&);

//create the pf candidate to vertex association map
std::auto_ptr<PFCandToVertexAssMap> CreatePFCandToVertexMap(edm::Handle<reco::PFCandidateCollection>, const edm::EventSetup&);
Expand Down Expand Up @@ -68,4 +71,4 @@ class PFCand_AssoMapAlgos : public PF_PU_AssoMapAlgos {

};

#endif
#endif
8 changes: 7 additions & 1 deletion CommonTools/RecoUtils/interface/PFCand_NoPU_WithAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
// Original Author: Matthias Geisler,32 4-B20,+41227676487,
// Created: Thu Dec 1 16:07:41 CET 2011
// $Id: PFCand_NoPU_WithAM.h,v 1.2 2012/04/18 15:09:23 mgeisler Exp $
// $Id: PFCand_NoPU_WithAM.h,v 1.3 2012/11/21 09:40:40 mgeisler Exp $
//
//
#include <string>
Expand All @@ -32,6 +32,8 @@
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

#include "DataFormats/Candidate/interface/Candidate.h"

#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"

Expand Down Expand Up @@ -61,13 +63,17 @@ class PFCand_NoPU_WithAM : public edm::EDProducer {

// ----------member data ---------------------------

edm::InputTag input_SourceColl_;

edm::InputTag input_AssociationType_;

edm::InputTag input_VertexPFCandAssociationMap_;

edm::InputTag input_VertexCollection_;

int input_MinQuality_;
int negativeQuality_;

};


Expand Down
2 changes: 1 addition & 1 deletion CommonTools/RecoUtils/interface/PF_PU_AssoMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
//
// Original Author: Matthias Geisler,32 4-B20,+41227676487,
// $Id$
// $Id: PF_PU_AssoMap.h,v 1.8 2012/11/21 09:42:35 mgeisler Exp $
//
//

Expand Down
119 changes: 87 additions & 32 deletions CommonTools/RecoUtils/interface/PF_PU_AssoMapAlgos.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//

#include <string>
#include <vector>

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
Expand Down Expand Up @@ -46,6 +47,13 @@

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

#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
#include "RecoVertex/VertexTools/interface/VertexDistance3D.h"
#include "RecoVertex/VertexTools/interface/VertexDistanceXY.h"
#include "RecoVertex/VertexPrimitives/interface/ConvertToFromReco.h"
#include "RecoVertex/VertexPrimitives/interface/VertexState.h"

//
// constants, enums and typedefs
//
Expand All @@ -55,15 +63,42 @@ const double lamMass = 1.11568;

/*limits for the quality criteria*/

const double tw_90 = 1.e-2;
const double tw_70 = 1.e-1;
const double tw_50 = 2.e-1;
//track weight step
const double tw_1st_90_cum = 0.004;
const double tw_1st_50 = 0.5;

const double tw_2nd_f1_cum = 0.05;
const double tw_2nd_f3_cum = 0.05;
const double tw_2nd_fz_cum = 0.05;

//secondary vertices step
const double sc_1st_70_cum = 8.;
const double sc_1st_50 = 2.;

const double sc_2nd_f1_0_cum = 0.2;
const double sc_2nd_f3_0_cum = 0.3;
const double sc_2nd_fz_0_cum = 0.3;

const double sc_2nd_f1_1_cum = 0.7;
const double sc_2nd_f3_1_cum = 1.;
const double sc_2nd_fz_1_cum = 1.;

//final step
const double f1_1st_70_cum = 0.03;
const double f1_1st_50_cum = 0.2;

const double f3_1st_70_cum = 0.03;
const double f3_1st_50_cum = 40.;
const double f3_1st_50 = 0.1;

const double fz_1st_70_cum = 0.03;
const double fz_1st_50_cum = 40.;
const double fz_1st_50 = 0.1;

const double f3_2nd_f3_cum = 0.04;
const double fz_2nd_fz_cum = 0.04;

const double sec_70 = 5.;
const double sec_50 = 19.;

const double fin_70 = 1.e-1;
const double fin_50 = 3.e-1;

typedef edm::AssociationMap<edm::OneToManyWithQuality<reco::VertexCollection, reco::TrackCollection, int> > TrackToVertexAssMap;
typedef edm::AssociationMap<edm::OneToManyWithQuality<reco::TrackCollection, reco::VertexCollection, int> > VertexToTrackAssMap;
Expand All @@ -78,15 +113,24 @@ typedef std::pair<reco::VertexRef, TrackQualityPair> VertexTrackQuality;
typedef std::pair <reco::VertexRef, float> VertexPtsumPair;
typedef std::vector< VertexPtsumPair > VertexPtsumVector;

typedef std::pair<int, int> StepQualityPair;
typedef std::vector<StepQualityPair> StepQualityPairVector;

typedef std::pair<int, double> StepDistancePair;
typedef std::vector<StepDistancePair> StepDistancePairVector;

class PF_PU_AssoMapAlgos{

public:

//dedicated constructor for the algorithms
PF_PU_AssoMapAlgos(const edm::ParameterSet&);
PF_PU_AssoMapAlgos(const edm::ParameterSet&);

//dedicated destructor for the algorithms
virtual ~PF_PU_AssoMapAlgos();

//get all needed collections at the beginning
void GetInputCollections(edm::Event&, const edm::EventSetup&);
virtual void GetInputCollections(edm::Event&, const edm::EventSetup&);

//create the track to vertex association map
std::auto_ptr<TrackToVertexAssMap> CreateTrackToVertexMap(edm::Handle<reco::TrackCollection>, const edm::EventSetup&);
Expand All @@ -109,10 +153,10 @@ class PF_PU_AssoMapAlgos{
//find an association for a certain track
VertexStepPair FindAssociation(const reco::TrackRef&, std::vector<reco::VertexRef>*,
edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, int);
edm::Handle<reco::BeamSpot>, int);

//get the quality for a certain association
int DefineQuality(int, int, double);
int DefineQuality(StepDistancePairVector, int, double);

private:

Expand All @@ -124,44 +168,45 @@ class PF_PU_AssoMapAlgos{
//function to find the closest vertex in 3D for a certain track
static reco::VertexRef FindClosest3D(reco::TransientTrack, std::vector<reco::VertexRef>*, double tWeight = 0.);

//function to calculate the deltaR between a vector and a vector connecting two points
static double dR(const math::XYZPoint&, const math::XYZVector&, edm::Handle<reco::BeamSpot>);

//function to filter the conversion collection
static std::auto_ptr<reco::ConversionCollection> GetCleanedConversions(edm::Handle<reco::ConversionCollection>,
edm::Handle<reco::BeamSpot>, bool);
virtual std::auto_ptr<reco::ConversionCollection> GetCleanedConversions(edm::Handle<reco::ConversionCollection>, bool);

//function to find out if the track comes from a gamma conversion
static bool ComesFromConversion(const reco::TrackRef, const reco::ConversionCollection&, reco::Conversion*);

static reco::VertexRef FindConversionVertex(const reco::TrackRef, const reco::Conversion&,
edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, std::vector<reco::VertexRef>*, double);
static reco::VertexRef FindConversionVertex(const reco::TrackRef, const reco::Conversion&, edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, std::vector<reco::VertexRef>*, double);

//function to filter the Kshort collection
static std::auto_ptr<reco::VertexCompositeCandidateCollection> GetCleanedKshort(edm::Handle<reco::VertexCompositeCandidateCollection>, edm::Handle<reco::BeamSpot>, bool);
virtual std::auto_ptr<reco::VertexCompositeCandidateCollection> GetCleanedKshort(edm::Handle<reco::VertexCompositeCandidateCollection>, bool);

//function to filter the Lambda collection
static std::auto_ptr<reco::VertexCompositeCandidateCollection> GetCleanedLambda(edm::Handle<reco::VertexCompositeCandidateCollection>, edm::Handle<reco::BeamSpot>, bool);
virtual std::auto_ptr<reco::VertexCompositeCandidateCollection> GetCleanedLambda(edm::Handle<reco::VertexCompositeCandidateCollection>, bool);

//function to find out if the track comes from a V0 decay
static bool ComesFromV0Decay(const reco::TrackRef, const reco::VertexCompositeCandidateCollection&,
const reco::VertexCompositeCandidateCollection&, reco::VertexCompositeCandidate*);
static bool ComesFromV0Decay(const reco::TrackRef, const reco::VertexCompositeCandidateCollection&, reco::VertexCompositeCandidate*);

static reco::VertexRef FindV0Vertex(const reco::TrackRef, const reco::VertexCompositeCandidate&,
edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, std::vector<reco::VertexRef>*, double);
static reco::VertexRef FindV0Vertex(const reco::TrackRef, const reco::VertexCompositeCandidate&, edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, std::vector<reco::VertexRef>*, double);

//function to filter the nuclear interaction collection
static std::auto_ptr<reco::PFDisplacedVertexCollection> GetCleanedNI(edm::Handle<reco::PFDisplacedVertexCollection>, edm::Handle<reco::BeamSpot>, bool);
virtual std::auto_ptr<reco::PFDisplacedVertexCollection> GetCleanedNI(edm::Handle<reco::PFDisplacedVertexCollection>, bool);

//function to find out if the track comes from a nuclear interaction
static bool ComesFromNI(const reco::TrackRef, const reco::PFDisplacedVertexCollection&, reco::PFDisplacedVertex*);

static reco::VertexRef FindNIVertex(const reco::TrackRef, const reco::PFDisplacedVertex&,
edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, std::vector<reco::VertexRef>*, double);

static reco::VertexRef FindNIVertex(const reco::TrackRef, const reco::PFDisplacedVertex&, edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, std::vector<reco::VertexRef>*, double, reco::TransientTrack);

//function to filter the inclusive vertex finder collection
virtual std::auto_ptr<reco::VertexCollection> GetCleanedIVF(edm::Handle<reco::VertexCollection>, bool);

//function to find out if the track comes from a inclusive vertex
static bool ComesFromIVF(const reco::TrackRef, const reco::VertexCollection&, reco::Vertex*);

static reco::VertexRef FindIVFVertex(const reco::TrackRef, const reco::Vertex&, edm::ESHandle<MagneticField>, const edm::EventSetup&,
edm::Handle<reco::BeamSpot>, std::vector<reco::VertexRef>*, double);

//function to find the vertex with the highest TrackWeight for a certain track
static reco::VertexRef TrackWeightAssociation(const reco::TrackBaseRef&, std::vector<reco::VertexRef>*);

Expand Down Expand Up @@ -197,15 +242,25 @@ class PF_PU_AssoMapAlgos{
edm::Handle<reco::PFDisplacedVertexCollection> displVertexCollH;
std::auto_ptr<reco::PFDisplacedVertexCollection> cleanedNICollP;

edm::InputTag IFVVertexCollection_;
edm::Handle<reco::VertexCollection> ivfVertexCollH;
std::auto_ptr<reco::VertexCollection> cleanedIVFCollP;

int input_FinalAssociation_;

bool ignoremissingpfcollection_;
bool missingColls; // is true if there is a diplaced vertex collection in the event

double input_nTrack_;
double input_nTrack_z_;
double input_nTrack_3D_;

int maxNumWarnings_; // CV: print Warning if TrackExtra objects don't exist in input file,
int numWarnings_; // but only a few times


VertexDistanceXY distanceComputerXY;

VertexState BSVertexState;

};

Expand Down
64 changes: 33 additions & 31 deletions CommonTools/RecoUtils/plugins/PFCand_AssoMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// Original Author: Matthias Geisler
// Created: Wed Apr 18 14:48:37 CEST 2012
// $Id: PFCand_AssoMap.cc,v 1.5 2012/11/21 09:52:27 mgeisler Exp $
// $Id: PFCand_AssoMap.cc,v 1.6 2012/12/06 14:02:13 mgeisler Exp $
//
//
#include "CommonTools/RecoUtils/interface/PFCand_AssoMap.h"
Expand All @@ -35,27 +35,27 @@ PFCand_AssoMap::PFCand_AssoMap(const edm::ParameterSet& iConfig):PFCand_AssoMapA

//now do what ever other initialization is needed

input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");

input_PFCandidates_ = iConfig.getParameter<edm::InputTag>("PFCandidateCollection");
input_PFCandidates_ = iConfig.getParameter<edm::InputTag>("PFCandidateCollection");

//register your products

if ( input_AssociationType_.label() == "PFCandsToVertex" ) {
produces<PFCandToVertexAssMap>();
} else {
if ( input_AssociationType_.label() == "VertexToPFCands" ) {
produces<VertexToPFCandAssMap>();
} else {
if ( input_AssociationType_.label() == "Both" ) {
produces<PFCandToVertexAssMap>();
produces<VertexToPFCandAssMap>();
} else {
std::cout << "No correct InputTag for AssociationType!" << std::endl;
std::cout << "Won't produce any AssociationMap!" << std::endl;
}
}
}
if ( input_AssociationType_.label() == "PFCandsToVertex" ) {
produces<PFCandToVertexAssMap>();
} else {
if ( input_AssociationType_.label() == "VertexToPFCands" ) {
produces<VertexToPFCandAssMap>();
} else {
if ( input_AssociationType_.label() == "Both" ) {
produces<PFCandToVertexAssMap>();
produces<VertexToPFCandAssMap>();
} else {
edm::LogWarning("Prtcl2VtxAssociation") << "No correct InputTag for AssociationType!" << std::endl
<< "Won't produce any AssociationMap!" << std::endl;
}
}
}

}

Expand All @@ -78,23 +78,25 @@ PFCand_AssoMap::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
using namespace std;
using namespace reco;

//get the input pfCandidateCollection
Handle<PFCandidateCollection> pfCandH;
iEvent.getByLabel(input_PFCandidates_,pfCandH);
//get the input pfCandidateCollection
Handle<PFCandidateCollection> pfCandH;
iEvent.getByLabel(input_PFCandidates_,pfCandH);

string asstype = input_AssociationType_.label();
string asstype = input_AssociationType_.label();

PFCand_AssoMapAlgos::GetInputCollections(iEvent,iSetup);
PFCand_AssoMapAlgos::GetPFCandInputCollections(iEvent,iSetup);

PFCand_AssoMapAlgos::SetMotherPointer(pfCandH);

if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
auto_ptr<PFCandToVertexAssMap> PFCand2Vertex = CreatePFCandToVertexMap(pfCandH, iSetup);
iEvent.put( SortPFCandAssociationMap( &(*PFCand2Vertex) ) );
}
if ( ( asstype == "PFCandsToVertex" ) || ( asstype == "Both" ) ) {
auto_ptr<PFCandToVertexAssMap> PFCand2Vertex = CreatePFCandToVertexMap(pfCandH, iSetup);
iEvent.put( SortPFCandAssociationMap( &(*PFCand2Vertex) ) );
}

if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
auto_ptr<VertexToPFCandAssMap> Vertex2PFCand = CreateVertexToPFCandMap(pfCandH, iSetup);
iEvent.put( Vertex2PFCand );
}
if ( ( asstype == "VertexToPFCands" ) || ( asstype == "Both" ) ) {
auto_ptr<VertexToPFCandAssMap> Vertex2PFCand = CreateVertexToPFCandMap(pfCandH, iSetup);
iEvent.put( Vertex2PFCand );
}

}

Expand Down
Loading