CMS 3D CMS Logo

HcalPulseContainmentTest.cc
Go to the documentation of this file.
1 #include <memory>
2 
7 
15 
16 #include <cassert>
17 #include <vector>
18 #include <iostream>
19 #include <iterator>
20 
21 class HcalTimeSlew;
22 
23 class HcalPulseContainmentTest : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
24 public:
25  explicit HcalPulseContainmentTest(const edm::ParameterSet& iConfig);
26  ~HcalPulseContainmentTest() override;
27 
28 private:
29  void beginJob() override;
30  void beginRun(edm::Run const&, edm::EventSetup const&) override {}
31  void analyze(edm::Event const&, edm::EventSetup const&) override;
32  void endRun(edm::Run const&, edm::EventSetup const&) override {}
33 
35 };
36 
38 
40 
42 
45  iSetup.get<HcalTimeSlewRecord>().get("HBHE", delay);
46  hcalTimeSlew_delay_ = &*delay;
47 
48  float fixedphase_ns = 6.0;
49  float max_fracerror = 0.02;
50  std::unique_ptr<HcalPulseContainmentManager> manager;
51  manager = std::unique_ptr<HcalPulseContainmentManager>(new HcalPulseContainmentManager(max_fracerror));
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  std::cout << corr1 << " " << corr2 << " " << corr3 << " " << corr4 << " " << std::endl;
68 }
69 
70 //define this as a plug-in
HcalPulseContainmentTest(const edm::ParameterSet &iConfig)
void beginRun(edm::Run const &, edm::EventSetup const &) override
const HcalTimeSlew * hcalTimeSlew_delay_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void endRun(edm::Run const &, edm::EventSetup const &) override
T get() const
Definition: EventSetup.h:73
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: Run.h:45