CMS 3D CMS Logo

FakeTBHodoscopeRawInfoProducer.cc
Go to the documentation of this file.
1 /*
2  * \file FakeTBHodoscopeRawInfoProducer.cc
3  *
4  * Mimic the hodoscope raw information using
5  * the generated vertex of the test beam simulation
6  *
7  */
8 
10 
18 
23 
24 #include <memory>
25 
27 public:
30 
32  ~FakeTBHodoscopeRawInfoProducer() override = default;
33 
35  void produce(edm::Event &event, const edm::EventSetup &eventSetup) override;
36 
37 private:
38  std::unique_ptr<EcalTBHodoscopeGeometry> theTBHodoGeom_;
39 
41 };
42 
44  : ecalTBInfo_(consumes<PEcalTBInfo>(edm::InputTag("EcalTBInfoLabel", "SimEcalTBG4Object"))) {
45  produces<EcalTBHodoscopeRawInfo>();
46 
47  theTBHodoGeom_ = std::make_unique<EcalTBHodoscopeGeometry>();
48 }
49 
51  std::unique_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
52 
53  // get the vertex information from the event
54 
55  const edm::Handle<PEcalTBInfo> &theEcalTBInfo = event.getHandle(ecalTBInfo_);
56 
57  double partXhodo = theEcalTBInfo->evXbeam();
58  double partYhodo = theEcalTBInfo->evYbeam();
59 
60  LogDebug("EcalTBHodo") << "TB frame vertex (X,Y) for hodoscope simulation: \n"
61  << "x = " << partXhodo << " y = " << partYhodo;
62 
63  // for each hodoscope plane determine the fibre number corresponding
64  // to the event vertex coordinates in the TB reference frame
65  // plane 0/2 = x plane 1/3 = y
66 
67  int nPlanes = static_cast<int>(theTBHodoGeom_->getNPlanes());
68  product->setPlanes(nPlanes);
69 
70  for (int iPlane = 0; iPlane < nPlanes; ++iPlane) {
71  float theCoord = (float)partXhodo;
72  if (iPlane == 1 || iPlane == 3)
73  theCoord = (float)partYhodo;
74 
75  std::vector<int> firedChannels = theTBHodoGeom_->getFiredFibresInPlane(theCoord, iPlane);
76  unsigned int nChannels = firedChannels.size();
77 
79  for (unsigned int i = 0; i < nChannels; ++i) {
80  planeHit.addHit(firedChannels[i]);
81  }
82 
83  product->setPlane(static_cast<unsigned int>(iPlane), planeHit);
84  }
85 
86  LogDebug("EcalTBHodo") << (*product);
87 
88  event.put(std::move(product));
89 }
90 
double evYbeam() const
Definition: PEcalTBInfo.h:35
const edm::EDGetTokenT< PEcalTBInfo > ecalTBInfo_
std::unique_ptr< EcalTBHodoscopeGeometry > theTBHodoGeom_
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Produce digis out of raw data.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~FakeTBHodoscopeRawInfoProducer() override=default
Destructor.
HLT enums.
FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet &ps)
Constructor.
double evXbeam() const
Definition: PEcalTBInfo.h:34
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
#define LogDebug(id)