CMS 3D CMS Logo

FFTJetInterface.cc
Go to the documentation of this file.
1 #include <cassert>
2 
4 
7 
10 
11 #define init_param(type, varname) varname(ps.getParameter<type>(#varname))
12 
13 namespace fftjetcms {
14 
15  bool FFTJetInterface::storeInSinglePrecision() const { return true; }
16 
18  : inputLabel(ps.getParameter<edm::InputTag>("src")),
20  jetType(parseJetType(ps.getParameter<std::string>("jetType"))),
23  etaDependentMagnutideFactors(ps.getParameter<std::vector<double> >("etaDependentMagnutideFactors")),
27  vertex_(0.0, 0.0, 0.0) {
29  throw cms::Exception("FFTJetBadConfig") << "Bad scale for the complete event : must be positive" << std::endl;
30 
31  inputToken = consumes<reco::CandidateView>(inputLabel);
32 
33  if (doPVCorrection && jetType == CALOJET)
34  srcPVsToken = consumes<reco::VertexCollection>(srcPVs);
35  }
36 
38 
40  // Figure out if we are going to perform the vertex adjustment
41  const bool adjustForVertex = doPVCorrection && jetType == CALOJET;
42 
43  // Figure out the vertex
44  if (adjustForVertex) {
46  iEvent.getByToken(srcPVsToken, pvCollection);
47  if (pvCollection->empty())
48  vertex_ = reco::Particle::Point(0.0, 0.0, 0.0);
49  else
50  vertex_ = pvCollection->begin()->position();
51  }
52 
53  // Get the input collection
54  iEvent.getByToken(inputToken, inputCollection);
55 
56  // Create the set of 4-vectors needed by the algorithm
57  eventData.clear();
58  candidateIndex.clear();
59  unsigned index = 0;
61  for (reco::CandidateView::const_iterator it = inputCollection->begin(); it != end; ++it, ++index) {
62  const reco::Candidate& item(*it);
63  if (anomalous(item))
64  continue;
65  if (edm::isNotFinite(item.pt()))
66  continue;
67 
68  if (adjustForVertex) {
69  const CaloTower& tower(dynamic_cast<const CaloTower&>(item));
70  eventData.push_back(VectorLike(tower.p4(vertex_)));
71  } else
72  eventData.push_back(item.p4());
73  candidateIndex.push_back(index);
74  }
75  assert(eventData.size() == candidateIndex.size());
76  }
77 
79  // It is a bug to call this function before defining the energy flow grid
80  assert(energyFlow.get());
81 
82  fftjet::Grid2d<Real>& g(*energyFlow);
83  g.reset();
84 
85  const unsigned nInputs = eventData.size();
86  const VectorLike* inp = nInputs ? &eventData[0] : nullptr;
87  for (unsigned i = 0; i < nInputs; ++i) {
88  const VectorLike& item(inp[i]);
89  g.fill(item.Eta(), item.Phi(), item.Et());
90  }
91 
92  if (!etaDependentMagnutideFactors.empty()) {
93  if (etaDependentMagnutideFactors.size() != g.nEta())
94  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetInterface::discretizeEnergyFlow() :"
95  " number of elements in the \"etaDependentMagnutideFactors\""
96  " vector is inconsistent with the grid binning"
97  << std::endl;
99  }
100  }
101 
102 } // namespace fftjetcms
edm::EDGetTokenT< reco::CandidateView > inputToken
const edm::InputTag inputLabel
edm::Handle< reco::CandidateView > inputCollection
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void loadInputCollection(const edm::Event &)
const edm::InputTag srcPVs
assert(be >=bs)
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:224
std::vector< unsigned > candidateIndex
reco::Particle::Point vertex_
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
math::XYZTLorentzVector VectorLike
const std::vector< double > etaDependentMagnutideFactors
edm::EDGetTokenT< reco::VertexCollection > srcPVsToken
math::XYZPoint Point
point in the space
Definition: Particle.h:25
const AnomalousTower anomalous
JetType parseJetType(const std::string &name)
Definition: JetType.cc:5
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
#define init_param(type, varname)
std::vector< fftjetcms::VectorLike > eventData