CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/RecoJets/JetAlgorithms/src/SubJetAlgorithm.cc

Go to the documentation of this file.
00001 #include "RecoJets/JetAlgorithms/interface/SubJetAlgorithm.h"
00002 #include "PrunedRecombPlugin.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "FWCore/Utilities/interface/Exception.h"
00005 
00006 
00007 
00008 using namespace std;
00009 using namespace edm;
00010 
00011 
00012 bool SubJetAlgorithm::get_pruning() const{
00013     return enable_pruning_;
00014 }
00015 
00016 void SubJetAlgorithm::set_zcut(double z){
00017     zcut_ = z;
00018 }
00019 
00020 void SubJetAlgorithm::set_rcut_factor(double r){
00021     rcut_factor_ = r;
00022 }
00023 
00024 
00025 //  Run the algorithm
00026 //  ------------------
00027 void SubJetAlgorithm::run( const vector<fastjet::PseudoJet> & cell_particles,
00028                              vector<CompoundPseudoJet> & hardjetsOutput,
00029                              edm::EventSetup const & c ) {
00030   fastjet::Strategy strategy = fastjet::Best;
00031   fastjet::RecombinationScheme recombScheme = fastjet::E_scheme;
00032   fastjet::JetAlgorithm algorithm = static_cast<fastjet::JetAlgorithm>(algorithm_);
00033   //jet definition, as given in the configuration file, jetDef0:
00034   fastjet::JetDefinition jetDef0(algorithm, jetsize_, recombScheme, strategy);
00035 
00036   //for actual jet clustering, either the pruned or the original version is used.
00037   //For the pruned version, a new jet definition using the PrunedRecombPlugin is required:
00038   std::auto_ptr<fastjet::JetDefinition> pjetdef;
00039   std::auto_ptr<fastjet::PrunedRecombPlugin> PRplugin;
00040   if(enable_pruning_){
00041       PRplugin.reset(new fastjet::PrunedRecombPlugin(jetDef0, jetDef0, zcut_, rcut_factor_));
00042       pjetdef.reset(new fastjet::JetDefinition(PRplugin.get()));
00043   }
00044 
00045   //the jet definition which is actually used to cluster the jet is "jetDef". Either
00046   // the pruned definition or the "original", unpruned one.
00047   const fastjet::JetDefinition & jetDef = enable_pruning_?(*pjetdef):jetDef0;
00048 
00049   //cluster the jets with the jet definition jetDef:
00050   fastjet::ClusterSequence clusterSeq(cell_particles, jetDef);
00051   vector<fastjet::PseudoJet> inclusiveJets = clusterSeq.inclusive_jets(ptMin_);
00052 
00053   // These will store the indices of each subjet that 
00054   // are present in each jet
00055   vector<vector<int> > indices(inclusiveJets.size());
00056   // Loop over inclusive jets, attempt to find substructure
00057   vector<fastjet::PseudoJet>::iterator jetIt = inclusiveJets.begin();
00058   for ( ; jetIt != inclusiveJets.end(); ++jetIt ) {
00059     //decompose into requested number of subjets:
00060     vector<fastjet::PseudoJet> subjets = clusterSeq.exclusive_subjets(*jetIt, nSubjets_);
00061     //create the subjets objects to put into the "output" objects
00062     vector<CompoundPseudoSubJet>  subjetsOutput;
00063     std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = subjets.begin(),
00064       itSubJet = itSubJetBegin, itSubJetEnd = subjets.end();
00065     for (; itSubJet != itSubJetEnd; ++itSubJet ){
00066       // Get the transient subjet constituents from fastjet
00067       vector<fastjet::PseudoJet> subjetFastjetConstituents = clusterSeq.constituents( *itSubJet );
00068       // Get the indices of the constituents:
00069       vector<int> constituents;
00070       vector<fastjet::PseudoJet>::const_iterator fastSubIt = subjetFastjetConstituents.begin(),
00071         transConstBegin = subjetFastjetConstituents.begin(),
00072         transConstEnd = subjetFastjetConstituents.end();
00073       for ( ; fastSubIt != transConstEnd; ++fastSubIt ) {
00074         if (fastSubIt->user_index() >= 0) {
00075           constituents.push_back( fastSubIt->user_index() );
00076         }
00077       }
00078       // Make a CompoundPseudoSubJet object to hold this subjet and the indices of its constituents
00079       subjetsOutput.push_back( CompoundPseudoSubJet( *itSubJet, constituents ) );
00080     }
00081     // Make a CompoundPseudoJet object to hold this hard jet, and the subjets that make it up
00082     hardjetsOutput.push_back( CompoundPseudoJet( *jetIt, subjetsOutput ) );
00083   }
00084 }