Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef SubsystemNeutronWriter_h
0002 #define SubsystemNeutronWriter_h
0003 
0004 /** theSubsystemNeutronWriter stores "events"
0005  * which consist of a list of SimHits,
0006  * grouped by detector type.  These can then
0007  * be read back to model neutron background
0008  * int muon chambers.
0009  *
0010  *  You can specify the cut on how long after the
0011  * signal event to define something as a Neutron Event
0012  * with the configurable Muon:NeutronTimeCut
0013  */
0014 
0015 #include <vector>
0016 #include <map>
0017 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0018 #include "FWCore/Framework/interface/stream/EDProducer.h"
0019 #include "FWCore/Utilities/interface/InputTag.h"
0020 
0021 namespace CLHEP {
0022   class HepRandomEngine;
0023 }
0024 
0025 class NeutronWriter;
0026 
0027 /// doesn't have to be a producer.  Can act as an analyzer, too.
0028 class SubsystemNeutronWriter : public edm::stream::EDProducer<> {
0029 public:
0030   explicit SubsystemNeutronWriter(edm::ParameterSet const& pset);
0031 
0032   /// destructor prints statistics on number of events written
0033   ~SubsystemNeutronWriter() override;
0034 
0035   void printStats();
0036 
0037   void produce(edm::Event& e, edm::EventSetup const& c) override;
0038 
0039   virtual int localDetId(int globalDetId) const = 0;
0040 
0041   virtual int chamberType(int globalDetId) const = 0;
0042 
0043   virtual int chamberId(int globalDetId) const = 0;
0044 
0045   /// decides whether this cluster is good enough to be included
0046   virtual bool accept(const edm::PSimHitContainer& cluster) const = 0;
0047 
0048   /// good practice to do once for each chamber type
0049   void initialize(int chamberType);
0050 
0051 protected:
0052   virtual void writeHits(int chamberType, edm::PSimHitContainer& chamberHits, CLHEP::HepRandomEngine*);
0053 
0054   void writeCluster(int chamberType, const edm::PSimHitContainer& cluster);
0055 
0056   /// helper to add time offsets and local det ID
0057   void adjust(PSimHit& h, float timeOffset, float smearing);
0058 
0059   /// updates the counter
0060   void updateCount(int chamberType);
0061 
0062 private:
0063   NeutronWriter* theHitWriter;
0064   bool useRandFlat;
0065   const edm::InputTag theInputTag;
0066   const double theNeutronTimeCut;
0067   const double theTimeWindow;
0068   const double theT0;
0069   const edm::EDGetTokenT<edm::PSimHitContainer> hitToken_;
0070   int theNEvents;
0071   bool initialized;
0072   // true means to translate DetId into just layer number, e.g., 1-6 in CSC
0073   bool useLocalDetId_;
0074   std::map<int, int> theCountPerChamberType;
0075 };
0076 
0077 #endif