CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
hcaltb::HcalTBTDCUnpacker Class Reference

#include <HcalTBTDCUnpacker.h>

Classes

struct  Hit
 
struct  WireChamberRecoData
 

Public Member Functions

 HcalTBTDCUnpacker (bool)
 
void setCalib (const std::vector< std::vector< std::string > > &calibLines_)
 
void unpack (const FEDRawData &raw, HcalTBEventPosition &pos, HcalTBTiming &timing) const
 

Private Member Functions

void reconstructTiming (const std::vector< Hit > &hits, HcalTBTiming &timing) const
 
void reconstructWC (const std::vector< Hit > &hits, HcalTBEventPosition &pos) const
 
void unpackHits (const FEDRawData &raw, std::vector< Hit > &hits, HcalTBTiming &timing) const
 

Private Attributes

FILE * dumpObs_
 
bool includeUnmatchedHits_
 
double tdc_convers [161]
 
double tdc_ped [161]
 
struct
hcaltb::HcalTBTDCUnpacker::WireChamberRecoData 
wc_ [PLANECOUNT]
 

Static Private Attributes

static const int PLANECOUNT = 16
 
static const int WC_CHANNELIDS [PLANECOUNT *3]
 

Detailed Description

Author
J. Mans, P. Dudero - Minnesota

Definition at line 12 of file HcalTBTDCUnpacker.h.

Constructor & Destructor Documentation

hcaltb::HcalTBTDCUnpacker::HcalTBTDCUnpacker ( bool  include_unmatched_hits)

Definition at line 30 of file HcalTBTDCUnpacker.cc.

30  :
31  includeUnmatchedHits_(include_unmatched_hits),
32  dumpObs_(0) {
33 // setupWC(); reads it from configuration file
34 // dumpObs_=fopen("dump_obs.csv","w");
35 }

Member Function Documentation

void hcaltb::HcalTBTDCUnpacker::reconstructTiming ( const std::vector< Hit > &  hits,
HcalTBTiming timing 
) const
private

Definition at line 170 of file HcalTBTDCUnpacker.cc.

References j, lcBeamCoincidence, lcBeamHalo1, lcBeamHalo2, lcBeamHalo3, lcBeamHalo4, lcLaserFlash, lcMuon1, lcMuon2, lcMuon3, lcQIEPhase, lcScint1, lcScint2, lcScint3, lcScint4, lcTOF1J, lcTOF1S, lcTOF2J, lcTOF2S, lcTriggerTime, lcTTCL1ATime, HcalTBTiming::setHits(), HcalTBTiming::setTimes(), and tdc_ped.

Referenced by unpack().

171  {
172  std::vector<Hit>::const_iterator j;
173  double trigger_time=0;
174  double ttc_l1a_time=0;
175  double laser_flash=0;
176  double qie_phase=0;
177  double TOF1S_time=0;
178  double TOF1J_time=0;
179  double TOF2S_time=0;
180  double TOF2J_time=0;
181 
182  std::vector<double> m1hits, m2hits, m3hits, s1hits, s2hits, s3hits, s4hits,
183  bh1hits, bh2hits, bh3hits, bh4hits,beam_coinc;
184 
185  for (j=hits.begin(); j!=hits.end(); j++) {
186  switch (j->channel) {
187  case lcTriggerTime: trigger_time = j->time-tdc_ped[lcTriggerTime]; break;
188  case lcTTCL1ATime: ttc_l1a_time = j->time-tdc_ped[lcTTCL1ATime]; break;
189  case lcBeamCoincidence: beam_coinc.push_back(j->time-tdc_ped[lcBeamCoincidence]); break;
190  case lcLaserFlash: laser_flash = j->time-tdc_ped[lcLaserFlash]; break;
191  case lcQIEPhase: qie_phase = j->time-tdc_ped[lcQIEPhase]; break;
192  case lcMuon1: m1hits.push_back(j->time-tdc_ped[lcMuon1]); break;
193  case lcMuon2: m2hits.push_back(j->time-tdc_ped[lcMuon2]); break;
194  case lcMuon3: m3hits.push_back(j->time-tdc_ped[lcMuon3]); break;
195  case lcScint1: s1hits.push_back(j->time-tdc_ped[lcScint1]); break;
196  case lcScint2: s2hits.push_back(j->time-tdc_ped[lcScint2]); break;
197  case lcScint3: s3hits.push_back(j->time-tdc_ped[lcScint3]); break;
198  case lcScint4: s4hits.push_back(j->time-tdc_ped[lcScint4]); break;
199  case lcTOF1S: TOF1S_time = j->time-tdc_ped[lcTOF1S]; break;
200  case lcTOF1J: TOF1J_time = j->time-tdc_ped[lcTOF1J]; break;
201  case lcTOF2S: TOF2S_time = j->time-tdc_ped[lcTOF2S]; break;
202  case lcTOF2J: TOF2J_time = j->time-tdc_ped[lcTOF2J]; break;
203  case lcBeamHalo1: bh1hits.push_back(j->time-tdc_ped[lcBeamHalo1]); break;
204  case lcBeamHalo2: bh2hits.push_back(j->time-tdc_ped[lcBeamHalo2]); break;
205  case lcBeamHalo3: bh3hits.push_back(j->time-tdc_ped[lcBeamHalo3]); break;
206  case lcBeamHalo4: bh4hits.push_back(j->time-tdc_ped[lcBeamHalo4]); break;
207  default: break;
208  }
209  }
210 
211  timing.setTimes(trigger_time,ttc_l1a_time,laser_flash,qie_phase,TOF1S_time,TOF1J_time,TOF2S_time,TOF2J_time);
212  timing.setHits (m1hits,m2hits,m3hits,s1hits,s2hits,s3hits,s4hits,bh1hits,bh2hits,bh3hits,bh4hits,beam_coinc);
213 
214 }
static const int lcBeamCoincidence
static const int lcTOF2S
static const int lcBeamHalo4
static const int lcTOF1S
static const int lcTTCL1ATime
static const int lcScint4
static const int lcScint3
static const int lcBeamHalo2
static const int lcLaserFlash
static const int lcScint1
int j
Definition: DBlmapReader.cc:9
static const int lcMuon3
static const int lcBeamHalo1
static const int lcTriggerTime
static const int lcTOF1J
static const int lcQIEPhase
static const int lcBeamHalo3
void setTimes(const double trigger_time, const double ttc_l1a_time, const double laser_flash, const double qie_phase, const double TOF1S_time, const double TOF1J_time, const double TOF2S_time, const double TOF2J_time)
Definition: HcalTBTiming.cc:29
static const int lcMuon1
void setHits(const std::vector< double > &m1hits, const std::vector< double > &m2hits, const std::vector< double > &m3hits, const std::vector< double > &s1hits, const std::vector< double > &s2hits, const std::vector< double > &s3hits, const std::vector< double > &s4hits, const std::vector< double > &bh1hits, const std::vector< double > &bh2hits, const std::vector< double > &bh3hits, const std::vector< double > &bh4hits, const std::vector< double > &beamCoincidenceHits)
Definition: HcalTBTiming.cc:47
static const int lcMuon2
static const int lcTOF2J
static const int lcScint2
void hcaltb::HcalTBTDCUnpacker::reconstructWC ( const std::vector< Hit > &  hits,
HcalTBEventPosition pos 
) const
private

Definition at line 270 of file HcalTBTDCUnpacker.cc.

References hcaltb::HcalTBTDCUnpacker::WireChamberRecoData::b0, hcaltb::HcalTBTDCUnpacker::WireChamberRecoData::b1, dumpObs_, cuy::ii, includeUnmatchedHits_, j, findQualityFiles::jj, timingPdfMaker::mean, hcaltb::N_SIGMA, PLANECOUNT, HcalTBEventPosition::setChamberHits(), hcaltb::TDC_OFFSET_CONSTANT, wc_, WC_CHANNELIDS, and x.

Referenced by unpack().

270  {
271  // process all planes, looping over all hits...
272  const int MAX_HITS=100;
273  float hits1[MAX_HITS], hits2[MAX_HITS], hitsA[MAX_HITS];
274  int n1,n2,nA,chan1,chan2,chanA;
275 
276  std::vector<double> x;
277 
278  for (int plane=0; plane<PLANECOUNT; plane++) {
279  n1=0; n2=0; nA=0;
280 
281  std::vector<double> plane_hits;
282  double hit_time;
283  hits1[0]=-1000;
284  hits2[0]=-1000;
285  hitsA[0]=-1000;
286  hitsA[1]=-1000;
287 
288  chan1=WC_CHANNELIDS[plane*3];
289  chan2=WC_CHANNELIDS[plane*3+1];
290  chanA=WC_CHANNELIDS[plane*3+2];
291 
292  for (std::vector<Hit>::const_iterator j=hits.begin(); j!=hits.end(); j++) {
293  if (j->channel==chan1 && n1<MAX_HITS) {
294  hits1[n1]=j->time-TDC_OFFSET_CONSTANT; n1++;
295  }
296  if (j->channel==chan2 && n2<MAX_HITS) {
297  hits2[n2]=j->time-TDC_OFFSET_CONSTANT; n2++;
298  }
299  if (j->channel==chanA && nA<MAX_HITS) {
300  hitsA[nA]=j->time-TDC_OFFSET_CONSTANT; nA++;
301  }
302  }
303 
304  if (n1!=0 && n2!=0 && dumpObs_!=0) {
305  fprintf(dumpObs_,"%d,%f,%f,%f,%f\n",plane,hits1[0],hits2[0],hitsA[0],hitsA[1]);
306  fflush(dumpObs_);
307  }
308 
309  // anode-matched hits
310  for (int ii=0; ii<n1; ii++) {
311  int jmin=-1, lmin=-1;
312  float dsumMin=99999;
313  for (int jj=0; jj<n2; jj++) {
314  for (int ll=0; ll<nA; ll++) {
315  float dsum=fabs(wc_[plane].mean - hits1[ii] - hits2[jj] + 2.0*hitsA[ll]);
316  if(dsum<(N_SIGMA*wc_[plane].sigma) && dsum<dsumMin){
317  jmin=jj;
318  lmin=ll;
319  dsumMin=dsum;
320  }
321  }
322  }
323  if (jmin>=0) {
324  hit_time = wc_[plane].b0 +
325  wc_[plane].b1 * (hits1[ii]-hits2[jmin]);
326  if((plane%2)==0)
327  {
328  plane_hits.push_back(-hit_time);
329  }else{
330  plane_hits.push_back(hit_time);
331  }
332  hits1[ii]=-99999;
333  hits2[jmin]=-99999;
334  hitsA[lmin]=99999;
335  }
336  }
337 
338  if (includeUnmatchedHits_||plane>9) // unmatched hits (all pairs get in here)
339  for (int ii=0; ii<n1; ii++) {
340  if (hits1[ii]<-99990) continue;
341  for (int jj=0; jj<n2; jj++) {
342  if (hits2[jj]<-99990) continue;
343  hit_time = wc_[plane].b0 +
344  wc_[plane].b1 * (hits1[ii]-hits2[jj]);
345  if((plane%2)==0)
346  {
347  plane_hits.push_back(-hit_time);
348  }else{
349  plane_hits.push_back(hit_time);
350  }
351  }
352  }
353 
354  if ((plane%2)==0) x=plane_hits;
355  else {
356  char chamber='A'+plane/2;
357  ep.setChamberHits(chamber,x,plane_hits);
358  }
359  }
360 
361 }
int ii
Definition: cuy.py:588
int j
Definition: DBlmapReader.cc:9
static const double N_SIGMA
static const double TDC_OFFSET_CONSTANT
Definition: DDAxes.h:10
static const int WC_CHANNELIDS[PLANECOUNT *3]
struct hcaltb::HcalTBTDCUnpacker::WireChamberRecoData wc_[PLANECOUNT]
void hcaltb::HcalTBTDCUnpacker::setCalib ( const std::vector< std::vector< std::string > > &  calibLines_)

Definition at line 36 of file HcalTBTDCUnpacker.cc.

References hcaltb::HcalTBTDCUnpacker::WireChamberRecoData::b0, hcaltb::HcalTBTDCUnpacker::WireChamberRecoData::b1, edm::hlt::Exception, i, cuy::ii, hcaltb::HcalTBTDCUnpacker::WireChamberRecoData::mean, hcaltb::HcalTBTDCUnpacker::WireChamberRecoData::sigma, findQualityFiles::size, tdc_convers, tdc_ped, and wc_.

Referenced by HcalTBObjectUnpacker::HcalTBObjectUnpacker().

36  {
37  for(int i=0;i<161;i++)
38  {
39  tdc_ped[i]=0.;tdc_convers[i]=1.;
40  }
41  for(unsigned int ii=0;ii<calibLines_.size();ii++)
42  {
43 // TDC configuration
44  if(calibLines_[ii][0]=="TDC")
45  {
46  if(calibLines_[ii].size()==4)
47  {
48  int channel=atoi(calibLines_[ii][1].c_str());
49  tdc_ped[channel]=atof(calibLines_[ii][2].c_str());
50  tdc_convers[channel]=atof(calibLines_[ii][3].c_str());
51  // printf("Got TDC %i ped %f , conversion %f\n",channel, tdc_ped[channel],tdc_convers[channel]);
52  }
53  else
54  {
55  throw cms::Exception("Incomplete configuration") <<
56  "Wrong TDC configuration format : expected 3 parameters, got "<<calibLines_[ii].size()-1;
57  }
58  } // End of the TDCs
59 
60 // Wire chambers calibration
61  if(calibLines_[ii][0]=="WC")
62  {
63  if(calibLines_[ii].size()==6)
64  {
65  int plane=atoi(calibLines_[ii][1].c_str());
66  wc_[plane].b0=atof(calibLines_[ii][2].c_str());
67  wc_[plane].b1=atof(calibLines_[ii][3].c_str());
68  wc_[plane].mean=atof(calibLines_[ii][4].c_str());
69  wc_[plane].sigma=atof(calibLines_[ii][5].c_str());
70  // printf("Got WC plane %i b0 %f, b1 %f, mean %f, sigma %f\n",plane,
71  // wc_[plane].b0,wc_[plane].b1,wc_[plane].mean,wc_[plane].sigma);
72  }
73  else
74  {
75  throw cms::Exception("Incomplete configuration") <<
76  "Wrong Wire Chamber configuration format : expected 5 parameters, got "<<calibLines_[ii].size()-1;
77  }
78  } // End of the Wire Chambers
79 
80  } // End of the CalibLines
81  }
int i
Definition: DBlmapReader.cc:9
int ii
Definition: cuy.py:588
tuple size
Write out results.
struct hcaltb::HcalTBTDCUnpacker::WireChamberRecoData wc_[PLANECOUNT]
void hcaltb::HcalTBTDCUnpacker::unpack ( const FEDRawData raw,
HcalTBEventPosition pos,
HcalTBTiming timing 
) const

Definition at line 83 of file HcalTBTDCUnpacker.cc.

References reconstructTiming(), reconstructWC(), and unpackHits().

Referenced by HcalTBObjectUnpacker::produce().

85  {
86  std::vector<Hit> hits;
87 
88  unpackHits(raw, hits, timing);
89 
90  reconstructWC(hits, pos);
91  reconstructTiming(hits, timing);
92 
93  }
void reconstructTiming(const std::vector< Hit > &hits, HcalTBTiming &timing) const
void unpackHits(const FEDRawData &raw, std::vector< Hit > &hits, HcalTBTiming &timing) const
void reconstructWC(const std::vector< Hit > &hits, HcalTBEventPosition &pos) const
void hcaltb::HcalTBTDCUnpacker::unpackHits ( const FEDRawData raw,
std::vector< Hit > &  hits,
HcalTBTiming timing 
) const
private

Definition at line 111 of file HcalTBTDCUnpacker.cc.

References hcaltb::HcalTBTDCUnpacker::Hit::channel, FEDRawData::data(), edm::hlt::Exception, h, hcaltb::ClassicTDCDataFormat::hits, i, hcaltb::ClassicTDCDataFormat::n_hits, hcaltb::ClassicTDCDataFormat::n_max_hits, hcaltb::CombinedTDCQDCDataFormat::n_qdc_hits, hcaltb::CombinedTDCQDCDataFormat::n_tdc_hits, HcalTBTiming::setV775(), FEDRawData::size(), tdc_convers, and hcaltb::HcalTBTDCUnpacker::Hit::time.

Referenced by unpack().

112  {
113  const ClassicTDCDataFormat* tdc=(const ClassicTDCDataFormat*)raw.data();
114 
115  if (raw.size()<3*8) {
116  throw cms::Exception("Missing Data") << "No data in the TDC block";
117  }
118 
119  const unsigned int* hitbase=0;
120  unsigned int totalhits=0;
121 
122  // old TDC (767)
123  if (tdc->n_max_hits!=192) {
124  const CombinedTDCQDCDataFormat* qdctdc=(const CombinedTDCQDCDataFormat*)raw.data();
125  hitbase=(const unsigned int*)(qdctdc);
126  hitbase+=6; // header
127  hitbase+=qdctdc->n_qdc_hits/2; // two unsigned short per unsigned long
128  totalhits=qdctdc->n_tdc_hits&0xFFFF; // mask off high bits
129 
130  // for (unsigned int i=0; i<qdctdc->n_qdc_hits; i++)
131  // printf("QADC: %02d %d\n",i,qdctdc->qdc_values[i]&0xFFF);
132 
133  } else {
134  hitbase=&(tdc->hits[0]);
135  totalhits=tdc->n_hits;
136  }
137 
138  for (unsigned int i=0; i<totalhits; i++) {
139  Hit h;
140  h.channel=(hitbase[i]&0x7FC00000)>>22; // hardcode channel assignment
141  h.time=(hitbase[i]&0xFFFFF)*tdc_convers[h.channel];
142  hits.push_back(h);
143  // printf("V767: %d %f\n",h.channel,h.time);
144  }
145 
146  // new TDC (V775)
147  int v775[32];
148  for (int i=0;i<32;i++) v775[i]=-1;
149  if (tdc->n_max_hits!=192) {
150  const CombinedTDCQDCDataFormat* qdctdc=(const CombinedTDCQDCDataFormat*)raw.data();
151  hitbase=(const unsigned int*)(qdctdc);
152  hitbase+=6; // header
153  hitbase+=qdctdc->n_qdc_hits/2; // two unsigned short per unsigned long
154  hitbase+=(qdctdc->n_tdc_hits&0xFFFF); // same length
155  totalhits=(qdctdc->n_tdc_hits&0xFFFF0000)>>16; // mask off high bits
156  for (unsigned int i=0; i<totalhits; i++) {
157  Hit h;
158 // h.channel=129+i;
159  h.channel=129+((hitbase[i]&0x3F0000)>>16);
160  h.time=(hitbase[i]&0xFFF)*tdc_convers[h.channel] ;
161  hits.push_back(h);
162  if ( (h.channel-129)<32 )
163  v775[(h.channel-129)] = (hitbase[i]&0xFFF);
164  // printf("V775: %d %f\n",h.channel,h.time);
165  }
166  }
167  timing.setV775(v775);
168 }
int i
Definition: DBlmapReader.cc:9
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void setV775(int *V775)
Definition: HcalTBTiming.cc:75
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28

Member Data Documentation

FILE* hcaltb::HcalTBTDCUnpacker::dumpObs_
private

Definition at line 41 of file HcalTBTDCUnpacker.h.

Referenced by reconstructWC().

bool hcaltb::HcalTBTDCUnpacker::includeUnmatchedHits_
private

Definition at line 38 of file HcalTBTDCUnpacker.h.

Referenced by reconstructWC().

const int hcaltb::HcalTBTDCUnpacker::PLANECOUNT = 16
staticprivate

Definition at line 32 of file HcalTBTDCUnpacker.h.

Referenced by reconstructWC().

double hcaltb::HcalTBTDCUnpacker::tdc_convers[161]
private

Definition at line 40 of file HcalTBTDCUnpacker.h.

Referenced by setCalib(), and unpackHits().

double hcaltb::HcalTBTDCUnpacker::tdc_ped[161]
private

Definition at line 39 of file HcalTBTDCUnpacker.h.

Referenced by reconstructTiming(), and setCalib().

struct hcaltb::HcalTBTDCUnpacker::WireChamberRecoData hcaltb::HcalTBTDCUnpacker::wc_[PLANECOUNT]
private

Referenced by reconstructWC(), and setCalib().

const int hcaltb::HcalTBTDCUnpacker::WC_CHANNELIDS
staticprivate
Initial value:
= {
12, 13, 14,
10, 11, 14,
22, 23, 24,
20, 21, 24,
32, 33, 34,
30, 31, 34,
101, 102, 104,
107, 108, 110,
113, 114, 116,
97, 98, 99,
42, 43, -1,
44, 60, -1,
40, 41, -1,
45, 61, -1,
52, 53, -1,
54, 62, -1
}

Definition at line 33 of file HcalTBTDCUnpacker.h.

Referenced by reconstructWC().