CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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       { "kHitFit",            kHitFit           },
00030       { 0, (HypoClassKey)-1 }
00031    };
00032 
00033    bool found = false;
00034    HypoClassKey value = (HypoClassKey)-1;
00035    for(int i = 0; hypoClassKeyStringToEnumMap[i].label && (!found); ++i){
00036      if(!strcmp(label.c_str(), hypoClassKeyStringToEnumMap[i].label)){
00037        found = true;
00038        value = hypoClassKeyStringToEnumMap[i].value;
00039      }
00040    }
00041 
00042    // in case of unrecognized selection type
00043    if(!found){
00044      throw cms::Exception("TtEventError") << label << " is not a recognized HypoClassKey";
00045    }
00046    return value;
00047 }
00048 
00049 // print pt, eta, phi, mass of a given candidate into an existing LogInfo
00050 void
00051 TtEvent::printParticle(edm::LogInfo &log, const char* name, const reco::Candidate* cand) const
00052 {
00053   if(!cand) {
00054     log << std::setw(15) << name << ": not available!\n";
00055     return;
00056   }
00057   log << std::setprecision(3) << setiosflags(std::ios::fixed | std::ios::showpoint);
00058   log << std::setw(15) << name         << ": "
00059       << std::setw( 7) << cand->pt()   << "; "
00060       << std::setw( 7) << cand->eta()  << "; "
00061       << std::setw( 7) << cand->phi()  << "; "
00062       << resetiosflags(std::ios::fixed | std::ios::showpoint) << setiosflags(std::ios::scientific)
00063       << std::setw(10) << cand->mass() << "\n";
00064   log << resetiosflags(std::ios::scientific);
00065 }