Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-05 11:11:21

0001 #include <memory>
0002 
0003 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseContainmentManager.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "CondFormats/DataRecord/interface/HcalTimeSlewRecord.h"
0006 
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0009 #include "FWCore/Framework/interface/Event.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/StreamID.h"
0013 #include "Geometry/Records/interface/HcalRecNumberingRecord.h"
0014 
0015 #include <cassert>
0016 #include <vector>
0017 #include <iostream>
0018 #include <iterator>
0019 
0020 class HcalTimeSlew;
0021 
0022 class HcalPulseContainmentTest : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0023 public:
0024   explicit HcalPulseContainmentTest(const edm::ParameterSet& iConfig);
0025   ~HcalPulseContainmentTest() override;
0026 
0027 private:
0028   void beginJob() override;
0029   void beginRun(edm::Run const&, edm::EventSetup const&) override {}
0030   void analyze(edm::Event const&, edm::EventSetup const&) override;
0031   void endRun(edm::Run const&, edm::EventSetup const&) override {}
0032 
0033   const edm::ESGetToken<HcalTimeSlew, HcalTimeSlewRecord> tok_slew_;
0034   const HcalTimeSlew* hcalTimeSlew_delay_;
0035 };
0036 
0037 HcalPulseContainmentTest::HcalPulseContainmentTest(const edm::ParameterSet& iConfig)
0038     : tok_slew_(esConsumes<HcalTimeSlew, HcalTimeSlewRecord>(edm::ESInputTag{"", "HBHE"})),
0039       hcalTimeSlew_delay_(nullptr) {}
0040 
0041 HcalPulseContainmentTest::~HcalPulseContainmentTest() {}
0042 
0043 void HcalPulseContainmentTest::beginJob() {}
0044 
0045 void HcalPulseContainmentTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0046   hcalTimeSlew_delay_ = &iSetup.getData(tok_slew_);
0047 
0048   float fixedphase_ns = 6.0;
0049   float max_fracerror = 0.02;
0050   std::unique_ptr<HcalPulseContainmentManager> manager;
0051   manager = std::make_unique<HcalPulseContainmentManager>(max_fracerror, true);
0052   manager->setTimeSlew(hcalTimeSlew_delay_);
0053 
0054   HcalDetId hb1(HcalBarrel, 1, 1, 1);
0055   HcalDetId he1(HcalEndcap, 17, 1, 1);
0056   double fc = 10.;
0057   // test re-finding the correction
0058   double corr1 = manager->correction(hb1, 4, fixedphase_ns, fc);
0059   double corr2 = manager->correction(hb1, 4, fixedphase_ns, fc);
0060   assert(corr1 == corr2);
0061   // fewer toAdd means bigger correction
0062   double corr3 = manager->correction(hb1, 2, fixedphase_ns, fc);
0063   assert(corr3 > corr1);
0064   // HB and HE have the same shape here
0065   double corr4 = manager->correction(he1, 4, fixedphase_ns, fc);
0066   assert(corr4 == corr1);
0067   edm::LogPrint("HcalPulseContainmentTest") << corr1 << " " << corr2 << " " << corr3 << " " << corr4;
0068   // test 1TS correction at high energy
0069   double corr5 = manager->correction(hb1, 1, fixedphase_ns, 100000.);
0070   edm::LogPrint("HcalPulseContainmentTest") << corr5;
0071   // test 2TS correction at high energy
0072   double corr6 = manager->correction(hb1, 2, fixedphase_ns, 100000.);
0073   edm::LogPrint("HcalPulseContainmentTest") << corr6;
0074 }
0075 
0076 //define this as a plug-in
0077 DEFINE_FWK_MODULE(HcalPulseContainmentTest);