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>
32 
33 using namespace edm;
34 using namespace std;
35 using namespace reco;
36 
37 namespace cms
38 {
39  //--------------------------------------------------------------------------
40  // Constructor : used to fill the parameters from the configuration file
41  // Currently there are only two defined parameters:
42  // 1. src = the label of the input data product (which must derive from
43  // Candidate)
44  // 2. METType = the type of to produce into the event. currently there are
45  // only two types of MET defined: (1) MET from calorimetery (and so
46  // contains extra information specific to calorimetery) and (2) the
47  // default MET which contains only generic information. Additional
48  // MET types will appear (such as GenMET) in the future. (All "types"
49  // of MET inherit from RecoCandidate and merely extend that class with
50  // extra information)
51  //-----------------------------------
52  METProducer::METProducer(const edm::ParameterSet& iConfig) : alg_() , resolutions_(0), tcmetalgorithm(0)
53  {
54  inputLabel = iConfig.getParameter<edm::InputTag>("src");
55  inputType = iConfig.getParameter<std::string>("InputType");
56  METtype = iConfig.getParameter<std::string>("METType");
57  alias = iConfig.getParameter<std::string>("alias");
58  globalThreshold = iConfig.getParameter<double>("globalThreshold");
60 
61  if( METtype == "CaloMET" )
62  {
63  noHF = iConfig.getParameter<bool>("noHF");
64  produces<CaloMETCollection>().setBranchAlias(alias.c_str());
65  calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
66  }
67  else if( METtype == "GenMET" )
68  {
69  onlyFiducial = iConfig.getParameter<bool>("onlyFiducialParticles");
70  usePt = iConfig.getUntrackedParameter<bool>("usePt",false);
71  produces<GenMETCollection>().setBranchAlias(alias.c_str());
72  }
73  else if( METtype == "PFMET" )
74  {
75  produces<PFMETCollection>().setBranchAlias(alias.c_str());
76 
77  calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
78 
79  if(calculateSignificance_){
80  jetsLabel_ = iConfig.getParameter<edm::InputTag>("jets");
81  }
82 
83  }
84  else if( METtype == "PFClusterMET" )
85  {
86  produces<PFClusterMETCollection>().setBranchAlias(alias.c_str());
87  }
88  else if (METtype == "TCMET" )
89  {
90  produces<METCollection>().setBranchAlias(alias.c_str());
91 
92  int rfType_ = iConfig.getParameter<int>("rf_type");
93  bool correctShowerTracks_ = iConfig.getParameter<bool>("correctShowerTracks");
94 
95  if(correctShowerTracks_){
96  // use 'shower' and 'noshower' response functions
98  }else{
99 
100  if( rfType_ == 1 ){
101  // use response function 'fit'
103  }
104  else if( rfType_ == 2 ){
105  // use response function 'mode'
107  }
108  }
109  tcmetalgorithm = new TCMETAlgo();
111  }
112  else
113  produces<METCollection>().setBranchAlias(alias.c_str());
114 
115  if (calculateSignificance_ && ( METtype == "CaloMET" || METtype == "PFMET")){
117 
118  }
119  }
120  //--------------------------------------------------------------------------
121 
122  //--------------------------------------------------------------------------
123  // Default Constructor
124  //-----------------------------------
126  {
127  tcmetalgorithm = 0; // why does this constructor exist?
128  produces<METCollection>();
129  }
130  //--------------------------------------------------------------------------
131 
132  //--------------------------------------------------------------------------
133  // Default Destructor
134  //-----------------------------------
136  //--------------------------------------------------------------------------
137 
138  //--------------------------------------------------------------------------
139  // Run Algorithm and put results into event
140  //-----------------------------------
142  {
143 
144  //-----------------------------------
145  // Step A: Get Inputs. Create an empty collection of candidates
147  event.getByLabel(inputLabel,input);
148  //-----------------------------------
149  // Step B: Create an empty MET struct output.
151  /*
152  //-----------------------------------
153  // Step C: Convert input source to type CandidateCollection
154  const RefToBaseVector<Candidate> inputCol = inputHandle->refVector();
155  const CandidateCollection *input = (const CandidateCollection *)inputCol.product();
156  */
157  //-----------------------------------
158  // Step C2: Invoke the MET algorithm, which runs on any CandidateCollection input.
159 
160  // alg_.run(input, &output, globalThreshold); // No need to run this for all METTypes!
161 
162  //-----------------------------------
163  // Step D: Invoke the specific "afterburner", which adds information
164  // depending on the input type, given via the config parameter.
165  // Also, after the specific algorithm has been called, store
166  // the output into the Event.
167 
168  if( METtype == "CaloMET" )
169  {
170  //Run Basic MET Algorithm
171  alg_.run(input, &output, globalThreshold);
172 
173  // Run CaloSpecific Algorithm
174  CaloSpecificAlgo calospecalgo;
175  CaloMET calomet = calospecalgo.addInfo(input,output,noHF, globalThreshold);
176 
177  //Run algorithm to calculate CaloMET Significance and add to the MET Object
179  {
180  SignCaloSpecificAlgo signcalospecalgo;
181  //metsig::SignAlgoResolutions resolutions(conf_);
182 
183  signcalospecalgo.calculateBaseCaloMET(input,output,*resolutions_,noHF,globalThreshold);
184  calomet.SetMetSignificance( signcalospecalgo.getSignificance() );
185  calomet.setSignificanceMatrix(signcalospecalgo.getSignificanceMatrix());
186  }
187  //Store CaloMET object in CaloMET collection
188  std::auto_ptr<CaloMETCollection> calometcoll;
189  calometcoll.reset(new CaloMETCollection);
190  calometcoll->push_back( calomet ) ;
191  event.put( calometcoll );
192 
193  }
194  //-----------------------------------
195  else if( METtype == "TCMET" )
196  {
197  std::auto_ptr<METCollection> tcmetcoll;
198  tcmetcoll.reset(new METCollection);
199  tcmetcoll->push_back( tcmetalgorithm->CalculateTCMET(event, setup ) ) ;
200  event.put( tcmetcoll );
201  }
202  //----------------------------------
203  else if( METtype == "PFMET" )
204  {
205  alg_.run(input, &output, globalThreshold);
206  PFSpecificAlgo pf;
207  std::auto_ptr<PFMETCollection> pfmetcoll;
208  pfmetcoll.reset (new PFMETCollection);
209 
210  // add resolutions and calculate significance
212  {
213  //metsig::SignAlgoResolutions resolutions(conf_);
215  event.getByLabel(jetsLabel_,jets);
216  pf.runSignificance(*resolutions_, jets);
217  }
218  pfmetcoll->push_back( pf.addInfo(input, output) );
219  event.put( pfmetcoll );
220  }
221  //----------------------------------
222  else if( METtype == "PFClusterMET" )
223  {
224  alg_.run(input, &output, globalThreshold);
225  PFClusterSpecificAlgo pfcluster;
226  std::auto_ptr<PFClusterMETCollection> pfclustermetcoll;
227  pfclustermetcoll.reset (new PFClusterMETCollection);
228 
229  pfclustermetcoll->push_back( pfcluster.addInfo(input, output) );
230  event.put( pfclustermetcoll );
231  }
232  //-----------------------------------
233  else if( METtype == "GenMET" )
234  {
236  std::auto_ptr<GenMETCollection> genmetcoll;
237  genmetcoll.reset (new GenMETCollection);
238  genmetcoll->push_back( gen.addInfo(input, &output, globalThreshold, onlyFiducial, usePt) );
239  event.put( genmetcoll );
240  }
241  else
242  {
243  alg_.run(input, &output, globalThreshold);
244  LorentzVector p4( output.mex, output.mey, 0.0, output.met);
245  Point vtx(0,0,0);
246  MET met( output.sumet, p4, vtx );
247  std::auto_ptr<METCollection> metcoll;
248  metcoll.reset(new METCollection);
249  metcoll->push_back( met );
250  event.put( metcoll );
251  }
252  //-----------------------------------
253  }
254  //--------------------------------------------------------------------------
255 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Collection of Gen MET.
reco::MET CalculateTCMET(edm::Event &event, const edm::EventSetup &setup)
Definition: TCMETAlgo.cc:161
edm::InputTag inputLabel
Definition: METProducer.h:59
bool calculateSignificance_
Definition: METProducer.h:65
reco::PFClusterMET addInfo(edm::Handle< edm::View< reco::Candidate > > PFClusterCandidates, CommonMETData met)
std::string alias
Definition: METProducer.h:62
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:141
Definition: MET.h:32
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)
vector< PseudoJet > jets
math::XYZPoint Point
Definition: METProducer.h:49
Structure containing data common to all types of MET.
Definition: CommonMETData.h:22
std::string inputType
Definition: METProducer.h:60
void setSignificanceMatrix(const TMatrixD &matrix)
Definition: MET.cc:185
void configure(const edm::ParameterSet &iConfig, int myResponseFunctionType)
Definition: TCMETAlgo.cc:65
Collection of MET.
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
TCMETAlgo * tcmetalgorithm
Definition: METProducer.h:81
reco::CaloMET addInfo(edm::Handle< edm::View< reco::Candidate > > towers, CommonMETData met, bool noHF, double globalThreshold)
Make CaloMET. Assumes MET is made from CaloTowerCandidates.
int myResponseFunctionType
Definition: METProducer.h:82
TMatrixD getSignificanceMatrix() const
double globalThreshold
Definition: METProducer.h:73
Collection of PFCluster MET.
edm::InputTag jetsLabel_
Definition: METProducer.h:67
metsig::SignAlgoResolutions * resolutions_
Definition: METProducer.h:66
math::XYZTLorentzVector LorentzVector
Definition: METProducer.h:48
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:135
std::string METtype
Definition: METProducer.h:61
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void SetMetSignificance(double metsig)
Definition: CaloMET.h:76
Collection of PF MET.