CMS 3D CMS Logo

EcalDigiToRaw.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalDigiToRaw
4 // Class: EcalDigiToRaw
5 //
13 //
14 // Original Author: Emmanuelle Perez
15 // Created: Sat Nov 25 13:59:51 CET 2006
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <iostream>
22 #include <string>
23 
24 // user include files
27 
30 
33 
38 
41 
43 
47 
51 
54 
56 public:
58 
59  void produce(edm::StreamID, edm::Event& e, const edm::EventSetup& c) const override;
60 
61  typedef long long Word64;
62  typedef unsigned int Word32;
63 
64  static const int BXMAX = 2808;
65 
66 private:
67  // ----------member data ---------------------------
68 
76 
77  const std::vector<int32_t> listDCCId_;
78 
80 };
81 
82 using namespace edm;
83 using namespace std;
84 
86  : listDCCId_{iConfig.getUntrackedParameter<std::vector<int32_t> >("listDCCId")},
87  config_{&listDCCId_,
88  iConfig.getUntrackedParameter<bool>("debug"),
89  iConfig.getUntrackedParameter<bool>("DoBarrel"),
90  iConfig.getUntrackedParameter<bool>("DoEndCap"),
91  iConfig.getUntrackedParameter<bool>("WriteTCCBlock"),
92  iConfig.getUntrackedParameter<bool>("WriteSRFlags"),
93  iConfig.getUntrackedParameter<bool>("WriteTowerBlock")} {
94  auto label = iConfig.getParameter<string>("Label");
95  auto instanceNameEB = iConfig.getParameter<string>("InstanceEB");
96  auto instanceNameEE = iConfig.getParameter<string>("InstanceEE");
97 
98  edm::InputTag EBlabel = edm::InputTag(label, instanceNameEB);
99  edm::InputTag EElabel = edm::InputTag(label, instanceNameEE);
100 
101  EBDigiToken_ = consumes<EBDigiCollection>(EBlabel);
102  EEDigiToken_ = consumes<EEDigiCollection>(EElabel);
103 
104  labelTT_ = consumes<EcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("labelTT"));
105 
106  labelEBSR_ = consumes<EBSrFlagCollection>(iConfig.getParameter<edm::InputTag>("labelEBSRFlags"));
107  labelEESR_ = consumes<EESrFlagCollection>(iConfig.getParameter<edm::InputTag>("labelEESRFlags"));
108  ecalmappingToken_ = esConsumes<EcalElectronicsMapping, EcalMappingRcd>();
109 
110  putToken_ = produces<FEDRawDataCollection>();
111 }
112 
113 //
114 // member functions
115 //
116 
117 // ------------ method called to for each event ------------
119  if (config_.debug_)
120  cout << "Enter in EcalDigiToRaw::produce ... " << endl;
121 
123  const EcalElectronicsMapping* TheMapping = ecalmapping.product();
124 
125  FEDRawDataCollection productRawData;
126 
128  int counter = iEvent.id().event();
129  params.counter_ = counter;
130  params.orbit_number_ = iEvent.orbitNumber();
131  params.bx_ = iEvent.bunchCrossing();
132  params.lv1_ = counter % (0x1 << 24);
133  params.runnumber_ = iEvent.id().run();
134 
135  BlockFormatter Headerblockformatter(config_, params);
136  TCCBlockFormatter TCCblockformatter(config_, params);
137  TowerBlockFormatter Towerblockformatter(config_, params);
138  SRBlockFormatter SRblockformatter(config_, params);
139 
140  Headerblockformatter.DigiToRaw(&productRawData);
141 
142  // --------- Now the Trigger Block part
143 
145 
146  Handle<EBSrFlagCollection> ebSrFlags;
147  Handle<EESrFlagCollection> eeSrFlags;
148 
149  if (config_.doTCC_) {
150  if (config_.debug_)
151  cout << "Creation of the TCC block " << endl;
152  // iEvent.getByType(ecalTrigPrim);
153  iEvent.getByToken(labelTT_, ecalTrigPrim);
154 
155  // loop on TP's and add one by one to the block
156  for (EcalTrigPrimDigiCollection::const_iterator it = ecalTrigPrim->begin(); it != ecalTrigPrim->end(); it++) {
157  const EcalTriggerPrimitiveDigi& trigprim = *it;
158  const EcalTrigTowerDetId& detid = it->id();
159 
160  if ((detid.subDet() == EcalBarrel) && (!config_.doBarrel_))
161  continue;
162  if ((detid.subDet() == EcalEndcap) && (!config_.doEndCap_))
163  continue;
164 
165  int iDCC = TheMapping->DCCid(detid);
166  int FEDid = FEDNumbering::MINECALFEDID + iDCC;
167 
168  FEDRawData& rawdata = productRawData.FEDData(FEDid);
169 
170  // adding the primitive to the block
171  TCCblockformatter.DigiToRaw(trigprim, rawdata, TheMapping);
172 
173  } // end loop on ecalTrigPrim
174 
175  } // endif doTCC
176 
177  if (config_.doSR_) {
178  if (config_.debug_)
179  cout << " Process the SR flags " << endl;
180 
181  if (config_.doBarrel_) {
182  // iEvent.getByType(ebSrFlags);
183  iEvent.getByToken(labelEBSR_, ebSrFlags);
184 
185  for (EBSrFlagCollection::const_iterator it = ebSrFlags->begin(); it != ebSrFlags->end(); it++) {
186  const EcalSrFlag& srflag = *it;
187  int flag = srflag.value();
188 
189  EcalTrigTowerDetId id = srflag.id();
190  int Dccid = TheMapping->DCCid(id);
191  int DCC_Channel = TheMapping->iTT(id);
192  int FEDid = FEDNumbering::MINECALFEDID + Dccid;
193  // if (Dccid == 10) cout << "Dcc " << Dccid << " DCC_Channel " << DCC_Channel << " flag " << flag << endl;
194  if (config_.debug_)
195  cout << "will process SRblockformatter_ for FEDid " << dec << FEDid << endl;
196  FEDRawData& rawdata = productRawData.FEDData(FEDid);
197  if (config_.debug_)
198  Headerblockformatter.print(rawdata);
199  SRblockformatter.DigiToRaw(Dccid, DCC_Channel, flag, rawdata);
200  }
201  } // end DoBarrel
202 
203  if (config_.doEndCap_) {
204  // iEvent.getByType(eeSrFlags);
205  iEvent.getByToken(labelEESR_, eeSrFlags);
206 
207  for (EESrFlagCollection::const_iterator it = eeSrFlags->begin(); it != eeSrFlags->end(); it++) {
208  const EcalSrFlag& srflag = *it;
209  int flag = srflag.value();
210  EcalScDetId id = srflag.id();
211  pair<int, int> ind = TheMapping->getDCCandSC(id);
212  int Dccid = ind.first;
213  int DCC_Channel = ind.second;
214 
215  int FEDid = FEDNumbering::MINECALFEDID + Dccid;
216  FEDRawData& rawdata = productRawData.FEDData(FEDid);
217  SRblockformatter.DigiToRaw(Dccid, DCC_Channel, flag, rawdata);
218  }
219  } // end doEndCap
220 
221  } // endif doSR
222 
223  // --------- Now the Tower Block part
224 
225  Handle<EBDigiCollection> ebDigis;
227 
228  if (config_.doTower_) {
229  if (config_.doBarrel_) {
230  if (config_.debug_)
231  cout << "Creation of the TowerBlock ... Barrel case " << endl;
232  iEvent.getByToken(EBDigiToken_, ebDigis);
233  for (EBDigiCollection::const_iterator it = ebDigis->begin(); it != ebDigis->end(); it++) {
234  const EBDataFrame& dataframe = *it;
235  const EBDetId& ebdetid = it->id();
236  int DCCid = TheMapping->DCCid(ebdetid);
237  int FEDid = FEDNumbering::MINECALFEDID + DCCid;
238  FEDRawData& rawdata = productRawData.FEDData(FEDid);
239  Towerblockformatter.DigiToRaw(dataframe, rawdata, TheMapping);
240  }
241  }
242 
243  if (config_.doEndCap_) {
244  if (config_.debug_)
245  cout << "Creation of the TowerBlock ... EndCap case " << endl;
246  iEvent.getByToken(EEDigiToken_, eeDigis);
247  for (EEDigiCollection::const_iterator it = eeDigis->begin(); it != eeDigis->end(); it++) {
248  const EEDataFrame& dataframe = *it;
249  const EEDetId& eedetid = it->id();
250  EcalElectronicsId elid = TheMapping->getElectronicsId(eedetid);
251  int DCCid = elid.dccId();
252  int FEDid = FEDNumbering::MINECALFEDID + DCCid;
253  FEDRawData& rawdata = productRawData.FEDData(FEDid);
254  Towerblockformatter.DigiToRaw(dataframe, rawdata, TheMapping);
255  }
256  }
257 
258  } // endif config_.doTower_
259 
260  // -------- Clean up things ...
261 
262  map<int, map<int, int> >& FEDorder = Towerblockformatter.GetFEDorder();
263 
264  Headerblockformatter.CleanUp(&productRawData, &FEDorder);
265 
266  /*
267  cout << "For FED 633 " << endl;
268  FEDRawData& rawdata = productRawData -> FEDData(633);
269  Headerblockformatter_ -> print(rawdata);
270 */
271 
272  // Headerblockformatter_ -> PrintSizes(productRawData.get());
273 
274  Towerblockformatter.EndEvent(&productRawData);
275 
276  iEvent.emplace(putToken_, std::move(productRawData));
277 
278  return;
279 }
280 
FEDNumbering.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::StreamID
Definition: StreamID.h:30
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
counter
Definition: counter.py:1
Handle.h
EcalDigiToRaw::BXMAX
static const int BXMAX
Definition: EcalDigiToRaw.cc:64
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
BlockFormatter::Config::doBarrel_
bool doBarrel_
Definition: BlockFormatter.h:22
TowerBlockFormatter::EndEvent
void EndEvent(FEDRawDataCollection *productRawData)
Definition: TowerBlockFormatter.cc:169
ESHandle.h
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
EcalElectronicsMapping::iTT
int iTT(const EcalTrigTowerDetId &id) const
returns the index of a Trigger Tower within its TCC.
Definition: EcalElectronicsMapping.cc:102
edm::EDGetTokenT
Definition: EDGetToken.h:33
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT< FEDRawDataCollection >
EBDataFrame
Definition: EBDataFrame.h:11
BlockFormatter::Config::doTCC_
bool doTCC_
Definition: BlockFormatter.h:24
EcalDigiToRaw::labelEBSR_
edm::EDGetTokenT< EBSrFlagCollection > labelEBSR_
Definition: EcalDigiToRaw.cc:70
EcalDigiToRaw::EcalDigiToRaw
EcalDigiToRaw(const edm::ParameterSet &pset)
Definition: EcalDigiToRaw.cc:85
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EcalSrFlag::value
int value() const
Definition: EcalSrFlag.h:44
EcalDigiToRaw::Word32
unsigned int Word32
Definition: EcalDigiToRaw.cc:62
EcalDetIdCollections.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EcalDigiToRaw::EEDigiToken_
edm::EDGetTokenT< EEDigiCollection > EEDigiToken_
Definition: EcalDigiToRaw.cc:73
TCCBlockFormatter.h
TowerBlockFormatter::DigiToRaw
void DigiToRaw(const EBDataFrame &dataframe, FEDRawData &rawdata, const EcalElectronicsMapping *TheMapping)
Definition: TowerBlockFormatter.cc:14
EcalDigiToRaw::EBDigiToken_
edm::EDGetTokenT< EBDigiCollection > EBDigiToken_
Definition: EcalDigiToRaw.cc:72
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
BlockFormatter::Params
Definition: BlockFormatter.h:28
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalElectronicsId::dccId
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Definition: EcalElectronicsId.h:31
BlockFormatter::print
void print(FEDRawData &rawdata)
Definition: BlockFormatter.cc:89
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
EcalBarrel
Definition: EcalSubdetector.h:10
EcalDigiToRaw::ecalmappingToken_
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > ecalmappingToken_
Definition: EcalDigiToRaw.cc:74
FEDRawData
Definition: FEDRawData.h:19
BlockFormatter
Definition: BlockFormatter.h:13
MakerMacros.h
BlockFormatter::Config::doTower_
bool doTower_
Definition: BlockFormatter.h:26
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TCCBlockFormatter
Definition: TCCBlockFormatter.h:19
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
TowerBlockFormatter.h
EcalMappingRcd.h
EcalScDetId
Definition: EcalScDetId.h:24
EcalDigiCollections.h
edm::ESHandle< EcalElectronicsMapping >
EcalElectronicsMapping::getElectronicsId
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
Definition: EcalElectronicsMapping.cc:324
BlockFormatter::DigiToRaw
void DigiToRaw(FEDRawDataCollection *productRawData)
Definition: BlockFormatter.cc:25
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
EEDetId
Definition: EEDetId.h:14
edm::global::EDProducer
Definition: EDProducer.h:32
EcalEndcap
Definition: EcalSubdetector.h:10
EcalElectronicsMapping::getDCCandSC
std::pair< int, int > getDCCandSC(EcalScDetId id) const
Definition: EcalElectronicsMapping.cc:761
TowerBlockFormatter::GetFEDorder
std::map< int, std::map< int, int > > & GetFEDorder()
Definition: TowerBlockFormatter.h:28
BlockFormatter::Config
Definition: BlockFormatter.h:18
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
BlockFormatter::Config::doEndCap_
bool doEndCap_
Definition: BlockFormatter.h:23
EcalSrFlag::id
virtual const DetId & id() const =0
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalSrFlag
Definition: EcalSrFlag.h:10
EcalElectronicsMapping.h
iEvent
int iEvent
Definition: GenABIO.cc:224
FEDRawDataCollection.h
edm::DataFrameContainer::begin
const_iterator begin() const
The iterator returned can not safely be used across threads.
Definition: DataFrameContainer.h:149
TowerBlockFormatter
Definition: TowerBlockFormatter.h:19
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
EcalElectronicsMapping::DCCid
int DCCid(const EBDetId &id) const
returns the DCC of an EBDetId
Definition: EcalElectronicsMapping.cc:70
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:18
edm::EventSetup
Definition: EventSetup.h:58
BlockFormatter::CleanUp
void CleanUp(FEDRawDataCollection *productRawData, std::map< int, std::map< int, int > > *FEDorder)
Definition: BlockFormatter.cc:104
EcalSrFlag.h
EcalTrigTowerDetId::subDet
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
Definition: EcalTrigTowerDetId.h:33
EcalDigiToRaw
Definition: EcalDigiToRaw.cc:55
EcalDigiToRaw::Word64
long long Word64
Definition: EcalDigiToRaw.cc:61
TCCBlockFormatter::DigiToRaw
void DigiToRaw(const EcalTriggerPrimitiveDigi &trigprim, FEDRawData &rawdata, const EcalElectronicsMapping *TheMapping)
Definition: TCCBlockFormatter.cc:17
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd >
SRBlockFormatter
Definition: SRBlockFormatter.h:13
EcalDigiToRaw::listDCCId_
const std::vector< int32_t > listDCCId_
Definition: EcalDigiToRaw.cc:77
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
BlockFormatter::Config::doSR_
bool doSR_
Definition: BlockFormatter.h:25
SRBlockFormatter.h
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
EcalDigiToRaw::produce
void produce(edm::StreamID, edm::Event &e, const edm::EventSetup &c) const override
Definition: EcalDigiToRaw.cc:118
BlockFormatter::Config::debug_
bool debug_
Definition: BlockFormatter.h:20
EventSetup.h
EcalDigiToRaw::config_
const BlockFormatter::Config config_
Definition: EcalDigiToRaw.cc:79
FEDNumbering::MINECALFEDID
Definition: FEDNumbering.h:43
BlockFormatter.h
ParameterSet.h
SRBlockFormatter::DigiToRaw
void DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawData &rawdata)
Definition: SRBlockFormatter.cc:9
EDProducer.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
EcalDigiToRaw::putToken_
edm::EDPutTokenT< FEDRawDataCollection > putToken_
Definition: EcalDigiToRaw.cc:75
EEDataFrame
Definition: EEDataFrame.h:12
edm::Event
Definition: Event.h:73
SimL1EmulatorDM_cff.eeDigis
eeDigis
Definition: SimL1EmulatorDM_cff.py:18
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
EcalDigiToRaw::labelEESR_
edm::EDGetTokenT< EESrFlagCollection > labelEESR_
Definition: EcalDigiToRaw.cc:71
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
EcalDigiToRaw::labelTT_
edm::EDGetTokenT< EcalTrigPrimDigiCollection > labelTT_
Definition: EcalDigiToRaw.cc:69
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37