CMS 3D CMS Logo

HcalTBObjectUnpacker.cc
Go to the documentation of this file.
1 
10 #include <iostream>
11 #include <fstream>
12 using namespace std;
13 
15  : triggerFed_(conf.getUntrackedParameter<int>("HcalTriggerFED", -1)),
16  sdFed_(conf.getUntrackedParameter<int>("HcalSlowDataFED", -1)),
17  spdFed_(conf.getUntrackedParameter<int>("HcalSourcePositionFED", -1)),
18  tdcFed_(conf.getUntrackedParameter<int>("HcalTDCFED", -1)),
19  qadcFed_(conf.getUntrackedParameter<int>("HcalQADCFED", -1)),
20  calibFile_(conf.getUntrackedParameter<string>("ConfigurationFile", "")),
21  tdcUnpacker_(conf.getUntrackedParameter<bool>("IncludeUnmatchedHits", false)),
22  doRunData_(false),
23  doTriggerData_(false),
24  doEventPosition_(false),
25  doTiming_(false),
26  doSourcePos_(false),
27  doBeamADC_(false) {
28  tok_raw_ = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("fedRawDataCollectionTag"));
29 
30  if (triggerFed_ >= 0) {
31  std::cout << "HcalTBObjectUnpacker will unpack Trigger FED ";
32  std::cout << triggerFed_ << endl;
33  doTriggerData_ = true;
34  }
35 
36  if (sdFed_ >= 0) {
37  std::cout << "HcalTBObjectUnpacker will unpack SlowData FED ";
38  std::cout << sdFed_ << endl;
39  doRunData_ = true;
40  doEventPosition_ = true; // at least the table
41  }
42 
43  if (tdcFed_ >= 0) {
44  std::cout << "HcalTBObjectUnpacker will unpack TDC FED ";
45  std::cout << tdcFed_ << endl;
46  doTiming_ = true;
47  doEventPosition_ = true; // at least the WC
48  }
49 
50  if (qadcFed_ >= 0) {
51  std::cout << "HcalTBObjectUnpacker will unpack QADC FED ";
52  std::cout << qadcFed_ << endl;
53  doBeamADC_ = true;
54  }
55 
56  if (spdFed_ >= 0) {
57  std::cout << "HcalTBObjectUnpacker will unpack Source Position Data FED ";
58  std::cout << spdFed_ << endl;
59  doSourcePos_ = true;
60  }
61 
62  if (tdcFed_ >= 0 || qadcFed_ >= 0) {
63  calibLines_.clear();
64  if (!calibFile_.empty()) {
65  parseCalib();
66  // printf("I got %d lines!\n",calibLines_.size());
67  if (calibLines_.empty())
68  throw cms::Exception("Incomplete configuration")
69  << "HcalTBObjectUnpacker: TDC/QADC/WC configuration file not found or is empty: " << calibFile_ << endl;
70  } else {
71  throw cms::Exception("Incomplete configuration")
72  << "HcalTBObjectUnpacker: TDC/QADC/WC configuration file not found: " << calibFile_ << endl;
73  }
74  }
75 
76  if (doTriggerData_)
77  produces<HcalTBTriggerData>();
78  if (doRunData_)
79  produces<HcalTBRunData>();
80  if (doEventPosition_)
81  produces<HcalTBEventPosition>();
82  if (doTiming_)
83  produces<HcalTBTiming>();
84  // if (doBeamADC_) produces<HcalTBBeamCounters>();
85  if (doBeamADC_) {
86  produces<HcalTBBeamCounters>();
88  }
89  if (doSourcePos_)
90  produces<HcalSourcePositionData>();
93 }
94 
95 // Virtual destructor needed.
97 
98 // Functions that gets called by framework every event
100  // Step A: Get Inputs
102  e.getByToken(tok_raw_, rawraw);
103 
104  // Step B: Create empty output
105  auto trigd = std::make_unique<HcalTBTriggerData>();
106 
107  auto rund = std::make_unique<HcalTBRunData>();
108 
109  auto epd = std::make_unique<HcalTBEventPosition>();
110 
111  auto tmgd = std::make_unique<HcalTBTiming>();
112 
113  auto bcntd = std::make_unique<HcalTBBeamCounters>();
114 
115  auto spd = std::make_unique<HcalSourcePositionData>();
116 
117  if (triggerFed_ >= 0) {
118  // Step C: unpack all requested FEDs
119  const FEDRawData& fed = rawraw->FEDData(triggerFed_);
120  tdUnpacker_.unpack(fed, *trigd);
121  }
122 
123  if (sdFed_ >= 0) {
124  // Step C: unpack all requested FEDs
125  const FEDRawData& fed = rawraw->FEDData(sdFed_);
126  sdUnpacker_.unpack(fed, *rund, *epd);
127  }
128 
129  if (tdcFed_ >= 0) {
130  // Step C: unpack all requested FEDs
131  const FEDRawData& fed = rawraw->FEDData(tdcFed_);
132  tdcUnpacker_.unpack(fed, *epd, *tmgd);
133  }
134 
135  if (qadcFed_ >= 0) {
136  // Step C: unpack all requested FEDs
137  const FEDRawData& fed = rawraw->FEDData(qadcFed_);
138  bool is04 = true;
139  if (qadcFed_ == 8)
140  is04 = false;
141  qadcUnpacker_.unpack(fed, *bcntd, is04);
142  }
143 
144  if (spdFed_ >= 0) {
145  // Step C: unpack all requested FEDs
146  const FEDRawData& fed = rawraw->FEDData(spdFed_);
147  spdUnpacker_.unpack(fed, *spd);
148  }
149 
150  // Step D: Put outputs into event
151  if (doTriggerData_)
152  e.put(std::move(trigd));
153  if (doRunData_)
154  e.put(std::move(rund));
155  if (doEventPosition_)
156  e.put(std::move(epd));
157  if (doTiming_)
158  e.put(std::move(tmgd));
159  if (doBeamADC_)
160  e.put(std::move(bcntd));
161  if (doSourcePos_)
162  e.put(std::move(spd));
163 }
164 
166  if (calibFile_.empty()) {
167  printf("HcalTBObjectUnpacker cowardly refuses to parse a NULL file...\n");
168  return;
169  }
170 
172 
173  ifstream infile(fip.fullPath().c_str());
174 
175  char buffer[1024];
176  string tmpStr;
177 
178  while (infile.getline(buffer, 1024)) {
179  if (buffer[0] == '#')
180  continue; //ignore comment
181  if (buffer[0] == '/' && buffer[1] == '/')
182  continue; //ignore comment
183  tmpStr = string(buffer);
184  vector<string> lineVect;
185 
186  int start = 0;
187  bool empty = true;
188  for (unsigned i = 0; i <= tmpStr.size(); i++) {
189  if (tmpStr[i] == ' ' || i == tmpStr.size()) {
190  if (!empty) {
191  std::string item(tmpStr, start, i - start);
192  lineVect.push_back(item);
193  empty = true;
194  // printf("Got: %s\n",item.c_str());
195  }
196  start = i + 1;
197  } else {
198  if (empty)
199  empty = false;
200  }
201  }
202 
203  if (!lineVect.empty())
204  calibLines_.push_back(lineVect);
205  }
206 
207  infile.close();
208  return;
209 }
210 
213 
HcalTBObjectUnpacker
Definition: HcalTBObjectUnpacker.h:33
HcalTBObjectUnpacker::sdUnpacker_
hcaltb::HcalTBSlowDataUnpacker sdUnpacker_
Definition: HcalTBObjectUnpacker.h:47
Handle.h
HcalTBObjectUnpacker::tdcFed_
int tdcFed_
Definition: HcalTBObjectUnpacker.h:43
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
start
Definition: start.py:1
HcalTBObjectUnpacker::doRunData_
bool doRunData_
Definition: HcalTBObjectUnpacker.h:51
funct::false
false
Definition: Factorize.h:29
HcalTBObjectUnpacker::doEventPosition_
bool doEventPosition_
Definition: HcalTBObjectUnpacker.h:51
HcalTBTiming.h
hcaltb::HcalTBQADCUnpacker::unpack
void unpack(const FEDRawData &raw, HcalTBBeamCounters &beamadc, bool is04_=true) const
Definition: HcalTBQADCUnpacker.cc:94
HcalTBTriggerData.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalTBObjectUnpacker::sdFed_
int sdFed_
Definition: HcalTBObjectUnpacker.h:41
HcalTBObjectUnpacker::parseCalib
void parseCalib()
Definition: HcalTBObjectUnpacker.cc:165
HcalTBObjectUnpacker::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: HcalTBObjectUnpacker.cc:99
HcalTBObjectUnpacker::spdFed_
int spdFed_
Definition: HcalTBObjectUnpacker.h:42
hcaltb::HcalTBSlowDataUnpacker::unpack
void unpack(const FEDRawData &raw, HcalTBRunData &htbrd, HcalTBEventPosition &htbep) const
Definition: HcalTBSlowDataUnpacker.cc:74
HcalTBObjectUnpacker::calibLines_
std::vector< std::vector< std::string > > calibLines_
Definition: HcalTBObjectUnpacker.h:53
edm::Handle< FEDRawDataCollection >
FEDRawData
Definition: FEDRawData.h:19
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
HcalTBObjectUnpacker::tok_raw_
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
Definition: HcalTBObjectUnpacker.h:54
hcaltb::HcalTBTDCUnpacker::unpack
void unpack(const FEDRawData &raw, HcalTBEventPosition &pos, HcalTBTiming &timing) const
Definition: HcalTBTDCUnpacker.cc:73
edm::FileInPath
Definition: FileInPath.h:61
MakerMacros.h
HcalTBObjectUnpacker::triggerFed_
int triggerFed_
Definition: HcalTBObjectUnpacker.h:40
hcaltb::HcalTBQADCUnpacker::setCalib
void setCalib(const std::vector< std::vector< std::string > > &calibLines_)
Definition: HcalTBQADCUnpacker.cc:72
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalTBObjectUnpacker::qadcUnpacker_
hcaltb::HcalTBQADCUnpacker qadcUnpacker_
Definition: HcalTBObjectUnpacker.h:49
HcalTBRunData.h
hcaltb::HcalTBTDCUnpacker::setCalib
void setCalib(const std::vector< std::vector< std::string > > &calibLines_)
Definition: HcalTBTDCUnpacker.cc:35
HcalTBBeamCounters.h
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
HcalTBObjectUnpacker::doTiming_
bool doTiming_
Definition: HcalTBObjectUnpacker.h:51
edm::ParameterSet
Definition: ParameterSet.h:47
HcalTBObjectUnpacker::qadcFed_
int qadcFed_
Definition: HcalTBObjectUnpacker.h:44
HcalTBObjectUnpacker::~HcalTBObjectUnpacker
~HcalTBObjectUnpacker() override
Definition: HcalTBObjectUnpacker.cc:96
ModuleDef.h
createfilelist.int
int
Definition: createfilelist.py:10
HcalTBObjectUnpacker::doBeamADC_
bool doBeamADC_
Definition: HcalTBObjectUnpacker.h:51
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:58
HcalTBObjectUnpacker::doSourcePos_
bool doSourcePos_
Definition: HcalTBObjectUnpacker.h:51
HcalTBObjectUnpacker::tdcUnpacker_
hcaltb::HcalTBTDCUnpacker tdcUnpacker_
Definition: HcalTBObjectUnpacker.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
hcaltb::HcalTBTriggerDataUnpacker::unpack
void unpack(const FEDRawData &raw, HcalTBTriggerData &htbtd) const
Definition: HcalTBTriggerDataUnpacker.cc:56
HcalTBObjectUnpacker::HcalTBObjectUnpacker
HcalTBObjectUnpacker(const edm::ParameterSet &ps)
Definition: HcalTBObjectUnpacker.cc:14
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
HcalTBObjectUnpacker::tdUnpacker_
hcaltb::HcalTBTriggerDataUnpacker tdUnpacker_
Definition: HcalTBObjectUnpacker.h:46
Exception
Definition: hltDiff.cc:245
HcalTBObjectUnpacker::calibFile_
std::string calibFile_
Definition: HcalTBObjectUnpacker.h:45
HcalTBEventPosition.h
hcaltb::HcalTBSourcePositionDataUnpacker::unpack
void unpack(const FEDRawData &raw, HcalSourcePositionData &hspd) const
Definition: HcalTBSourcePositionDataUnpacker.cc:27
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:349
HcalTBObjectUnpacker::doTriggerData_
bool doTriggerData_
Definition: HcalTBObjectUnpacker.h:51
HcalTBObjectUnpacker.h
cms::Exception
Definition: Exception.h:70
edm::Event
Definition: Event.h:73
EDCollection.h
edm::InputTag
Definition: InputTag.h:15
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HcalTBObjectUnpacker::spdUnpacker_
hcaltb::HcalTBSourcePositionDataUnpacker spdUnpacker_
Definition: HcalTBObjectUnpacker.h:50