45 using namespace PFTauDiscriminants;
59 typedef std::vector<std::pair<TTree*, const PFTauDecayModeMatchMap*> >
treeToMatchTuple;
65 virtual void endJob() ;
91 mcTruthSource_(iConfig.getParameter<
InputTag>(
"mcTruthSource")),
92 matchingSources_(iConfig.getParameter<vector<
ParameterSet> >(
"matchingSources")),
93 iAmSignal_(iConfig.getParameter<bool>(
"iAmSignal")),
94 maxTracks_(iConfig.getParameter<uint32_t>(
"maxTracks")),
95 maxPiZeroes_(iConfig.getParameter<uint32_t>(
"maxPiZeroes")),
96 outputRootFileName_(iConfig.getParameter<string>(
"outputRootFileName"))
100 edm::LogInfo(
"TauMVATrainer") <<
"Initializing TauMVATrainer ctor...";
104 edm::LogInfo(
"TauMVATrainer") <<
"Adding discriminants to TauDiscriminantManager...";
114 edm::LogInfo(
"TauMVATrainer") <<
"Building truth tree...";
115 TTree* truthTree =
new TTree(
"truth",
"truth");
122 for(std::vector<ParameterSet>::const_iterator iSrc =
matchingSources_.begin();
132 edm::LogInfo(
"TauMVATrainer") <<
"Building reco tree w/ label: " << label <<
"...";
133 TTree* newTree =
new TTree(label.c_str(),label.c_str());
153 using namespace reco;
162 size_t numberOfTruthObjects = truthObjects->size();
164 for(
size_t iTrueTau = 0; iTrueTau < numberOfTruthObjects; ++iTrueTau)
173 for(tauMatchingInfos::iterator iMatchingInfo =
matchingInfo_.begin();
179 iEvent.
getByLabel(iMatchingInfo->truthToRecoTauMatchingTag, theMatching);
183 iEvent.
getByLabel(iMatchingInfo->decayModeToRecoTauAssociationTag, theDMAssoc);
186 TTree* treeToFill = iMatchingInfo->associatedTTree;
189 PFTauRef theAssociatedRecoTau = (*theMatching)[theTrueTau];
192 bool isNonNull = (theAssociatedRecoTau.
isNonnull() && theAssociatedRecoTau->signalPFChargedHadrCands().size());
198 const PFTauDecayMode& theAssociatedDecayMode = (*theDMAssoc)[theAssociatedRecoTau];
200 bool prePass =
false;
201 bool preFail =
false;
205 unsigned int numberOfOutliers = theAssociatedDecayMode.
pfTauRef()->isolationPFCands().size();
207 if (numberOfTracks >
maxTracks_ || numberOfPiZeros >
maxPiZeroes_ || (charge != 1 && numberOfTracks == 3))
210 else if (numberOfTracks == 1 && numberOfPiZeros == 0 && numberOfOutliers == 0)
234 for(std::map<string, TTree*>::iterator iTree =
myTrainerTrees_.begin();
238 const TTree* myTree = iTree->second;
239 edm::LogInfo(
"TauMVATrainer") <<
"Tree " << myTree->GetName() <<
" has " << myTree->GetEntries() <<
" entries.";
std::string outputRootFileName_
std::map< string, TTree * > myTrainerTrees_
InputTag truthToRecoTauMatchingTag
void addDiscriminant(Discriminant *const aDiscriminant)
add a discriminant
#define DEFINE_FWK_MODULE(type)
edm::Handle< PFTauDecayModeMatchMap > truthToRecoTauMatchingHandle
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool setTau(const reco::PFTauDecayMode &theTau, bool prePass=false, bool preFail=false)
set objects for this discriminant
edm::Handle< PFTauDecayModeAssociation > decayModeToRecoTauAssociationHandle
const VertexCompositeCandidate & chargedPions() const
returns collection of charged pions w/ vertex information (tracks are refit)
virtual size_type numberOfDaughters() const
number of daughters
const PFTauRef & pfTauRef() const
return reference to associated PFTau object
bool isNonnull() const
Checks for non-null.
InputTag decayModeToRecoTauAssociationTag
std::vector< ParameterSet > matchingSources_
const CompositeCandidate & neutralPions() const
returns a collection of merged Pi0s
std::vector< tauMatchingInfoHolder > tauMatchingInfos
void setEvent(const edm::Event &, double eventWeight)
set the current event. Must be called (once per event) before setTau or setNullResult ...
virtual int charge() const
electric charge
std::vector< std::pair< TTree *, const PFTauDecayModeMatchMap * > > treeToMatchTuple
std::vector< tauMatchingInfoHolder > matchingInfo_
edm::Ref< PFTauDecayModeCollection > PFTauDecayModeRef
presistent reference to a PFTauDecayMode
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool branchTree(TTree *const treeToBranch, bool addTargetBranch=false, bool addWeightBranch=false)
add a set of branches ot the TTree
const_iterator begin()
iterators over the list
collection::const_iterator const_iterator
DiscriminantList myDiscriminants_
PFTauDiscriminantManager discriminantManager_
void setSignalFlag(bool isSignal)
TauMVATrainer(const edm::ParameterSet &)