CMS 3D CMS Logo

FakeTBEventHeaderProducer.cc
Go to the documentation of this file.
1 /*
2  * \file FakeTBEventHeaderProducer.cc
3  *
4  * Mimic the event header information
5  * for the test beam simulation
6  *
7  */
8 
11 
19 
23 
25 public:
27  explicit FakeTBEventHeaderProducer(const edm::ParameterSet &ps);
28 
30  ~FakeTBEventHeaderProducer() override = default;
31 
33  void produce(edm::Event &event, const edm::EventSetup &eventSetup) override;
34 
35 private:
37 };
38 
40  : ecalTBInfo_(consumes<PEcalTBInfo>(edm::InputTag("EcalTBInfoLabel", "SimEcalTBG4Object"))) {
41  produces<EcalTBEventHeader>();
42 }
43 
45  std::unique_ptr<EcalTBEventHeader> product(new EcalTBEventHeader());
46 
47  // get the vertex information from the event
48 
49  const PEcalTBInfo *theEcalTBInfo = nullptr;
50  const edm::Handle<PEcalTBInfo> &EcalTBInfo = event.getHandle(ecalTBInfo_);
51  if (EcalTBInfo.isValid()) {
52  theEcalTBInfo = EcalTBInfo.product();
53  } else {
54  edm::LogError("FakeTBEventHeaderProducer") << "Error! can't get the product PEcalTBInfo";
55  }
56 
57  if (!theEcalTBInfo) {
58  return;
59  }
60 
61  // 64 bits event ID in CMSSW converted to EcalTBEventHeader ID
62  int evtid = (int)event.id().event();
63  product->setEventNumber(evtid);
64  product->setRunNumber(event.id().run());
65  product->setBurstNumber(1);
66  product->setTriggerMask(0x1);
67  product->setCrystalInBeam(EBDetId(1, theEcalTBInfo->nCrystal(), EBDetId::SMCRYSTALMODE));
68 
69  LogDebug("FakeTBHeader") << (*product);
70  LogDebug("FakeTBHeader") << (*product).eventType();
71  LogDebug("FakeTBHeader") << (*product).crystalInBeam();
72 
73  event.put(std::move(product));
74 }
75 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
T const * product() const
Definition: Handle.h:70
Log< level::Error, false > LogError
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Produce digis out of raw data.
const edm::EDGetTokenT< PEcalTBInfo > ecalTBInfo_
int nCrystal() const
Definition: PEcalTBInfo.h:27
FakeTBEventHeaderProducer(const edm::ParameterSet &ps)
Constructor.
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
def move(src, dest)
Definition: eostools.py:511
~FakeTBEventHeaderProducer() override=default
Destructor.
Definition: event.py:1
#define LogDebug(id)