Skip to content

Commit

Permalink
Take care of most of the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Apr 10, 2017
1 parent 387a9c0 commit 9cd2b60
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
12 changes: 8 additions & 4 deletions Calibration/HcalCalibAlgos/plugins/HcalHBHEMuonAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class HcalHBHEMuonAnalyzer : public edm::EDAnalyzer {
std::string labelVtx_, labelHBHERecHit_, labelMuon_;
int verbosity_, maxDepth_, kount_;
bool useRaw_;
const int MaxDepth=7;

edm::EDGetTokenT<edm::TriggerResults> tok_trigRes_;
edm::EDGetTokenT<reco::VertexCollection> tok_Vtx_;
Expand Down Expand Up @@ -146,8 +147,8 @@ HcalHBHEMuonAnalyzer::HcalHBHEMuonAnalyzer(const edm::ParameterSet& iConfig) {
labelMuon_ = iConfig.getParameter<std::string>("LabelMuon");
verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
maxDepth_ = iConfig.getUntrackedParameter<int>("MaxDepth",4);
if (maxDepth_ > 7) maxDepth_ = 7;
else if (maxDepth_ < 1) maxDepth_ = 4;
if (maxDepth_ > MaxDepth) maxDepth_ = MaxDepth;
else if (maxDepth_ < 1) maxDepth_ = 4;
std::string modnam = iConfig.getUntrackedParameter<std::string>("ModuleName","");
std::string procnm = iConfig.getUntrackedParameter<std::string>("ProcessName","");
useRaw_ = iConfig.getUntrackedParameter<bool>("UseRaw",false);
Expand Down Expand Up @@ -191,6 +192,8 @@ HcalHBHEMuonAnalyzer::~HcalHBHEMuonAnalyzer() {
void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
++kount_;
clearVectors();
// depthHE is the first depth index for HE for |ieta| = 16
// It used to be 3 for all runs preceding 2017 and 4 beyond that
int depthHE = (maxDepth_ <= 6) ? 3 : 4;
runNumber_ = iEvent.id().run();
eventNumber_ = iEvent.id().event();
Expand Down Expand Up @@ -384,10 +387,11 @@ void HcalHBHEMuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSet
hoEnergy_.push_back(RecMuon->calEnergy().hoS9);

double eEcal(0), eHcal(0), activeLengthTot(0), activeLengthHotTot(0);
double eHcalDepth[7], eHcalDepthHot[7], activeL[7], activeHotL[7];
double eHcalDepth[MaxDepth], eHcalDepthHot[MaxDepth];
double activeL[MaxDepth], activeHotL[MaxDepth];
unsigned int isHot(0);
bool tmpmatch(false);
for (int i=0; i<7; ++i)
for (int i=0; i<MaxDepth; ++i)
eHcalDepth[i] = eHcalDepthHot[i] = activeL[i] = activeHotL[i] = -10000;

if (RecMuon->innerTrack().isNonnull()) {
Expand Down
39 changes: 28 additions & 11 deletions Calibration/IsolatedParticles/plugins/HcalHBHEMuonSimAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand Down Expand Up @@ -64,7 +64,8 @@ class HcalHBHEMuonSimAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns,
int verbosity_, maxDepth_;
double etaMax_;
std::vector<HcalDDDRecConstants::HcalActiveLength> actHB_, actHE_;

const int MaxDepth=7;
const int idMuon_=13;
double tMinE_, tMaxE_, tMinH_, tMaxH_;
edm::Service<TFileService> fs_;
edm::EDGetTokenT<edm::SimTrackContainer> tok_SimTk_;
Expand Down Expand Up @@ -96,7 +97,7 @@ class HcalHBHEMuonSimAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns,

HcalHBHEMuonSimAnalyzer::HcalHBHEMuonSimAnalyzer(const edm::ParameterSet& iConfig) {

usesResource("TFileService");
usesResource(TFileService::kSharedResource);

//now do what ever initialization is needed
g4Label_ = iConfig.getParameter<std::string>("ModuleLabel");
Expand All @@ -116,8 +117,8 @@ HcalHBHEMuonSimAnalyzer::HcalHBHEMuonSimAnalyzer(const edm::ParameterSet& iConfi
tok_caloEB_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_,ebLabel_));
tok_caloEE_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_,eeLabel_));
tok_caloHH_ = consumes<edm::PCaloHitContainer>(edm::InputTag(g4Label_,hcLabel_));
if (maxDepth_ > 7) maxDepth_ = 7;
else if (maxDepth_ < 1) maxDepth_ = 4;
if (maxDepth_ > MaxDepth) maxDepth_ = MaxDepth;
else if (maxDepth_ < 1) maxDepth_ = 4;

std::cout << "Labels: " << g4Label_ << ":" << ebLabel_ << ":" << eeLabel_
<< ":" << hcLabel_ << "\nVerbosity " << verbosity_ << " MaxDepth "
Expand All @@ -136,6 +137,8 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent,
#ifdef EDM_ML_DEBUG
debug = ((verbosity_/10)>0);
#endif
// depthHE is the first depth index for HE for |ieta| = 16
// It used to be 3 for all runs preceding 2017 and 4 beyond that
int depthHE = (maxDepth_ <= 6) ? 3 : 4;

edm::ESHandle<HcalDDDRecConstants> pHRNDC;
Expand Down Expand Up @@ -164,6 +167,9 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent,
std::vector<PCaloHit> calohh;
bool testN(false);
for (unsigned int k=1; k<pcalohh->size(); ++k) {
// if it is a standard DetId bits 28..31 will carry the det #
// for HCAL det # is 4 and if there is at least one hit in the collection
// have det # which is not 4 this collection is created using TestNumbering
int det = ((((*pcalohh)[k].id())>>28)&0xF);
if (det != 4) {testN = true; break;}
}
Expand Down Expand Up @@ -199,15 +205,16 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent,
// Loop over all SimTracks
for (edm::SimTrackContainer::const_iterator simTrkItr=SimTk->begin();
simTrkItr!= SimTk->end(); simTrkItr++) {
if ((std::abs(simTrkItr->type()) == 13) && (simTrkItr->vertIndex() == 0) &&
if ((std::abs(simTrkItr->type()) == idMuon_) && (simTrkItr->vertIndex() == 0) &&
(std::abs(simTrkItr->momentum().eta()) < etaMax_)) {
unsigned int thisTrk = simTrkItr->trackId();
spr::propagatedTrackDirection trkD = spr::propagateCALO(thisTrk, SimTk, SimVtx, geo, bField, debug);

double eEcal(0), eHcal(0), activeLengthTot(0), activeLengthHotTot(0);
double eHcalDepth[7], eHcalDepthHot[7], activeL[7], activeHotL[7];
double eHcalDepth[MaxDepth], eHcalDepthHot[MaxDepth];
double activeL[MaxDepth], activeHotL[MaxDepth];
unsigned int isHot(0);
for (int i=0; i<7; ++i)
for (int i=0; i<MaxDepth; ++i)
eHcalDepth[i] = eHcalDepthHot[i] = activeL[i] = activeHotL[i] = -10000;

#ifdef EDM_ML_DEBUG
Expand Down Expand Up @@ -312,7 +319,7 @@ void HcalHBHEMuonSimAnalyzer::analyze(const edm::Event& iEvent,
}
#ifdef EDM_ML_DEBUG
if ((verbosity_%10) > 0) {
for (int k=0; k<7; ++k)
for (int k=0; k<MaxDepth; ++k)
std::cout << "Depth " << k << " E " << eHcalDepth[k] << ":"
<< eHcalDepthHot[k] << std::endl;
}
Expand Down Expand Up @@ -431,8 +438,18 @@ void HcalHBHEMuonSimAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& d
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
desc.add<std::string>("ModuleLabel","g4SimHits");
desc.add<std::string>("EBCollection","EcalHitsEB");
desc.add<std::string>("EECollection","EcalHitsEE");
desc.add<std::string>("HCCollection","HcalHits");
desc.addUntracked<int>("Verbosity",0);
desc.addUntracked<int>("MaxDepth",4);
desc.addUntracked<double>("EtaMax",3.0);
desc.addUntracked<double>("TimeMinCutECAL",-500.0);
desc.addUntracked<double>("TimeMaxCutECAL",500.0);
desc.addUntracked<double>("TimeMinCutHCAL",-500.0);
desc.addUntracked<double>("TimeMaxCutHCAL",500.0);
descriptions.add("hcalHBHEMuonSim",desc);
}

void HcalHBHEMuonSimAnalyzer::clearVectors() {
Expand Down

0 comments on commit 9cd2b60

Please sign in to comment.