File indexing completed on 2024-04-06 12:29:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "DataFormats/Common/interface/Handle.h"
0010
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 #include "FWCore/Framework/interface/stream/EDProducer.h"
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 #include "FWCore/PluginManager/interface/ModuleDef.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018
0019 #include "Geometry/EcalTestBeam/interface/EcalTBHodoscopeGeometry.h"
0020 #include "SimDataFormats/EcalTestBeam/interface/PEcalTBInfo.h"
0021 #include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopePlaneRawHits.h"
0022 #include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopeRawInfo.h"
0023
0024 #include <memory>
0025
0026 class FakeTBHodoscopeRawInfoProducer : public edm::stream::EDProducer<> {
0027 public:
0028
0029 explicit FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet &ps);
0030
0031
0032 ~FakeTBHodoscopeRawInfoProducer() override = default;
0033
0034
0035 void produce(edm::Event &event, const edm::EventSetup &eventSetup) override;
0036
0037 private:
0038 std::unique_ptr<EcalTBHodoscopeGeometry> theTBHodoGeom_;
0039
0040 const edm::EDGetTokenT<PEcalTBInfo> ecalTBInfo_;
0041 };
0042
0043 FakeTBHodoscopeRawInfoProducer::FakeTBHodoscopeRawInfoProducer(const edm::ParameterSet &ps)
0044 : ecalTBInfo_(consumes<PEcalTBInfo>(edm::InputTag("EcalTBInfoLabel", "SimEcalTBG4Object"))) {
0045 produces<EcalTBHodoscopeRawInfo>();
0046
0047 theTBHodoGeom_ = std::make_unique<EcalTBHodoscopeGeometry>();
0048 }
0049
0050 void FakeTBHodoscopeRawInfoProducer::produce(edm::Event &event, const edm::EventSetup &eventSetup) {
0051 std::unique_ptr<EcalTBHodoscopeRawInfo> product(new EcalTBHodoscopeRawInfo());
0052
0053
0054
0055 const edm::Handle<PEcalTBInfo> &theEcalTBInfo = event.getHandle(ecalTBInfo_);
0056
0057 double partXhodo = theEcalTBInfo->evXbeam();
0058 double partYhodo = theEcalTBInfo->evYbeam();
0059
0060 LogDebug("EcalTBHodo") << "TB frame vertex (X,Y) for hodoscope simulation: \n"
0061 << "x = " << partXhodo << " y = " << partYhodo;
0062
0063
0064
0065
0066
0067 int nPlanes = static_cast<int>(theTBHodoGeom_->getNPlanes());
0068 product->setPlanes(nPlanes);
0069
0070 for (int iPlane = 0; iPlane < nPlanes; ++iPlane) {
0071 float theCoord = (float)partXhodo;
0072 if (iPlane == 1 || iPlane == 3)
0073 theCoord = (float)partYhodo;
0074
0075 std::vector<int> firedChannels = theTBHodoGeom_->getFiredFibresInPlane(theCoord, iPlane);
0076 unsigned int nChannels = firedChannels.size();
0077
0078 EcalTBHodoscopePlaneRawHits planeHit(nChannels);
0079 for (unsigned int i = 0; i < nChannels; ++i) {
0080 planeHit.addHit(firedChannels[i]);
0081 }
0082
0083 product->setPlane(static_cast<unsigned int>(iPlane), planeHit);
0084 }
0085
0086 LogDebug("EcalTBHodo") << (*product);
0087
0088 event.put(std::move(product));
0089 }
0090
0091 DEFINE_FWK_MODULE(FakeTBHodoscopeRawInfoProducer);