CMS 3D CMS Logo

HcalPulseContainmentTest.cc
Go to the documentation of this file.
1 #include <memory>
2 
6 
14 
15 #include <cassert>
16 #include <vector>
17 #include <iostream>
18 #include <iterator>
19 
20 class HcalTimeSlew;
21 
22 class HcalPulseContainmentTest : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
23 public:
24  explicit HcalPulseContainmentTest(const edm::ParameterSet& iConfig);
25  ~HcalPulseContainmentTest() override;
26 
27 private:
28  void beginJob() override;
29  void beginRun(edm::Run const&, edm::EventSetup const&) override {}
30  void analyze(edm::Event const&, edm::EventSetup const&) override;
31  void endRun(edm::Run const&, edm::EventSetup const&) override {}
32 
35 };
36 
38  : tok_slew_(esConsumes<HcalTimeSlew, HcalTimeSlewRecord>(edm::ESInputTag{"", "HBHE"})),
39  hcalTimeSlew_delay_(nullptr) {}
40 
42 
44 
47 
48  float fixedphase_ns = 6.0;
49  float max_fracerror = 0.02;
50  std::unique_ptr<HcalPulseContainmentManager> manager;
51  manager = std::make_unique<HcalPulseContainmentManager>(max_fracerror, true);
52  manager->setTimeSlew(hcalTimeSlew_delay_);
53 
54  HcalDetId hb1(HcalBarrel, 1, 1, 1);
55  HcalDetId he1(HcalEndcap, 17, 1, 1);
56  double fc = 10.;
57  // test re-finding the correction
58  double corr1 = manager->correction(hb1, 4, fixedphase_ns, fc);
59  double corr2 = manager->correction(hb1, 4, fixedphase_ns, fc);
60  assert(corr1 == corr2);
61  // fewer toAdd means bigger correction
62  double corr3 = manager->correction(hb1, 2, fixedphase_ns, fc);
63  assert(corr3 > corr1);
64  // HB and HE have the same shape here
65  double corr4 = manager->correction(he1, 4, fixedphase_ns, fc);
66  assert(corr4 == corr1);
67  edm::LogPrint("HcalPulseContainmentTest") << corr1 << " " << corr2 << " " << corr3 << " " << corr4;
68  // test 1TS correction at high energy
69  double corr5 = manager->correction(hb1, 1, fixedphase_ns, 100000.);
70  edm::LogPrint("HcalPulseContainmentTest") << corr5;
71  // test 2TS correction at high energy
72  double corr6 = manager->correction(hb1, 2, fixedphase_ns, 100000.);
73  edm::LogPrint("HcalPulseContainmentTest") << corr6;
74 }
75 
76 //define this as a plug-in
HcalPulseContainmentTest(const edm::ParameterSet &iConfig)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void beginRun(edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
assert(be >=bs)
const HcalTimeSlew * hcalTimeSlew_delay_
int iEvent
Definition: GenABIO.cc:224
bool getData(T &iHolder) const
Definition: EventSetup.h:122
Log< level::Warning, true > LogPrint
const edm::ESGetToken< HcalTimeSlew, HcalTimeSlewRecord > tok_slew_
void endRun(edm::Run const &, edm::EventSetup const &) override
HLT enums.
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: Run.h:45