Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:46

0001 /** \class GEMFakeEvent
0002  *   Class for testing creation of fake digis in every GEM strip
0003  *
0004  *  \author Khotilovich Vadim
0005  */
0006 
0007 #include "FWCore/Framework/interface/one/EDProducer.h"
0008 #include "Geometry/GEMGeometry/interface/GEMEtaPartition.h"
0009 #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h"
0010 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0011 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0012 #include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
0013 #include "DataFormats/Common/interface/Handle.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 
0018 using namespace std;
0019 
0020 class GEMFakeEvent : public edm::one::EDProducer<> {
0021 public:
0022   GEMFakeEvent(const edm::ParameterSet& config);
0023 
0024   ~GEMFakeEvent() override {}
0025 
0026   void produce(edm::Event& e, const edm::EventSetup& c) override;
0027 
0028 private:
0029   const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> geomToken_;
0030   int nEtaPartitions_;
0031 };
0032 
0033 GEMFakeEvent::GEMFakeEvent(const edm::ParameterSet& config)
0034     : geomToken_(esConsumes<GEMGeometry, MuonGeometryRecord>()) {
0035   cout << "Initialize the Event Dump" << endl;
0036   produces<GEMDigiCollection>();
0037 
0038   nEtaPartitions_ = config.getUntrackedParameter<int>("nEtaPartitions", 6);
0039 }
0040 
0041 void GEMFakeEvent::produce(edm::Event& ev, const edm::EventSetup& es) {
0042   cout << "RUN " << ev.id().run() << " EVENT " << ev.id().event() << endl;
0043 
0044   cout << "Getting the gem geometry" << endl;
0045   const auto& gemGeom = es.getHandle(geomToken_);
0046 
0047   unique_ptr<GEMDigiCollection> pDigis(new GEMDigiCollection());
0048 
0049   for (int e = -1; e <= 1; e += 2) {
0050     for (int c = 1; c <= 36; ++c) {
0051       for (int l = 1; l <= 2; ++l) {
0052         for (int p = 1; p <= nEtaPartitions_; ++p) {
0053           GEMDetId d(e, 1, 1, l, c, p);
0054           const GEMEtaPartition* ep = gemGeom->etaPartition(d);
0055           int ntrips = ep->nstrips();
0056           cout << "----- adding digis in GEM " << d << " with number of strips " << ntrips << endl;
0057           for (int s = 1; s <= ntrips; ++s) {
0058             if (s == 1 || s == ntrips)
0059               cout << " s=" << s << endl;
0060             if (s == 2)
0061               cout << "..." << endl;
0062             GEMDigi gemDigi(s, 0);
0063             pDigis->insertDigi(d, gemDigi);
0064           }
0065         }
0066       }
0067     }
0068   }
0069 
0070   cout << "Will put GEMDigiCollection into event..." << endl;
0071   ev.put(std::move(pDigis));
0072   cout << "Done with event!" << endl;
0073 }
0074 
0075 DEFINE_FWK_MODULE(GEMFakeEvent);