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 
25 public:
26  explicit HcalPulseContainmentTest(const edm::ParameterSet& iConfig);
27  ~HcalPulseContainmentTest() override;
28 
29 private:
30  void beginJob() override;
31  void beginRun(edm::Run const&, edm::EventSetup const&) override {}
32  void analyze(edm::Event const&, edm::EventSetup const&) override;
33  void endRun(edm::Run const&, edm::EventSetup const&) override {}
34 
36 };
37 
39  hcalTimeSlew_delay_ = nullptr;
40 }
41 
43 
45 }
46 
48 
50  iSetup.get<HcalTimeSlewRecord>().get("HBHE", delay);
51  hcalTimeSlew_delay_ = &*delay;
52 
53  float fixedphase_ns = 6.0;
54  float max_fracerror = 0.02;
55  std::auto_ptr<HcalPulseContainmentManager> manager;
56  manager = std::auto_ptr<HcalPulseContainmentManager>( new HcalPulseContainmentManager(max_fracerror));
57  manager->setTimeSlew(hcalTimeSlew_delay_);
58 
59  HcalDetId hb1(HcalBarrel, 1, 1, 1);
60  HcalDetId he1(HcalEndcap, 17, 1, 1);
61  double fc = 10.;
62  // test re-finding the correction
63  double corr1 = manager->correction(hb1, 4, fixedphase_ns, fc);
64  double corr2 = manager->correction(hb1, 4, fixedphase_ns, fc);
65  assert(corr1 == corr2);
66  // fewer toAdd means bigger correction
67  double corr3 = manager->correction(hb1, 2, fixedphase_ns, fc);
68  assert(corr3 > corr1);
69  // HB and HE have the same shape here
70  double corr4 = manager->correction(he1, 4, fixedphase_ns, fc);
71  assert(corr4 == corr1);
72  std::cout << corr1 << " " <<corr2 << " " <<corr3 << " " <<corr4 << " " << std::endl;
73 }
74 
75 //define this as a plug-in
HcalPulseContainmentTest(const edm::ParameterSet &iConfig)
void beginRun(edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const HcalTimeSlew * hcalTimeSlew_delay_
int iEvent
Definition: GenABIO.cc:230
const T & get() const
Definition: EventSetup.h:59
void endRun(edm::Run const &, edm::EventSetup const &) override
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: Run.h:43