test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Attributes
PFTau3ProngReco Class Reference
Inheritance diagram for PFTau3ProngReco:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  DiscCutPair
 

Public Types

enum  Alg { useKalmanFit =0, useTrackHelix }
 
typedef std::vector
< DiscCutPair * > 
DiscCutPairVec
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 PFTau3ProngReco (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~PFTau3ProngReco ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

int Algorithm_
 
std::auto_ptr
< StringCutObjectSelector
< reco::PFTau > > 
cut_
 
DiscCutPairVec discriminators_
 
KinematicParticleVertexFitter kpvFitter_
 
int ndfPVT_
 
edm::InputTag PFTauTag_
 
edm::InputTag PFTauTIPTag_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 73 of file PFTau3ProngReco.cc.

Member Typedef Documentation

Definition at line 85 of file PFTau3ProngReco.cc.

Member Enumeration Documentation

Enumerator
useKalmanFit 
useTrackHelix 

Definition at line 75 of file PFTau3ProngReco.cc.

Constructor & Destructor Documentation

PFTau3ProngReco::PFTau3ProngReco ( const edm::ParameterSet iConfig)
explicit

Definition at line 100 of file PFTau3ProngReco.cc.

References PFTau3ProngReco::DiscCutPair::cut_, cut_, PFTau3ProngReco::DiscCutPair::cutFormula_, HLT_25ns10e33_v2_cff::discriminators, discriminators_, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), PFTau3ProngReco::DiscCutPair::inputTag_, TrackValidation_cff::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

100  :
101  PFTauTag_(iConfig.getParameter<edm::InputTag>("PFTauTag")),
102  PFTauTIPTag_(iConfig.getParameter<edm::InputTag>("PFTauTIPTag")),
103  Algorithm_(iConfig.getParameter<int>("Algorithm")),
104  ndfPVT_(iConfig.getUntrackedParameter("ndfPVT",(int)5))
105 {
107  std::vector<edm::ParameterSet> discriminators =iConfig.getParameter<std::vector<edm::ParameterSet> >("discriminators");
108  // Build each of our cuts
109  BOOST_FOREACH(const edm::ParameterSet &pset, discriminators) {
110  DiscCutPair* newCut = new DiscCutPair();
111  newCut->inputTag_ = pset.getParameter<edm::InputTag>("discriminator");
112  if ( pset.existsAs<std::string>("selectionCut") ) newCut->cutFormula_ = new TFormula("selectionCut", pset.getParameter<std::string>("selectionCut").data());
113  else newCut->cut_ = pset.getParameter<double>("selectionCut");
114  discriminators_.push_back(newCut);
115  }
116  // Build a string cut if desired
117  if (iConfig.exists("cut")) cut_.reset(new StringCutObjectSelector<reco::PFTau>(iConfig.getParameter<std::string>( "cut" )));
119  produces<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef> > >();
120  produces<PFTau3ProngSummaryCollection>("PFTau3ProngSummary");
121 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag PFTauTIPTag_
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > cut_
DiscCutPairVec discriminators_
edm::InputTag PFTauTag_
PFTau3ProngReco::~PFTau3ProngReco ( )

Definition at line 123 of file PFTau3ProngReco.cc.

123  {
124 
125 }

Member Function Documentation

void PFTau3ProngReco::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 127 of file PFTau3ProngReco.cc.

References PdtPdgMini::a_1_plus, funct::abs(), reco::PFTau3ProngSummary::AddSolution(), Algorithm_, EnergyCorrector::c, RecoTauCleanerPlugins::charge, PFTau3ProngReco::DiscCutPair::cut_, cut_, PFTau3ProngReco::DiscCutPair::cutFormula_, ztail::d, discriminators_, alignCSCRings::e, tauImpactParameter::TauA1NuConstrainedFitter::fit(), KinematicParticleVertexFitter::fit(), edm::EventSetup::get(), edm::Event::getByLabel(), tauImpactParameter::TauA1NuConstrainedFitter::getMother(), edm::Event::getRefBeforePut(), tauImpactParameter::TauA1NuConstrainedFitter::getRefitDaughters(), PFTau3ProngReco::DiscCutPair::handle_, i, PFTau3ProngReco::DiscCutPair::inputTag_, edm::HandleBase::isValid(), j, edm::Ref< C, T, F >::key(), kpvFitter_, ndfPVT_, tauImpactParameter::LorentzVectorParticle::p4(), p4, HLT_25ns10e33_v2_cff::parameters, KinematicParticleFactoryFromTransientTrack::particle(), SingleMuPt40Fwdv2_cfi_GEN_SIM::pdgId, PFTauTag_, PFTauTIPTag_, tauImpactParameter::PDGInfo::pi_mass(), HLT_25ns10e33_v2_cff::primaryVertex, edm::Event::put(), MetAnalyzer::pv(), TrackCollections2monitor_cff::selectedTracks, metsig::tau, useKalmanFit, and useTrackHelix.

127  {
128  // Obtain Collections
129  edm::ESHandle<TransientTrackBuilder> transTrackBuilder;
130  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",transTrackBuilder);
131 
133  iEvent.getByLabel(PFTauTag_,Tau);
134 
136  iEvent.getByLabel(PFTauTIPTag_,TIPAV);
137 
138  auto_ptr<edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef> > > AVPFTau3PS(new edm::AssociationVector<PFTauRefProd, std::vector<reco::PFTau3ProngSummaryRef> >(PFTauRefProd(Tau)));
139  std::auto_ptr<PFTau3ProngSummaryCollection> PFTau3PSCollection_out= std::auto_ptr<PFTau3ProngSummaryCollection>(new PFTau3ProngSummaryCollection());
140  reco::PFTau3ProngSummaryRefProd PFTau3RefProd_out = iEvent.getRefBeforePut<reco::PFTau3ProngSummaryCollection>("PFTau3ProngSummary");
141 
142  // Load each discriminator
143  BOOST_FOREACH(DiscCutPair *disc, discriminators_) {iEvent.getByLabel(disc->inputTag_, disc->handle_);}
144 
145  // For each Tau Run Algorithim
146  if(Tau.isValid()){
147  for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) {
148  reco::PFTauRef tau(Tau, iPFTau);
149  reco::PFTau3ProngSummary PFTau3PS;
151  // Check if it passed all the discrimiantors
152  bool passed(true);
153  BOOST_FOREACH(const DiscCutPair* disc, discriminators_) {
154  // Check this discriminator passes
155  bool passedDisc = true;
156  if ( disc->cutFormula_ )passedDisc = (disc->cutFormula_->Eval((*disc->handle_)[tau]) > 0.5);
157  else passedDisc = ((*disc->handle_)[tau] > disc->cut_);
158  if ( !passedDisc ){passed = false; break;}
159  }
160  if (passed && cut_.get()){passed = (*cut_)(*tau);}
161  if (passed){
162  PDGInfo pdgInfo;
163  const reco::PFTauTransverseImpactParameterRef theTIP=TIPAV->value(tau.key());
164  const reco::VertexRef primaryVertex=theTIP->primaryVertex();
166  // Now compute the 3 prong Tau
167  bool SecondaryVtxOK(false);
169  if(theTIP->hasSecondaryVertex() && primaryVertex->ndof()>ndfPVT_){
170  const VertexRef secVtx=theTIP->secondaryVertex();
171  GlobalPoint sv(secVtx->position().x(),secVtx->position().y(),secVtx->position().z());
172  double vtxchi2(0), vtxndf(1);
174  vtxchi2=secVtx->chi2();
175  vtxndf=secVtx->ndof();
176  const std::vector<reco::Track>& selectedTracks=secVtx->refittedTracks();
177  std::vector<reco::TransientTrack> transTrkVect;
178  for(unsigned int i = 0; i!=selectedTracks.size();i++) transTrkVect.push_back(transTrackBuilder->build(selectedTracks[i]));
180  float piMassSigma(1.e-6), piChi(0.0), piNdf(0.0);
181  std::vector<RefCountedKinematicParticle> pions;
182  for(unsigned int i = 0; i<transTrkVect.size();i++) pions.push_back(kinFactory.particle(transTrkVect[i],pdgInfo.pi_mass(),piChi,piNdf,sv,piMassSigma));
183  RefCountedKinematicTree jpTree = kpvFitter_.fit(pions);
184  jpTree->movePointerToTheTop();
185  const KinematicParameters parameters = jpTree->currentParticle()->currentState().kinematicParameters();
186  AlgebraicSymMatrix77 cov=jpTree->currentParticle()->currentState().kinematicParametersError().matrix();
187  // get pions
188  double c(0);
189  std::vector<reco::Track> Tracks;
190  std::vector<LorentzVectorParticle> ReFitPions;
191  for(unsigned int i=0;i<transTrkVect.size();i++){
192  c+=transTrkVect[i].charge();
193  ReFitPions.push_back(ParticleBuilder::createLorentzVectorParticle(transTrkVect[i],*secVtx,true,true));
194  }
195  // now covert a1 into LorentzVectorParticle
196  TVectorT<double> a1_par(LorentzVectorParticle::NLorentzandVertexPar);
197  TMatrixTSym<double> a1_cov(LorentzVectorParticle::NLorentzandVertexPar);
198  for(int i = 0; i<LorentzVectorParticle::NLorentzandVertexPar; i++){
199  a1_par(i)=parameters(i);
200  for(int j = 0; j<LorentzVectorParticle::NLorentzandVertexPar; j++){
201  a1_cov(i,j)=cov(i,j);
202  }
203  }
204  a1=LorentzVectorParticle(a1_par,a1_cov,abs(PdtPdgMini::a_1_plus)*c,c,transTrackBuilder->field()->inInverseGeV(sv).z());
205  SecondaryVtxOK=true;
206  PFTau3PS=reco::PFTau3ProngSummary(theTIP,a1.p4(),vtxchi2,vtxndf);
207  }
208  else if(useTrackHelix==Algorithm_){
209  // use Track Helix
210  std::vector<TrackParticle> pions;
211  GlobalPoint pvpoint(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z());
212  const std::vector<edm::Ptr<reco::PFCandidate> > cands = tau->signalPFChargedHadrCands();
213  for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter) {
214  if(iter->get()->trackRef().isNonnull()){
215  reco::TransientTrack transTrk=transTrackBuilder->build(iter->get()->trackRef());
216  pions.push_back(ParticleBuilder::createTrackParticle(transTrk,pvpoint,true,true));
217  }
218  else if(iter->get()->gsfTrackRef().isNonnull()){
219  //reco::TransientTrack transTrk=transTrackBuilder->build(iter->get()->gsfTrackRef());
220  //pions.push_back(ParticleBuilder::CreateTrackParticle(transTrk,pvpoint,true,true));
221  }
222  }
223  TVector3 pv(secVtx->position().x(),secVtx->position().y(),secVtx->position().z());
224  Chi2VertexFitter chi2v(pions,pv);
225  SecondaryVtxOK=chi2v.fit();
226  double c(0); for(unsigned int i=0;i<pions.size();i++){c+=pions[i].charge();}
227  int pdgid=abs(PdtPdgMini::a_1_plus)*c;
228  a1=chi2v.getMother(pdgid);
229  PFTau3PS =reco::PFTau3ProngSummary(theTIP,a1.p4(),vtxchi2,vtxndf);
230  }
231  }
232  if(SecondaryVtxOK){
233  // Tau Solver
234  TVector3 pv(primaryVertex->position().x(),primaryVertex->position().y(),primaryVertex->position().z());
235  TMatrixTSym<double> pvcov(LorentzVectorParticle::NVertex);
237  primaryVertex->fill(pvCov);
238  for(int i = 0; i<LorentzVectorParticle::NVertex; i++){
239  for(int j = 0; j<LorentzVectorParticle::NVertex; j++){
240  pvcov(i,j)=pvCov(i,j);
241  }
242  }
243  for(unsigned int i=0; i<PFTau3ProngSummary::nsolutions;i++){
244  TauA1NuConstrainedFitter TauA1NU(i,a1,pv,pvcov);
245  bool isFitOK=TauA1NU.fit();
246  if(isFitOK){
247  LorentzVectorParticle theTau=TauA1NU.getMother();
248  std::vector<LorentzVectorParticle> daughter=TauA1NU.getRefitDaughters();
249  std::vector<TLorentzVector> daughter_p4;
250  std::vector<int> daughter_charge,daughter_PDGID;
251  for(unsigned int d=0;d<daughter.size();d++){
252  daughter_p4.push_back(daughter[d].p4());
253  daughter_charge.push_back((int)daughter[d].charge());
254  daughter_PDGID.push_back(daughter[d].pdgId());
255  }
256  PFTau3PS.AddSolution(i,theTau.p4(),daughter_p4,daughter_charge,daughter_PDGID,(isFitOK),0.0,-999);
257  }
258  }
259  }
260  }
261  reco::PFTau3ProngSummaryRef PFTau3PSRef=reco::PFTau3ProngSummaryRef(PFTau3RefProd_out,PFTau3PSCollection_out->size());
262  PFTau3PSCollection_out->push_back(PFTau3PS);
263  AVPFTau3PS->setValue(iPFTau,PFTau3PSRef);
264  }
265  }
266  iEvent.put(PFTau3PSCollection_out,"PFTau3ProngSummary");
267  iEvent.put(AVPFTau3PS);
268 }
std::vector< reco::PFTau3ProngSummary > PFTau3ProngSummaryCollection
collection of PFTau3ProngSummary objects
KinematicParticleVertexFitter kpvFitter_
int i
Definition: DBlmapReader.cc:9
edm::InputTag PFTauTIPTag_
ErrorD< N >::type type
Definition: Error.h:33
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
Definition: PFTauFwd.h:15
uint16_t size_type
std::auto_ptr< StringCutObjectSelector< reco::PFTau > > cut_
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
Definition: Matrices.h:9
tuple d
Definition: ztail.py:151
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
double p4[4]
Definition: TauolaWrapper.h:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
static double pi_mass()
Definition: PDGInfo.h:13
DiscCutPairVec discriminators_
bool isValid() const
Definition: HandleBase.h:75
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &particles) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
RefProd< PROD > getRefBeforePut()
Definition: Event.h:141
edm::Ref< PFTau3ProngSummaryCollection > PFTau3ProngSummaryRef
presistent reference to a PFTau3ProngSummary
virtual bool AddSolution(unsigned int solution, const TLorentzVector &tau, const std::vector< TLorentzVector > &daughter_p4, const std::vector< int > &daughter_charge, const std::vector< int > &daughter_PDGID, bool has3ProngSolution, double solutionChi2, double thetaGJsig)
const T & get() const
Definition: EventSetup.h:56
RefCountedKinematicParticle particle(const reco::TransientTrack &initialTrack, const ParticleMass &massGuess, float chiSquared, float degreesOfFr, float &m_sigma) const
edm::InputTag PFTauTag_

Member Data Documentation

int PFTau3ProngReco::Algorithm_
private

Definition at line 93 of file PFTau3ProngReco.cc.

Referenced by produce().

std::auto_ptr<StringCutObjectSelector<reco::PFTau> > PFTau3ProngReco::cut_
private

Definition at line 95 of file PFTau3ProngReco.cc.

Referenced by PFTau3ProngReco(), and produce().

DiscCutPairVec PFTau3ProngReco::discriminators_
private

Definition at line 94 of file PFTau3ProngReco.cc.

Referenced by PFTau3ProngReco(), and produce().

KinematicParticleVertexFitter PFTau3ProngReco::kpvFitter_
private

Definition at line 97 of file PFTau3ProngReco.cc.

Referenced by produce().

int PFTau3ProngReco::ndfPVT_
private

Definition at line 96 of file PFTau3ProngReco.cc.

Referenced by produce().

edm::InputTag PFTau3ProngReco::PFTauTag_
private

Definition at line 91 of file PFTau3ProngReco.cc.

Referenced by produce().

edm::InputTag PFTau3ProngReco::PFTauTIPTag_
private

Definition at line 92 of file PFTau3ProngReco.cc.

Referenced by produce().