CMS 3D CMS Logo

Adjuster.h
Go to the documentation of this file.
1 #ifndef SimGeneral_MixingModule_Adjuster_h
2 #define SimGeneral_MixingModule_Adjuster_h
3 
15 
16 #include <memory>
17 #include <vector>
18 #include <string>
19 #include <iostream>
20 
21 class FastTrackerRecHit;
22 
23 namespace edm {
24  class ModuleCallingContext;
25 
26  class AdjusterBase {
27  public:
28  virtual ~AdjusterBase() {}
29  virtual void doOffset(int bunchspace, int bcr, const edm::EventPrincipal&, ModuleCallingContext const*, unsigned int EventNr, int vertexOffset) = 0;
30  virtual bool checkSignal(edm::Event const& event) = 0;
31  };
32 
33  template<typename T>
34  class Adjuster : public AdjusterBase {
35 
36  public:
37  Adjuster(InputTag const& tag, edm::ConsumesCollector&& iC, bool wrap);
38 
39  ~Adjuster() override {}
40 
41  void doOffset(int bunchspace, int bcr, const edm::EventPrincipal&, ModuleCallingContext const*, unsigned int EventNr, int vertexOffset) override;
42 
43  bool checkSignal(edm::Event const& event) override {
44  bool got = false;
45  edm::Handle<T> result_t;
46  got = event.getByToken(token_, result_t);
47  return got;
48  }
49 
50  private:
52  bool WrapT_ = false;
54  };
55 
56  //==============================================================================
57  // implementations
58  //==============================================================================
59 
60  namespace detail {
61  void doTheOffset(int bunchspace, int bcr, std::vector<SimTrack>& product, unsigned int eventNr, int vertexOffset, bool wraptimes);
62  void doTheOffset(int bunchspace, int bcr, std::vector<SimVertex>& product, unsigned int eventNr, int vertexOffset, bool wraptimes);
63  void doTheOffset(int bunchspace, int bcr, std::vector<PCaloHit>& product, unsigned int eventNr, int vertexOffset, bool wraptimes);
64  void doTheOffset(int bunchspace, int bcr, std::vector<PSimHit>& product, unsigned int eventNr, int vertexOffset, bool wraptimes);
65  void doTheOffset(int bunchspace, int bcr, TrackingRecHitCollection & product, unsigned int eventNr, int vertexOffset, bool wraptimes);
66  }
67 
68  template<typename T>
69  void Adjuster<T>::doOffset(int bunchspace, int bcr, const EventPrincipal &ep, ModuleCallingContext const* mcc, unsigned int eventNr, int vertexOffset) {
70  std::shared_ptr<Wrapper<T> const> shPtr = getProductByTag<T>(ep, tag_, mcc);
71  if (shPtr) {
72  T& product = const_cast<T&>(*shPtr->product());
73  detail::doTheOffset(bunchspace, bcr, product, eventNr, vertexOffset, WrapT_);
74  }
75  }
76 
77  template<typename T>
78  Adjuster<T>::Adjuster(InputTag const& tag, ConsumesCollector&& iC, bool wrapLongTimes) : tag_(tag), token_(iC.consumes<T>(tag)) {
79  if(wrapLongTimes) {
80  std::string Musearch = tag_.instance();
81  if(Musearch.find("Muon") == 0) WrapT_ = true; // wrap time for neutrons in Muon system subdetectors
82  }
83  }
84 }
85 
86 #endif
void doOffset(int bunchspace, int bcr, const edm::EventPrincipal &, ModuleCallingContext const *, unsigned int EventNr, int vertexOffset) override
Definition: Adjuster.h:69
~Adjuster() override
Definition: Adjuster.h:39
virtual void doOffset(int bunchspace, int bcr, const edm::EventPrincipal &, ModuleCallingContext const *, unsigned int EventNr, int vertexOffset)=0
virtual ~AdjusterBase()
Definition: Adjuster.h:28
void doTheOffset(int bunchSpace, int bcr, std::vector< SimTrack > &simtracks, unsigned int evtNr, int vertexOffset, bool wrap)
Definition: Adjuster.cc:7
bunchspace
in terms of 25 ns
Adjuster(InputTag const &tag, edm::ConsumesCollector &&iC, bool wrap)
Definition: Adjuster.h:78
bool WrapT_
Definition: Adjuster.h:52
bool checkSignal(edm::Event const &event) override
Definition: Adjuster.h:43
HLT enums.
EDGetTokenT< T > token_
Definition: Adjuster.h:53
virtual bool checkSignal(edm::Event const &event)=0
auto wrap(F iFunc) -> decltype(iFunc())
long double T
std::string const & instance() const
Definition: InputTag.h:37
InputTag tag_
Definition: Adjuster.h:51
Definition: event.py:1