CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 // system include files
21 #include <memory>
22 
23 // user include files
25 
28 
32 
33 #include <string>
34 #include <iostream>
35 #include <vector>
36 #include <iomanip>
37 
41 //
42 // class declaration
43 //
44 
46 {
47 public:
50 
51 private:
52  virtual void produce(edm::Event&, const edm::EventSetup&) override;
53 
54  // ----------member data ---------------------------
55 
57  std::vector<int> fedUnpackList_;
59 };
60 
61 
62 
63 //
64 // constructors and destructor
65 //
67 {
68  //now do what ever initialization is needed
69 
70  DataLabel_ = iConfig.getParameter<edm::InputTag>("InputLabel");
71  fedUnpackList_ = iConfig.getUntrackedParameter< std::vector<int> >("FEDs", std::vector<int>());
72  writeAllEcalFEDs_ = iConfig.getUntrackedParameter<bool >("writeAllEcalFED", false);
73  if (fedUnpackList_.empty())
75  fedUnpackList_.push_back(i);
76 
77  produces< FEDRawDataCollection >();
78 }
79 
80 
82 {
83 
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86 
87 }
88 
89 
90 //
91 // member functions
92 //
93 
94 // ------------ method called on each new Event ------------
95 void
97 {
98  using namespace edm;
99 
101  iEvent.getByLabel(DataLabel_,rawdata);
102 
103  std::auto_ptr<FEDRawDataCollection> producedData(new FEDRawDataCollection);
104  // get fed raw data and SM id
105 
106  // loop over FEDS
107  for (std::vector<int>::const_iterator i=fedUnpackList_.begin(); i!=fedUnpackList_.end(); i++)
108  {
109 
110  // get fed raw data and SM id
111  const FEDRawData & fedData = rawdata->FEDData(*i);
112  int length = fedData.size()/sizeof(uint64_t);
113 
114  // LogDebug("EcalRawToDigi") << "raw data length: " << length ;
115  //if data size is not null interpret data
116  if ( length >= 1 )
117  {
118  uint64_t * pData = (uint64_t *)(fedData.data());
119  //When crc error is found return true
120  uint64_t * fedTrailer = pData + (length - 1);
121  bool crcError = (*fedTrailer >> 2 ) & 0x1;
122  // this fed has data -- lets copy it
123  if (writeAllEcalFEDs_ || crcError)
124  {
125  FEDRawData & fedDataProd = producedData->FEDData(*i);
126  if ( fedDataProd.size() != 0 )
127  {
128  // std::cout << " More than one FEDRawDataCollection with data in FED ";
129  // std::cout << j << " Skipping the 2nd\n";
130  continue;
131  }
132  fedDataProd.resize(fedData.size());
133  unsigned char *dataProd=fedDataProd.data();
134  const unsigned char *data=fedData.data();
135  for ( unsigned int k=0; k<fedData.size(); ++k )
136  {
137  dataProd[k]=data[k];
138  }
139  }
140  }
141  }
142 
143  iEvent.put(producedData);
144 }
145 
146 //define this as a plug-in
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int iEvent
Definition: GenABIO.cc:230
void resize(size_t newsize)
Definition: FEDRawData.cc:32
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
EcalFEDWithCRCErrorProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
unsigned long long uint64_t
Definition: Time.h:15
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
dictionary rawdata
Definition: lumiPlot.py:393