Skip to content

Commit

Permalink
Merge pull request #16619 from gpetruc/PFCandidate_time_81X
Browse files Browse the repository at this point in the history
Timing information in PF
  • Loading branch information
davidlange6 committed Nov 23, 2016
2 parents bebeae9 + 440627f commit 263a7e9
Show file tree
Hide file tree
Showing 29 changed files with 370 additions and 172 deletions.
14 changes: 14 additions & 0 deletions DataFormats/ParticleFlowCandidate/interface/PFCandidate.h
Expand Up @@ -414,6 +414,15 @@ namespace reco {
virtual double vy() const {return vertex().y();}
virtual double vz() const {return vertex().z();}

/// do we have a valid time information
bool isTimeValid() const { return timeError_ >= 0.f; }
/// \return the timing
float time() const { return time_; }
/// \return the timing uncertainty
float timeError() const { return timeError_; }
/// \set the timing information
void setTime(float time, float timeError = 0.f) { time_ = time; timeError_ = timeError; }

private:
/// Polymorphic overlap
virtual bool overlap( const Candidate & ) const;
Expand Down Expand Up @@ -510,6 +519,11 @@ namespace reco {
std::vector<unsigned long long> refsInfo_;
std::vector<const void *> refsCollectionCache_;

/// timing information (valid if timeError_ >= 0)
float time_;
/// timing information uncertainty (<0 if timing not available)
float timeError_;

};

/// particle ID component tag
Expand Down
11 changes: 8 additions & 3 deletions DataFormats/ParticleFlowCandidate/src/PFCandidate.cc
Expand Up @@ -48,7 +48,8 @@ PFCandidate::PFCandidate() :
mva_nothing_gamma_(bigMva_),
mva_nothing_nh_(bigMva_),
mva_gamma_nh_(bigMva_),
getter_(0),storedRefsBitPattern_(0)
getter_(0),storedRefsBitPattern_(0),
time_(0.f),timeError_(-1.f)
{

muonTrackType_ = reco::Muon::None;
Expand Down Expand Up @@ -89,7 +90,8 @@ PFCandidate::PFCandidate( Charge charge,
mva_nothing_gamma_(bigMva_),
mva_nothing_nh_(bigMva_),
mva_gamma_nh_(bigMva_),
getter_(0),storedRefsBitPattern_(0)
getter_(0),storedRefsBitPattern_(0),
time_(0.f),timeError_(-1.f)
{
refsInfo_.reserve(3);
blocksStorage_.reserve(10);
Expand Down Expand Up @@ -152,7 +154,8 @@ PFCandidate::PFCandidate( PFCandidate const& iOther) :
getter_(iOther.getter_),
storedRefsBitPattern_(iOther.storedRefsBitPattern_),
refsInfo_(iOther.refsInfo_),
refsCollectionCache_(iOther.refsCollectionCache_)
refsCollectionCache_(iOther.refsCollectionCache_),
time_(iOther.time_),timeError_(iOther.timeError_)
{
auto tmp = iOther.elementsInBlocks_.load(std::memory_order_acquire);
if(nullptr != tmp) {
Expand Down Expand Up @@ -195,6 +198,8 @@ PFCandidate& PFCandidate::operator=(PFCandidate const& iOther) {
storedRefsBitPattern_=iOther.storedRefsBitPattern_;
refsInfo_=iOther.refsInfo_;
refsCollectionCache_=iOther.refsCollectionCache_;
time_=iOther.time_;
timeError_=iOther.timeError_;

return *this;
}
Expand Down
9 changes: 6 additions & 3 deletions DataFormats/ParticleFlowCandidate/src/classes_def.xml
@@ -1,6 +1,7 @@
<lcgdict>

<class name="reco::PFCandidate" ClassVersion="17">
<class name="reco::PFCandidate" ClassVersion="18">
<version ClassVersion="18" checksum="910857761"/>
<version ClassVersion="17" checksum="3126170233"/>
<version ClassVersion="16" checksum="3060382005"/>
<version ClassVersion="15" checksum="1136968957"/>
Expand Down Expand Up @@ -48,7 +49,8 @@
<class name="edm::ValueMap<edm::Ptr<reco::PFCandidate> >"/>
<class name="edm::reftobase::RefVectorHolder<reco::PFCandidateRefVector >"/>

<class name="reco::IsolatedPFCandidate" ClassVersion="13">
<class name="reco::IsolatedPFCandidate" ClassVersion="14">
<version ClassVersion="14" checksum="207328514"/>
<version ClassVersion="13" checksum="1855164250"/>
<version ClassVersion="12" checksum="2650360086"/>
<version ClassVersion="11" checksum="696008414"/>
Expand All @@ -61,7 +63,8 @@
<class name="reco::IsolatedPFCandidateRefVector"/>
<class name="reco::IsolatedPFCandidatePtr"/>

<class name="reco::PileUpPFCandidate" ClassVersion="13">
<class name="reco::PileUpPFCandidate" ClassVersion="14">
<version ClassVersion="14" checksum="4065938015"/>
<version ClassVersion="13" checksum="1734488695"/>
<version ClassVersion="12" checksum="2377890195"/>
<version ClassVersion="11" checksum="1422984859"/>
Expand Down
18 changes: 17 additions & 1 deletion DataFormats/ParticleFlowReco/interface/PFBlockElement.h
Expand Up @@ -60,7 +60,9 @@ namespace reco {
PFBlockElement(Type type=NONE) :
type_(type),
locked_(false),
index_( static_cast<unsigned>(-1) ) {
index_( static_cast<unsigned>(-1) ),
time_(0.f), timeError_(-1.f)
{
}


Expand Down Expand Up @@ -134,6 +136,15 @@ namespace reco {
const PFMultilinksType& getMultilinks() const {return multilinks_.linkedClusters;}
// ! Glowinski & Gouzevitch

/// do we have a valid time information
bool isTimeValid() const { return timeError_ >= 0.f; }
/// \return the timing
float time() const { return time_; }
/// \return the timing uncertainty
float timeError() const { return timeError_; }
/// \set the timing information
void setTime(float time, float timeError = 0.f) { time_ = time; timeError_ = timeError; }

protected:

/// type, see PFBlockElementType
Expand All @@ -151,6 +162,11 @@ namespace reco {
// Glowinski & Gouzevitch
PFMultiLinksTC multilinks_;
// ! Glowinski & Gouzevitch

/// timing information (valid if timeError_ >= 0)
float time_;
/// timing information uncertainty (<0 if timing not available)
float timeError_;

const static reco::TrackRef nullTrack_;
const static PFRecTrackRef nullPFRecTrack_;
Expand Down
12 changes: 8 additions & 4 deletions DataFormats/ParticleFlowReco/interface/PFCluster.h
Expand Up @@ -81,12 +81,16 @@ namespace reco {
/// cluster energy
double energy() const {return energy_;}

/// cluster time
double time() const {return time_;}
/// \return cluster time
float time() const {return time_;}
/// \return the timing uncertainty
float timeError() const { return timeError_; }

/// cluster depth
double depth() const {return depth_;}

void setTime(double time) {time_ = time;}
void setTime(float time, float timeError=0) {time_ = time; timeError_ = timeError; }
void setTimeError(float timeError) { timeError_ = timeError; }
void setDepth(double depth) {depth_ = depth;}

/// cluster position: rho, eta, phi
Expand Down Expand Up @@ -180,7 +184,7 @@ namespace reco {
REPPoint posrep_;

///Michalis :Add timing and depth information
double time_;
float time_, timeError_;
double depth_;

/// transient layer
Expand Down
21 changes: 14 additions & 7 deletions DataFormats/ParticleFlowReco/src/classes_def_2.xml
@@ -1,7 +1,8 @@
<lcgdict>
<selection>

<class name="reco::PFCluster" ClassVersion="16">
<class name="reco::PFCluster" ClassVersion="17">
<version ClassVersion="17" checksum="3021111509"/>
<version ClassVersion="16" checksum="1786894710"/>
<version ClassVersion="15" checksum="1837961152"/>
<version ClassVersion="14" checksum="3610074122"/>
Expand Down Expand Up @@ -124,7 +125,8 @@
<class name="std::vector<reco::PFSimParticle>"/>
<class name="edm::Wrapper<std::vector<reco::PFSimParticle> >"/>

<class name="reco::PFBlockElement" ClassVersion="12">
<class name="reco::PFBlockElement" ClassVersion="13">
<version ClassVersion="13" checksum="4257111441"/>
<version ClassVersion="12" checksum="3101496393"/>
<version ClassVersion="11" checksum="3944635097"/>
<!-- <field name="multilinkslinks_" transient="true"/> -->
Expand All @@ -140,7 +142,8 @@
<class name="edm::OwnVector<reco::PFBlockElement, edm::ClonePolicy<reco::PFBlockElement> >"/>
<class name="edm::Wrapper<edm::OwnVector<reco::PFBlockElement, edm::ClonePolicy<reco::PFBlockElement> > >" />

<class name="reco::PFBlockElementTrack" ClassVersion="13">
<class name="reco::PFBlockElementTrack" ClassVersion="14">
<version ClassVersion="14" checksum="3952424659"/>
<version ClassVersion="13" checksum="1449646331"/>
<version ClassVersion="12" checksum="417575083"/>
<version ClassVersion="10" checksum="2342660248"/>
Expand All @@ -150,7 +153,8 @@
-->
</class>

<class name="reco::PFBlockElementGsfTrack" ClassVersion="12">
<class name="reco::PFBlockElementGsfTrack" ClassVersion="13">
<version ClassVersion="13" checksum="2453155267"/>
<version ClassVersion="12" checksum="1521047275"/>
<version ClassVersion="11" checksum="1367777435"/>
<version ClassVersion="10" checksum="549349370"/>
Expand All @@ -160,7 +164,8 @@
-->
</class>

<class name="reco::PFBlockElementBrem" ClassVersion="12">
<class name="reco::PFBlockElementBrem" ClassVersion="13">
<version ClassVersion="13" checksum="157699540"/>
<version ClassVersion="12" checksum="112730380"/>
<version ClassVersion="11" checksum="2362699420"/>
<version ClassVersion="10" checksum="2231967579"/>
Expand All @@ -171,7 +176,8 @@
</class>


<class name="reco::PFBlockElementCluster" ClassVersion="13">
<class name="reco::PFBlockElementCluster" ClassVersion="14">
<version ClassVersion="14" checksum="407383072"/>
<version ClassVersion="13" checksum="775826696"/>
<version ClassVersion="12" checksum="1263691576"/>
<version ClassVersion="10" checksum="2503385411"/>
Expand Down Expand Up @@ -284,7 +290,8 @@
<class name="edm::Wrapper<edm::ValueMap<reco::PreIdRef> >"/>
<class name="edm::Ref<std::vector<reco::PreId>,reco::PreId,edm::refhelper::FindUsingAdvance<std::vector<reco::PreId>,reco::PreId> >" />

<class name="reco::PFBlockElementSuperCluster" ClassVersion="13">
<class name="reco::PFBlockElementSuperCluster" ClassVersion="14">
<version ClassVersion="14" checksum="285242772"/>
<version ClassVersion="13" checksum="3749373244"/>
<version ClassVersion="12" checksum="1656578540"/>
<version ClassVersion="10" checksum="456156271"/>
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/PatCandidates/src/classes_def_objects.xml
Expand Up @@ -264,7 +264,8 @@
<version ClassVersion="11" checksum="3492108938"/>
<version ClassVersion="10" checksum="417284221"/>
</class>
<class name="pat::PFParticle" ClassVersion="13">
<class name="pat::PFParticle" ClassVersion="14">
<version ClassVersion="14" checksum="2795911745"/>
<version ClassVersion="13" checksum="223824921"/>
<version ClassVersion="12" checksum="4118931093"/>
<version ClassVersion="11" checksum="2923110109"/>
Expand Down
31 changes: 31 additions & 0 deletions FWCore/ParameterSet/python/Config.py
Expand Up @@ -2085,6 +2085,37 @@ def _mod_fred(obj):
p.a = EDAnalyzer("MyAnalyzer", flintstones = PSet(fred = PSet(wilma = int32(1))))
self.assertRaises(KeyError, lambda: m1.toModify(p.a, flintstones = dict(imnothere = dict(wilma=2))))
self.assertRaises(KeyError, lambda: m1.toModify(p.a, foo = 1))
#test setting a value in a VPSet
m1 = Modifier()
p = Process("test",m1)
p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
m1.toModify(p.a, flintstones = {1:dict(wilma = int32(2))})
self.assertEqual(p.a.flintstones[0].fred.value(),1)
self.assertEqual(p.a.flintstones[1].wilma.value(),2)
#test setting a value in a list of values
m1 = Modifier()
p = Process("test",m1)
p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
m1.toModify(p.a, fred = {1:7})
self.assertEqual(p.a.fred[0],1)
self.assertEqual(p.a.fred[1],7)
self.assertEqual(p.a.fred[2],3)
#test IndexError setting a value in a list to an item key not in the list
m1 = Modifier()
p = Process("test",m1)
p.a = EDAnalyzer("MyAnalyzer", fred = vuint32(1,2,3))
raised = False
try: m1.toModify(p.a, fred = {5:7})
except IndexError, e: raised = True
self.assertEqual(raised, True)
#test TypeError setting a value in a list using a key that is not an int
m1 = Modifier()
p = Process("test",m1)
p.a = EDAnalyzer("MyAnalyzer", flintstones = VPSet(PSet(fred = int32(1)), PSet(wilma = int32(1))))
raised = False
try: m1.toModify(p.a, flintstones = dict(bogus = int32(37)))
except TypeError, e: raised = True
self.assertEqual(raised, True)
#test that load causes process wide methods to run
def _rem_a(proc):
del proc.a
Expand Down
18 changes: 15 additions & 3 deletions FWCore/ParameterSet/python/Mixins.py
Expand Up @@ -623,13 +623,25 @@ def _modifyParametersFromDict(params, newParams, errorRaiser, keyDepth=""):
p =pset.parameters_()
_modifyParametersFromDict(p,
value,errorRaiser,
keyDepth+"."+key)
("%s.%s" if type(key)==str else "%s[%s]")%(keyDepth,key))
for k,v in p.iteritems():
setattr(pset,k,v)
elif isinstance(params[key],_ValidatingParameterListBase):
if any(type(k) != int for k in value.keys()):
raise TypeError("Attempted to change a list using a dict whose keys are not integers")
plist = params[key]
if any((k < 0 or k >= len(plist)) for k in value.keys()):
raise IndexError("Attempted to set an index which is not in the list")
p = dict(enumerate(plist))
_modifyParametersFromDict(p,
value,errorRaiser,
("%s.%s" if type(key)==str else "%s[%s]")%(keyDepth,key))
for k,v in p.iteritems():
plist[k] = v
else:
raise ValueError("Attempted to change non PSet value "+keyDepth+" using a dictionary")
elif isinstance(value,_ParameterTypeBase):
params[key] =value
elif isinstance(value,_ParameterTypeBase) or (type(key) == int):
params[key] = value
else:
params[key].setValue(value)
else:
Expand Down
16 changes: 15 additions & 1 deletion PhysicsTools/HepMCCandAlgos/plugins/GenParticleProducer.cc
Expand Up @@ -86,6 +86,7 @@ using namespace HepMC;

static const int PDGCacheMax = 32768;
static const double mmToCm = 0.1;
static const double mmToNs = 1.0/299792458e-6;

GenParticleProducer::GenParticleProducer( const ParameterSet & cfg ) :
firstEvent_(true),
Expand All @@ -96,6 +97,8 @@ GenParticleProducer::GenParticleProducer( const ParameterSet & cfg ) :
useCF_(cfg.getUntrackedParameter<bool>( "useCrossingFrame", false ))
{
produces<GenParticleCollection>();
produces<math::XYZPointF>("xyz0");
produces<float>("t0");
if( saveBarCodes_ ) {
std::string alias( cfg.getParameter<std::string>( "@module_label" ) );
produces<vector<int> >().setBranchAlias( alias + "BarCodes" );
Expand Down Expand Up @@ -178,6 +181,8 @@ void GenParticleProducer::produce( Event& evt, const EventSetup& es ) {
vector<const HepMC::GenParticle *> particles( size );
auto candsPtr = std::make_unique<GenParticleCollection>(size);
auto barCodeVector = std::make_unique<vector<int>>(size);
std::unique_ptr<math::XYZPointF> xyz0Ptr(new math::XYZPointF(0.,0.,0.));
std::unique_ptr<float> t0Ptr(new float(0.f));
ref_ = evt.getRefBeforePut<GenParticleCollection>();
GenParticleCollection & cands = * candsPtr;
size_t offset = 0;
Expand All @@ -196,6 +201,11 @@ void GenParticleProducer::produce( Event& evt, const EventSetup& es ) {
if(hi && hi->Ncoll_hard() > 1) isHI = true;
size_t num_particles = mc->particles_size();
LogDebug("GenParticleProducer")<<"num_particles : "<<num_particles<<endl;
if (ipile == 0) {
auto origin = (*mc->vertices_begin())->position();
xyz0Ptr->SetXYZ(origin.x() * mmToCm, origin.y() * mmToCm, origin.z() * mmToCm);
*t0Ptr = origin.t() * mmToNs;
}
fillIndices(mc, particles, *barCodeVector, offset);
// fill output collection and save association
for( size_t ipar = offset; ipar < offset + num_particles; ++ ipar ) {
Expand Down Expand Up @@ -236,6 +246,9 @@ void GenParticleProducer::produce( Event& evt, const EventSetup& es ) {
offset += num_particles;
}
}else{
auto origin = (*mc->vertices_begin())->position();
xyz0Ptr->SetXYZ(origin.x() * mmToCm, origin.y() * mmToCm, origin.z() * mmToCm);
*t0Ptr = origin.t() * mmToNs;
fillIndices(mc, particles, *barCodeVector, 0);

// fill output collection and save association
Expand All @@ -260,7 +273,8 @@ void GenParticleProducer::produce( Event& evt, const EventSetup& es ) {
evt.put(std::move(candsPtr));
if(saveBarCodes_) evt.put(std::move(barCodeVector));
if(cfhepmcprod) delete cfhepmcprod;

evt.put(std::move(xyz0Ptr),"xyz0");
evt.put(std::move(t0Ptr),"t0");
}

bool GenParticleProducer::convertParticle(reco::GenParticle& cand, const HepMC::GenParticle * part){
Expand Down
3 changes: 3 additions & 0 deletions PhysicsTools/PatAlgos/plugins/PileupSummaryInfoSlimmer.cc
Expand Up @@ -37,6 +37,7 @@ void PileupSummaryInfoSlimmer::produce(edm::StreamID,
const float TrueNumInteractions = psu.getTrueNumInteractions();

std::vector<float> zpositions;
std::vector<float> times;
std::vector<float> sumpT_lowpT;
std::vector<float> sumpT_highpT;
std::vector<int> ntrks_lowpT;
Expand All @@ -50,6 +51,7 @@ void PileupSummaryInfoSlimmer::produce(edm::StreamID,

if( keep_details ) {
zpositions = psu.getPU_zpositions();
times = psu.getPU_times();
sumpT_lowpT = psu.getPU_sumpT_lowpT();
sumpT_highpT = psu.getPU_sumpT_highpT();
ntrks_lowpT = psu.getPU_ntrks_lowpT();
Expand All @@ -60,6 +62,7 @@ void PileupSummaryInfoSlimmer::produce(edm::StreamID,
// insert the slimmed vertex info
output->emplace_back(num_PU_vertices,
zpositions,
times,
sumpT_lowpT, sumpT_highpT,
ntrks_lowpT, ntrks_highpT,
eventInfo,
Expand Down

0 comments on commit 263a7e9

Please sign in to comment.