Skip to content

Commit

Permalink
Merge pull request #12444 from bsunanda/Run2-hcx51
Browse files Browse the repository at this point in the history
bsunanda:Run2-hcx51 Remove wrong constructor of hcalTopology
  • Loading branch information
davidlange6 committed Nov 19, 2015
2 parents ed1f55e + d1be748 commit 6adcb1a
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 83 deletions.
7 changes: 4 additions & 3 deletions SimCalorimetry/HcalSimAlgos/test/BuildFile.xml
@@ -1,13 +1,14 @@
<environment>
<use name="SimCalorimetry/HcalSimAlgos"/>
<use name="SimDataFormats/CrossingFrame"/>
<bin file="HcalDigitizerTest.cpp"/>
<bin file="HPDIonFeedbackTest.cpp"/>
<bin file="writeHPDLibrary.cc"/>
<bin file="readHPDLibrary.cc"/>
<bin file="HcalShapeIntegratorTest.cpp"/>
<bin file="HcalTimeSlewTest.cpp"/>
<library file="HcalSignalGeneratorTest.cpp" name="HcalSignalGeneratorTest">
<flags EDM_PLUGIN="1"/>
<flags EDM_PLUGIN="1"/>
<library file="HcalSignalGeneratorTest.cpp" name="HcalSignalGeneratorTest">
</library>
<library file="HcalDigitizerTest.cc" name="HcalDigitizerTest">
</library>
</environment>
Expand Up @@ -33,106 +33,112 @@
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "Geometry/HcalTowerAlgo/interface/HcalHardcodeGeometryLoader.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Frameworkfwd.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"
#include "Geometry/Records/interface/HcalRecNumberingRecord.h"
#include "CLHEP/Random/JamesRandom.h"
#include <vector>
#include<iostream>
#include<iterator>
using namespace std;
using namespace cms;

void testHitCorrection(HcalHitCorrection * correction, MixCollection<PCaloHit> & hits, CLHEP::HepRandomEngine* engine)
{
correction->fillChargeSums(hits);
for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
hitItr != hits.end(); ++hitItr)
{
DetId detId((*hitItr).id());
if (detId.det()==DetId::Calo && detId.subdetId()==HcalZDCDetId::SubdetectorId){
std::cout<<"ZDC -- ";
}
std::cout << "HIT charge " << correction->charge(*hitItr) << " delay " << correction->delay(*hitItr, engine)
<< " Timebin " << correction->timeBin(*hitItr) <<std::endl;
}
}
class HcalDigitizerTest : public edm::one::EDAnalyzer<edm::one::WatchRuns> {

public:
explicit HcalDigitizerTest(const edm::ParameterSet&);
~HcalDigitizerTest();

private:
void beginJob() override;
void beginRun(edm::Run const&, edm::EventSetup const&) override {}
void analyze(edm::Event const&, edm::EventSetup const&) override;
void endRun(edm::Run const&, edm::EventSetup const&) override {}
void testHitCorrection(HcalHitCorrection*, MixCollection<PCaloHit>& ,
CLHEP::HepRandomEngine*);

std::vector<PCaloHit> hits;
std::vector<DetId> hcalDetIds, hoDetIds, hfDetIds, hzdcDetIds, allDetIds;
std::vector<HcalDetId> outerHcalDetIds;
};

HcalDigitizerTest::HcalDigitizerTest(const edm::ParameterSet&) { }

HcalDigitizerTest::~HcalDigitizerTest() { }

void HcalDigitizerTest::beginJob() {

int main() {
// make a silly little hit in each subdetector, which should
// correspond to a 100 GeV particle

HcalDetId barrelDetId(HcalBarrel, 1, 1, 1);
//PCaloHit barrelHit(barrelDetId.rawId(), 0.855, 0.);
for (int phi = 1; phi < 50 ; ++phi) {
HcalDetId detId(HcalBarrel, 1 , phi, 1);
PCaloHit barrelHit(detId.rawId(), 0.085*phi, 0.);
hcalDetIds.push_back(detId);
hits.push_back(barrelHit);
}

HcalDetId endcapDetId(HcalEndcap, 17, 1, 1);
PCaloHit endcapHit(endcapDetId.rawId(), 0.9, 0.);
hcalDetIds.push_back(endcapDetId);
hits.push_back(endcapHit);

HcalDetId outerDetId(HcalOuter, 1, 1, 4);
PCaloHit outerHit(outerDetId.rawId(), 0.45, 0.);
hoDetIds.push_back(outerDetId);
outerHcalDetIds.push_back(outerDetId);
hits.push_back(outerHit);

HcalDetId forwardDetId1(HcalForward, 30, 1, 1);
PCaloHit forwardHit1(forwardDetId1.rawId(), 35.2, 0.);
hfDetIds.push_back(forwardDetId1);
hits.push_back(forwardHit1);

HcalDetId forwardDetId2(HcalForward, 30, 1, 2);
PCaloHit forwardHit2(forwardDetId2.rawId(), 47.8, 0.);
hfDetIds.push_back(forwardDetId2);
hits.push_back(forwardHit2);

HcalZDCDetId zdcDetId(HcalZDCDetId::Section(1),true,1);
PCaloHit zdcHit(zdcDetId.rawId(), 50.0, 0.123);

std::cout<<zdcDetId<<std::endl;
std::cout<<zdcHit<<std::endl;

vector<PCaloHit> hits;
//hits.push_back(barrelHit);
//hits.push_back(endcapHit);
hits.push_back(outerHit);
hits.push_back(forwardHit1);
hits.push_back(forwardHit2);
hits.push_back(zdcHit);

vector<DetId> hcalDetIds, hoDetIds, hfDetIds, hzdcDetIds;
vector<HcalDetId> outerHcalDetIds;
//hcalDetIds.push_back(barrelDetId);
//hcalDetIds.push_back(endcapDetId);
for(int phi = 1; phi < 50 ; ++phi)
{
HcalDetId detId(HcalBarrel, 1 , phi, 1);
PCaloHit barrelHit(detId.rawId(), 0.085*phi, 0.);
hcalDetIds.push_back(detId);
hits.push_back(barrelHit);
}


HcalTopology topology(HcalTopologyMode::LHC,2,3);

hoDetIds.push_back(outerDetId);
vector<HcalDetId> outerhcalDetIds;
outerHcalDetIds.push_back(outerDetId);
hfDetIds.push_back(forwardDetId1);
hfDetIds.push_back(forwardDetId2);
hzdcDetIds.push_back(zdcDetId);
hits.push_back(zdcHit);

std::cout << zdcDetId << std::endl;
std::cout << zdcHit << std::endl;

vector<DetId> allDetIds;
allDetIds.insert(allDetIds.end(), hcalDetIds.begin(), hcalDetIds.end());
allDetIds.insert(allDetIds.end(), hoDetIds.begin(), hoDetIds.end());
allDetIds.insert(allDetIds.end(), hfDetIds.begin(), hfDetIds.end());
allDetIds.insert(allDetIds.end(), hzdcDetIds.begin(), hzdcDetIds.end());
}

void HcalDigitizerTest::analyze(const edm::Event& iEvent,
const edm::EventSetup& iSetup) {

edm::ESHandle<HcalTopology> htopo;
iSetup.get<HcalRecNumberingRecord>().get(htopo);
HcalTopology topology = (*htopo);

string hitsName = "HcalHits";
vector<string> caloDets;

std::string hitsName = "HcalHits";
std::vector<std::string> caloDets;
CrossingFrame<PCaloHit> crossingFrame(-5, 5, 25, hitsName, 0);
edm::EventID eventId;
crossingFrame.addSignals(&hits, eventId);
crossingFrame.addSignals(&hits, iEvent.id());

// make 1 GeV pileup hit
HcalDetId barrelDetId(HcalBarrel, 1, 1, 1);
PCaloHit barrelPileup(barrelDetId.rawId(), 0.00855, 0.);
// 10 GeV pileup hit
PCaloHit forwardPileup(forwardDetId1.rawId(), 3.52, 0.);
PCaloHit zdcPileup(zdcDetId.rawId(), 3.52, 0.);
HcalDetId forwardDetId1(HcalForward, 30, 1, 1);
PCaloHit forwardPileup(forwardDetId1.rawId(), 3.52, 0.);
HcalZDCDetId zdcDetId(HcalZDCDetId::Section(1),true,1);
PCaloHit zdcPileup(zdcDetId.rawId(), 3.52, 0.);

vector<PCaloHit> pileups;
//pileups.push_back(barrelPileup);
std::vector<PCaloHit> pileups;
pileups.push_back(barrelPileup);
pileups.push_back(forwardPileup);
pileups.push_back(zdcPileup);
///TODO fix once the new crossingframe is released
Expand All @@ -152,8 +158,7 @@ int main() {
CaloShapeIntegrator hfShapeIntegrator(new HFShape());
CaloShapeIntegrator zdcShapeIntegrator(new ZDCShape());
CaloShapes sipmShapes(&sipmShapeIntegrator);
//for(float t = -25; t < 200; t += 5)
//{
//for(float t = -25; t < 200; t += 5) {
// std::cout << t << " " << hcalShape(t) << " " << sipmShape(t) << " " << hcalShapeIntegrator(t) << " "<< sipmShapeIntegrator(t) << std::endl;
//}

Expand Down Expand Up @@ -187,7 +192,7 @@ int main() {
HcalGains gains(&topology);
HcalGainWidths gainWidths(&topology);
// make a calibration service by hand
for(vector<DetId>::const_iterator detItr = allDetIds.begin(); detItr != allDetIds.end(); ++detItr) {
for (auto detItr = allDetIds.begin(); detItr != allDetIds.end(); ++detItr) {
pedestals.addValues(HcalDbHardcode::makePedestal(*detItr, false,0));
pedestalWidths.addValues(HcalDbHardcode::makePedestalWidth(*detItr));
gains.addValues(HcalDbHardcode::makeGain(*detItr));
Expand All @@ -212,7 +217,6 @@ int main() {
calibratorHandle.setData(&gains);
calibratorHandle.setData(&gainWidths);


bool addNoise = false;
bool PM1 = false;
bool PM2 = false;
Expand All @@ -223,7 +227,6 @@ int main() {
parameterMap.setDbService(&calibratorHandle);
siPMParameterMap.setDbService(&calibratorHandle);


CaloTDigitizer<HBHEDigitizerTraits> hbheDigitizer(&hbheResponse, &electronicsSim, addNoise);
CaloTDigitizer<HODigitizerTraits> hoDigitizer(&hoResponse, &electronicsSim, addNoise);
CaloTDigitizer<HFDigitizerTraits> hfDigitizer(&hfResponse, &electronicsSim, addNoise);
Expand All @@ -234,10 +237,10 @@ int main() {
hoDigitizer.setDetIds(hoDetIds);
zdcDigitizer.setDetIds(hzdcDetIds);

auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection);
auto_ptr<HODigiCollection> hoResult(new HODigiCollection);
auto_ptr<HFDigiCollection> hfResult(new HFDigiCollection);
auto_ptr<ZDCDigiCollection> zdcResult(new ZDCDigiCollection);
std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection);
std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection);
std::auto_ptr<HFDigiCollection> hfResult(new HFDigiCollection);
std::auto_ptr<ZDCDigiCollection> zdcResult(new ZDCDigiCollection);

MixCollection<PCaloHit> hitCollection(&crossingFrame);

Expand All @@ -252,17 +255,31 @@ int main() {
//zdcDigitizer.run(hitCollection, *zdcResult);

// print out all the digis
cout << "HBHE Frames" << endl;
copy(hbheResult->begin(), hbheResult->end(), std::ostream_iterator<HBHEDataFrame>(std::cout, "\n"));
std::cout << "HBHE Frames" << std::endl;
std::copy(hbheResult->begin(), hbheResult->end(), std::ostream_iterator<HBHEDataFrame>(std::cout, "\n"));

cout << "HF Frames" << endl;
copy(hfResult->begin(), hfResult->end(), std::ostream_iterator<HFDataFrame>(std::cout, "\n"));
std::cout << "HF Frames" << std::endl;
std::copy(hfResult->begin(), hfResult->end(), std::ostream_iterator<HFDataFrame>(std::cout, "\n"));

cout << "ZDC Frames" << endl;
copy(zdcResult->begin(), zdcResult->end(), std::ostream_iterator<ZDCDataFrame>(std::cout, "\n"));

return 0;
std::cout << "ZDC Frames" << std::endl;
std::copy(zdcResult->begin(), zdcResult->end(), std::ostream_iterator<ZDCDataFrame>(std::cout, "\n"));
}

void HcalDigitizerTest::testHitCorrection(HcalHitCorrection* correction,
MixCollection<PCaloHit>& hits,
CLHEP::HepRandomEngine* engine) {
correction->fillChargeSums(hits);
for (auto hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
DetId detId((*hitItr).id());
if (detId.det()==DetId::Calo &&
detId.subdetId()==HcalZDCDetId::SubdetectorId) {
std::cout<<"ZDC -- ";
}
std::cout << "HIT charge " << correction->charge(*hitItr) << " delay "
<< correction->delay(*hitItr, engine)
<< " Timebin " << correction->timeBin(*hitItr) <<std::endl;
}
}


//define this as a plug-in
DEFINE_FWK_MODULE(HcalDigitizerTest);
21 changes: 21 additions & 0 deletions SimCalorimetry/HcalSimAlgos/test/HcalDigitizerTest_cfg.py
@@ -0,0 +1,21 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("Test")

process.load("SimGeneral.MixingModule.mixNoPU_cfi")
process.load("Configuration.Geometry.GeometryExtendedReco_cff")
process.load("Configuration.StandardSequences.MagneticField_cff")
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run1_mc', '')

process.source = cms.Source("EmptySource")

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(1)
)

process.hcalDigitizerTest = cms.EDAnalyzer("HcalDigitizerTest")

process.p1 = cms.Path(process.hcalDigitizerTest)

Expand Up @@ -3,9 +3,12 @@
process = cms.Process("Mu2")

process.load("SimGeneral.MixingModule.mixNoPU_cfi")
process.load("Configuration.StandardSequences.Geometry_cff")
process.load("Configuration.Geometry.GeometryExtendedReco_cff")
process.load("Configuration.StandardSequences.MagneticField_cff")
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run1_mc', '')

process.source = cms.Source("PoolSource",
debugFlag = cms.untracked.bool(True),
debugVebosity = cms.untracked.uint32(10),
Expand All @@ -19,7 +22,6 @@

process.eventContent = cms.EDAnalyzer("EventContentAnalyzer")
process.DQMStore = cms.Service("DQMStore")
process.GlobalTag.globaltag = "IDEAL_30X::All"
process.dump = cms.EDAnalyzer("HcalDigiDump")
process.load("Configuration.StandardSequences.Digi_cff")
process.load("Configuration.StandardSequences.Services_cff")
Expand Down

0 comments on commit 6adcb1a

Please sign in to comment.