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  : edm::EDProducer(),
19  inputLabel(ps.getParameter<edm::InputTag>("src")),
21  jetType(parseJetType(ps.getParameter<std::string>("jetType"))),
24  etaDependentMagnutideFactors(ps.getParameter<std::vector<double> >("etaDependentMagnutideFactors")),
28  vertex_(0.0, 0.0, 0.0) {
30  throw cms::Exception("FFTJetBadConfig") << "Bad scale for the complete event : must be positive" << std::endl;
31 
32  inputToken = consumes<reco::CandidateView>(inputLabel);
33 
34  if (doPVCorrection && jetType == CALOJET)
35  srcPVsToken = consumes<reco::VertexCollection>(srcPVs);
36  }
37 
39 
41  // Figure out if we are going to perform the vertex adjustment
42  const bool adjustForVertex = doPVCorrection && jetType == CALOJET;
43 
44  // Figure out the vertex
45  if (adjustForVertex) {
47  iEvent.getByToken(srcPVsToken, pvCollection);
48  if (pvCollection->empty())
49  vertex_ = reco::Particle::Point(0.0, 0.0, 0.0);
50  else
51  vertex_ = pvCollection->begin()->position();
52  }
53 
54  // Get the input collection
55  iEvent.getByToken(inputToken, inputCollection);
56 
57  // Create the set of 4-vectors needed by the algorithm
58  eventData.clear();
59  candidateIndex.clear();
60  unsigned index = 0;
62  for (reco::CandidateView::const_iterator it = inputCollection->begin(); it != end; ++it, ++index) {
63  const reco::Candidate& item(*it);
64  if (anomalous(item))
65  continue;
66  if (edm::isNotFinite(item.pt()))
67  continue;
68 
69  if (adjustForVertex) {
70  const CaloTower& tower(dynamic_cast<const CaloTower&>(item));
71  eventData.push_back(VectorLike(tower.p4(vertex_)));
72  } else
73  eventData.push_back(item.p4());
74  candidateIndex.push_back(index);
75  }
76  assert(eventData.size() == candidateIndex.size());
77  }
78 
80  // It is a bug to call this function before defining the energy flow grid
81  assert(energyFlow.get());
82 
83  fftjet::Grid2d<Real>& g(*energyFlow);
84  g.reset();
85 
86  const unsigned nInputs = eventData.size();
87  const VectorLike* inp = nInputs ? &eventData[0] : nullptr;
88  for (unsigned i = 0; i < nInputs; ++i) {
89  const VectorLike& item(inp[i]);
90  g.fill(item.Eta(), item.Phi(), item.Et());
91  }
92 
93  if (!etaDependentMagnutideFactors.empty()) {
94  if (etaDependentMagnutideFactors.size() != g.nEta())
95  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetInterface::discretizeEnergyFlow() :"
96  " number of elements in the \"etaDependentMagnutideFactors\""
97  " vector is inconsistent with the grid binning"
98  << std::endl;
100  }
101  }
102 
103 } // namespace fftjetcms
fftjeteflowsmoother_cfi.anomalous
anomalous
Definition: fftjeteflowsmoother_cfi.py:61
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
fftjetcms::FFTJetInterface::FFTJetInterface
FFTJetInterface()=delete
CaloTower.h
fftjetcms
Definition: AbsPileupCalculator.h:15
fftjetcms::FFTJetInterface::loadInputCollection
void loadInputCollection(const edm::Event &)
Definition: FFTJetInterface.cc:40
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
edm
HLT enums.
Definition: AlignableModifier.h:19
fftjetcms::FFTJetInterface::inputCollection
edm::Handle< reco::CandidateView > inputCollection
Definition: FFTJetInterface.h:103
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
cms::cuda::assert
assert(be >=bs)
fftjetdijetfilter_cfi.completeEventScale
completeEventScale
Definition: fftjetdijetfilter_cfi.py:17
fftjetcms::VectorLike
math::XYZTLorentzVector VectorLike
Definition: fftjetTypedefs.h:26
Jet.h
recoTrackAccumulator_cfi.outputLabel
outputLabel
Definition: recoTrackAccumulator_cfi.py:13
fftjetcms::FFTJetInterface::getEventScale
double getEventScale() const
Definition: FFTJetInterface.cc:38
fftjetcms::FFTJetInterface::inputLabel
const edm::InputTag inputLabel
Definition: FFTJetInterface.h:73
fftjetdijetfilter_cfi.insertCompleteEvent
insertCompleteEvent
Definition: fftjetdijetfilter_cfi.py:16
edm::Handle< reco::VertexCollection >
fftjetcms::FFTJetInterface::completeEventScale
const double completeEventScale
Definition: FFTJetInterface.h:112
fftjeteflowsmoother_cfi.etaDependentMagnutideFactors
etaDependentMagnutideFactors
Definition: fftjeteflowsmoother_cfi.py:47
FFTJetInterface.h
fftjetcms::FFTJetInterface::srcPVsToken
edm::EDGetTokenT< reco::VertexCollection > srcPVsToken
Definition: FFTJetInterface.h:116
fftjetcms::FFTJetInterface::jetType
const JetType jetType
Definition: FFTJetInterface.h:79
fftjetcms::FFTJetInterface::candidateIndex
std::vector< unsigned > candidateIndex
Definition: FFTJetInterface.h:97
fftjetcms::FFTJetInterface::srcPVs
const edm::InputTag srcPVs
Definition: FFTJetInterface.h:85
fftjetcms::FFTJetInterface::etaDependentMagnutideFactors
const std::vector< double > etaDependentMagnutideFactors
Definition: FFTJetInterface.h:88
mps_fire.end
end
Definition: mps_fire.py:242
anotherprimaryvertexanalyzer_cfi.pvCollection
pvCollection
Definition: anotherprimaryvertexanalyzer_cfi.py:4
fftjetcms::CALOJET
Definition: JetType.h:7
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_FULL_cff.doPVCorrection
doPVCorrection
Definition: HLT_FULL_cff.py:8654
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
fftjetcms::FFTJetInterface::vertex_
reco::Particle::Point vertex_
Definition: FFTJetInterface.h:113
fftjetcms::parseJetType
JetType parseJetType(const std::string &name)
Definition: JetType.cc:5
iEvent
int iEvent
Definition: GenABIO.cc:224
fftjetcms::FFTJetInterface::energyFlow
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
Definition: FFTJetInterface.h:100
CaloTower
Definition: CaloTower.h:26
fftjetcms::FFTJetInterface::insertCompleteEvent
const bool insertCompleteEvent
Definition: FFTJetInterface.h:111
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
fftjetcms::FFTJetInterface::storeInSinglePrecision
bool storeInSinglePrecision() const
Definition: FFTJetInterface.cc:15
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
DataMixerDataOnData_cff.inputLabel
inputLabel
Definition: DataMixerDataOnData_cff.py:44
reco::Candidate
Definition: Candidate.h:27
fftjetcms::FFTJetInterface::anomalous
const AnomalousTower anomalous
Definition: FFTJetInterface.h:91
init_param
#define init_param(type, varname)
Definition: FFTJetInterface.cc:11
std
Definition: JetResolutionObject.h:76
isFinite.h
fftjetcms::FFTJetInterface::eventData
std::vector< fftjetcms::VectorLike > eventData
Definition: FFTJetInterface.h:94
Exception
Definition: hltDiff.cc:246
HLT_FULL_cff.jetType
jetType
Definition: HLT_FULL_cff.py:8630
HLT_FULL_cff.srcPVs
srcPVs
Definition: HLT_FULL_cff.py:8693
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
fftjetcms::FFTJetInterface::discretizeEnergyFlow
void discretizeEnergyFlow()
Definition: FFTJetInterface.cc:79
reco::Particle::Point
math::XYZPoint Point
point in the space
Definition: Particle.h:25
fftjetcms::FFTJetInterface::doPVCorrection
const bool doPVCorrection
Definition: FFTJetInterface.h:82
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::Event
Definition: Event.h:73
fftjetcms::FFTJetInterface::inputToken
edm::EDGetTokenT< reco::CandidateView > inputToken
Definition: FFTJetInterface.h:115
g
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