CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorRawToDigi.cc
Go to the documentation of this file.
1 using namespace std;
8 
12 #include <iostream>
14 
16  dataTag_(conf.getParameter<edm::InputTag>("InputLabel")),
17  unpacker_(conf.getUntrackedParameter<int>("CastorFirstFED",FEDNumbering::MINCASTORFEDID),conf.getParameter<int>("firstSample"),conf.getParameter<int>("lastSample")),
18  ctdcunpacker_(conf.getUntrackedParameter<int>("CastorFirstFED",FEDNumbering::MINCASTORFEDID),conf.getParameter<int>("firstSample"),conf.getParameter<int>("lastSample")),
19  filter_(conf.getParameter<bool>("FilterDataQuality"),conf.getParameter<bool>("FilterDataQuality"),
20  false,
21  0, 0,
22  -1),
23  fedUnpackList_(conf.getUntrackedParameter<std::vector<int> >("FEDs", std::vector<int>())),
24  firstFED_(conf.getUntrackedParameter<int>("CastorFirstFED",FEDNumbering::MINCASTORFEDID)),
25 // unpackCalib_(conf.getUntrackedParameter<bool>("UnpackCalib",false)),
26  complainEmptyData_(conf.getUntrackedParameter<bool>("ComplainEmptyData",false)),
27  usingctdc_(conf.getUntrackedParameter<bool>("CastorCtdc",false)),
28  unpackTTP_(conf.getUntrackedParameter<bool>("UnpackTTP",false)),
29  silent_(conf.getUntrackedParameter<bool>("silent",true)),
30  usenominalOrbitMessageTime_(conf.getUntrackedParameter<bool>("UseNominalOrbitMessageTime",true)),
31  expectedOrbitMessageTime_(conf.getUntrackedParameter<int>("ExpectedOrbitMessageTime",-1))
32 
33 {
34  if (fedUnpackList_.empty()) {
36  fedUnpackList_.push_back(i);
37  }
38 
40  std::ostringstream ss;
41  for (unsigned int i=0; i<fedUnpackList_.size(); i++)
42  ss << fedUnpackList_[i] << " ";
43  edm::LogInfo("CASTOR") << "CastorRawToDigi will unpack FEDs ( " << ss.str() << ")";
44 
45  // products produced...
46  produces<CastorDigiCollection>();
47  produces<CastorTrigPrimDigiCollection>();
48  produces<HcalUnpackerReport>();
49  if (unpackTTP_)
50  produces<HcalTTPDigiCollection>();
51 
52 // if (unpackCalib_)
53 // produces<HcalCalibDigiCollection>();
54 
55 }
56 
57 // Virtual destructor needed.
59 
60 // Functions that gets called by framework every event
62 {
63  // Step A: Get Inputs
65  e.getByLabel(dataTag_,rawraw);
66  // get the mapping
68  es.get<CastorDbRecord>().get( pSetup );
69  const CastorElectronicsMap* readoutMap=pSetup->getCastorMapping();
70 
71  // Step B: Create empty output : three vectors for three classes...
72  std::vector<CastorDataFrame> castor;
73  std::vector<HcalTTPDigi> ttp;
74  std::vector<CastorTriggerPrimitiveDigi> htp;
75 
76  std::auto_ptr<HcalUnpackerReport> report(new HcalUnpackerReport);
77 
79  colls.castorCont=&castor;
80  if (unpackTTP_) colls.ttp=&ttp;
81  colls.tpCont=&htp;
82  //colls.calibCont=&hc;
83 
84  // Step C: unpack all requested FEDs
85  for (std::vector<int>::const_iterator i=fedUnpackList_.begin(); i!=fedUnpackList_.end(); i++) {
86  const FEDRawData& fed = rawraw->FEDData(*i);
87  if (fed.size()==0) {
88  if (complainEmptyData_) {
89  edm::LogWarning("EmptyData") << "No data for FED " << *i;
90  report->addError(*i);
91  }
92  } else if (fed.size()<8*3) {
93  edm::LogWarning("EmptyData") << "Tiny data " << fed.size() << " for FED " << *i;
94  report->addError(*i);
95  } else {
96  try {
97  if ( usingctdc_ ) {
98  ctdcunpacker_.unpack(fed,*readoutMap,colls, *report);
99  } else {
100  unpacker_.unpack(fed,*readoutMap,colls, *report);
101  }
102  report->addUnpacked(*i);
103  } catch (cms::Exception& e) {
104  edm::LogWarning("Unpacking error") << e.what();
105  report->addError(*i);
106  } catch (...) {
107  edm::LogWarning("Unpacking exception");
108  report->addError(*i);
109  }
110  }
111  }
112 
113  // Step B: encapsulate vectors in actual collections
114  std::auto_ptr<CastorDigiCollection> castor_prod(new CastorDigiCollection());
115  std::auto_ptr<CastorTrigPrimDigiCollection> htp_prod(new CastorTrigPrimDigiCollection());
116 
117  castor_prod->swap_contents(castor);
118  htp_prod->swap_contents(htp);
119 
120  // Step C2: filter FEDs, if required
121  if (filter_.active()) {
122  CastorDigiCollection filtered_castor=filter_.filter(*castor_prod,*report);
123 
124  castor_prod->swap(filtered_castor);
125  }
126 
127  // Step D: Put outputs into event
128  // just until the sorting is proven
129  castor_prod->sort();
130  htp_prod->sort();
131 
132  e.put(castor_prod);
133  e.put(htp_prod);
134 
136 // if (unpackCalib_) {
137 // std::auto_ptr<CastorCalibDigiCollection> hc_prod(new CastorCalibDigiCollection());
138 // hc_prod->swap_contents(hc);
139 // hc_prod->sort();
140 // e.put(hc_prod);
141 // }
142  if (unpackTTP_) {
143  std::auto_ptr<HcalTTPDigiCollection> prod(new HcalTTPDigiCollection());
144  prod->swap_contents(ttp);
145 
146  prod->sort();
147  e.put(prod);
148  }
149  e.put(report);
150 }
153  if ( irun.run() > 132640 ) {
155  } else if ( irun.run() > 132174 ) {
157  } else if ( irun.run() > 124371 ) {
159  } else if ( irun.run() > 123984 ) {
161  } else if ( irun.run() > 123584 ) {
163  } else {
165  }
167  }
168 }
169 
virtual char const * what() const
Definition: Exception.cc:141
CastorDataFrameFilter filter_
int i
Definition: DBlmapReader.cc:9
RunNumber_t run() const
Definition: RunBase.h:42
virtual void beginRun(edm::Run &, edm::EventSetup const &)
CastorDigiCollection filter(const CastorDigiCollection &incol, HcalUnpackerReport &r)
filter Castor data frames
CastorUnpacker unpacker_
void swap(SortedCollection &other)
CastorCtdcUnpacker ctdcunpacker_
std::vector< int > fedUnpackList_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:49
edm::InputTag dataTag_
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false)
For histograms, no begin and end.
tuple report
Definition: zeeHLT_cff.py:9
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
void setExpectedOrbitMessageTime(int time)
bool active() const
whether any filters are on
virtual ~CastorRawToDigi()
CastorRawToDigi(const edm::ParameterSet &ps)
std::vector< CastorDataFrame > * castorCont
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple conf
Definition: dbtoconf.py:185
std::vector< CastorTriggerPrimitiveDigi > * tpCont
const T & get() const
Definition: EventSetup.h:55
bool usenominalOrbitMessageTime_
edm::SortedCollection< HcalTTPDigi > HcalTTPDigiCollection
edm::SortedCollection< CastorDataFrame > CastorDigiCollection
edm::SortedCollection< CastorTriggerPrimitiveDigi > CastorTrigPrimDigiCollection
virtual void produce(edm::Event &e, const edm::EventSetup &c)
Definition: Run.h:33
std::vector< HcalTTPDigi > * ttp