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 // $Id: EcalFEDWithCRCErrorProducer.cc,v 1.5 2010/10/05 13:39:30 vlimant Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
26 
29 
33 
34 #include <string>
35 #include <iostream>
36 #include <vector>
37 #include <iomanip>
38 
42 //
43 // class declaration
44 //
45 
47 {
48 public:
51 
52 private:
53  virtual void produce(edm::Event&, const edm::EventSetup&);
54 
55  // ----------member data ---------------------------
56 
58  std::vector<int> fedUnpackList_;
60 };
61 
62 
63 
64 //
65 // constructors and destructor
66 //
68 {
69  //now do what ever initialization is needed
70 
71  DataLabel_ = iConfig.getParameter<edm::InputTag>("InputLabel");
72  fedUnpackList_ = iConfig.getUntrackedParameter< std::vector<int> >("FEDs", std::vector<int>());
73  writeAllEcalFEDs_ = iConfig.getUntrackedParameter<bool >("writeAllEcalFED", false);
74  if (fedUnpackList_.empty())
76  fedUnpackList_.push_back(i);
77 
78  produces< FEDRawDataCollection >();
79 }
80 
81 
83 {
84 
85  // do anything here that needs to be done at desctruction time
86  // (e.g. close files, deallocate resources etc.)
87 
88 }
89 
90 
91 //
92 // member functions
93 //
94 
95 // ------------ method called on each new Event ------------
96 void
98 {
99  using namespace edm;
100 
102  iEvent.getByLabel(DataLabel_,rawdata);
103 
104  std::auto_ptr<FEDRawDataCollection> producedData(new FEDRawDataCollection);
105  // get fed raw data and SM id
106 
107  // loop over FEDS
108  for (std::vector<int>::const_iterator i=fedUnpackList_.begin(); i!=fedUnpackList_.end(); i++)
109  {
110 
111  // get fed raw data and SM id
112  const FEDRawData & fedData = rawdata->FEDData(*i);
113  int length = fedData.size()/sizeof(uint64_t);
114 
115  // LogDebug("EcalRawToDigi") << "raw data length: " << length ;
116  //if data size is not null interpret data
117  if ( length >= 1 )
118  {
119  uint64_t * pData = (uint64_t *)(fedData.data());
120  //When crc error is found return true
121  uint64_t * fedTrailer = pData + (length - 1);
122  bool crcError = (*fedTrailer >> 2 ) & 0x1;
123  // this fed has data -- lets copy it
124  if (writeAllEcalFEDs_ || crcError)
125  {
126  FEDRawData & fedDataProd = producedData->FEDData(*i);
127  if ( fedDataProd.size() != 0 )
128  {
129  // std::cout << " More than one FEDRawDataCollection with data in FED ";
130  // std::cout << j << " Skipping the 2nd\n";
131  continue;
132  }
133  fedDataProd.resize(fedData.size());
134  unsigned char *dataProd=fedDataProd.data();
135  const unsigned char *data=fedData.data();
136  for ( unsigned int k=0; k<fedData.size(); ++k )
137  {
138  dataProd[k]=data[k];
139  }
140  }
141  }
142  }
143 
144  iEvent.put(producedData);
145 }
146 
147 //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:49
int iEvent
Definition: GenABIO.cc:243
void resize(size_t newsize)
Definition: FEDRawData.cc:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
EcalFEDWithCRCErrorProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
int k[5][pyjets_maxn]
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:29
dictionary rawdata
Definition: lumiPlot.py:393