CMS 3D CMS Logo

EcalFEDWithCRCErrorProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalFEDWithCRCErrorProducer
4 // Class: EcalFEDWithCRCErrorProducer
5 //
13 //
14 // Original Author: Giovanni FRANZONI
15 // Created: Tue Jan 22 13:55:00 CET 2008
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
24 
27 
31 
32 #include <string>
33 #include <iostream>
34 #include <vector>
35 #include <iomanip>
36 
40 //
41 // class declaration
42 //
43 
45 public:
48 
49 private:
50  void produce(edm::Event&, const edm::EventSetup&) override;
51 
52  // ----------member data ---------------------------
53 
55  std::vector<int> fedUnpackList_;
57 };
58 
59 //
60 // constructors and destructor
61 //
63  //now do what ever initialization is needed
64 
65  DataLabel_ = iConfig.getParameter<edm::InputTag>("InputLabel");
66  fedUnpackList_ = iConfig.getUntrackedParameter<std::vector<int> >("FEDs", std::vector<int>());
67  writeAllEcalFEDs_ = iConfig.getUntrackedParameter<bool>("writeAllEcalFED", false);
68  if (fedUnpackList_.empty())
70  fedUnpackList_.push_back(i);
71 
72  produces<FEDRawDataCollection>();
73 }
74 
76  // do anything here that needs to be done at desctruction time
77  // (e.g. close files, deallocate resources etc.)
78 }
79 
80 //
81 // member functions
82 //
83 
84 // ------------ method called on each new Event ------------
86  using namespace edm;
87 
89  iEvent.getByLabel(DataLabel_, rawdata);
90 
91  auto producedData = std::make_unique<FEDRawDataCollection>();
92  // get fed raw data and SM id
93 
94  // loop over FEDS
95  for (std::vector<int>::const_iterator i = fedUnpackList_.begin(); i != fedUnpackList_.end(); i++) {
96  // get fed raw data and SM id
97  const FEDRawData& fedData = rawdata->FEDData(*i);
98  int length = fedData.size() / sizeof(uint64_t);
99 
100  // LogDebug("EcalRawToDigi") << "raw data length: " << length ;
101  //if data size is not null interpret data
102  if (length >= 1) {
103  uint64_t* pData = (uint64_t*)(fedData.data());
104  //When crc error is found return true
105  uint64_t* fedTrailer = pData + (length - 1);
106  bool crcError = (*fedTrailer >> 2) & 0x1;
107  // this fed has data -- lets copy it
108  if (writeAllEcalFEDs_ || crcError) {
109  FEDRawData& fedDataProd = producedData->FEDData(*i);
110  if (fedDataProd.size() != 0) {
111  // std::cout << " More than one FEDRawDataCollection with data in FED ";
112  // std::cout << j << " Skipping the 2nd\n";
113  continue;
114  }
115  fedDataProd.resize(fedData.size());
116  unsigned char* dataProd = fedDataProd.data();
117  const unsigned char* data = fedData.data();
118  for (unsigned int k = 0; k < fedData.size(); ++k) {
119  dataProd[k] = data[k];
120  }
121  }
122  }
123  }
124 
125  iEvent.put(std::move(producedData));
126 }
127 
128 //define this as a plug-in
EcalFEDWithCRCErrorProducer::fedUnpackList_
std::vector< int > fedUnpackList_
Definition: EcalFEDWithCRCErrorProducer.cc:55
FEDNumbering.h
FEDNumbering::MINECALFEDID
Definition: FEDNumbering.h:43
mps_fire.i
i
Definition: mps_fire.py:355
EDProducer.h
edm
HLT enums.
Definition: AlignableModifier.h:19
EcalFEDWithCRCErrorProducer::EcalFEDWithCRCErrorProducer
EcalFEDWithCRCErrorProducer(const edm::ParameterSet &)
Definition: EcalFEDWithCRCErrorProducer.cc:62
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EcalFEDWithCRCErrorProducer
Definition: EcalFEDWithCRCErrorProducer.cc:44
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
EcalFEDWithCRCErrorProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: EcalFEDWithCRCErrorProducer.cc:85
FEDRawData
Definition: FEDRawData.h:19
MakerMacros.h
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqmdumpme.k
k
Definition: dqmdumpme.py:60
EcalFEDWithCRCErrorProducer::writeAllEcalFEDs_
bool writeAllEcalFEDs_
Definition: EcalFEDWithCRCErrorProducer.cc:56
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
EcalFEDWithCRCErrorProducer::DataLabel_
edm::InputTag DataLabel_
Definition: EcalFEDWithCRCErrorProducer.cc:54
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
FEDRawDataCollection.h
edm::EventSetup
Definition: EventSetup.h:57
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
edm::EDProducer
Definition: EDProducer.h:36
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
ParameterSet.h
EcalFEDWithCRCErrorProducer::~EcalFEDWithCRCErrorProducer
~EcalFEDWithCRCErrorProducer() override
Definition: EcalFEDWithCRCErrorProducer.cc:75
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
FEDNumbering::MAXECALFEDID
Definition: FEDNumbering.h:44