CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoJets/JetProducers/plugins/CATopJetProducer.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/MakerMacros.h"
00002 #include "CATopJetProducer.h"
00003 
00004 
00005 using namespace edm;
00006 using namespace cms;
00007 using namespace reco;
00008 using namespace std;
00009 
00010 CATopJetProducer::CATopJetProducer(edm::ParameterSet const& conf):
00011        FastjetJetProducer( conf ),
00012        tagAlgo_(conf.getParameter<int>("tagAlgo")),
00013        ptMin_(conf.getParameter<double>("jetPtMin")),
00014        centralEtaCut_(conf.getParameter<double>("centralEtaCut")),
00015        verbose_(conf.getParameter<bool>("verbose"))
00016 {
00017 
00018         if (tagAlgo_ == CA_TOPTAGGER ) {
00019                 
00020                 legacyCMSTopTagger_ = std::auto_ptr<CATopJetAlgorithm>(
00021                         new CATopJetAlgorithm(src_,
00022                         conf.getParameter<bool>  ("verbose"),              
00023                         conf.getParameter<int>  ("algorithm"),                  // 0 = KT, 1 = CA, 2 = anti-KT
00024                         conf.getParameter<int>   ("useAdjacency"),                      // choose adjacency requirement:
00025                                                                                 //  0 = no adjacency
00026                                                                                 //  1 = deltar adjacency 
00027                                                                                 //  2 = modified adjacency
00028                                                                                 //  3 = calotower neirest neigbor based adjacency (untested)
00029                        conf.getParameter<double>("centralEtaCut"),              // eta for defining "central" jets
00030                        conf.getParameter<double>("jetPtMin"),                   // min jet pt
00031                        conf.getParameter<std::vector<double> >("sumEtBins"),    // sumEt bins over which cuts may vary. vector={bin 0 lower bound, bin 1 lower bound, ...} 
00032                        conf.getParameter<std::vector<double> >("rBins"),        // Jet distance paramter R. R values depend on sumEt bins.
00033                        conf.getParameter<std::vector<double> >("ptFracBins"),   // fraction of hard jet pt that subjet must have (deltap)
00034                        conf.getParameter<std::vector<double> >("deltarBins"),   // Applicable only if useAdjacency=1. deltar adjacency values for each sumEtBin
00035                        conf.getParameter<std::vector<double> >("nCellBins"),    // Applicable only if useAdjacency=3. number of cells to consider two subjets adjacent
00036                        conf.getParameter<double>("inputEtMin"),                 // seed threshold - NOT USED
00037                        conf.getParameter<bool>  ("useMaxTower"),                // use max tower as adjacency criterion, otherwise use centroid - NOT USED
00038                        conf.getParameter<double>("sumEtEtaCut"),                // eta for event SumEt - NOT USED
00039                         conf.getParameter<double>("etFrac")                     // fraction of event sumEt / 2 for a jet to be considered "hard" -NOT USED
00040                 ));
00041         }
00042         else if (tagAlgo_ == FJ_CMS_TOPTAG ) {
00043                 fjCMSTopTagger_ = std::auto_ptr<fastjet::CMSTopTagger>(
00044                         new fastjet::CMSTopTagger()
00045                 );
00046         }
00047         else if (tagAlgo_ == FJ_HEP_TOPTAG ) {
00048                 fjHEPTopTagger_ = std::auto_ptr<fastjet::HEPTopTagger>(
00049                         new fastjet::HEPTopTagger()
00050                 );
00051         }
00052         else if (tagAlgo_ == FJ_JHU_TOPTAG ) {
00053                 fjJHUTopTagger_ = std::auto_ptr<fastjet::JHTopTagger>(
00054                         new fastjet::JHTopTagger()
00055                 );
00056         }
00057         else if (tagAlgo_ == FJ_NSUB_TAG ) {
00058                 
00059                 fastjet::JetDefinition::Plugin *plugin = new fastjet::SISConePlugin(0.6, 0.75);
00060                 fastjet::JetDefinition NsubJetDef(plugin);
00061                 fjNSUBTagger_ = std::auto_ptr<fastjet::RestFrameNSubjettinessTagger>(
00062                         new fastjet::RestFrameNSubjettinessTagger(NsubJetDef)
00063                 );
00064         }
00065                                 
00066                 
00067 
00068 
00069 
00070 }
00071 
00072 void CATopJetProducer::produce(  edm::Event & e, const edm::EventSetup & c ) 
00073 {
00074   FastjetJetProducer::produce(e, c);
00075 }
00076 
00077 void CATopJetProducer::runAlgorithm( edm::Event& iEvent, const edm::EventSetup& iSetup)
00078 {
00079   if ( !doAreaFastjet_ && !doRhoFastjet_) {
00080     fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequence( fjInputs_, *fjJetDefinition_ ) );
00081   } else if (voronoiRfact_ <= 0) {
00082     fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequenceArea( fjInputs_, *fjJetDefinition_ , *fjAreaDefinition_ ) );
00083   } else {
00084     fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequenceVoronoiArea( fjInputs_, *fjJetDefinition_ , fastjet::VoronoiAreaSpec(voronoiRfact_) ) );
00085   }
00086 
00087   if (tagAlgo_ == CA_TOPTAGGER){
00088         (*legacyCMSTopTagger_).run( fjInputs_, fjJets_, fjClusterSeq_ );
00089         
00090   }
00091   else {
00092         
00093         //Run the jet clustering
00094         vector<fastjet::PseudoJet> inclusiveJets = fjClusterSeq_->inclusive_jets(ptMin_);
00095 
00096         if ( verbose_ ) cout << "Getting central jets" << endl;
00097         // Find the transient central jets
00098         vector<fastjet::PseudoJet> centralJets;
00099         for (unsigned int i = 0; i < inclusiveJets.size(); i++) {
00100                 
00101                 if (inclusiveJets[i].perp() > ptMin_ && fabs(inclusiveJets[i].rapidity()) < centralEtaCut_) {
00102                         centralJets.push_back(inclusiveJets[i]);
00103                 }
00104         }
00105 
00106         fastjet::CMSTopTagger & CMSTagger = *fjCMSTopTagger_;
00107         fastjet::HEPTopTagger & HEPTagger = *fjHEPTopTagger_;
00108         fastjet::JHTopTagger & JHUTagger = *fjJHUTopTagger_;
00109         fastjet::RestFrameNSubjettinessTagger & NSUBTagger = *fjNSUBTagger_;
00110 
00111 
00112         vector<fastjet::PseudoJet>::iterator jetIt = centralJets.begin(), centralJetsEnd = centralJets.end();
00113         if ( verbose_ )cout<<"Loop over jets"<<endl;
00114         for ( ; jetIt != centralJetsEnd; ++jetIt ) {
00115                 
00116                 if (verbose_) cout << "CMS FJ jet pt: " << (*jetIt).perp() << endl;
00117 
00118                 fastjet::PseudoJet taggedJet;
00119                 if (tagAlgo_ == FJ_CMS_TOPTAG) taggedJet = CMSTagger.result(*jetIt);
00120                 else if (tagAlgo_ == FJ_HEP_TOPTAG) taggedJet = HEPTagger.result(*jetIt);
00121                 else if (tagAlgo_ == FJ_JHU_TOPTAG) taggedJet = JHUTagger.result(*jetIt);
00122                 else if (tagAlgo_ == FJ_NSUB_TAG) taggedJet = NSUBTagger.result(*jetIt);
00123                 else cout << "NOT A VALID TAGGING ALGORITHM CHOICE!" << endl;
00124 
00125                 if (taggedJet != 0) fjJets_.push_back(taggedJet);
00126         }
00127   }
00128 } 
00129 //define this as a plug-in
00130 DEFINE_FWK_MODULE(CATopJetProducer);