test
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.getParameter<int>("CastorFirstFED"),conf.getParameter<int>("firstSample"),conf.getParameter<int>("lastSample")),
18  ctdcunpacker_(conf.getParameter<int>("CastorFirstFED"),conf.getParameter<int>("firstSample"),conf.getParameter<int>("lastSample")),
19  filter_(conf.getParameter<bool>("FilterDataQuality"),conf.getParameter<bool>("FilterDataQuality"),false,0,0,-1),
20  fedUnpackList_(conf.getUntrackedParameter<std::vector<int> >("FEDs",std::vector<int>())),
21  firstFED_(conf.getParameter<int>("CastorFirstFED")),
22  complainEmptyData_(conf.getUntrackedParameter<bool>("ComplainEmptyData",false)),
23  usingctdc_(conf.getParameter<bool>("CastorCtdc")),
24  unpackTTP_(conf.getParameter<bool>("UnpackTTP")),
25  silent_(conf.getUntrackedParameter<bool>("silent",true)),
26  usenominalOrbitMessageTime_(conf.getParameter<bool>("UseNominalOrbitMessageTime")),
27  expectedOrbitMessageTime_(conf.getParameter<int>("ExpectedOrbitMessageTime"))
28 
29 {
30  if (fedUnpackList_.empty()) {
32  fedUnpackList_.push_back(i);
33  }
34 
36  std::ostringstream ss;
37  for (unsigned int i=0; i<fedUnpackList_.size(); i++)
38  ss << fedUnpackList_[i] << " ";
39  edm::LogInfo("CASTOR") << "CastorRawToDigi will unpack FEDs ( " << ss.str() << ")";
40 
41  // products produced...
42  produces<CastorDigiCollection>();
43  produces<CastorTrigPrimDigiCollection>();
44  produces<HcalUnpackerReport>();
45  if (unpackTTP_)
46  produces<HcalTTPDigiCollection>();
47 
48  tok_input_ = consumes<FEDRawDataCollection>(dataTag_);
49 
50 }
51 
52 // Virtual destructor needed.
54 
55 // Functions that gets called by framework every event
57 {
58  // Step A: Get Inputs
60  e.getByToken(tok_input_,rawraw);
61  // get the mapping
63  es.get<CastorDbRecord>().get( pSetup );
64  const CastorElectronicsMap* readoutMap=pSetup->getCastorMapping();
65 
66  // Step B: Create empty output : three vectors for three classes...
67  std::vector<CastorDataFrame> castor;
68  std::vector<HcalTTPDigi> ttp;
69  std::vector<CastorTriggerPrimitiveDigi> htp;
70 
71  std::auto_ptr<HcalUnpackerReport> report(new HcalUnpackerReport);
72 
74  colls.castorCont=&castor;
75  if (unpackTTP_) colls.ttp=&ttp;
76  colls.tpCont=&htp;
77 
78  // Step C: unpack all requested FEDs
79  for (std::vector<int>::const_iterator i=fedUnpackList_.begin(); i!=fedUnpackList_.end(); i++) {
80  const FEDRawData& fed = rawraw->FEDData(*i);
81  if (fed.size()==0) {
82  if (complainEmptyData_) {
83  edm::LogWarning("EmptyData") << "No data for FED " << *i;
84  report->addError(*i);
85  }
86  } else if (fed.size()<8*3) {
87  edm::LogWarning("EmptyData") << "Tiny data " << fed.size() << " for FED " << *i;
88  report->addError(*i);
89  } else {
90  try {
91  if ( usingctdc_ ) {
92  ctdcunpacker_.unpack(fed,*readoutMap,colls, *report);
93  } else {
94  unpacker_.unpack(fed,*readoutMap,colls, *report);
95  }
96  report->addUnpacked(*i);
97  } catch (cms::Exception& e) {
98  edm::LogWarning("Unpacking error") << e.what();
99  report->addError(*i);
100  } catch (...) {
101  edm::LogWarning("Unpacking exception");
102  report->addError(*i);
103  }
104  }
105  }
106 
107  // Step B: encapsulate vectors in actual collections
108  std::auto_ptr<CastorDigiCollection> castor_prod(new CastorDigiCollection());
109  std::auto_ptr<CastorTrigPrimDigiCollection> htp_prod(new CastorTrigPrimDigiCollection());
110 
111  castor_prod->swap_contents(castor);
112  htp_prod->swap_contents(htp);
113 
114  // Step C2: filter FEDs, if required
115  if (filter_.active()) {
116  CastorDigiCollection filtered_castor=filter_.filter(*castor_prod,*report);
117 
118  castor_prod->swap(filtered_castor);
119  }
120 
121  // Step D: Put outputs into event
122  // just until the sorting is proven
123  castor_prod->sort();
124  htp_prod->sort();
125 
126  e.put(castor_prod);
127  e.put(htp_prod);
128 
129  if (unpackTTP_) {
130  std::auto_ptr<HcalTTPDigiCollection> prod(new HcalTTPDigiCollection());
131  prod->swap_contents(ttp);
132 
133  prod->sort();
134  e.put(prod);
135  }
136  e.put(report);
137 }
140  if ( irun.run() > 132640 ) {
142  } else if ( irun.run() > 132174 ) {
144  } else if ( irun.run() > 124371 ) {
146  } else if ( irun.run() > 123984 ) {
148  } else if ( irun.run() > 123584 ) {
150  } else {
152  }
154  }
155 }
156 
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
CastorDigiCollection filter(const CastorDigiCollection &incol, HcalUnpackerReport &r)
filter Castor data frames
CastorUnpacker unpacker_
void swap(SortedCollection &other)
CastorCtdcUnpacker ctdcunpacker_
std::vector< int > fedUnpackList_
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
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
edm::EDGetTokenT< FEDRawDataCollection > tok_input_
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:116
void setExpectedOrbitMessageTime(int time)
bool active() const
whether any filters are on
virtual ~CastorRawToDigi()
CastorRawToDigi(const edm::ParameterSet &ps)
std::vector< CastorDataFrame > * castorCont
tuple conf
Definition: dbtoconf.py:185
std::vector< CastorTriggerPrimitiveDigi > * tpCont
const T & get() const
Definition: EventSetup.h:55
bool usenominalOrbitMessageTime_
edm::SortedCollection< HcalTTPDigi > HcalTTPDigiCollection
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
edm::SortedCollection< CastorDataFrame > CastorDigiCollection
volatile std::atomic< bool > shutdown_flag false
edm::SortedCollection< CastorTriggerPrimitiveDigi > CastorTrigPrimDigiCollection
Definition: Run.h:41
std::vector< HcalTTPDigi > * ttp