CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
METProducer.cc
Go to the documentation of this file.
1 // File: METProducer.cc
2 // Description: see METProducer.h
3 // Author: R. Cavanaugh, The University of Florida
4 // Creation Date: 20.04.2006.
5 //
6 //--------------------------------------------
7 // Modification by R. Remington on 10/21/08
8 // Added globalThreshold input Parameter to impose on each tower in tower collection
9 // that is looped over by the CaloSpecificAlgo. This is in order to fulfill Scheme B threhsolds...
10 // Modified: 12.13.2008 by R.Cavanaugh, UIC/Fermilab
11 // Description: include Particle Flow MET
12 // Modified: 12.12.2008 by R. Remington, UFL
13 // Description: include TCMET , move alg_.run() inside of relevant if-statements, and add METSignficance algorithm to METtype="CaloMET" cases
14 
15 #include <memory>
31 
32 using namespace edm;
33 using namespace std;
34 using namespace reco;
35 
36 namespace cms
37 {
38  //--------------------------------------------------------------------------
39  // Constructor : used to fill the parameters from the configuration file
40  // Currently there are only two defined parameters:
41  // 1. src = the label of the input data product (which must derive from
42  // Candidate)
43  // 2. METType = the type of to produce into the event. currently there are
44  // only two types of MET defined: (1) MET from calorimetery (and so
45  // contains extra information specific to calorimetery) and (2) the
46  // default MET which contains only generic information. Additional
47  // MET types will appear (such as GenMET) in the future. (All "types"
48  // of MET inherit from RecoCandidate and merely extend that class with
49  // extra information)
50  //-----------------------------------
51  METProducer::METProducer(const edm::ParameterSet& iConfig) : conf_(iConfig), alg_() , resolutions_(0)
52  {
53  inputLabel = iConfig.getParameter<edm::InputTag>("src");
54  inputType = iConfig.getParameter<std::string>("InputType");
55  METtype = iConfig.getParameter<std::string>("METType");
56  alias = iConfig.getParameter<std::string>("alias");
57  globalThreshold = iConfig.getParameter<double>("globalThreshold");
59 
60  if( METtype == "CaloMET" )
61  {
62  noHF = iConfig.getParameter<bool>("noHF");
63  produces<CaloMETCollection>().setBranchAlias(alias.c_str());
64  calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
65  }
66  else if( METtype == "GenMET" )
67  {
68  onlyFiducial = iConfig.getParameter<bool>("onlyFiducialParticles");
69  usePt = iConfig.getUntrackedParameter<bool>("usePt",false);
70  produces<GenMETCollection>().setBranchAlias(alias.c_str());
71  }
72  else if( METtype == "PFMET" )
73  {
74  produces<PFMETCollection>().setBranchAlias(alias.c_str());
75 
76  calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
77 
78  if(calculateSignificance_){
79  jetsLabel_ = iConfig.getParameter<edm::InputTag>("jets");
80  }
81 
82  }
83  else if (METtype == "TCMET" )
84  {
85  produces<METCollection>().setBranchAlias(alias.c_str());
87 
88  int rfType_ = iConfig.getParameter<int>("rf_type");
89  bool correctShowerTracks_ = iConfig.getParameter<bool>("correctShowerTracks");
90 
91  if(correctShowerTracks_){
92  showerRF_ = (*ALGO.getResponseFunction_shower());
93  responseFunction_ = (*ALGO.getResponseFunction_noshower());
94  }else{
95 
96  if( rfType_ == 1 )
97  responseFunction_ = (*ALGO.getResponseFunction_fit());
98  else if( rfType_ == 2 )
99  responseFunction_ = (*ALGO.getResponseFunction_mode());
100 
101  }
102  }
103  else
104  produces<METCollection>().setBranchAlias(alias.c_str());
105 
106  if (calculateSignificance_ && ( METtype == "CaloMET" || METtype == "PFMET")){
108 
109  }
110  }
111  //--------------------------------------------------------------------------
112 
113  //--------------------------------------------------------------------------
114  // Default Constructor
115  //-----------------------------------
117  {
118  produces<METCollection>();
119  }
120  //--------------------------------------------------------------------------
121 
122  //--------------------------------------------------------------------------
123  // Default Destructor
124  //-----------------------------------
126  //--------------------------------------------------------------------------
127 
128  //--------------------------------------------------------------------------
129  // Run Algorithm and put results into event
130  //-----------------------------------
132  {
133 
134  //-----------------------------------
135  // Step A: Get Inputs. Create an empty collection of candidates
137  event.getByLabel(inputLabel,input);
138  //-----------------------------------
139  // Step B: Create an empty MET struct output.
141  /*
142  //-----------------------------------
143  // Step C: Convert input source to type CandidateCollection
144  const RefToBaseVector<Candidate> inputCol = inputHandle->refVector();
145  const CandidateCollection *input = (const CandidateCollection *)inputCol.product();
146  */
147  //-----------------------------------
148  // Step C2: Invoke the MET algorithm, which runs on any CandidateCollection input.
149 
150  // alg_.run(input, &output, globalThreshold); // No need to run this for all METTypes!
151 
152  //-----------------------------------
153  // Step D: Invoke the specific "afterburner", which adds information
154  // depending on the input type, given via the config parameter.
155  // Also, after the specific algorithm has been called, store
156  // the output into the Event.
157 
158  if( METtype == "CaloMET" )
159  {
160  //Run Basic MET Algorithm
161  alg_.run(input, &output, globalThreshold);
162 
163  // Run CaloSpecific Algorithm
164  CaloSpecificAlgo calospecalgo;
165  CaloMET calomet = calospecalgo.addInfo(input,output,noHF, globalThreshold);
166 
167  //Run algorithm to calculate CaloMET Significance and add to the MET Object
169  {
170  SignCaloSpecificAlgo signcalospecalgo;
171  //metsig::SignAlgoResolutions resolutions(conf_);
172 
173  signcalospecalgo.calculateBaseCaloMET(input,output,*resolutions_,noHF,globalThreshold);
174  calomet.SetMetSignificance( signcalospecalgo.getSignificance() );
175  calomet.setSignificanceMatrix(signcalospecalgo.getSignificanceMatrix());
176  }
177  //Store CaloMET object in CaloMET collection
178  std::auto_ptr<CaloMETCollection> calometcoll;
179  calometcoll.reset(new CaloMETCollection);
180  calometcoll->push_back( calomet ) ;
181  event.put( calometcoll );
182 
183  }
184  //-----------------------------------
185  else if( METtype == "TCMET" )
186  {
187  TCMETAlgo tcmetalgorithm;
188  std::auto_ptr<METCollection> tcmetcoll;
189  tcmetcoll.reset(new METCollection);
190  tcmetcoll->push_back( tcmetalgorithm.CalculateTCMET(event, setup, conf_, &responseFunction_, &showerRF_) ) ;
191  event.put( tcmetcoll );
192  }
193  //----------------------------------
194  else if( METtype == "PFMET" )
195  {
196  alg_.run(input, &output, globalThreshold);
197  PFSpecificAlgo pf;
198  std::auto_ptr<PFMETCollection> pfmetcoll;
199  pfmetcoll.reset (new PFMETCollection);
200 
201  // add resolutions and calculate significance
203  {
204  //metsig::SignAlgoResolutions resolutions(conf_);
206  event.getByLabel(jetsLabel_,jets);
207  pf.runSignificance(*resolutions_, jets);
208  }
209  pfmetcoll->push_back( pf.addInfo(input, output) );
210  event.put( pfmetcoll );
211  }
212  //-----------------------------------
213  else if( METtype == "GenMET" )
214  {
215  GenSpecificAlgo gen;
216  std::auto_ptr<GenMETCollection> genmetcoll;
217  genmetcoll.reset (new GenMETCollection);
218  genmetcoll->push_back( gen.addInfo(input, &output, globalThreshold, onlyFiducial, usePt) );
219  event.put( genmetcoll );
220  }
221  else
222  {
223  alg_.run(input, &output, globalThreshold);
224  LorentzVector p4( output.mex, output.mey, 0.0, output.met);
225  Point vtx(0,0,0);
226  MET met( output.sumet, p4, vtx );
227  std::auto_ptr<METCollection> metcoll;
228  metcoll.reset(new METCollection);
229  metcoll->push_back( met );
230  event.put( metcoll );
231  }
232  //-----------------------------------
233  }
234  //--------------------------------------------------------------------------
235 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Collection of Gen MET.
edm::InputTag inputLabel
Definition: METProducer.h:58
bool calculateSignificance_
Definition: METProducer.h:64
std::string alias
Definition: METProducer.h:61
reco::GenMET addInfo(edm::Handle< edm::View< reco::Candidate > > particles, CommonMETData *met, double globalThreshold, bool onlyFiducial=false, bool usePt=false)
Make GenMET. Assumes MET is made from MCCandidates.
Collection of Calo MET.
virtual void run(edm::Handle< edm::View< reco::Candidate > >, CommonMETData *, double)
Definition: METAlgo.cc:41
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: METProducer.cc:131
Definition: MET.h:32
TH2D responseFunction_
Definition: METProducer.h:82
double p4[4]
Definition: TauolaWrapper.h:92
void calculateBaseCaloMET(edm::Handle< edm::View< reco::Candidate > > towers, CommonMETData met, const metsig::SignAlgoResolutions &resolutions, bool noHF, double globalthreshold)
math::XYZPoint Point
Definition: METProducer.h:47
Structure containing data common to all types of MET.
Definition: CommonMETData.h:22
std::string inputType
Definition: METProducer.h:59
void setSignificanceMatrix(const TMatrixD &matrix)
Definition: MET.cc:186
Collection of MET.
edm::ParameterSet conf_
Definition: METProducer.h:56
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
tuple input
Definition: collect_tpl.py:10
reco::CaloMET addInfo(edm::Handle< edm::View< reco::Candidate > > towers, CommonMETData met, bool noHF, double globalThreshold)
Make CaloMET. Assumes MET is made from CaloTowerCandidates.
TMatrixD getSignificanceMatrix() const
double globalThreshold
Definition: METProducer.h:72
edm::InputTag jetsLabel_
Definition: METProducer.h:66
metsig::SignAlgoResolutions * resolutions_
Definition: METProducer.h:65
reco::MET CalculateTCMET(edm::Event &event, const edm::EventSetup &setup, const edm::ParameterSet &iConfig, TH2D *response_function, TH2D *showerRF)
Definition: TCMETAlgo.cc:68
math::XYZTLorentzVector LorentzVector
Definition: METProducer.h:46
reco::PFMET addInfo(edm::Handle< edm::View< reco::Candidate > > PFCandidates, CommonMETData met)
void runSignificance(metsig::SignAlgoResolutions &resolutions, edm::Handle< edm::View< reco::PFJet > > jets)
virtual ~METProducer()
Definition: METProducer.cc:125
std::string METtype
Definition: METProducer.h:60
void SetMetSignificance(double metsig)
Definition: CaloMET.h:76
Collection of PF MET.