CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

cms::METProducer Class Reference

#include <METProducer.h>

Inheritance diagram for cms::METProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef edm::OwnVector
< reco::Candidate
CandidateCollection
typedef math::XYZTLorentzVector LorentzVector
typedef math::XYZPoint Point

Public Member Functions

 METProducer (const edm::ParameterSet &)
 METProducer ()
virtual void produce (edm::Event &, const edm::EventSetup &)
virtual ~METProducer ()

Private Attributes

METAlgo alg_
std::string alias
bool calculateSignificance_
double globalThreshold
edm::InputTag inputLabel
std::string inputType
edm::InputTag jetsLabel_
std::string METtype
int myResponseFunctionType
bool noHF
bool onlyFiducial
metsig::SignAlgoResolutionsresolutions_
TCMETAlgotcmetalgorithm
bool usePt

Detailed Description

Definition at line 45 of file METProducer.h.


Member Typedef Documentation

Definition at line 50 of file METProducer.h.

Definition at line 48 of file METProducer.h.

Definition at line 49 of file METProducer.h.


Constructor & Destructor Documentation

METProducer::METProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 52 of file METProducer.cc.

References alias, calculateSignificance_, TCMETAlgo::configure(), funct::false, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), globalThreshold, inputLabel, inputType, jetsLabel_, METtype, myResponseFunctionType, noHF, onlyFiducial, resolutions_, tcmetalgorithm, and usePt.

                                                         : alg_() , resolutions_(0), tcmetalgorithm(0) 
  {
    inputLabel = iConfig.getParameter<edm::InputTag>("src");
    inputType  = iConfig.getParameter<std::string>("InputType");
    METtype    = iConfig.getParameter<std::string>("METType");
    alias      = iConfig.getParameter<std::string>("alias");
    globalThreshold = iConfig.getParameter<double>("globalThreshold");
    calculateSignificance_ = false ;

    if( METtype == "CaloMET" ) 
      {
        noHF = iConfig.getParameter<bool>("noHF");
        produces<CaloMETCollection>().setBranchAlias(alias.c_str()); 
        calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
      }
    else if( METtype == "GenMET" )  
      {
        onlyFiducial = iConfig.getParameter<bool>("onlyFiducialParticles");
        usePt      = iConfig.getUntrackedParameter<bool>("usePt",false);
        produces<GenMETCollection>().setBranchAlias(alias.c_str());
      }
    else if( METtype == "PFMET" )
      {
        produces<PFMETCollection>().setBranchAlias(alias.c_str()); 

        calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");

        if(calculateSignificance_){
            jetsLabel_ = iConfig.getParameter<edm::InputTag>("jets");
        }

      }
    else if( METtype == "PFClusterMET" )
      {
        produces<PFClusterMETCollection>().setBranchAlias(alias.c_str()); 
      }
    else if (METtype == "TCMET" )
      {
        produces<METCollection>().setBranchAlias(alias.c_str());

        int rfType_               = iConfig.getParameter<int>("rf_type");
        bool correctShowerTracks_ = iConfig.getParameter<bool>("correctShowerTracks"); 

        if(correctShowerTracks_){
          // use 'shower' and 'noshower' response functions
          myResponseFunctionType = 0;
        }else{
          
          if( rfType_ == 1 ){
            // use response function 'fit'
            myResponseFunctionType = 1;
          }
          else if( rfType_ == 2 ){
            // use response function 'mode'
            myResponseFunctionType = 2;
          }
        }
        tcmetalgorithm = new TCMETAlgo();
        tcmetalgorithm->configure(iConfig, myResponseFunctionType );
      }
    else                            
      produces<METCollection>().setBranchAlias(alias.c_str()); 

    if (calculateSignificance_ && ( METtype == "CaloMET" || METtype == "PFMET")){
        resolutions_ = new metsig::SignAlgoResolutions(iConfig);
        
    }
  }
METProducer::METProducer ( ) [explicit]

Definition at line 125 of file METProducer.cc.

References tcmetalgorithm.

                           : alg_() 
  {
    tcmetalgorithm = 0; // why does this constructor exist?
    produces<METCollection>(); 
  }
METProducer::~METProducer ( ) [virtual]

Definition at line 135 of file METProducer.cc.

References tcmetalgorithm.

{ delete tcmetalgorithm;}

Member Function Documentation

void METProducer::produce ( edm::Event event,
const edm::EventSetup setup 
) [virtual]

Implements edm::EDProducer.

Definition at line 141 of file METProducer.cc.

References CaloSpecificAlgo::addInfo(), PFClusterSpecificAlgo::addInfo(), PFSpecificAlgo::addInfo(), GenSpecificAlgo::addInfo(), alg_, SignCaloSpecificAlgo::calculateBaseCaloMET(), calculateSignificance_, TCMETAlgo::CalculateTCMET(), cmsDownloadME::gen, SignCaloSpecificAlgo::getSignificance(), SignCaloSpecificAlgo::getSignificanceMatrix(), globalThreshold, LaserDQM_cfg::input, inputLabel, fwrapper::jets, jetsLabel_, CaloMET_cfi::met, CommonMETData::met, METtype, CommonMETData::mex, CommonMETData::mey, noHF, onlyFiducial, convertSQLitetoXML_cfg::output, p4, resolutions_, METAlgo::run(), PFSpecificAlgo::runSignificance(), reco::CaloMET::SetMetSignificance(), reco::MET::setSignificanceMatrix(), CommonMETData::sumet, tcmetalgorithm, and usePt.

  {

    //-----------------------------------
    // Step A: Get Inputs.  Create an empty collection of candidates
    edm::Handle<edm::View<Candidate> > input;
    event.getByLabel(inputLabel,input);
    //-----------------------------------
    // Step B: Create an empty MET struct output.
    CommonMETData output;
    /*
    //-----------------------------------
    // Step C: Convert input source to type CandidateCollection
    const RefToBaseVector<Candidate> inputCol = inputHandle->refVector();
    const CandidateCollection *input = (const CandidateCollection *)inputCol.product();
    */
    //-----------------------------------
    // Step C2: Invoke the MET algorithm, which runs on any CandidateCollection input. 

    //    alg_.run(input, &output, globalThreshold);   // No need to run this for all METTypes!
 
    //-----------------------------------
    // Step D: Invoke the specific "afterburner", which adds information
    //         depending on the input type, given via the config parameter.
    //         Also, after the specific algorithm has been called, store
    //         the output into the Event.

    if( METtype == "CaloMET" ) 
    {
      //Run Basic MET Algorithm
      alg_.run(input, &output, globalThreshold);

      // Run CaloSpecific Algorithm
      CaloSpecificAlgo calospecalgo;
      CaloMET calomet = calospecalgo.addInfo(input,output,noHF, globalThreshold);

      //Run algorithm to calculate CaloMET Significance and add to the MET Object
      if( calculateSignificance_ ) 
      {
          SignCaloSpecificAlgo signcalospecalgo;
          //metsig::SignAlgoResolutions resolutions(conf_);
          
          signcalospecalgo.calculateBaseCaloMET(input,output,*resolutions_,noHF,globalThreshold);
          calomet.SetMetSignificance( signcalospecalgo.getSignificance() );
          calomet.setSignificanceMatrix(signcalospecalgo.getSignificanceMatrix());
        }
      //Store CaloMET object in CaloMET collection 
      std::auto_ptr<CaloMETCollection> calometcoll;
      calometcoll.reset(new CaloMETCollection);
      calometcoll->push_back( calomet ) ;
      event.put( calometcoll );  
      
    }
    //-----------------------------------
    else if( METtype == "TCMET" )
      {
        std::auto_ptr<METCollection> tcmetcoll;
        tcmetcoll.reset(new METCollection);
        tcmetcoll->push_back( tcmetalgorithm->CalculateTCMET(event, setup ) ) ;
        event.put( tcmetcoll );
      }
    //----------------------------------
    else if( METtype == "PFMET" )
      {
        alg_.run(input, &output, globalThreshold);
        PFSpecificAlgo pf;
        std::auto_ptr<PFMETCollection> pfmetcoll;
        pfmetcoll.reset (new PFMETCollection);
        
        // add resolutions and calculate significance
        if( calculateSignificance_ )
          {
            //metsig::SignAlgoResolutions resolutions(conf_);
            edm::Handle<edm::View<reco::PFJet> > jets;
            event.getByLabel(jetsLabel_,jets);
            pf.runSignificance(*resolutions_, jets);
          }
        pfmetcoll->push_back( pf.addInfo(input, output) );
        event.put( pfmetcoll );
      }
    //----------------------------------
    else if( METtype == "PFClusterMET" )
      {
        alg_.run(input, &output, globalThreshold);
        PFClusterSpecificAlgo pfcluster;
        std::auto_ptr<PFClusterMETCollection> pfclustermetcoll;
        pfclustermetcoll.reset (new PFClusterMETCollection);
        
        pfclustermetcoll->push_back( pfcluster.addInfo(input, output) );
        event.put( pfclustermetcoll );
      }
    //-----------------------------------
    else if( METtype == "GenMET" ) 
    {
      GenSpecificAlgo gen;
      std::auto_ptr<GenMETCollection> genmetcoll;
      genmetcoll.reset (new GenMETCollection);
      genmetcoll->push_back( gen.addInfo(input, &output, globalThreshold, onlyFiducial, usePt) );
      event.put( genmetcoll );
    }
    else
      {
      alg_.run(input, &output, globalThreshold); 
      LorentzVector p4( output.mex, output.mey, 0.0, output.met);
      Point vtx(0,0,0);
      MET met( output.sumet, p4, vtx );
      std::auto_ptr<METCollection> metcoll;
      metcoll.reset(new METCollection);
      metcoll->push_back( met );
      event.put( metcoll );
    }
    //-----------------------------------
  }

Member Data Documentation

Definition at line 58 of file METProducer.h.

Referenced by produce().

std::string cms::METProducer::alias [private]

Definition at line 62 of file METProducer.h.

Referenced by METProducer().

Definition at line 65 of file METProducer.h.

Referenced by METProducer(), and produce().

Definition at line 73 of file METProducer.h.

Referenced by METProducer(), and produce().

Definition at line 59 of file METProducer.h.

Referenced by METProducer(), and produce().

std::string cms::METProducer::inputType [private]

Definition at line 60 of file METProducer.h.

Referenced by METProducer().

Definition at line 67 of file METProducer.h.

Referenced by METProducer(), and produce().

std::string cms::METProducer::METtype [private]

Definition at line 61 of file METProducer.h.

Referenced by METProducer(), and produce().

Definition at line 82 of file METProducer.h.

Referenced by METProducer().

bool cms::METProducer::noHF [private]

Definition at line 70 of file METProducer.h.

Referenced by METProducer(), and produce().

Definition at line 76 of file METProducer.h.

Referenced by METProducer(), and produce().

Definition at line 66 of file METProducer.h.

Referenced by METProducer(), and produce().

Definition at line 81 of file METProducer.h.

Referenced by METProducer(), produce(), and ~METProducer().

bool cms::METProducer::usePt [private]

Definition at line 79 of file METProducer.h.

Referenced by METProducer(), and produce().