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

MT MTV (and speedup) #4669

Merged
merged 13 commits into from Jul 21, 2014
4 changes: 2 additions & 2 deletions CommonTools/RecoAlgos/interface/TrackFullCloneSelectorBase.h
Expand Up @@ -17,7 +17,7 @@
#include <memory>
#include <algorithm>
#include <map>
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -33,7 +33,7 @@
namespace reco { namespace modules {

template<typename Selector>
class TrackFullCloneSelectorBase : public edm::EDProducer {
class TrackFullCloneSelectorBase : public edm::stream::EDProducer<> {
public:
/// constructor
explicit TrackFullCloneSelectorBase( const edm::ParameterSet & cfg ) :
Expand Down
Expand Up @@ -42,7 +42,7 @@
#include "DataFormats/Common/interface/DetSetVector.h"

//--- Framework
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"

Expand All @@ -59,7 +59,7 @@
class MagneticField;
namespace cms
{
class SiPixelRecHitConverter : public edm::EDProducer
class SiPixelRecHitConverter : public edm::stream::EDProducer<>
{
public:
//--- Constructor, virtual destructor (just in case)
Expand Down
@@ -1,11 +1,11 @@
#ifndef SiStripRecHitConverter_h
#define SiStripRecHitConverter_h

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitConverterAlgorithm.h"

class SiStripRecHitConverter : public edm::EDProducer
class SiStripRecHitConverter : public edm::stream::EDProducer<>
{

public:
Expand Down
31 changes: 21 additions & 10 deletions SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h
Expand Up @@ -6,8 +6,8 @@
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/Math/interface/LorentzVector.h"
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

//
// Forward declarations
Expand Down Expand Up @@ -88,10 +88,12 @@ class TrackingParticle
tv_iterator decayVertices_end() const;


int charge() const; ///< @brief Electric charge. Note this is taken from the first SimTrack only.
int threeCharge() const; ///< @brief Kept for backwards compatibility. Gives 3*charge(), don't know why.
const LorentzVector& p4() const; ///< @brief Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
///< @brief Electric charge. Note this is taken from the first SimTrack only.
float charge() const { return g4Tracks_[0].charge(); }
///< Gives charge in unit of quark charge (should be 3 time the abaove)
int threeCharge() const { return lrintf(3.f*charge()); }

const LorentzVector& p4() const; ///< @brief Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.

Vector momentum() const; ///< spatial momentum vector

Expand All @@ -113,36 +115,45 @@ class TrackingParticle
double eta() const; ///< @brief Momentum pseudorapidity. Note this is taken from the first SimTrack only.
double rapidity() const; ///< @brief Rapidity. Note this is taken from the first SimTrack only.
double y() const; ///< @brief Same as rapidity().
Point vertex() const; ///< @brief Parent vertex position

///< @brief Parent vertex position
Point vertex() const {
const TrackingVertex::LorentzVector & p = (*parentVertex_).position();
return Point(p.x(),p.y(),p.z());
}

double vx() const; ///< @brief x coordinate of parent vertex position
double vy() const; ///< @brief y coordinate of parent vertex position
double vz() const; ///< @brief z coordinate of parent vertex position
/** @brief Status word.
*
* Returns status() from the first gen particle, or -99 if there are no gen particles attached. */
int status() const;
int status() const {
return genParticles_.empty() ? -99 : (*genParticles_[0]).status();
}

static const unsigned int longLivedTag; ///< long lived flag

bool longLived() const; ///< is long lived?
///< is long lived?
bool longLived() const { return status()&longLivedTag;}

/** @brief Gives the total number of hits, including muon hits. Hits on overlaps in the same layer count separately.
*
* Equivalent to trackPSimHit().size() in the old TrackingParticle implementation. */
int numberOfHits() const;
int numberOfHits() const {return numberOfHits_;}

/** @brief The number of hits in the tracker. Hits on overlaps in the same layer count separately.
*
* Equivalent to trackPSimHit(DetId::Tracker).size() in the old TrackingParticle implementation. */
int numberOfTrackerHits() const;
int numberOfTrackerHits() const {return numberOfTrackerHits_;}

/** @deprecated The number of hits in the tracker but taking account of overlaps.
* Deprecated in favour of the more aptly named numberOfTrackerLayers(). */
int matchedHit() const;
/** @brief The number of tracker layers with a hit.
*
* Different from numberOfTrackerHits because this method counts multiple hits on overlaps in the layer as one hit. */
int numberOfTrackerLayers() const;
int numberOfTrackerLayers() const {return numberOfTrackerLayers_;}

void setNumberOfHits( int numberOfHits );
void setNumberOfTrackerHits( int numberOfTrackerHits );
Expand Down
44 changes: 3 additions & 41 deletions SimDataFormats/TrackingAnalysis/src/TrackingParticle.cc
Expand Up @@ -24,13 +24,13 @@ TrackingParticle::~TrackingParticle()

int TrackingParticle::pdgId() const
{
if( genParticles_.empty() ) return g4Tracks_.at( 0 ).type();
if( genParticles_.empty() ) return g4Tracks_[0].type();
else return (*genParticles_.begin())->pdgId();
}

EncodedEventId TrackingParticle::eventId() const
{
return g4Tracks_.at( 0 ).eventId();
return g4Tracks_[0].eventId();
}

void TrackingParticle::addGenParticle( const reco::GenParticleRef& ref )
Expand Down Expand Up @@ -113,19 +113,10 @@ tv_iterator TrackingParticle::decayVertices_end() const
return decayVertices_.end();
}

int TrackingParticle::charge() const
{
return g4Tracks_.at( 0 ).charge();
}

int TrackingParticle::threeCharge() const
{
return g4Tracks_.at( 0 ).charge()*3;
}

const TrackingParticle::LorentzVector& TrackingParticle::p4() const
{
return g4Tracks_.at( 0 ).momentum();
return g4Tracks_[0].momentum();
}

TrackingParticle::Vector TrackingParticle::momentum() const
Expand Down Expand Up @@ -218,11 +209,6 @@ double TrackingParticle::y() const
return rapidity();
}

TrackingParticle::Point TrackingParticle::vertex() const
{
return Point( vx(), vy(), vz() );
}

double TrackingParticle::vx() const
{
const TrackingVertex& r=( *parentVertex_);
Expand All @@ -241,37 +227,13 @@ double TrackingParticle::vz() const
return r.position().Z();
}

int TrackingParticle::status() const
{
if( genParticles_.empty() ) return -99; // Use the old invalid status flag that used to be set by TrackingTruthProducer.
else return (*genParticles_.begin())->status();
}

bool TrackingParticle::longLived() const
{
return status()&longLivedTag;
}

int TrackingParticle::numberOfHits() const
{
return numberOfHits_;
}

int TrackingParticle::numberOfTrackerHits() const
{
return numberOfTrackerHits_;
}

int TrackingParticle::matchedHit() const
{
edm::LogWarning("TrackingParticle") << "The method matchedHit() has been deprecated. Use numberOfTrackerLayers() instead.";
return numberOfTrackerLayers_;
}

int TrackingParticle::numberOfTrackerLayers() const
{
return numberOfTrackerLayers_;
}

void TrackingParticle::setNumberOfHits( int numberOfHits )
{
Expand Down
37 changes: 21 additions & 16 deletions SimTracker/Common/interface/TrackingParticleSelector.h
Expand Up @@ -10,6 +10,7 @@
*/
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/Math/interface/PtEtaPhiMass.h"

class TrackingParticleSelector {

Expand All @@ -23,15 +24,19 @@ class TrackingParticleSelector {

/// Operator() performs the selection: e.g. if (tPSelector(tp)) {...}
bool operator()( const TrackingParticle & tp ) const {
auto pdgid = tp.pdgId();
if (chargedOnly_ && tp.charge()==0) return false;//select only if charge!=0

bool testId = false;
unsigned int idSize = pdgId_.size();
if (idSize==0) testId = true;
else for (unsigned int it=0;it!=idSize;++it){
if (tp.pdgId()==pdgId_[it]) testId = true;
if (pdgid==pdgId_[it]) { testId = true; break;}
}

bool signal = true;
if (signalOnly_) signal = (tp.eventId().bunchCrossing()== 0 && tp.eventId().event() == 0); // signal only means no PU particles

// select only stable particles
bool stable = true;
if (stableOnly_) {
Expand All @@ -40,32 +45,32 @@ class TrackingParticleSelector {
} else {
for( TrackingParticle::genp_iterator j = tp.genParticle_begin(); j != tp.genParticle_end(); ++ j ) {
if (j->get()==0 || j->get()->status() != 1) {
stable = 0; break;
stable = false; break;
}
}
// test for remaining unstabled due to lack of genparticle pointer
if(stable == 1 && tp.status() == -99 &&
(fabs(tp.pdgId()) != 11 && fabs(tp.pdgId()) != 13 && fabs(tp.pdgId()) != 211 &&
fabs(tp.pdgId()) != 321 && fabs(tp.pdgId()) != 2212 && fabs(tp.pdgId()) != 3112 &&
fabs(tp.pdgId()) != 3222 && fabs(tp.pdgId()) != 3312 && fabs(tp.pdgId()) != 3334)) stable = 0;
if( (stable & (tp.status() == -99) ) &&
(std::abs(pdgid) != 11 && std::abs(pdgid) != 13 && std::abs(pdgid) != 211 &&
std::abs(pdgid) != 321 && std::abs(pdgid) != 2212 && std::abs(pdgid) != 3112 &&
std::abs(pdgid) != 3222 && std::abs(pdgid) != 3312 && std::abs(pdgid) != 3334)) stable = false;
}
}

auto etaOk = [&](const TrackingParticle::Vector& p)->bool{ float eta= etaFromXYZ(p.x(),p.y(),p.z()); return (eta>= minRapidity_) & (eta<=maxRapidity_);};
return (
tp.numberOfTrackerLayers() >= minHit_ &&
sqrt(tp.momentum().perp2()) >= ptMin_ &&
tp.momentum().eta() >= minRapidity_ && tp.momentum().eta() <= maxRapidity_ &&
sqrt(tp.vertex().perp2()) <= tip_ &&
fabs(tp.vertex().z()) <= lip_ &&
testId &&
signal &&
stable
(testId & signal & stable) &&
tp.numberOfTrackerLayers() >= minHit_ &&
tp.momentum().perp2() >= ptMin_*ptMin_ &&
etaOk(tp.momentum()) &&
std::abs(tp.vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty necessary...
tp.vertex().perp2() <= tip_*tip_
);
}

private:
double ptMin_;
double minRapidity_;
double maxRapidity_;
float minRapidity_;
float maxRapidity_;
double tip_;
double lip_;
int minHit_;
Expand Down
Expand Up @@ -2,7 +2,7 @@
#define SimTracker_TrackerHitAssociation_ClusterTPAssociationProducer_h

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
Expand All @@ -21,7 +21,7 @@

class EncodedEventId;

class ClusterTPAssociationProducer : public edm::EDProducer
class ClusterTPAssociationProducer : public edm::stream::EDProducer<>
{
public:
//typedef std::pair<uint32_t, EncodedEventId> SimTrackIdentifier;
Expand Down
2 changes: 1 addition & 1 deletion Validation/RecoTrack/interface/MultiTrackValidator.h
Expand Up @@ -12,7 +12,7 @@
#include "Validation/RecoTrack/interface/MTVHistoProducerAlgo.h"


class MultiTrackValidator : public thread_unsafe::DQMEDAnalyzer, protected MultiTrackValidatorBase {
class MultiTrackValidator : public DQMEDAnalyzer, protected MultiTrackValidatorBase {
public:
/// Constructor
MultiTrackValidator(const edm::ParameterSet& pset);
Expand Down