CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #include "AnalysisDataFormats/TopObjects/interface/TtEvent.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include <cstring>
00004 
00005 // find corresponding hypotheses based on JetLepComb
00006 int
00007 TtEvent::correspondingHypo(const HypoClassKey& key1, const unsigned& hyp1, const HypoClassKey& key2) const
00008 {
00009   for(unsigned hyp2 = 0; hyp2 < this->numberOfAvailableHypos(key2); ++hyp2) {
00010     if( this->jetLeptonCombination(key1, hyp1) == this->jetLeptonCombination(key2, hyp2) )
00011       return hyp2;
00012   }
00013   return -1; // if no corresponding hypothesis was found
00014 }
00015 
00016 // return the corresponding enum value from a string
00017 TtEvent::HypoClassKey
00018 TtEvent::hypoClassKeyFromString(const std::string& label) const 
00019 {
00020    static HypoClassKeyStringToEnum hypoClassKeyStringToEnumMap[] = {
00021       { "kGeom",              kGeom             },
00022       { "kWMassMaxSumPt",     kWMassMaxSumPt    },
00023       { "kMaxSumPtWMass",     kMaxSumPtWMass    },
00024       { "kGenMatch",          kGenMatch         },
00025       { "kMVADisc",           kMVADisc          },
00026       { "kKinFit",            kKinFit           },
00027       { "kKinSolution",       kKinSolution      },
00028       { "kWMassDeltaTopMass", kWMassDeltaTopMass},
00029       { 0, (HypoClassKey)-1 }
00030    };
00031 
00032    bool found = false;
00033    HypoClassKey value = (HypoClassKey)-1;
00034    for(int i = 0; hypoClassKeyStringToEnumMap[i].label && (!found); ++i){
00035      if(!strcmp(label.c_str(), hypoClassKeyStringToEnumMap[i].label)){
00036        found = true;
00037        value = hypoClassKeyStringToEnumMap[i].value;
00038      }
00039    }
00040 
00041    // in case of unrecognized selection type
00042    if(!found){
00043      throw cms::Exception("TtEventError") << label << " is not a recognized HypoClassKey";
00044    }
00045    return value;
00046 }
00047 
00048 // print pt, eta, phi, mass of a given candidate into an existing LogInfo
00049 void
00050 TtEvent::printParticle(edm::LogInfo &log, const char* name, const reco::Candidate* cand) const
00051 {
00052   if(!cand) {
00053     log << std::setw(15) << name << ": not available!\n";
00054     return;
00055   }
00056   log << std::setprecision(3) << setiosflags(std::ios::fixed | std::ios::showpoint);
00057   log << std::setw(15) << name         << ": "
00058       << std::setw( 7) << cand->pt()   << "; "
00059       << std::setw( 7) << cand->eta()  << "; "
00060       << std::setw( 7) << cand->phi()  << "; "
00061       << resetiosflags(std::ios::fixed | std::ios::showpoint) << setiosflags(std::ios::scientific)
00062       << std::setw(10) << cand->mass() << "\n";
00063   log << resetiosflags(std::ios::scientific);
00064 }