CMS 3D CMS Logo

METProducer.cc

Go to the documentation of this file.
00001 // File: METProducer.cc 
00002 // Description:  see METProducer.h
00003 // Author: R. Cavanaugh, The University of Florida
00004 // Creation Date:  20.04.2006.
00005 //
00006 //--------------------------------------------
00007 //Modified:     29.10.2008 by R.Cavanaugh, UIC/Fermilab
00008 //Description:  include Particle Flow MET
00009 //
00010 #include <memory>
00011 #include "RecoMET/METProducers/interface/METProducer.h"
00012 #include "RecoMET/METAlgorithms/interface/SignCaloSpecificAlgo.h"
00013 #include "RecoMET/METAlgorithms/interface/SignAlgoResolutions.h"
00014 #include "RecoMET/METAlgorithms/interface/CaloSpecificAlgo.h"
00015 #include "RecoMET/METAlgorithms/interface/PFSpecificAlgo.h"
00016 #include "RecoMET/METAlgorithms/interface/GenSpecificAlgo.h"
00017 //#include "DataFormats/METObjects/interface/METCollection.h"
00018 #include "DataFormats/JetReco/interface/CaloJet.h"
00019 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00020 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00021 #include "DataFormats/METReco/interface/PFMETCollection.h"
00022 #include "DataFormats/METReco/interface/GenMETCollection.h"
00023 #include "DataFormats/METReco/interface/METCollection.h"
00024 #include "DataFormats/METReco/interface/CommonMETData.h"
00025 #include "DataFormats/Candidate/interface/LeafCandidate.h"
00026 #include "DataFormats/Candidate/interface/Particle.h"
00027 #include "DataFormats/Candidate/interface/Candidate.h"
00028 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00029 #include "DataFormats//Common/interface/View.h"
00030 
00031 using namespace edm;
00032 using namespace std;
00033 using namespace reco;
00034 
00035 namespace cms 
00036 {
00037   //--------------------------------------------------------------------------
00038   // Constructor : used to fill the parameters from the configuration file
00039   // Currently there are only two defined parameters:
00040   // 1. src = the label of the input data product (which must derive from 
00041   //    Candidate)
00042   // 2. METType = the type of to produce into the event.  currently there are
00043   //    only two types of MET defined: (1) MET from calorimetery (and so 
00044   //    contains extra information specific to calorimetery) and (2) the 
00045   //    default MET which contains only generic information.  Additional
00046   //    MET types will appear (such as GenMET) in the future.  (All "types"
00047   //    of MET inherit from RecoCandidate and merely extend that class with
00048   //    extra information)
00049   //-----------------------------------
00050   METProducer::METProducer(const edm::ParameterSet& iConfig) : conf_(iConfig),alg_() 
00051   {
00052     inputLabel = iConfig.getParameter<edm::InputTag>("src");
00053     inputType  = iConfig.getParameter<std::string>("InputType");
00054     METtype    = iConfig.getParameter<std::string>("METType");
00055     alias      = iConfig.getParameter<std::string>("alias");
00056     globalThreshold = iConfig.getParameter<double>("globalThreshold");
00057     noHF = iConfig.getParameter<bool>("noHF");
00058 
00059     if(      METtype == "CaloMET" ) 
00060       produces<CaloMETCollection>().setBranchAlias(alias.c_str()); 
00061     else if( METtype == "PFMET" )
00062       produces<PFMETCollection>().setBranchAlias(alias.c_str()); 
00063     else if( METtype == "GenMET" )  
00064       produces<GenMETCollection>().setBranchAlias(alias.c_str());
00065     else if (METtype == "CaloMETSignif")
00066       produces<CaloMETCollection>().setBranchAlias(alias.c_str());
00067     else                            
00068       produces<METCollection>().setBranchAlias(alias.c_str()); 
00069   }
00070   //--------------------------------------------------------------------------
00071 
00072   //--------------------------------------------------------------------------
00073   // Default Constructor
00074   //-----------------------------------
00075   METProducer::METProducer() : alg_() 
00076   {
00077     produces<METCollection>(); 
00078   }
00079   //--------------------------------------------------------------------------
00080 
00081   //--------------------------------------------------------------------------
00082   // Default Destructor
00083   //-----------------------------------
00084   METProducer::~METProducer() {}
00085   //--------------------------------------------------------------------------
00086 
00087   //--------------------------------------------------------------------------
00088   // Run Algorithm and put results into event
00089   //-----------------------------------
00090   void METProducer::produce(Event& event, const EventSetup& setup) 
00091   {
00092 
00093     //-----------------------------------
00094     // Step A: Get Inputs.  Create an empty collection of candidates
00095     edm::Handle<edm::View<Candidate> > input;
00096     event.getByLabel(inputLabel,input);
00097     //-----------------------------------
00098     // Step B: Create an empty MET struct output.
00099     CommonMETData output;
00100     /*
00101     //-----------------------------------
00102     // Step C: Convert input source to type CandidateCollection
00103     const RefToBaseVector<Candidate> inputCol = inputHandle->refVector();
00104     const CandidateCollection *input = (const CandidateCollection *)inputCol.product();
00105     */
00106     //-----------------------------------
00107     // Step C2: Invoke the MET algorithm, which runs on any CandidateCollection input. 
00108     alg_.run(input, &output, globalThreshold);
00109     //-----------------------------------
00110     // Step D: Invoke the specific "afterburner", which adds information
00111     //         depending on the input type, given via the config parameter.
00112     //         Also, after the specific algorithm has been called, store
00113     //         the output into the Event.
00114     if( METtype == "CaloMET" ) 
00115     {
00116       CaloSpecificAlgo calo;
00117       std::auto_ptr<CaloMETCollection> calometcoll; 
00118       calometcoll.reset(new CaloMETCollection);
00119       calometcoll->push_back( calo.addInfo(input, output, noHF, globalThreshold) );
00120       event.put( calometcoll );
00121     }
00122     //-----------------------------------
00123     else if( METtype == "PFMET" )
00124     {
00125       PFSpecificAlgo pf;
00126       std::auto_ptr<PFMETCollection> pfmetcoll;
00127       pfmetcoll.reset (new PFMETCollection);
00128       pfmetcoll->push_back( pf.addInfo(input, output) );
00129       event.put( pfmetcoll );
00130     }
00131     //-----------------------------------
00132     else if( METtype == "GenMET" ) 
00133     {
00134       GenSpecificAlgo gen;
00135       std::auto_ptr<GenMETCollection> genmetcoll;
00136       genmetcoll.reset (new GenMETCollection);
00137       genmetcoll->push_back( gen.addInfo(input, output) );
00138       event.put( genmetcoll );
00139     }
00140     //-----------------------------------
00141     else if( METtype == "CaloMETSignif" ) 
00142     {
00143       SignCaloSpecificAlgo calo;
00144       // first calculate all standard info. Then over-write the values used by the significance:
00145       std::auto_ptr<CaloMETCollection> calometcoll; 
00146       calometcoll.reset(new CaloMETCollection);
00147       metsig::SignAlgoResolutions resolutions(conf_);
00148       calometcoll->push_back( calo.addInfo(input, output, resolutions, noHF, globalThreshold) );
00149       event.put( calometcoll );
00150     }
00151     //-----------------------------------
00152     else
00153     {
00154       LorentzVector p4( output.mex, output.mey, 0.0, output.met);
00155       Point vtx(0,0,0);
00156       MET met( output.sumet, p4, vtx );
00157       std::auto_ptr<METCollection> metcoll;
00158       metcoll.reset(new METCollection);
00159       metcoll->push_back( met );
00160       event.put( metcoll );
00161     }
00162     //-----------------------------------
00163   }
00164   //--------------------------------------------------------------------------
00165 }

Generated on Tue Jun 9 17:44:08 2009 for CMSSW by  doxygen 1.5.4