test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalFiberPattern.cc
Go to the documentation of this file.
3 
4 static inline int setIf(const std::string& name,const std::map<std::string, std::string>& params) {
5  std::map<std::string, std::string>::const_iterator j=params.find(name);
6  if (j==params.end()) throw cms::Exception("InvalidFormat") << "Missing parameter '" << name << "'";
7  else return strtol(j->second.c_str(),0,0);
8 }
9 
10 HcalFiberPattern::HcalFiberPattern(const std::map<std::string, std::string>& params, const std::vector<uint32_t>& data) : pattern_(data) {
11  crate_=setIf("CRATE",params);
12  slot_=setIf("SLOT",params);
13  fiber_=setIf("FIBER",params);
14  dcc_=setIf("DCC",params);
15  spigot_=setIf("SPIGOT",params);
16  tb_=setIf("TOPBOTTOM",params);
17 }
18 
20  uint32_t w1=pattern_[bc*2]; // lsw
21  uint32_t w2=pattern_[bc*2+1]; // msw
22 
23  int adc=0, capid=0;
24  bool dv=(w1&0x10000)!=0;
25  bool er=(w1&0x20000)!=0;
26 
27  switch (fc) {
28  case (0):
29  adc=(w2&0xFE00)>>9;
30  capid=(w1&0x0180)>>7;
31  break;
32  case (1):
33  adc=(w2&0xFE)>>1;
34  capid=(w1&0x0060)>>5;
35  break;
36  case (2):
37  adc=(w1&0xFE00)>>9;
38  capid=(w1&0x0018)>>3;
39  break;
40  default:
41  break;
42  }
43  return HcalQIESample(adc,capid,fiber_,fc,dv,er);
44 }
45 
46 std::vector<HcalQIESample> HcalFiberPattern::getSamples(int bunch, int npresamples, int nsamples, int fiberChan) {
47  if (bunch<npresamples) throw cms::Exception("InvalidArgument") << "Asked for " << npresamples << " presamples with event at bunch " << bunch;
48  if (nsamples-npresamples+bunch>=(int)(pattern_.size()/2)) throw cms::Exception("InvalidArgument") << "Asked for " << nsamples << " with event at " << bunch << " and " << npresamples << " presamples, but only " << pattern_.size()/2 << " bunches are available";
49 
50  std::vector<HcalQIESample> retval;
51  retval.reserve(nsamples);
52 
53  for (int i=0; i<nsamples; i++) {
54  int bc=bunch+i-npresamples;
55  retval.push_back(unpack(bc,fiberChan));
56  }
57  return retval;
58 }
59 
61  HcalElectronicsId retval(fiberChan,fiber_,spigot_,dcc_);
62  retval.setHTR(crate_,slot_,tb_);
63  return retval;
64 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
HcalFiberPattern(const std::map< std::string, std::string > &params, const std::vector< uint32_t > &data)
int j
Definition: DBlmapReader.cc:9
void setHTR(int crate, int slot, int tb)
HcalElectronicsId getId(int fiberChan)
std::vector< uint32_t > pattern_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< HcalQIESample > getSamples(int bunch, int npresamples, int nsamples, int fiberChan)
HcalQIESample unpack(int bc, int fc)
static int setIf(const std::string &name, const std::map< std::string, std::string > &params)
Readout chain identification for Hcal.