CMS 3D CMS Logo

TruthTauDecayModeProducer Class Reference

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

#include <TruthTauDecayModeProducer.cc>

Inheritance diagram for TruthTauDecayModeProducer:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Member Functions

virtual void beginJob (const edm::EventSetup &)
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_

Classes

struct  tauObjectsHolder


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_.

00070 {
00071    edm::LogInfo("TruthTauDecayModeProducer") << "Initializing ctor of TruthTauDecayModeProducer";
00072    iAmSignal_           = iConfig.getParameter<bool>("iAmSignal");
00073    inputTag_            = iConfig.getParameter<edm::InputTag>("inputTag");
00074    leadTrackPtCut_      = iConfig.getParameter<double>("leadTrackPtCut");
00075    leadTrackEtaCut_     = iConfig.getParameter<double>("leadTrackEtaCut");
00076    totalPtCut_          = iConfig.getParameter<double>("totalPtCut");
00077    totalEtaCut_         = iConfig.getParameter<double>("totalEtaCut");
00078    //register your products
00079    edm::LogInfo("TruthTauDecayModeProducer") << "Registering products";
00080    produces<std::vector<reco::PFTauDecayMode> >();
00081    edm::LogInfo("TruthTauDecayModeProducer") << "TruthTauDecayModeProducer initialized";
00082 }

TruthTauDecayModeProducer::~TruthTauDecayModeProducer (  ) 

Definition at line 85 of file TruthTauDecayModeProducer.cc.

00086 {
00087 }


Member Function Documentation

void TruthTauDecayModeProducer::beginJob ( const edm::EventSetup  )  [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 213 of file TruthTauDecayModeProducer.cc.

00214 {
00215 }

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

Reimplemented from edm::EDProducer.

Definition at line 219 of file TruthTauDecayModeProducer.cc.

00219                                   {
00220 }

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

Implements edm::EDProducer.

Definition at line 90 of file TruthTauDecayModeProducer.cc.

References funct::abs(), addP4, TruthTauDecayModeProducer::tauObjectsHolder::chargedObjects, edm::Event::getByLabel(), GeneratorTau::getGenChargedPions(), GeneratorTau::getGenNeutralPions(), iAmSignal_, GeneratorTau::init(), inputTag_, GeneratorTau::isFinalStateTau(), leadTrackEtaCut_, leadTrackPtCut_, TruthTauDecayModeProducer::tauObjectsHolder::neutralObjects, edm::Event::put(), HcalSimpleRecAlgoImpl::reco(), AddFourMomenta::set(), std, totalEtaCut_, and totalPtCut_.

00091 {
00092    using namespace edm;
00093    using namespace std;
00094    using namespace reco;
00095 
00096    vector<tauObjectsHolder> tausToAdd_;
00097 
00098    /* **********************************************
00099     * **********  True Tau Case          ***********
00100     * ********************************************** */
00101    if (iAmSignal_)
00102    {
00103       Handle<RefToBaseVector<reco::Candidate> > decayedMCTaus;
00104       iEvent.getByLabel(inputTag_, decayedMCTaus);
00105       for(edm::RefToBaseVector<reco::Candidate>::const_iterator iterGen = decayedMCTaus->begin();
00106             iterGen != decayedMCTaus->end();
00107             ++iterGen)
00108       {
00109          //copy into custom format (this casting is bullshit)
00110          GeneratorTau tempTau = static_cast<const GenParticle&>(*(*iterGen));
00111          //LogInfo("MCTauCandidateProducer") << "Generator tau produced, initializing.. ";
00112          tempTau.init();
00113          //LogInfo("MCTauCandidateProducer") << "GenTau initialization done";
00114          if (tempTau.isFinalStateTau())
00115          {
00116             // Build a Tau Candidate from the information contained in the parsing class
00117             tauObjectsHolder tempTauHolder;
00118             tempTauHolder.chargedObjects = tempTau.getGenChargedPions();
00119             tempTauHolder.neutralObjects = tempTau.getGenNeutralPions();
00120             tausToAdd_.push_back(tempTauHolder);
00121          }
00122       }
00123    } else
00124    {
00125    /* **********************************************
00126     * **********  QCD Case               ***********
00127     * ********************************************** */
00128       Handle<GenJetCollection> genJets;
00129       iEvent.getByLabel(inputTag_, genJets);
00130       for(GenJetCollection::const_iterator aGenJet = genJets->begin(); aGenJet != genJets->end(); ++aGenJet)
00131       {
00132          // get all constituents
00133          vector<const GenParticle*> theJetConstituents = aGenJet->getGenConstituents();
00134 
00135          tauObjectsHolder tempTauHolder;
00136          // filter the constituents
00137          for( vector<const GenParticle*>::const_iterator aCandidate = theJetConstituents.begin();
00138                aCandidate != theJetConstituents.end();
00139                ++aCandidate)
00140          {
00141             int pdgId = abs((*aCandidate)->pdgId());
00142             const Candidate* theCandidate = static_cast<const Candidate*>(*aCandidate);
00143             //filter nus
00144             if (pdgId == 16 || pdgId == 12 || pdgId == 14)
00145             {
00146                //do nothing
00147             } else 
00148             {
00149                // call everything charged a pion
00150                // call everything neutral a neutral pion
00151                if (theCandidate->charge() != 0)
00152                   tempTauHolder.chargedObjects.push_back(theCandidate);
00153                else
00154                   tempTauHolder.neutralObjects.push_back(theCandidate);
00155             }
00156          }
00157          tausToAdd_.push_back(tempTauHolder);
00158       }
00159    }
00160 
00161    //output collection
00162    std::auto_ptr<vector<PFTauDecayMode> > pOut( new vector<PFTauDecayMode> );
00163    for(vector<tauObjectsHolder>::const_iterator iTempTau  = tausToAdd_.begin();
00164                                                 iTempTau != tausToAdd_.end();
00165                                               ++iTempTau)
00166    {
00167       double leadTrackPt  = 0.;
00168       double leadTrackEta = 0.;
00169       VertexCompositeCandidate chargedObjectsToAdd;
00170       const vector<const Candidate*>* chargedObjects = &(iTempTau->chargedObjects);
00171       for(vector<const Candidate*>::const_iterator iCharged  = chargedObjects->begin();
00172                                                    iCharged != chargedObjects->end();
00173                                                  ++iCharged)
00174       {
00175          chargedObjectsToAdd.addDaughter(**iCharged);
00176          double trackPt = (*iCharged)->pt();
00177          if (trackPt > leadTrackPt)
00178          {
00179             leadTrackPt  = trackPt;
00180             leadTrackEta = (*iCharged)->eta();
00181          }
00182       }
00183       //update the composite four vector
00184       addP4.set(chargedObjectsToAdd);
00185 
00186       CompositeCandidate neutralPionsToAdd;
00187       const vector<const Candidate*>* neutralObjects = &(iTempTau->neutralObjects);
00188       for(vector<const Candidate*>::const_iterator iNeutral  = neutralObjects->begin();
00189                                                    iNeutral != neutralObjects->end();
00190                                                  ++iNeutral)
00191       {
00192          neutralPionsToAdd.addDaughter(**iNeutral);
00193       }
00194       addP4.set(neutralPionsToAdd);
00195 
00196       Particle::LorentzVector myFourVector = chargedObjectsToAdd.p4();
00197       myFourVector += neutralPionsToAdd.p4();
00198 
00199       if(leadTrackPt > leadTrackPtCut_ && abs(leadTrackEta) < leadTrackEtaCut_ && myFourVector.pt() > totalPtCut_ && abs(myFourVector.eta()) < totalEtaCut_)
00200       {
00201          //TODO: add vertex fitting
00202          CompositeCandidate theOutliers;
00203          PFTauRef             noPFTau;     //empty REF to PFTau
00204          PFTauDecayMode decayModeToAdd(chargedObjectsToAdd, neutralPionsToAdd, theOutliers);
00205          decayModeToAdd.setPFTauRef(noPFTau);
00206          pOut->push_back(decayModeToAdd);
00207       }
00208    }
00209    iEvent.put(pOut);
00210 }


Member Data Documentation

AddFourMomenta TruthTauDecayModeProducer::addP4 [private]

Definition at line 66 of file TruthTauDecayModeProducer.cc.

Referenced by produce().

bool TruthTauDecayModeProducer::iAmSignal_ [private]

Definition at line 60 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

edm::InputTag TruthTauDecayModeProducer::inputTag_ [private]

Definition at line 61 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::leadTrackEtaCut_ [private]

Definition at line 63 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::leadTrackPtCut_ [private]

Definition at line 62 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::totalEtaCut_ [private]

Definition at line 65 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().

double TruthTauDecayModeProducer::totalPtCut_ [private]

Definition at line 64 of file TruthTauDecayModeProducer.cc.

Referenced by produce(), and TruthTauDecayModeProducer().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:34:37 2009 for CMSSW by  doxygen 1.5.4