Skip to content

Commit

Permalink
Merge pull request cms-sw#2845 from davidlange6/static_Var_fixes_v2
Browse files Browse the repository at this point in the history
MT -- Removing use of statics in reco
  • Loading branch information
ktf committed Mar 16, 2014
2 parents 829fdf3 + 6757e83 commit b09da1f
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 102 deletions.
2 changes: 1 addition & 1 deletion EventFilter/RPCRawToDigi/plugins/RPCUnpackingModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void RPCUnpackingModule::beginRun(const edm::Run &run, const edm::EventSetup& es

void RPCUnpackingModule::produce(Event & ev, const EventSetup& es)
{
static bool debug = edm::MessageDrop::instance()->debugEnabled;
bool debug = edm::MessageDrop::instance()->debugEnabled;
eventCounter_++;
if (debug) LogDebug ("RPCUnpacker::produce") <<"Beginning To Unpack Event: "<<eventCounter_;

Expand Down
21 changes: 8 additions & 13 deletions RecoJets/JetPlusTracks/plugins/SimpleZSPJPTJetCorrector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,20 @@ typedef ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > XYZTLorentzVec
using namespace std;


namespace zspjpt {

bool debug = false;

} // namespace

SimpleZSPJPTJetCorrector::SimpleZSPJPTJetCorrector ()
{}
{ debug_=false;}

SimpleZSPJPTJetCorrector::SimpleZSPJPTJetCorrector (const std::string& fDataFile)
{
debug_=false;
mParameters = new JetCorrectorParameters (fDataFile,"");

//std::cout<<" Formula "<<((mParameters->definitions()).formula()).c_str()<<std::endl;

mFunc = new TFormula("function",((mParameters->definitions()).formula()).c_str());

// Read parameters
if (zspjpt::debug) {
if (debug_) {
std::cout<<" Size of parameters as read by SimpleJetCorrectorParameters "<<mParameters->size()<<std::endl;
for(unsigned int i = 0; i<mParameters->size(); i++){
const std::vector<float> p = mParameters->record (i).parameters ();
Expand Down Expand Up @@ -74,7 +69,7 @@ double SimpleZSPJPTJetCorrector::correctionEtEtaPhiP (double fEt, double fEta, d
mFunc->SetParameter(i,p[i]);
}

if (zspjpt::debug) {
if (debug_) {
cout<<" Et and eta of jet "<<et<<" "<<eta<<" bin "<<band<<" "<<p[1]<<" "<<p[2]<<" "<<p[3]<<
" "<<p[4]<<" "<<p[5]<<endl;
}
Expand All @@ -90,13 +85,13 @@ double SimpleZSPJPTJetCorrector::correctionEtEtaPhiP (double fEt, double fEta, d
//
if(koef <= 0.000001)
{
if (zspjpt::debug) std::cout<<"SimpleZSPJPTJetCorrector::Problem with ZSP corrections "<<koef<<std::endl;
if (debug_) std::cout<<"SimpleZSPJPTJetCorrector::Problem with ZSP corrections "<<koef<<std::endl;
koef = 1.;
}

double etnew = et/koef;

if (zspjpt::debug) cout<<" The new energy found "<<etnew<<" "<<et<<" "<<koef<<endl;
if (debug_) cout<<" The new energy found "<<etnew<<" "<<et<<" "<<koef<<endl;

return etnew/et;
}
Expand All @@ -115,14 +110,14 @@ double SimpleZSPJPTJetCorrector::correctionPUEtEtaPhiP (double fEt, double fEta,

const std::vector<float> p = mParameters->record (band).parameters ();

if (zspjpt::debug) {
if (debug_) {
cout<<" Et and eta of jet "<<et<<" "<<eta<<" bin "<<band<<std::endl;
}

double koef = (et-p[2])/et;
double etnew = et/koef;

if (zspjpt::debug) cout<<" The new energy found "<<etnew<<" "<<et<<endl;
if (debug_) cout<<" The new energy found "<<etnew<<" "<<et<<endl;

return etnew/et;
}
Expand Down
2 changes: 2 additions & 0 deletions RecoJets/JetPlusTracks/plugins/SimpleZSPJPTJetCorrector.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class SimpleZSPJPTJetCorrector {
SimpleZSPJPTJetCorrector& operator= (const SimpleZSPJPTJetCorrector&);
JetCorrectorParameters* mParameters;
TFormula* mFunc;
bool debug_; //removing statics - just add it to the class for now

};

#endif
1 change: 0 additions & 1 deletion RecoLocalCalo/CaloTowersCreator/interface/EScales.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ struct EScales{
double HF2Scale;
std::string instanceLabel;
};
struct EScales EScales;

#endif

18 changes: 0 additions & 18 deletions RecoLocalCalo/CaloTowersCreator/interface/ctEScales.h

This file was deleted.

48 changes: 12 additions & 36 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,11 @@
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "RecoLocalCalo/CaloTowersCreator/interface/EScales.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"
// severity level for ECAL
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
#include "CommonTools/Utils/interface/StringToEnumValue.h"

const std::vector<double>&
CaloTowersCreator::getGridValues()
{
static std::vector<double> retval;

if (retval.size() == 0)
{
retval.push_back(0.);
retval.push_back(10.);
retval.push_back(20.);
retval.push_back(30.);
retval.push_back(40.);
retval.push_back(50.);
retval.push_back(100.);
retval.push_back(1000.);
}

return retval;
}


CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) :
algo_(conf.getParameter<double>("EBThreshold"),
Expand Down Expand Up @@ -118,14 +97,14 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) :
toks_ecal_.push_back(consumes<EcalRecHitCollection>(ecalLabels_[i]));


EBEScale=EScales.EBScale;
EEEScale=EScales.EEScale;
HBEScale=EScales.HBScale;
HESEScale=EScales.HESScale;
HEDEScale=EScales.HEDScale;
HOEScale=EScales.HOScale;
HF1EScale=EScales.HF1Scale;
HF2EScale=EScales.HF2Scale;
EBEScale=eScales_.EBScale;
EEEScale=eScales_.EEScale;
HBEScale=eScales_.HBScale;
HESEScale=eScales_.HESScale;
HEDEScale=eScales_.HEDScale;
HOEScale=eScales_.HOScale;
HF1EScale=eScales_.HF1Scale;
HF2EScale=eScales_.HF2Scale;

// get the Ecal severities to be excluded
const std::vector<std::string> severitynames =
Expand All @@ -137,8 +116,8 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) :
theEcalSeveritiesToBeUsedInBadTowers_ =
StringToEnumValue<EcalSeverityLevel::SeverityLevel>(conf.getParameter<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers") );

if (EScales.instanceLabel=="") produces<CaloTowerCollection>();
else produces<CaloTowerCollection>(EScales.instanceLabel);
if (eScales_.instanceLabel=="") produces<CaloTowerCollection>();
else produces<CaloTowerCollection>(eScales_.instanceLabel);

/*
std::cout << "VI Producer "
Expand Down Expand Up @@ -262,16 +241,13 @@ void CaloTowersCreator::produce(edm::Event& e, const edm::EventSetup& c) {
else if ((ec_tmp->begin()->detid()).subdetId() == EcalEndcap ) {
eeHandle = ec_tmp;
}

}

algo_.setEbHandle(ebHandle);
algo_.setEeHandle(eeHandle);

//-----------------------------------------------------------



bool present;

// Step A/C: Get Inputs and process (repeatedly)
Expand Down Expand Up @@ -308,8 +284,8 @@ void CaloTowersCreator::produce(edm::Event& e, const edm::EventSetup& c) {
*/

// Step D: Put into the event
if (EScales.instanceLabel=="") e.put(prod);
else e.put(prod,EScales.instanceLabel);
if (eScales_.instanceLabel=="") e.put(prod);
else e.put(prod,eScales_.instanceLabel);


}
Expand Down
3 changes: 2 additions & 1 deletion RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
#include "RecoLocalCalo/CaloTowersCreator/interface/CaloTowersCreationAlgo.h"

#include "RecoLocalCalo/CaloTowersCreator/interface/EScales.h"

/** \class CaloTowersCreator
*
Expand Down Expand Up @@ -74,6 +74,7 @@ class CaloTowersCreator : public edm::EDProducer {
edm::ESWatcher<HcalChannelQualityRcd> hcalChStatusWatcher_;
edm::ESWatcher<IdealGeometryRecord> caloTowerConstituentsWatcher_;
edm::ESWatcher<EcalSeverityLevelAlgoRcd> ecalSevLevelWatcher_;
EScales eScales_;

};

Expand Down
27 changes: 0 additions & 27 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersReCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "RecoLocalCalo/CaloTowersCreator/interface/ctEScales.h"

CaloTowersReCreator::CaloTowersReCreator(const edm::ParameterSet& conf) :
algo_(0.,0., false, false, false, false, 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0., // thresholds cannot be reapplied
Expand Down Expand Up @@ -52,8 +51,6 @@ CaloTowersReCreator::CaloTowersReCreator(const edm::ParameterSet& conf) :
HOEScale=conf.getParameter<double>("HOEScale");
HF1EScale=conf.getParameter<double>("HF1EScale");
HF2EScale=conf.getParameter<double>("HF2EScale");
if (ctEScales.instanceLabel=="") produces<CaloTowerCollection>();
else produces<CaloTowerCollection>(ctEScales.instanceLabel);
// two notes:
// 1) all this could go in a pset
// 2) not clear the instanceLabel thing
Expand Down Expand Up @@ -84,26 +81,6 @@ void CaloTowersReCreator::produce(edm::Event& e, const edm::EventSetup& c) {
edm::Handle<CaloTowerCollection> calt;
e.getByToken(tok_calo_,calt);

/*
if (!calt.isValid()) {
// can't find it!
if (!allowMissingInputs_) {
*calt; // will throw the proper exception
}
} else {
algo_.process(*calt);
}
// Step B: Create empty output
std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
// Step C: Process
algo_.finish(*prod);
// Step D: Put into the event
if (ctEScales.instanceLabel=="") e.put(prod);
else e.put(prod,ctEScales.instanceLabel);
*/

// modified to rescale the CaloTowers directly
// without going through metatowers
Expand All @@ -122,10 +99,6 @@ void CaloTowersReCreator::produce(edm::Event& e, const edm::EventSetup& c) {
// step C: rescale (without going threough metataowers)
algo_.rescaleTowers(*calt, *prod);

// Step D: Put into the event
if (ctEScales.instanceLabel=="") e.put(prod);
else e.put(prod,ctEScales.instanceLabel);
}

}

7 changes: 2 additions & 5 deletions RecoLocalCalo/HcalRecAlgos/src/HBHEPulseShapeFlag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,8 @@ double HBHEPulseShapeFlagSetter::DualNominalFitSingleTry(const std::vector<doubl
if(CumulativeIdealPulse[Offset+250] - CumulativeIdealPulse[Offset] < 1e-5)
return 1000000;

static std::vector<double> F1;
static std::vector<double> F2;

F1.resize(DigiSize);
F2.resize(DigiSize);
std::vector<double> F1(DigiSize);
std::vector<double> F2(DigiSize);

double SumF1F1 = 0;
double SumF1F2 = 0;
Expand Down

0 comments on commit b09da1f

Please sign in to comment.