CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CalibratedDigis.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: UserCode/CalibratedDigis
4 // Class: CalibratedDigis
5 //
13 //
14 // Original Author: Luigi Guiducci
15 // Created: Fri, 11 Jan 2019 12:49:12 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
29 
36 
38 
46 
48 
49 namespace edm {
50  class ParameterSet;
51  class EventSetup;
52 } // namespace edm
53 
54 using namespace std;
55 using namespace edm;
56 using namespace cmsdt;
57 //
58 // class declaration
59 //
60 
62 public:
63  explicit CalibratedDigis(const edm::ParameterSet&);
64  ~CalibratedDigis() override;
65 
66 private:
69  int scenario;
70 
71  void produce(edm::Event&, const edm::EventSetup&) override;
72 
73  std::unique_ptr<DTTTrigBaseSync> theSync;
74 
75  // ----------member data ---------------------------
79 
80  static constexpr float bxspacing = 25.0;
81  static constexpr float timeshift = 400.0;
82  static constexpr float flatcalib = 325.0;
83 };
84 
85 //
86 // constructors and destructor
87 //
89  //register your products
90  dtDigiTag = iConfig.getParameter<InputTag>("dtDigiTag");
91  dtDigisToken = consumes<DTDigiCollection>(dtDigiTag);
92 
93  theSync = DTTTrigSyncFactory::get()->create(iConfig.getParameter<string>("tTrigMode"),
94  iConfig.getParameter<ParameterSet>("tTrigModeConfig"),
95  consumesCollector());
96 
97  flat_calib_ = iConfig.getParameter<int>("flat_calib");
98  timeOffset_ = iConfig.getParameter<int>("timeOffset");
99 
100  scenario = iConfig.getUntrackedParameter<int>("scenario");
101 
102  produces<DTDigiCollection>();
103  //now do what ever other initialization is needed
104 }
105 
107  // do anything here that needs to be done at destruction time
108  // (e.g. close files, deallocate resources etc.)
109 }
110 
111 //
112 // member functions
113 //
114 
115 // ------------ method called to produce the data ------------
117  using namespace edm;
118  theSync->setES(iSetup);
119  iEvent.getByToken(dtDigisToken, DTDigiHandle);
120  DTDigiCollection mydigis;
121 
122  for (const auto& dtLayerIt : *DTDigiHandle) {
123  const DTLayerId& layerId = dtLayerIt.first;
124  for (DTDigiCollection::const_iterator digiIt = dtLayerIt.second.first; digiIt != dtLayerIt.second.second;
125  ++digiIt) {
126  DTWireId wireId(layerId, (*digiIt).wire());
127  float digiTime = (*digiIt).time();
128  int wire = (*digiIt).wire();
129  int number = (*digiIt).number();
130  float newTime = 0;
131  if (flat_calib_ != 0)
132  newTime = digiTime - flatcalib + bxspacing * iEvent.eventAuxiliary().bunchCrossing() + float(timeOffset_);
133  else {
134  if (scenario == MC) //FIX MC
135  newTime = digiTime + bxspacing * timeshift;
136  else if (scenario == SLICE_TEST) //FIX SliceTest
137  newTime = digiTime;
138  else
139  newTime = digiTime - theSync->offset(wireId) + bxspacing * iEvent.eventAuxiliary().bunchCrossing() +
140  float(timeOffset_);
141  }
142  DTDigi newDigi(wire, newTime, number);
143  mydigis.insertDigi(layerId, newDigi);
144  }
145  }
146  auto CorrectedDTDigiCollection = std::make_unique<DTDigiCollection>(mydigis);
147  iEvent.put(std::move(CorrectedDTDigiCollection));
148 }
149 
150 //define this as a plug-in
T getUntrackedParameter(std::string const &, T const &) const
CalibratedDigis(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::unique_ptr< DTTTrigBaseSync > theSync
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:95
edm::EDGetTokenT< DTDigiCollection > dtDigisToken
int bunchCrossing() const
scenario
Definition: constants.h:173
int iEvent
Definition: GenABIO.cc:224
edm::InputTag dtDigiTag
def move
Definition: eostools.py:511
edm::Handle< DTDigiCollection > DTDigiHandle
Definition: DTDigi.h:17
int wire() const
Return the wire number.
Definition: DTWireId.h:42
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< DigiType >::const_iterator const_iterator
~CalibratedDigis() override
#define get