CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

TruthTauDecayModeProducer Class Reference

#include <TruthTauDecayModeProducer.cc>

Inheritance diagram for TruthTauDecayModeProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Classes

struct  tauObjectsHolder

Public Member Functions

 TruthTauDecayModeProducer (const edm::ParameterSet &)
 ~TruthTauDecayModeProducer ()

Private Member Functions

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

Private Attributes

AddFourMomenta addP4
bool iAmSignal_
edm::InputTag inputTag_
double leadTrackEtaCut_
double leadTrackPtCut_
double totalEtaCut_
double totalPtCut_

Detailed Description

Description: Produces reco::PFTauDecayModes corresponding to MonteCarlo objects For signal, it uses decayed MC taus For background, it uses GenJets

Implementation: <Notes on="" implementation>="">

Definition at line 44 of file TruthTauDecayModeProducer.cc.


Constructor & Destructor Documentation

TruthTauDecayModeProducer::TruthTauDecayModeProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 69 of file TruthTauDecayModeProducer.cc.

References edm::ParameterSet::getParameter(), iAmSignal_, inputTag_, leadTrackEtaCut_, leadTrackPtCut_, totalEtaCut_, and totalPtCut_.

{
   edm::LogInfo("TruthTauDecayModeProducer") << "Initializing ctor of TruthTauDecayModeProducer";
   iAmSignal_           = iConfig.getParameter<bool>("iAmSignal");
   inputTag_            = iConfig.getParameter<edm::InputTag>("inputTag");
   leadTrackPtCut_      = iConfig.getParameter<double>("leadTrackPtCut");
   leadTrackEtaCut_     = iConfig.getParameter<double>("leadTrackEtaCut");
   totalPtCut_          = iConfig.getParameter<double>("totalPtCut");
   totalEtaCut_         = iConfig.getParameter<double>("totalEtaCut");
   //register your products
   edm::LogInfo("TruthTauDecayModeProducer") << "Registering products";
   produces<std::vector<reco::PFTauDecayMode> >();
   edm::LogInfo("TruthTauDecayModeProducer") << "TruthTauDecayModeProducer initialized";
}
TruthTauDecayModeProducer::~TruthTauDecayModeProducer ( )

Definition at line 85 of file TruthTauDecayModeProducer.cc.

{
}

Member Function Documentation

void TruthTauDecayModeProducer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 213 of file TruthTauDecayModeProducer.cc.

{
}
void TruthTauDecayModeProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 219 of file TruthTauDecayModeProducer.cc.

                                  {
}
void TruthTauDecayModeProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 90 of file TruthTauDecayModeProducer.cc.

References abs, reco::CompositeCandidate::addDaughter(), addP4, TruthTauDecayModeProducer::tauObjectsHolder::chargedObjects, edm::Event::getByLabel(), GeneratorTau::getGenChargedPions(), GeneratorTau::getGenNeutralPions(), iAmSignal_, GeneratorTau::init(), inputTag_, GeneratorTau::isFinalStateTau(), leadTrackEtaCut_, leadTrackPtCut_, TruthTauDecayModeProducer::tauObjectsHolder::neutralObjects, reco::LeafCandidate::p4(), benchmark_cfg::pdgId, edm::Event::put(), dt_dqm_sourceclient_common_cff::reco, AddFourMomenta::set(), reco::PFTauDecayMode::setPFTauRef(), totalEtaCut_, and totalPtCut_.

{
   using namespace edm;
   using namespace std;
   using namespace reco;

   std::vector<tauObjectsHolder> tausToAdd_;

   /* **********************************************
    * **********  True Tau Case          ***********
    * ********************************************** */
   if (iAmSignal_)
   {
      edm::Handle<RefToBaseVector<reco::Candidate> > decayedMCTaus;
      iEvent.getByLabel(inputTag_, decayedMCTaus);
      for(edm::RefToBaseVector<reco::Candidate>::const_iterator iterGen = decayedMCTaus->begin();
            iterGen != decayedMCTaus->end();
            ++iterGen)
      {
         //copy into custom format (this casting is bullshit)
         GeneratorTau tempTau = static_cast<const GenParticle&>(*(*iterGen));
         //LogInfo("MCTauCandidateProducer") << "Generator tau produced, initializing.. ";
         tempTau.init();
         //LogInfo("MCTauCandidateProducer") << "GenTau initialization done";
         if (tempTau.isFinalStateTau())
         {
            // Build a Tau Candidate from the information contained in the parsing class
            tauObjectsHolder tempTauHolder;
            tempTauHolder.chargedObjects = tempTau.getGenChargedPions();
            tempTauHolder.neutralObjects = tempTau.getGenNeutralPions();
            tausToAdd_.push_back(tempTauHolder);
         }
      }
   } else
   {
   /* **********************************************
    * **********  QCD Case               ***********
    * ********************************************** */
      edm::Handle<GenJetCollection> genJets;
      iEvent.getByLabel(inputTag_, genJets);
      for(GenJetCollection::const_iterator aGenJet = genJets->begin(); aGenJet != genJets->end(); ++aGenJet)
      {
         // get all constituents
         std::vector<const GenParticle*> theJetConstituents = aGenJet->getGenConstituents();

         tauObjectsHolder tempTauHolder;
         // filter the constituents
         for( std::vector<const GenParticle*>::const_iterator aCandidate = theJetConstituents.begin();
               aCandidate != theJetConstituents.end();
               ++aCandidate)
         {
            int pdgId = std::abs((*aCandidate)->pdgId());
            const Candidate* theCandidate = static_cast<const Candidate*>(*aCandidate);
            //filter nus
            if (pdgId == 16 || pdgId == 12 || pdgId == 14)
            {
               //do nothing
            } else 
            {
               // call everything charged a pion
               // call everything neutral a neutral pion
               if (theCandidate->charge() != 0)
                  tempTauHolder.chargedObjects.push_back(theCandidate);
               else
                  tempTauHolder.neutralObjects.push_back(theCandidate);
            }
         }
         tausToAdd_.push_back(tempTauHolder);
      }
   }

   //output collection
   std::auto_ptr<vector<PFTauDecayMode> > pOut( new std::vector<PFTauDecayMode> );
   for(std::vector<tauObjectsHolder>::const_iterator iTempTau  = tausToAdd_.begin();
                                                iTempTau != tausToAdd_.end();
                                              ++iTempTau)
   {
      double leadTrackPt  = 0.;
      double leadTrackEta = 0.;
      VertexCompositeCandidate chargedObjectsToAdd;
      const std::vector<const Candidate*>* chargedObjects = &(iTempTau->chargedObjects);
      for(std::vector<const Candidate*>::const_iterator iCharged  = chargedObjects->begin();
                                                   iCharged != chargedObjects->end();
                                                 ++iCharged)
      {
         chargedObjectsToAdd.addDaughter(**iCharged);
         double trackPt = (*iCharged)->pt();
         if (trackPt > leadTrackPt)
         {
            leadTrackPt  = trackPt;
            leadTrackEta = (*iCharged)->eta();
         }
      }
      //update the composite four vector
      addP4.set(chargedObjectsToAdd);

      CompositeCandidate neutralPionsToAdd;
      const std::vector<const Candidate*>* neutralObjects = &(iTempTau->neutralObjects);
      for(std::vector<const Candidate*>::const_iterator iNeutral  = neutralObjects->begin();
                                                   iNeutral != neutralObjects->end();
                                                 ++iNeutral)
      {
         neutralPionsToAdd.addDaughter(**iNeutral);
      }
      addP4.set(neutralPionsToAdd);

      Particle::LorentzVector myFourVector = chargedObjectsToAdd.p4();
      myFourVector += neutralPionsToAdd.p4();

      if(leadTrackPt > leadTrackPtCut_ && std::abs(leadTrackEta) < leadTrackEtaCut_ && myFourVector.pt() > totalPtCut_ && std::abs(myFourVector.eta()) < totalEtaCut_)
      {
         //TODO: add vertex fitting
         CompositeCandidate theOutliers;
         PFTauRef             noPFTau;     //empty REF to PFTau
         PFTauDecayMode decayModeToAdd(chargedObjectsToAdd, neutralPionsToAdd, theOutliers);
         decayModeToAdd.setPFTauRef(noPFTau);
         pOut->push_back(decayModeToAdd);
      }
   }
   iEvent.put(pOut);
}

Member Data Documentation

Definition at line 66 of file TruthTauDecayModeProducer.cc.

Referenced by produce().

Definition at line 60 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

Definition at line 61 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

Definition at line 63 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

Definition at line 62 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

Definition at line 65 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

Definition at line 64 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().