CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/AnalysisDataFormats/TopObjects/src/TtEvent.cc

Go to the documentation of this file.
00001 #include "AnalysisDataFormats/TopObjects/interface/TtEvent.h"
00002 #include "CommonTools/Utils/interface/StringToEnumValue.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include <cstring>
00005 
00006 // find corresponding hypotheses based on JetLepComb
00007 int
00008 TtEvent::correspondingHypo(const HypoClassKey& key1, const unsigned& hyp1, const HypoClassKey& key2) const
00009 {
00010   for(unsigned hyp2 = 0; hyp2 < this->numberOfAvailableHypos(key2); ++hyp2) {
00011     if( this->jetLeptonCombination(key1, hyp1) == this->jetLeptonCombination(key2, hyp2) )
00012       return hyp2;
00013   }
00014   return -1; // if no corresponding hypothesis was found
00015 }
00016 
00017 // return the corresponding enum value from a string
00018 TtEvent::HypoClassKey
00019 TtEvent::hypoClassKeyFromString(const std::string& label) const 
00020 {
00021   return (HypoClassKey) StringToEnumValue<HypoClassKey>(label);
00022 }
00023 
00024 // print pt, eta, phi, mass of a given candidate into an existing LogInfo
00025 void
00026 TtEvent::printParticle(edm::LogInfo &log, const char* name, const reco::Candidate* cand) const
00027 {
00028   if(!cand) {
00029     log << std::setw(15) << name << ": not available!\n";
00030     return;
00031   }
00032   log << std::setprecision(3) << setiosflags(std::ios::fixed | std::ios::showpoint);
00033   log << std::setw(15) << name         << ": "
00034       << std::setw( 7) << cand->pt()   << "; "
00035       << std::setw( 7) << cand->eta()  << "; "
00036       << std::setw( 7) << cand->phi()  << "; "
00037       << resetiosflags(std::ios::fixed | std::ios::showpoint) << setiosflags(std::ios::scientific)
00038       << std::setw(10) << cand->mass() << "\n";
00039   log << resetiosflags(std::ios::scientific);
00040 }