CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
25 public:
28 
31 
33  void produce(edm::Event &event, const edm::EventSetup &eventSetup) override;
34 
35 private:
37 
39 };
40 
42  ecalTBInfo_ = consumes<PEcalTBInfo>(edm::InputTag("EcalTBInfoLabel", "SimEcalTBG4Object"));
43  produces<EcalTBHodoscopeRawInfo>();
44 
46 }
47 
49 
51  std::unique_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
52 
53  // get the vertex information from the event
54 
55  edm::Handle<PEcalTBInfo> theEcalTBInfo;
56  event.getByToken(ecalTBInfo_, theEcalTBInfo);
57 
58  double partXhodo = theEcalTBInfo->evXbeam();
59  double partYhodo = theEcalTBInfo->evYbeam();
60 
61  LogDebug("EcalTBHodo") << "TB frame vertex (X,Y) for hodoscope simulation: \n"
62  << "x = " << partXhodo << " y = " << partYhodo;
63 
64  // for each hodoscope plane determine the fibre number corresponding
65  // to the event vertex coordinates in the TB reference frame
66  // plane 0/2 = x plane 1/3 = y
67 
68  int nPlanes = static_cast<int>(theTBHodoGeom_->getNPlanes());
69  product->setPlanes(nPlanes);
70 
71  for (int iPlane = 0; iPlane < nPlanes; ++iPlane) {
72  float theCoord = (float)partXhodo;
73  if (iPlane == 1 || iPlane == 3)
74  theCoord = (float)partYhodo;
75 
76  std::vector<int> firedChannels = theTBHodoGeom_->getFiredFibresInPlane(theCoord, iPlane);
77  unsigned int nChannels = firedChannels.size();
78 
79  EcalTBHodoscopePlaneRawHits planeHit(nChannels);
80  for (unsigned int i = 0; i < nChannels; ++i) {
81  planeHit.addHit(firedChannels[i]);
82  }
83 
84  product->setPlane(static_cast<unsigned int>(iPlane), planeHit);
85  }
86 
87  LogDebug("EcalTBHodo") << (*product);
88 
89  event.put(std::move(product));
90 }
91 
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< PEcalTBInfo > ecalTBInfo_
def move
Definition: eostools.py:511
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Produce digis out of raw data.
static std::vector< int > getFiredFibresInPlane(float xtr, int plane)
~FakeTBHodoscopeRawInfoProducer() override
Destructor.
FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet &ps)
Constructor.
#define LogDebug(id)