CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
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 
47  std::unique_ptr<EcalTBEventHeader> product(new EcalTBEventHeader());
48 
49  // get the vertex information from the event
50 
51  const PEcalTBInfo *theEcalTBInfo = nullptr;
52  edm::Handle<PEcalTBInfo> EcalTBInfo;
53  event.getByToken(ecalTBInfo_, EcalTBInfo);
54  if (EcalTBInfo.isValid()) {
55  theEcalTBInfo = EcalTBInfo.product();
56  } else {
57  edm::LogError("FakeTBEventHeaderProducer") << "Error! can't get the product PEcalTBInfo";
58  }
59 
60  if (!theEcalTBInfo) {
61  return;
62  }
63 
64  // 64 bits event ID in CMSSW converted to EcalTBEventHeader ID
65  int evtid = (int)event.id().event();
66  product->setEventNumber(evtid);
67  product->setRunNumber(event.id().run());
68  product->setBurstNumber(1);
69  product->setTriggerMask(0x1);
70  product->setCrystalInBeam(EBDetId(1, theEcalTBInfo->nCrystal(), EBDetId::SMCRYSTALMODE));
71 
72  LogDebug("FakeTBHeader") << (*product);
73  LogDebug("FakeTBHeader") << (*product).eventType();
74  LogDebug("FakeTBHeader") << (*product).crystalInBeam();
75 
76  event.put(std::move(product));
77 }
78 
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Error, false > LogError
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Produce digis out of raw data.
~FakeTBEventHeaderProducer() override
Destructor.
int nCrystal() const
Definition: PEcalTBInfo.h:27
def move
Definition: eostools.py:511
bool isValid() const
Definition: HandleBase.h:70
T const * product() const
Definition: Handle.h:70
FakeTBEventHeaderProducer(const edm::ParameterSet &ps)
Constructor.
edm::EventID id() const
Definition: EventBase.h:59
edm::EDGetTokenT< PEcalTBInfo > ecalTBInfo_
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define LogDebug(id)