75 produces<CaloTowerCollection>();
96 <<
" are invalid. empty merged collection";
97 iEvent.put(std::make_unique<CaloTowerCollection>());
101 regTower = extraTower;
102 iEvent.put(std::make_unique<CaloTowerCollection>(*regTower));
106 auto output = std::make_unique<CaloTowerCollection>();
114 std::vector<CaloTowerCollection::const_iterator> overlappingTowers;
115 overlappingTowers.reserve(extraTower->
size());
117 for (; rt_it != rt_end; ++rt_it) {
119 if (et_it != extraTower->
end()) {
129 overlappingTowers.push_back(et_it);
133 output->push_back(*rt_it);
139 for (; et_it != et_end; ++et_it) {
140 if (
std::find(overlappingTowers.begin(), overlappingTowers.end(), et_it) == overlappingTowers.end())
143 output->push_back(*et_it);
156 double newOuterE = 0;
164 if (
rt.ietaAbs() < 16 && (fabs(
rt.outerEnergy() -
et.outerEnergy()) < 0.00001)) {
166 newOuterE =
rt.outerEnergy();
168 newOuterE =
rt.outerEnergy() +
et.outerEnergy();
171 bool rt_hasEcalConstit =
false;
172 bool et_hasEcalConstit =
false;
174 bool rt_hasHcalConstit =
false;
175 bool et_hasHcalConstit =
false;
179 std::vector<DetId>::const_iterator rc_begin =
rt.constituents().begin();
180 std::vector<DetId>::const_iterator rc_end =
rt.constituents().end();
181 std::vector<DetId>::const_iterator rc_it;
183 for (rc_it = rc_begin; rc_it != rc_end; ++rc_it) {
185 rt_hasHcalConstit =
true;
188 for (rc_it = rc_begin; rc_it != rc_end; ++rc_it) {
190 rt_hasEcalConstit =
true;
194 std::vector<DetId>::const_iterator ec_begin =
et.constituents().begin();
195 std::vector<DetId>::const_iterator ec_end =
et.constituents().end();
196 std::vector<DetId>::const_iterator ec_it;
198 for (ec_it = ec_begin; ec_it != ec_end; ++ec_it) {
200 et_hasHcalConstit =
true;
203 for (ec_it = ec_begin; ec_it != ec_end; ++ec_it) {
205 et_hasEcalConstit =
true;
209 std::vector<DetId> combinedConstituents =
rt.constituents();
210 for (ec_it = ec_begin; ec_it != ec_end; ++ec_it) {
213 if (
std::find(combinedConstituents.begin(), combinedConstituents.end(), *ec_it) == combinedConstituents.end())
214 combinedConstituents.push_back(*ec_it);
223 if (rt_hasEcalConstit && et_hasEcalConstit) {
224 if (
rt.emEnergy() > 0 &&
et.emEnergy() > 0) {
225 double sumEmE =
rt.emEnergy() +
et.emEnergy();
227 double x =
rt.emEnergy() *
rt.emPosition().x() +
et.emEnergy() *
et.emPosition().x();
228 double y =
rt.emEnergy() *
rt.emPosition().y() +
et.emEnergy() *
et.emPosition().y();
229 double z =
rt.emEnergy() *
rt.emPosition().z() +
et.emEnergy() *
et.emPosition().z();
231 GlobalPoint weightedEmdPosition(
x / sumEmE,
y / sumEmE,
z / sumEmE);
232 newEmPosition = weightedEmdPosition;
235 }
else if (rt_hasEcalConstit && !et_hasEcalConstit) {
236 newEmPosition =
rt.emPosition();
237 }
else if (!rt_hasEcalConstit && et_hasEcalConstit) {
238 newEmPosition =
et.emPosition();
243 if (rt_hasHcalConstit) {
244 newHadPosition =
rt.hadPosition();
245 }
else if (et_hasHcalConstit) {
246 newHadPosition =
et.hadPosition();
252 rt.emEnergy() +
et.emEnergy(),
253 rt.hadEnergy() +
et.hadEnergy(),
266 unsigned int numBadHcalChan =
rt.numBadHcalCells() -
et.numProblematicHcalCells() -
rt.numRecoveredHcalCells();
267 unsigned int numBadEcalChan =
rt.numBadEcalCells() -
et.numProblematicEcalCells() -
rt.numRecoveredEcalCells();
269 unsigned int numProbHcalChan =
rt.numProblematicHcalCells() +
et.numProblematicHcalCells();
270 unsigned int numProbEcalChan =
rt.numProblematicEcalCells() +
et.numProblematicEcalCells();
272 unsigned int numRecHcalChan =
rt.numRecoveredHcalCells() +
et.numRecoveredHcalCells();
273 unsigned int numRecEcalChan =
rt.numRecoveredEcalCells() +
et.numRecoveredEcalCells();
276 numBadHcalChan, numBadEcalChan, numRecHcalChan, numRecEcalChan, numProbHcalChan, numProbEcalChan);
edm::EDGetTokenT< CaloTowerCollection > tok_reg_
CaloTower mergedTower(const CaloTower &t1, const CaloTower &t2)
T getParameter(std::string const &) const
CaloTowersMerger(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
void setCaloTowerStatus(unsigned int numBadHcalChan, unsigned int numBadEcalChan, unsigned int numRecHcalChan, unsigned int numRecEcalChan, unsigned int numProbHcalChan, unsigned int numProbEcalChan)
edm::EDGetTokenT< CaloTowerCollection > tok_ext_
std::vector< CaloTower >::const_iterator const_iterator
edm::InputTag extraTowerTag
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void setHottestCellE(double e)
void addConstituents(const std::vector< DetId > &ids)
const_iterator begin() const
const_iterator end() const
void produce(edm::Event &, const edm::EventSetup &) override
edm::InputTag regularTowerTag
~CaloTowersMerger() override
iterator find(key_type k)