CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FFTJetInterface.cc
Go to the documentation of this file.
1 #include <cassert>
2 
4 
6 
11 
12 #define init_param(type, varname) varname (ps.getParameter< type >( #varname ))
13 
14 using namespace fftjetcms;
15 
16 namespace fftjetcms {
17 
19 {
20  return true;
21 }
22 
23 
25  const std::string& name)
26 {
27  if (!name.compare("BasicJet"))
28  return BASICJET;
29  else if (!name.compare("GenJet"))
30  return GENJET;
31  else if (!name.compare("CaloJet"))
32  return CALOJET;
33  else if (!name.compare("PFJet"))
34  return PFJET;
35  else if (!name.compare("TrackJet"))
36  return TRACKJET;
37  else if (!name.compare("JPTJet"))
38  return JPTJET;
39  else
40  throw cms::Exception("FFTJetBadConfig")
41  << "Unsupported jet type specification \""
42  << name << "\"" << std::endl;
43 }
44 
45 
47  : inputLabel(ps.getParameter<edm::InputTag>("src")),
48  init_param(std::string, outputLabel),
49  jetType(parse_jet_type(ps.getParameter<std::string>("jetType"))),
50  init_param(bool, doPVCorrection),
51  init_param(edm::InputTag, srcPVs),
52  etaDependentMagnutideFactors(
53  ps.getParameter<std::vector<double> >(
54  "etaDependentMagnutideFactors")),
55  init_param(edm::ParameterSet, anomalous),
56  init_param(bool, insertCompleteEvent),
57  init_param(double, completeEventScale),
58  vertex_(0.0, 0.0, 0.0)
59 {
61  throw cms::Exception("FFTJetBadConfig")
62  << "Bad scale for the complete event : must be positive"
63  << std::endl;
64 }
65 
66 
68 {
70 }
71 
72 
74 {
75  // Figure out if we are going to perform the vertex adjustment
76  const bool adjustForVertex = doPVCorrection && jetType == CALOJET;
77 
78  // Figure out the vertex
79  if (adjustForVertex)
80  {
82  iEvent.getByLabel(srcPVs, pvCollection);
83  if (pvCollection->empty())
84  vertex_ = reco::Particle::Point(0.0, 0.0, 0.0);
85  else
86  vertex_ = pvCollection->begin()->position();
87  }
88 
89  // Get the input collection
91 
92  // Create the set of 4-vectors needed by the algorithm
93  eventData.clear();
94  candidateIndex.clear();
95  unsigned index = 0;
98  it != end; ++it, ++index)
99  {
100  const reco::Candidate& item(*it);
101  if (anomalous(item))
102  continue;
103  if (std::isnan(item.pt()))
104  continue;
105 
106  if (adjustForVertex)
107  {
108  const CaloTower& tower(dynamic_cast<const CaloTower&>(item));
109  eventData.push_back(VectorLike(tower.p4(vertex_)));
110  }
111  else
112  eventData.push_back(item.p4());
113  candidateIndex.push_back(index);
114  }
115  assert(eventData.size() == candidateIndex.size());
116 }
117 
118 
120 {
121  // It is a bug to call this function before defining the energy flow grid
122  assert(energyFlow.get());
123 
124  fftjet::Grid2d<Real>& g(*energyFlow);
125  g.reset();
126 
127  const unsigned nInputs = eventData.size();
128  const VectorLike* inp = nInputs ? &eventData[0] : 0;
129  for (unsigned i=0; i<nInputs; ++i)
130  {
131  const VectorLike& item(inp[i]);
132  g.fill(item.Eta(), item.Phi(), item.Et());
133  }
134 
135  if (!etaDependentMagnutideFactors.empty())
136  {
137  if (etaDependentMagnutideFactors.size() != g.nEta())
138  throw cms::Exception("FFTJetBadConfig")
139  << "ERROR in FFTJetInterface::discretizeEnergyFlow() :"
140  " number of elements in the \"etaDependentMagnutideFactors\""
141  " vector is inconsistent with the grid binning"
142  << std::endl;
143  g.scaleData(&etaDependentMagnutideFactors[0],
145  }
146 }
147 
148 }
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
const edm::InputTag inputLabel
edm::Handle< reco::CandidateView > inputCollection
math::PtEtaPhiMLorentzVector p4(double vtxZ) const
Definition: CaloTower.cc:105
virtual double pt() const =0
transverse momentum
void loadInputCollection(const edm::Event &)
const edm::InputTag srcPVs
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
int iEvent
Definition: GenABIO.cc:243
std::vector< unsigned > candidateIndex
reco::Particle::Point vertex_
math::XYZTLorentzVector VectorLike
bool isnan(float x)
Definition: math.h:13
const std::vector< double > etaDependentMagnutideFactors
math::XYZPoint Point
point in the space
Definition: Particle.h:29
#define end
Definition: vmac.h:38
const AnomalousTower anomalous
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
bool storeInSinglePrecision() const
static JetType parse_jet_type(const std::string &name)
#define init_param(type, varname)
std::vector< fftjetcms::VectorLike > eventData
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector