CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
MultipleAlgoIterator Class Reference

#include <MultipleAlgoIterator.h>

Inheritance diagram for MultipleAlgoIterator:
PileUpSubtractor

Public Member Functions

void calculatePedestal (std::vector< fastjet::PseudoJet > const &coll) override
 
double getEt (const reco::CandidatePtr &in) const
 
double getEta (const reco::CandidatePtr &in) const
 
 MultipleAlgoIterator (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
void offsetCorrectJets () override
 
void rescaleRMS (double s)
 
void subtractPedestal (std::vector< fastjet::PseudoJet > &coll) override
 
 ~MultipleAlgoIterator () override
 
- Public Member Functions inherited from PileUpSubtractor
virtual void calculateOrphanInput (std::vector< fastjet::PseudoJet > &orphanInput)
 
virtual double getCone (double cone, double eta, double phi, double &et, double &pu)
 
virtual double getMeanAtTower (const reco::CandidatePtr &in) const
 
int getN (const reco::CandidatePtr &in) const
 
int getNwithJets (const reco::CandidatePtr &in) const
 
virtual double getPileUpAtTower (const reco::CandidatePtr &in) const
 
virtual double getPileUpEnergy (int ijet) const
 
virtual double getSigmaAtTower (const reco::CandidatePtr &in) const
 
int ieta (const reco::CandidatePtr &in) const
 
int iphi (const reco::CandidatePtr &in) const
 
 PileUpSubtractor (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
virtual void reset (std::vector< edm::Ptr< reco::Candidate > > &input, std::vector< fastjet::PseudoJet > &towers, std::vector< fastjet::PseudoJet > &output)
 
virtual void setDefinition (JetDefPtr const &jetDef)
 
virtual void setupGeometryMap (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~PileUpSubtractor ()
 

Public Attributes

bool dropZeroTowers_
 
bool sumRecHits_
 

Additional Inherited Members

- Public Types inherited from PileUpSubtractor
typedef std::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
 
typedef std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
 
typedef std::shared_ptr< fastjet::JetDefinition > JetDefPtr
 
typedef std::shared_ptr< fastjet::RangeDefinition > RangeDefPtr
 
- Protected Attributes inherited from PileUpSubtractor
int activeAreaRepeats
 
std::vector< HcalDetIdallgeomid_
 
bool doAreaFastjet_
 
bool doRhoFastjet_
 
std::map< int, double > emean_
 
std::map< int, double > esigma_
 
ActiveAreaSpecPtr fjActiveArea_
 
ClusterSequencePtr fjClusterSeq_
 
std::vector< fastjet::PseudoJet > * fjInputs_
 
JetDefPtr fjJetDefinition_
 
std::vector< fastjet::PseudoJet > * fjJets_
 
std::vector< fastjet::PseudoJet > fjOriginalInputs_
 
CaloGeometry const * geo_
 
std::map< int, int > geomtowers_
 
double ghostArea
 
double ghostEtaMax
 
int ietamax_
 
int ietamin_
 
std::vector< edm::Ptr< reco::Candidate > > * inputs_
 
std::vector< double > jetOffset_
 
double jetPtMin_
 
double nSigmaPU_
 
std::map< int, int > ntowersWithJets_
 
double puPtMin_
 
double radiusPU_
 
bool reRunAlgo_
 

Detailed Description

Definition at line 6 of file MultipleAlgoIterator.h.

Constructor & Destructor Documentation

◆ MultipleAlgoIterator()

MultipleAlgoIterator::MultipleAlgoIterator ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 8 of file MultipleAlgoIterator.h.

9  : PileUpSubtractor(iConfig, std::move(iC)),
10  sumRecHits_(iConfig.getParameter<bool>("sumRecHits")),
11  dropZeroTowers_(iConfig.getUntrackedParameter<bool>("dropZeroTowers", true)) {
12  ;
13  }

◆ ~MultipleAlgoIterator()

MultipleAlgoIterator::~MultipleAlgoIterator ( )
inlineoverride

Definition at line 23 of file MultipleAlgoIterator.h.

23 { ; }

Member Function Documentation

◆ calculatePedestal()

void MultipleAlgoIterator::calculatePedestal ( std::vector< fastjet::PseudoJet > const &  coll)
overridevirtual

Reimplemented from PileUpSubtractor.

Definition at line 99 of file MultipleAlgoIterator.cc.

99  {
100  LogDebug("PileUpSubtractor") << "The subtractor calculating pedestals...\n";
101 
102  map<int, double> emean2;
103  map<int, int> ntowers;
104 
105  int ietaold = -10000;
106  int ieta0 = -100;
107 
108  // Initial values for emean_, emean2, esigma_, ntowers
109 
110  for (int i = ietamin_; i < ietamax_ + 1; i++) {
111  emean_[i] = 0.;
112  emean2[i] = 0.;
113  esigma_[i] = 0.;
114  ntowers[i] = 0;
115  }
116 
117  for (vector<fastjet::PseudoJet>::const_iterator input_object = coll.begin(), fjInputsEnd = coll.end();
118  input_object != fjInputsEnd;
119  ++input_object) {
120  const reco::CandidatePtr& originalTower = (*inputs_)[input_object->user_index()];
121  ieta0 = ieta(originalTower);
122  double Original_Et = originalTower->et();
123  if (sumRecHits_) {
124  Original_Et = getEt(originalTower);
125  }
126 
127  if (ieta0 - ietaold != 0) {
128  emean_[ieta0] = emean_[ieta0] + Original_Et;
129  emean2[ieta0] = emean2[ieta0] + Original_Et * Original_Et;
130  ntowers[ieta0] = 1;
131  ietaold = ieta0;
132  } else {
133  emean_[ieta0] = emean_[ieta0] + Original_Et;
134  emean2[ieta0] = emean2[ieta0] + Original_Et * Original_Et;
135  ntowers[ieta0]++;
136  }
137  }
138 
139  for (map<int, int>::const_iterator gt = geomtowers_.begin(); gt != geomtowers_.end(); gt++) {
140  int it = (*gt).first;
141 
142  double e1 = (*(emean_.find(it))).second;
143  double e2 = (*emean2.find(it)).second;
144  int nt = (*gt).second - (*(ntowersWithJets_.find(it))).second;
145 
146  LogDebug("PileUpSubtractor") << " ieta : " << it << " number of towers : " << nt << " e1 : " << e1 << " e2 : " << e2
147  << "\n";
148 
149  if (nt > 0) {
150  emean_[it] = e1 / nt;
151  double eee = e2 / nt - e1 * e1 / (nt * nt);
152  if (eee < 0.)
153  eee = 0.;
154  esigma_[it] = nSigmaPU_ * sqrt(eee);
155  } else {
156  emean_[it] = 0.;
157  esigma_[it] = 0.;
158  }
159  LogDebug("PileUpSubtractor") << " ieta : " << it << " Pedestals : " << emean_[it] << " " << esigma_[it] << "\n";
160  }
161 }

References StorageManager_cfg::e1, reco::Candidate::et(), mps_fire::i, LEDCalibrationChannels::ieta, LogDebug, nt, edm::second(), and mathSSE::sqrt().

◆ getEt()

double MultipleAlgoIterator::getEt ( const reco::CandidatePtr in) const

Definition at line 163 of file MultipleAlgoIterator.cc.

163  {
164  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
165  const GlobalPoint& pos = geo_->getPosition(ctc->id());
166  double energy = ctc->emEnergy() + ctc->hadEnergy();
167  double et = energy * sin(pos.theta());
168  return et;
169 }

References CaloTower::emEnergy(), HCALHighEnergyHPDFilter_cfi::energy, EgHLTOffHistBins_cfi::et, CaloTower::hadEnergy(), CaloTower::id(), recoMuon::in, and funct::sin().

◆ getEta()

double MultipleAlgoIterator::getEta ( const reco::CandidatePtr in) const

Definition at line 171 of file MultipleAlgoIterator.cc.

171  {
172  const CaloTower* ctc = dynamic_cast<const CaloTower*>(in.get());
173  const GlobalPoint& pos = geo_->getPosition(ctc->id());
174  double eta = pos.eta();
175  return eta;
176 }

References PVValHelper::eta, CaloTower::id(), and recoMuon::in.

◆ offsetCorrectJets()

void MultipleAlgoIterator::offsetCorrectJets ( )
overridevirtual

Reimplemented from PileUpSubtractor.

Definition at line 16 of file MultipleAlgoIterator.cc.

16  {
17  LogDebug("PileUpSubtractor") << "The subtractor correcting jets...\n";
18  jetOffset_.clear();
19 
20  using namespace reco;
21 
22  (*fjInputs_) = fjOriginalInputs_;
25  const fastjet::JetDefinition& def = *fjJetDefinition_;
26  if (!doAreaFastjet_ && !doRhoFastjet_) {
27  fjClusterSeq_ = std::make_shared<fastjet::ClusterSequence>(*fjInputs_, def);
28  } else {
29  fjClusterSeq_ = ClusterSequencePtr(new fastjet::ClusterSequenceArea(*fjInputs_, def, *fjActiveArea_));
30  }
31 
32  (*fjJets_) = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
33 
34  jetOffset_.reserve(fjJets_->size());
35 
36  vector<fastjet::PseudoJet>::iterator pseudojetTMP = fjJets_->begin(), jetsEnd = fjJets_->end();
37  for (; pseudojetTMP != jetsEnd; ++pseudojetTMP) {
38  int ijet = pseudojetTMP - fjJets_->begin();
39  jetOffset_[ijet] = 0;
40 
41  std::vector<fastjet::PseudoJet> towers = sorted_by_pt(pseudojetTMP->constituents());
42 
43  double newjetet = 0.;
44  for (vector<fastjet::PseudoJet>::const_iterator ito = towers.begin(), towEnd = towers.end(); ito != towEnd; ++ito) {
45  const reco::CandidatePtr& originalTower = (*inputs_)[ito->user_index()];
46  int it = ieta(originalTower);
47  double Original_Et = originalTower->et();
48  double etnew = Original_Et - (*emean_.find(it)).second - (*esigma_.find(it)).second;
49  if (etnew < 0.)
50  etnew = 0;
51  newjetet = newjetet + etnew;
52  jetOffset_[ijet] += Original_Et - etnew;
53  }
54  }
55 }

References spu::def(), reco::Candidate::et(), LEDCalibrationChannels::ieta, LogDebug, edm::second(), and HLT_2018_cff::towers.

◆ rescaleRMS()

void MultipleAlgoIterator::rescaleRMS ( double  s)

Definition at line 10 of file MultipleAlgoIterator.cc.

10  {
11  for (std::map<int, double>::iterator iter = esigma_.begin(); iter != esigma_.end(); ++iter) {
12  iter->second = s * (iter->second);
13  }
14 }

References alignCSCRings::s.

◆ subtractPedestal()

void MultipleAlgoIterator::subtractPedestal ( std::vector< fastjet::PseudoJet > &  coll)
overridevirtual

Reimplemented from PileUpSubtractor.

Definition at line 57 of file MultipleAlgoIterator.cc.

57  {
58  LogDebug("PileUpSubtractor") << "The subtractor subtracting pedestals...\n";
59 
60  int it = -100;
61 
62  vector<fastjet::PseudoJet> newcoll;
63 
64  for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin(), fjInputsEnd = coll.end();
65  input_object != fjInputsEnd;
66  ++input_object) {
67  reco::CandidatePtr const& itow = (*inputs_)[input_object->user_index()];
68 
69  it = ieta(itow);
70  iphi(itow);
71 
72  double Original_Et = itow->et();
73  if (sumRecHits_) {
74  Original_Et = getEt(itow);
75  }
76 
77  double etnew = Original_Et - (*(emean_.find(it))).second - (*(esigma_.find(it))).second;
78  float mScale = etnew / input_object->Et();
79  if (etnew < 0.)
80  mScale = 0.;
81 
82  math::XYZTLorentzVectorD towP4(input_object->px() * mScale,
83  input_object->py() * mScale,
84  input_object->pz() * mScale,
85  input_object->e() * mScale);
86 
87  int index = input_object->user_index();
88  input_object->reset_momentum(towP4.px(), towP4.py(), towP4.pz(), towP4.energy());
89  input_object->set_user_index(index);
90 
91  if (etnew > 0. && dropZeroTowers_)
92  newcoll.push_back(*input_object);
93  }
94 
95  if (dropZeroTowers_)
96  coll = newcoll;
97 }

References reco::Candidate::et(), LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, and LogDebug.

Member Data Documentation

◆ dropZeroTowers_

bool MultipleAlgoIterator::dropZeroTowers_

Definition at line 22 of file MultipleAlgoIterator.h.

◆ sumRecHits_

bool MultipleAlgoIterator::sumRecHits_

Definition at line 21 of file MultipleAlgoIterator.h.

PileUpSubtractor::ClusterSequencePtr
std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
Definition: PileUpSubtractor.h:25
CaloTower::emEnergy
double emEnergy() const
Definition: CaloTower.h:134
PileUpSubtractor::ieta
int ieta(const reco::CandidatePtr &in) const
Definition: PileUpSubtractor.cc:327
PileUpSubtractor::iphi
int iphi(const reco::CandidatePtr &in) const
Definition: PileUpSubtractor.cc:338
mps_fire.i
i
Definition: mps_fire.py:355
nt
int nt
Definition: AMPTWrapper.h:42
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
pos
Definition: PixelAliasList.h:18
CaloTower::id
CaloTowerDetId id() const
Definition: CaloTower.h:127
PileUpSubtractor::doRhoFastjet_
bool doRhoFastjet_
Definition: PileUpSubtractor.h:65
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PileUpSubtractor::fjActiveArea_
ActiveAreaSpecPtr fjActiveArea_
Definition: PileUpSubtractor.h:75
alignCSCRings.s
s
Definition: alignCSCRings.py:92
MultipleAlgoIterator::rescaleRMS
void rescaleRMS(double s)
Definition: MultipleAlgoIterator.cc:10
PVValHelper::eta
Definition: PVValidationHelpers.h:69
PileUpSubtractor::doAreaFastjet_
bool doAreaFastjet_
Definition: PileUpSubtractor.h:64
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CaloTower::hadEnergy
double hadEnergy() const
Definition: CaloTower.h:135
PileUpSubtractor::PileUpSubtractor
PileUpSubtractor(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
Definition: PileUpSubtractor.cc:20
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
Point3DBase< float, GlobalTag >
PileUpSubtractor::geo_
CaloGeometry const * geo_
Definition: PileUpSubtractor.h:76
PileUpSubtractor::jetOffset_
std::vector< double > jetOffset_
Definition: PileUpSubtractor.h:85
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
PileUpSubtractor::fjOriginalInputs_
std::vector< fastjet::PseudoJet > fjOriginalInputs_
Definition: PileUpSubtractor.h:60
PileUpSubtractor::fjJets_
std::vector< fastjet::PseudoJet > * fjJets_
Definition: PileUpSubtractor.h:59
recoMuon::in
Definition: RecoMuonEnumerators.h:6
PileUpSubtractor::fjJetDefinition_
JetDefPtr fjJetDefinition_
Definition: PileUpSubtractor.h:55
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
PileUpSubtractor::geomtowers_
std::map< int, int > geomtowers_
Definition: PileUpSubtractor.h:80
CaloTower
Definition: CaloTower.h:26
PileUpSubtractor::esigma_
std::map< int, double > esigma_
Definition: PileUpSubtractor.h:82
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
MultipleAlgoIterator::getEt
double getEt(const reco::CandidatePtr &in) const
Definition: MultipleAlgoIterator.cc:163
MultipleAlgoIterator::dropZeroTowers_
bool dropZeroTowers_
Definition: MultipleAlgoIterator.h:22
MultipleAlgoIterator::sumRecHits_
bool sumRecHits_
Definition: MultipleAlgoIterator.h:21
edm::Ptr< Candidate >
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
PileUpSubtractor::fjInputs_
std::vector< fastjet::PseudoJet > * fjInputs_
Definition: PileUpSubtractor.h:58
HLT_2018_cff.towers
towers
Definition: HLT_2018_cff.py:35030
eostools.move
def move(src, dest)
Definition: eostools.py:511
PileUpSubtractor::ietamin_
int ietamin_
Definition: PileUpSubtractor.h:78
PileUpSubtractor::ietamax_
int ietamax_
Definition: PileUpSubtractor.h:77
PileUpSubtractor::nSigmaPU_
double nSigmaPU_
Definition: PileUpSubtractor.h:73
MultipleAlgoIterator::subtractPedestal
void subtractPedestal(std::vector< fastjet::PseudoJet > &coll) override
Definition: MultipleAlgoIterator.cc:57
PileUpSubtractor::jetPtMin_
double jetPtMin_
Definition: PileUpSubtractor.h:66
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
PileUpSubtractor::ntowersWithJets_
std::map< int, int > ntowersWithJets_
Definition: PileUpSubtractor.h:81
PileUpSubtractor::emean_
std::map< int, double > emean_
Definition: PileUpSubtractor.h:83
PileUpSubtractor::fjClusterSeq_
ClusterSequencePtr fjClusterSeq_
Definition: PileUpSubtractor.h:56
reco::Candidate::et
virtual double et() const =0
transverse energy