Skip to content

Commit

Permalink
Fix memory leak in EGamma algo
Browse files Browse the repository at this point in the history
---
yaml
---
svn_rev: 139994
current_ref: refs/heads/usePFclusteringInRegionsForMuonsBackUp
current_commit: e4432b3
head_branch: refs/heads/CMSSW_4_1_X
  • Loading branch information
R. Alex Barbieri committed May 14, 2014
1 parent b7aa279 commit 3343588
Show file tree
Hide file tree
Showing 16 changed files with 458 additions and 366 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ refs/heads/CMSSW_4_1_X: a4334f9063dcad3cb0c038ac911fd8357c3bbaaa
refs/heads/with_VBF_Hbb_fragment: 5b1f2347e6db46cfd6288879a97056d280cf27c5
refs/heads/withOnlineToOfflineProducer: c0b9423e0d6c6d5315f93d1ee32e9bf68078d9c0
refs/heads/withNewDZ: a67661d3e05d8a51194ddc51d1ff68044af2314a
refs/heads/usePFclusteringInRegionsForMuonsBackUp: 252c4507d30da9c838013ec506616cf2103c9d63
refs/heads/usePFclusteringInRegionsForMuonsBackUp: e4432b3e0e0ad1910e6fe182d344dcd4016a2d67
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// Description: Placeholder for calorimeter trigger parameters
///
/// Implementation:
///
///
///
/// \author: Jim Brooke
///
Expand All @@ -14,21 +14,15 @@

#include "CondFormats/L1TObjects/interface/LUT.h"

#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
#include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1HtMissScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1HfRingEtScaleRcd.h"

#include <memory>
#include <iostream>
#include <vector>
#include <cmath>

namespace l1t {

class CaloParams {

public:

CaloParams() {}
Expand Down Expand Up @@ -79,7 +73,7 @@ namespace l1t {
double egMaxHcalEt() const { return egMaxHcalEt_; }
int egEtToRemoveHECutHw() const {return floor(egEtToRemoveHECut_/egLsb_);}
double egEtToRemoveHECut() const {return egEtToRemoveHECut_;}
double egMaxHOverE() const { return egMaxHOverE_; }
double egMaxHOverE() const { return egMaxHOverE_; }
double egRelativeJetIsolationCut() const { return egRelativeJetIsolationCut_; }
unsigned egIsoAreaNrTowersEta()const{return egIsoAreaNrTowersEta_;}
unsigned egIsoAreaNrTowersPhi()const{return egIsoAreaNrTowersPhi_;}
Expand All @@ -91,7 +85,7 @@ namespace l1t {
l1t::LUT* egIsolationLUT() { return egIsolationLUT_.get(); }
std::string egCalibrationType() const { return egCalibrationType_; }
std::vector<double> egCalibrationParams() { return egCalibrationParams_; }
L1CaloEtScale emScale() { return emScale_; }


void setEgLsb(double lsb) { egLsb_ = lsb; }
void setEgSeedThreshold(double thresh) { egSeedThreshold_ = thresh; }
Expand All @@ -100,7 +94,7 @@ namespace l1t {
void setEgEtToRemoveHECut(double thresh) { egEtToRemoveHECut_ = thresh;}
void setEgMaxHOverE(double cut) { egMaxHOverE_ = cut; }
void setEgRelativeJetIsolationCut(double cutValue) { egRelativeJetIsolationCut_ = cutValue; }

void setEgIsoAreaNrTowersEta(unsigned iEgIsoAreaNrTowersEta){egIsoAreaNrTowersEta_=iEgIsoAreaNrTowersEta;}
void setEgIsoAreaNrTowersPhi(unsigned iEgIsoAreaNrTowersPhi){egIsoAreaNrTowersPhi_=iEgIsoAreaNrTowersPhi;}
void setEgIsoVetoNrTowersPhi(unsigned iEgIsoVetoNrTowersPhi){egIsoVetoNrTowersPhi_=iEgIsoVetoNrTowersPhi;}
Expand All @@ -111,7 +105,6 @@ namespace l1t {
void setEgIsolationLUT(std::shared_ptr<LUT> lut) { egIsolationLUT_ = lut; }
void setEgCalibrationType(std::string type) { egCalibrationType_ = type; }
void setEgCalibrationParams(std::vector<double> params) { egCalibrationParams_ = params; }
void setEmScale(L1CaloEtScale emScale) { emScale_ = emScale; }


// tau
Expand Down Expand Up @@ -145,7 +138,6 @@ namespace l1t {
std::vector<double> jetPUSParams() { return jetPUSParams_; }
std::string jetCalibrationType() const { return jetCalibrationType_; }
std::vector<double> jetCalibrationParams() { return jetCalibrationParams_; }
L1CaloEtScale jetScale() { return jetScale_; }

void setJetLsb(double lsb) { jetLsb_ = lsb; }
void setJetSeedThreshold(double thresh) { jetSeedThreshold_ = thresh; }
Expand All @@ -154,24 +146,19 @@ namespace l1t {
void setJetPUSParams(std::vector<double> params) { jetPUSParams_ = params; }
void setJetCalibrationType(std::string type) { jetCalibrationType_ = type; }
void setJetCalibrationParams(std::vector<double> params) { jetCalibrationParams_ = params; }
void setJetScale(L1CaloEtScale jetScale) { jetScale_ = jetScale; }



// sums
double etSumLsb() const { return etSumLsb_; }
int etSumEtaMin(unsigned isum) const;
int etSumEtaMax(unsigned isum) const;
int etSumEtThresholdHw(unsigned isum) const { return floor(etSumEtThreshold(isum)/etSumLsb_); }
double etSumEtThreshold(unsigned isum) const;
L1CaloEtScale HtMissScale() {return HtMissScale_;}
L1CaloEtScale HfRingScale() {return HfRingScale_;}


void setEtSumLsb(double lsb) { etSumLsb_ = lsb; }
void setEtSumEtaMin(unsigned isum, int eta);
void setEtSumEtaMax(unsigned isum, int eta);
void setEtSumEtThreshold(unsigned isum, double thresh);
void setHtMissScale(L1CaloEtScale HtMissScale){HtMissScale_ = HtMissScale;}
void setHfRingScale(L1CaloEtScale HfRingScale){HfRingScale_ = HfRingScale;}
void setEtSumEtThreshold(unsigned isum, double thresh);

// print parameters to stream:
void print(std::ostream&) const;
Expand Down Expand Up @@ -227,7 +214,7 @@ namespace l1t {

// bitmask for storing ECAL/HCAL ratio in tower object
int towerMaskRatio_;

// turn encoding on/off
bool towerDoEncoding_;

Expand Down Expand Up @@ -262,24 +249,24 @@ namespace l1t {

// Et threshold to remove the H/E cut from the EGammas
double egEtToRemoveHECut_;

// EG maximum value of H/E
double egMaxHOverE_;

// Relative jet isolation cut for EG (Stage1Layer2)
double egRelativeJetIsolationCut_;

// isolation area in eta is seed tower +/- <=egIsoAreaNrTowersPhi
unsigned egIsoAreaNrTowersEta_;
unsigned egIsoAreaNrTowersEta_;

// isolation area in phi is seed tower +/- <=egIsoAreaNrTowersPhi
unsigned egIsoAreaNrTowersPhi_;
unsigned egIsoAreaNrTowersPhi_;

// veto region is seed tower +/- <=egIsoVetoNrTowersPhi
unsigned egIsoVetoNrTowersPhi_;

unsigned egIsoVetoNrTowersPhi_;
// for # towers based PU estimator, estimator is #towers/egIsoPUEstTowerGranularity_
unsigned egIsoPUEstTowerGranularity_;
unsigned egIsoPUEstTowerGranularity_;

// eta range over which # towers is estimated
unsigned egIsoMaxEtaAbsForTowerSum_;
Expand All @@ -292,16 +279,14 @@ namespace l1t {

// EG calibration coefficients
std::vector<double> egCalibrationParams_;

// EG isolation PUS
std::string egIsoPUSType_;

// EG isolation LUT (indexed by eta, Et ?)
std::shared_ptr<l1t::LUT> egIsolationLUT_;

L1CaloEtScale emScale_;




/* Tau */

Expand All @@ -313,7 +298,7 @@ namespace l1t {

// Et threshold on tau neighbour towers
double tauNeighbourThreshold_;

// Relative jet isolation cut for Taus (Stage1Layer2)
double tauRelativeJetIsolationCut_;
// Tau isolation PUS
Expand Down Expand Up @@ -342,7 +327,7 @@ namespace l1t {
double jetNeighbourThreshold_;

// jet PUS scheme ("None" means no PU)
std::string jetPUSType_;
std::string jetPUSType_;

// jet PU params
std::vector<double> jetPUSParams_;
Expand All @@ -353,8 +338,6 @@ namespace l1t {
// jet calibration coefficients
std::vector<double> jetCalibrationParams_;

L1CaloEtScale jetScale_;



/* Sums */
Expand All @@ -378,9 +361,6 @@ namespace l1t {
int minGctEtaForSums_;
int maxGctEtaForSums_;

L1CaloEtScale HtMissScale_;
L1CaloEtScale HfRingScale_;

};

}// namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ namespace l1t {

class Stage1Layer2SingleTrackHI : public Stage1Layer2TauAlgorithm {
public:
Stage1Layer2SingleTrackHI(CaloParams* params);
Stage1Layer2SingleTrackHI();
virtual ~Stage1Layer2SingleTrackHI();
virtual void processEvent(const std::vector<l1t::CaloEmCand> & clusters,
virtual void processEvent(//const std::vector<l1t::CaloStage1> & clusters,
const std::vector<l1t::CaloEmCand> & clusters,
const std::vector<l1t::CaloRegion> & regions,
const std::vector<l1t::Jet> * jets,
std::vector<l1t::Tau> * taus);

private:
CaloParams* const params_;

/* private: */
/* double regionLSB_; */
};

class Stage1Layer2TauAlgorithmImpPP : public Stage1Layer2TauAlgorithm {
Expand All @@ -33,15 +33,15 @@ namespace l1t {
const std::vector<l1t::Jet> * jets,
std::vector<l1t::Tau> * taus);

private:
private:

CaloParams* const params_;

int AssociatedSecondRegionEt(int ieta, int iphi,
const std::vector<l1t::CaloRegion> & regions,
double& isolation) const;

double JetIsolation(int et, int ieta, int iphi,
double JetIsolation(int et, int ieta, int iphi,
const std::vector<l1t::Jet> & jets) const;

//int tauSeed;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es)
Handle<l1t::EtSumBxCollection> EtSum;
e.getByToken(EtSumToken_,EtSum);

edm::ESHandle< L1CaloEtScale > emScale ;
es.get< L1EmEtScaleRcd >().get( emScale ) ;

edm::ESHandle< L1CaloEtScale > jetScale ;
es.get< L1JetEtScaleRcd >().get( jetScale ) ;


// create the em and jet collections
std::auto_ptr<L1GctEmCandCollection> isoEmResult(new L1GctEmCandCollection( ) );
std::auto_ptr<L1GctEmCandCollection> nonIsoEmResult(new L1GctEmCandCollection( ) );
Expand Down Expand Up @@ -140,10 +147,15 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es)
int tauCount = 0; //max 4
for(l1t::TauBxCollection::const_iterator itTau = Tau->begin(itBX);
itTau != Tau->end(itBX); ++itTau){
// taus are not allowed to be forward
const bool forward= false;
// forward def is okay for Taus
const bool forward= (itTau->hwEta() < 4 || itTau->hwEta() > 17);
const uint16_t rankPt = jetScale->rank((uint16_t)itTau->hwPt());

unsigned iEta = itTau->hwEta();
unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11);
unsigned gtEta=(((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0));

L1GctJetCand TauCand(itTau->hwPt(), itTau->hwPhi(), itTau->hwEta(),
L1GctJetCand TauCand(rankPt, itTau->hwPhi(), gtEta,
true, forward,0, 0, itBX);
//L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
// bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
Expand All @@ -160,7 +172,13 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es)
itJet != Jet->end(itBX); ++itJet){
// use 2nd quality bit to define forward
const bool forward = ((itJet->hwQual() & 0x2) != 0);
L1GctJetCand JetCand(itJet->hwPt(), itJet->hwPhi(), itJet->hwEta(),
const uint16_t rankPt = jetScale->rank((uint16_t)itJet->hwPt());

unsigned iEta = itJet->hwEta();
unsigned rctEta = (iEta<11 ? 10-iEta : iEta-11);
unsigned gtEta=(((rctEta % 7) & 0x7) | (iEta<11 ? 0x8 : 0));

L1GctJetCand JetCand(rankPt, itJet->hwPhi(), gtEta,
false, forward,0, 0, itBX);
//L1GctJetCand(unsigned rank, unsigned phi, unsigned eta,
// bool isTau, bool isFor, uint16_t block, uint16_t index, int16_t bx);
Expand All @@ -177,7 +195,6 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es)
}
}
}

//looping over EtSum elments with a specific BX
for (l1t::EtSumBxCollection::const_iterator itEtSum = EtSum->begin(itBX);
itEtSum != EtSum->end(itBX); ++itEtSum){
Expand All @@ -200,6 +217,28 @@ l1t::L1TCaloUpgradeToGCTConverter::produce(Event& e, const EventSetup& es)
}
}



//*isoEmResult =
//this->ConvertToNonIsoEmCand(EGamma);
// DataFormatter.ConvertToNonIsoEmCand(*EGamma, nonIsoEmResult);
// DataFormatter.ConvertToCenJetCand(*Jet, cenJetResult);
// DataFormatter.ConvertToForJetCand(*Jet, forJetResult);
// DataFormatter.ConvertToTauJetCand(*Tau, tauJetResult);

// DataFormatter.ConvertToEtTotal(EtSum, etTotResult);
// DataFormatter.ConvertToEtHad(EtSum,etHadResult);
// DataFormatter.ConvertToEtMiss(EtSum,etMissResult);
// DataFormatter.ConvertToHtMiss(EtSum,htMissResult);
// DataFormatter.ConvertToHFBitCounts(EtSum,hfBitCountResult);
// DataFormatter.ConvertToHFRingEtSums(EtSum, hfRingEtSumResult);

// DataFormatter.ConvertToIntJet(Jet, internalJetResult);
// DataFormatter.ConvertToIntEtSum(EtSum,internalEtSumResult);
// DataFormatter.ConvertToIntHtMiss(EtSum,internalHtMissResult);



e.put(isoEmResult,"isoEm");
e.put(nonIsoEmResult,"nonIsoEm");
e.put(cenJetResult,"cenJets");
Expand Down
Loading

0 comments on commit 3343588

Please sign in to comment.