CMS 3D CMS Logo

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 
28 
35 
37 
45 
47 
48 namespace edm {
49  class ParameterSet;
50  class EventSetup;
51 } // namespace edm
52 
53 using namespace std;
54 using namespace edm;
55 using namespace cmsdt;
56 //
57 // class declaration
58 //
59 
61 public:
62  explicit CalibratedDigis(const edm::ParameterSet&);
63  ~CalibratedDigis() override;
64 
65 private:
68  int scenario;
69 
70  void produce(edm::Event&, const edm::EventSetup&) override;
71 
72  std::unique_ptr<DTTTrigBaseSync> theSync;
73 
74  // ----------member data ---------------------------
78 
79  static constexpr float bxspacing = 25.0;
80  static constexpr float timeshift = 400.0;
81  static constexpr float flatcalib = 325.0;
82 };
83 
84 //
85 // constructors and destructor
86 //
88  //register your products
89  dtDigiTag = iConfig.getParameter<InputTag>("dtDigiTag");
90  dtDigisToken = consumes<DTDigiCollection>(dtDigiTag);
91 
92  theSync = DTTTrigSyncFactory::get()->create(iConfig.getParameter<string>("tTrigMode"),
93  iConfig.getParameter<ParameterSet>("tTrigModeConfig"));
94 
95  flat_calib_ = iConfig.getParameter<int>("flat_calib");
96  timeOffset_ = iConfig.getParameter<int>("timeOffset");
97 
98  scenario = iConfig.getUntrackedParameter<int>("scenario");
99 
100  produces<DTDigiCollection>();
101  //now do what ever other initialization is needed
102 }
103 
105  // do anything here that needs to be done at destruction time
106  // (e.g. close files, deallocate resources etc.)
107 }
108 
109 //
110 // member functions
111 //
112 
113 // ------------ method called to produce the data ------------
115  using namespace edm;
116  theSync->setES(iSetup);
117  iEvent.getByToken(dtDigisToken, DTDigiHandle);
118  DTDigiCollection mydigis;
119 
120  for (const auto& dtLayerIt : *DTDigiHandle) {
121  const DTLayerId& layerId = dtLayerIt.first;
122  for (DTDigiCollection::const_iterator digiIt = dtLayerIt.second.first; digiIt != dtLayerIt.second.second;
123  ++digiIt) {
124  DTWireId wireId(layerId, (*digiIt).wire());
125  float digiTime = (*digiIt).time();
126  int wire = (*digiIt).wire();
127  int number = (*digiIt).number();
128  float newTime = 0;
129  if (flat_calib_ != 0)
130  newTime = digiTime - flatcalib + bxspacing * iEvent.eventAuxiliary().bunchCrossing() + float(timeOffset_);
131  else {
132  if (scenario == MC) //FIX MC
133  newTime = digiTime + bxspacing * timeshift;
134  else if (scenario == SLICE_TEST) //FIX SliceTest
135  newTime = digiTime;
136  else
137  newTime = digiTime - theSync->offset(wireId) + bxspacing * iEvent.eventAuxiliary().bunchCrossing() +
138  float(timeOffset_);
139  }
140  DTDigi newDigi(wire, newTime, number);
141  mydigis.insertDigi(layerId, newDigi);
142  }
143  }
144  auto CorrectedDTDigiCollection = std::make_unique<DTDigiCollection>(mydigis);
145  iEvent.put(std::move(CorrectedDTDigiCollection));
146 }
147 
148 //define this as a plug-in
Handle.h
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
ESHandle.h
CalibratedDigis::dtDigiTag
edm::InputTag dtDigiTag
Definition: CalibratedDigis.cc:77
DTLayerId.h
edm::EDGetTokenT< DTDigiCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
EDProducer.h
CalibratedDigis::flat_calib_
int flat_calib_
Definition: CalibratedDigis.cc:67
CalibratedDigis::scenario
int scenario
Definition: CalibratedDigis.cc:68
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
CalibratedDigis::timeOffset_
int timeOffset_
Definition: CalibratedDigis.cc:66
edm::Handle< DTDigiCollection >
CalibratedDigis::CalibratedDigis
CalibratedDigis(const edm::ParameterSet &)
Definition: CalibratedDigis.cc:87
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
CalibratedDigis::DTDigiHandle
edm::Handle< DTDigiCollection > DTDigiHandle
Definition: CalibratedDigis.cc:76
CalibratedDigis::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CalibratedDigis.cc:114
MakerMacros.h
cmsdt
Definition: constants.h:39
constants.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
DTWireId
Definition: DTWireId.h:12
CalibratedDigis::~CalibratedDigis
~CalibratedDigis() override
Definition: CalibratedDigis.cc:104
cmsdt::scenario
scenario
Definition: constants.h:173
DTLayerId
Definition: DTLayerId.h:12
DTGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
cmsdt::SLICE_TEST
Definition: constants.h:173
Event.h
DTDigiCollection
iEvent
int iEvent
Definition: GenABIO.cc:224
DTTTrigBaseSync.h
CalibratedDigis
Definition: CalibratedDigis.cc:60
edm::stream::EDProducer
Definition: EDProducer.h:36
cmsdt::MC
Definition: constants.h:173
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DTWireId.h
Frameworkfwd.h
DTTTrigSyncFactory.h
CalibratedDigis_cfi.CalibratedDigis
CalibratedDigis
Definition: CalibratedDigis_cfi.py:6
DTDigi
Definition: DTDigi.h:17
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CalibratedDigis::dtDigisToken
edm::EDGetTokenT< DTDigiCollection > dtDigisToken
Definition: CalibratedDigis.cc:75
CalibratedDigis_cfi.dtDigiTag
dtDigiTag
Definition: CalibratedDigis_cfi.py:26
ConsumesCollector.h
DTDigiCollection.h
ParameterSet.h
MuonGeometryRecord.h
edm::Event
Definition: Event.h:73
StreamID.h
edm::InputTag
Definition: InputTag.h:15
CalibratedDigis::theSync
std::unique_ptr< DTTTrigBaseSync > theSync
Definition: CalibratedDigis.cc:72