CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DCCDataMapper.cc
Go to the documentation of this file.
1 #include "DCCDataMapper.h"
2 
3 /*--------------------------------------------*/
4 /* DCCTBDataMapper::DCCTBDataMapper */
5 /* class constructor */
6 /*--------------------------------------------*/
8 : parser_(myParser){
9 
10  dccFields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
11  emptyEventFields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
12 
13  tcc68Fields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
14  tcc32Fields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
15  tcc16Fields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
16 
17  srp68Fields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
18  srp32Fields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
19  srp16Fields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
20 
21  towerFields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
22  xtalFields_ = new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
23  trailerFields_= new std::set<DCCTBDataField * , DCCTBDataFieldComparator>;
24 
26  buildTCCFields();
27  buildSRPFields();
31 }
32 
33 /*---------------------------------------------*/
34 /* DCCTBDataMapper::~DCCTBDataMapper */
35 /* class destructor (free memory) */
36 /*---------------------------------------------*/
38 
39  std::set<DCCTBDataField *,DCCTBDataFieldComparator>::iterator it;
40 
41  for(it = dccFields_->begin() ;it != dccFields_->end(); it++){ delete (*it);}
42  for(it = emptyEventFields_->begin() ;it != emptyEventFields_->end(); it++){ delete (*it);}
43 
44  for(it = tcc68Fields_->begin() ;it != tcc68Fields_->end(); it++){ delete (*it);}
45  for(it = tcc32Fields_->begin() ;it != tcc32Fields_->end(); it++){ delete (*it);}
46  for(it = tcc16Fields_->begin() ;it != tcc16Fields_->end(); it++){ delete (*it);}
47 
48  for(it = srp68Fields_->begin() ;it != srp68Fields_->end(); it++){ delete (*it);}
49  for(it = srp32Fields_->begin() ;it != srp32Fields_->end(); it++){ delete (*it);}
50  for(it = srp16Fields_->begin() ;it != srp16Fields_->end(); it++){ delete (*it);}
51 
52  for(it = towerFields_->begin() ;it != towerFields_->end(); it++){ delete (*it);}
53  for(it = xtalFields_->begin() ;it != xtalFields_->end(); it++){ delete (*it);}
54  for(it = trailerFields_->begin();it != trailerFields_->end(); it++){ delete (*it);}
55 
56  delete dccFields_;
57  delete emptyEventFields_;
58 
59  delete tcc68Fields_;
60  delete tcc32Fields_;
61  delete tcc16Fields_;
62 
63  delete srp68Fields_;
64  delete srp32Fields_;
65  delete srp16Fields_;
66 
67  delete towerFields_;
68  delete xtalFields_;
69  delete trailerFields_;
70 }
71 
72 
73 /*-------------------------------------------------*/
74 /* DCCTBDataMapper::buildDccFields */
75 /* builds raw data header fields */
76 /*-------------------------------------------------*/
78 
79  //32 Bit word numb 0
82 
85 
88 
91 
92  //32Bit word numb 1
95 
98 
101 
102  //32Bit word numb 2
105 
108 
109  //32Bit word numb 3
112 
113  //32 Bit word numb 4
116 
117  //32Bit word numb 5
120 
121  //32 Bit word numb 6
123 
124  //32 Bit word numb 7
128 
134 
135 
136  //add Headers Qualifiers: 8 words with 6 bits each written on the 2nd 32bit words
137  for(uint32_t i=1;i<=8;i++){
138  std::string header = std::string("H") + parser_->getDecString(i);
139  dccFields_->insert( new DCCTBDataField(header,HD_WPOSITION + (i-1)*2 ,HD_BPOSITION,HD_MASK));
140 
141  //fill only for empty events
142  if(i<3){ emptyEventFields_->insert( new DCCTBDataField(header,HD_WPOSITION + (i-1)*2 ,HD_BPOSITION,HD_MASK)); }
143  }
144 
145 
146  //add FE_CHSTATUS: 5 words each having 14 FE_CHSTATUS
147  for(uint32_t wcount = 1; wcount<=5; wcount++){
148 
149  //1st word 32 bit
150  for(uint32_t i=1;i<=8;i++){
151  std::string chStatus = std::string("FE_CHSTATUS#") + parser_->getDecString( (wcount-1)*14 + i );
152  dccFields_->insert( new DCCTBDataField(chStatus, FE_CHSTATUS_WPOSITION +(wcount-1)*2, 4*(i-1),FE_CHSTATUS_MASK));
153  }
154 
155  //2nd word 32 bit
156  for(uint32_t i=9;i<=14;i++){
157  std::string chStatus = std::string("FE_CHSTATUS#") + parser_->getDecString((wcount-1)*14 + i);
158  dccFields_->insert( new DCCTBDataField(chStatus, FE_CHSTATUS_WPOSITION + (wcount-1)*2 + 1,4*(i-9),FE_CHSTATUS_MASK));
159  }
160 
161  }
162 
163 }
164 
165 /*-------------------------------------------------*/
166 /* DCCTBDataMapper::buildTCCFields */
167 /* builds raw data TCC block fields */
168 /*-------------------------------------------------*/
170 
171  std::vector<std::set<DCCTBDataField *, DCCTBDataFieldComparator> *> pVector;
172  pVector.push_back(tcc16Fields_);
173  pVector.push_back(tcc32Fields_);
174  pVector.push_back(tcc68Fields_);
175 
176  for(int i=0; i< ((int)(pVector.size())) ;i++){
177  (pVector[i])->insert( new DCCTBDataField("TCC ID",TCCID_WPOSITION ,TCCID_BPOSITION,TCCID_MASK));
181  (pVector[i])->insert( new DCCTBDataField("E1", TCCE1_WPOSITION, TCCE1_BPOSITION, TCCE1_MASK));
182  (pVector[i])->insert( new DCCTBDataField("#TT", NTT_WPOSITION, NTT_BPOSITION, NTT_MASK));
183  (pVector[i])->insert( new DCCTBDataField("#TIME SAMPLES",TCCTSAMP_WPOSITION, TCCTSAMP_BPOSITION,TCCTSAMP_MASK));
186  }
187 
188  uint32_t nTSamples = parser_->numbTriggerSamples();
189 
190  uint32_t totalTT = 68*nTSamples;
191 
192  uint32_t filter1 = 16*nTSamples;
193  uint32_t filter2 = 32*nTSamples;
194 
195  uint32_t count(2) ;
196 
197  // Fill block with TT definition
198  for(uint32_t tt=1; tt<=totalTT; tt++){
199  std::string tpg = std::string("TPG#") + parser_->getDecString(tt);
200  std::string ttFlag = std::string("TTF#") + parser_->getDecString(tt);
201 
202  if(tt<=filter1){
203  tcc16Fields_->insert( new DCCTBDataField(tpg, TPG_WPOSITION -1 + count/2, TPG_BPOSITION + 16*( (count+2)%2 ),TPG_MASK));
204  tcc16Fields_->insert( new DCCTBDataField(ttFlag, TTF_WPOSITION -1 + count/2, TTF_BPOSITION + 16*( (count+2)%2 ),TTF_MASK));
205  }
206  if(tt<=filter2){
207  tcc32Fields_->insert( new DCCTBDataField(tpg, TPG_WPOSITION -1 + count/2, TPG_BPOSITION + 16*( (count+2)%2 ),TPG_MASK));
208  tcc32Fields_->insert( new DCCTBDataField(ttFlag, TTF_WPOSITION -1 + count/2, TTF_BPOSITION + 16*( (count+2)%2 ),TTF_MASK));
209  }
210 
211  tcc68Fields_->insert( new DCCTBDataField(tpg, TPG_WPOSITION -1 + count/2, TPG_BPOSITION + 16*( (count+2)%2 ),TPG_MASK));
212  tcc68Fields_->insert( new DCCTBDataField(ttFlag, TTF_WPOSITION -1 + count/2, TTF_BPOSITION + 16*( (count+2)%2 ),TTF_MASK));
213  count++;
214  }
215 
216 }
217 
218 // ---> update with the correct number of SRP fields
220  std::vector<std::set<DCCTBDataField *, DCCTBDataFieldComparator> * > pVector;
221  pVector.push_back(srp68Fields_);
222  pVector.push_back(srp32Fields_);
223  pVector.push_back(srp16Fields_);
224 
225  for(int i=0; i< ((int)(pVector.size())) ;i++){
226  // This method must be modified to take into account the different SRP blocks : 68 SRF in the barrel, 34 ,35 or 36 in the EE
227  (pVector[i])->insert( new DCCTBDataField("SRP ID",SRPID_WPOSITION ,SRPID_BPOSITION,SRPID_MASK));
230 
232  (pVector[i])->insert( new DCCTBDataField("E1", SRPE1_WPOSITION, SRPE1_BPOSITION, SRPE1_MASK));
233  (pVector[i])->insert( new DCCTBDataField("#SR FLAGS",NSRF_WPOSITION, NSRF_BPOSITION,NSRF_MASK));
236  }
237 
238  uint32_t srpFlags(68);
239 
240  uint32_t count1(1), count2(1), srSize(3), factor(0), wcount(0);
241  for(uint32_t nsr =1; nsr<=srpFlags; nsr++){
242 
243  std::string sr = std::string("SR#") + parser_->getDecString(nsr);
244 
245  srp68Fields_->insert( new DCCTBDataField(sr,SRF_WPOSITION + wcount, SRF_BPOSITION + SRPBOFFSET*factor + (count2-1)*srSize,SRF_MASK));
246  if( nsr<=32 ){ srp32Fields_->insert( new DCCTBDataField(sr,SRF_WPOSITION + wcount, SRF_BPOSITION + SRPBOFFSET*factor + (count2-1)*srSize,SRF_MASK));}
247  if( nsr<=16 ){ srp16Fields_->insert( new DCCTBDataField(sr,SRF_WPOSITION + wcount, SRF_BPOSITION + SRPBOFFSET*factor + (count2-1)*srSize,SRF_MASK));}
248 
249  count1++; count2++;
250 
251  //update word count
252  if( count1 > 8){ wcount++; count1=1;}
253 
254  //update bit offset
255  if(count1 > 4){ factor = 1;}
256  else{factor = 0;}
257 
258  //update bit shift
259  if( count2 > 4){ count2 = 1;}
260 
261  }
262 }
263 
264 
265 /*-------------------------------------------------*/
266 /* DCCTBDataMapper::buildTowerFields */
267 /* builds raw data Tower Data fields */
268 /*-------------------------------------------------*/
270  //32bit word numb 1
272  towerFields_->insert( new DCCTBDataField("#TIME SAMPLES",XSAMP_WPOSITION ,XSAMP_BPOSITION,XSAMP_MASK));
275 
276  //32 bit word numb 2
280 }
281 
282 
283 /*-------------------------------------------------*/
284 /* DCCTBDataMapper::buildXtalFields */
285 /* builds raw data Crystal Data fields */
286 /*-------------------------------------------------*/
288 
289  //32bit word numb 1
295 
296  //first ADC is still on 1st word
298 
299  //add the rest of the ADCs
300  for(uint32_t i=2; i <= parser_->numbXtalSamples();i++){
302  if(i%2){ xtalFields_->insert(new DCCTBDataField(adc,ADC_WPOSITION + i/2, ADCBOFFSET,ADC_MASK)); }
303  else { xtalFields_->insert(new DCCTBDataField(adc,ADC_WPOSITION + i/2, 0,ADC_MASK)); }
304  }
305 
306  //the last word has written the test zero suppression flag and the gain decision bit
307  uint32_t tzsOffset_ = parser_->numbXtalSamples()/2;
310 }
311 
312 
313 /*-------------------------------------------------*/
314 /* DCCTBDataMapper::buildTrailerFields */
315 /* builds raw data Trailer words */
316 /*-------------------------------------------------*/
318  //32bit word numb 1
323 
324  //32bit word numb 2
327 
328 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * dccFields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * srp32Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc68Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * trailerFields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc16Fields_
std::string getDecString(uint32_t data)
DCCTBDataMapper(DCCTBDataParser *myParser)
Definition: DCCDataMapper.cc:7
uint32_t numbTriggerSamples()
uint32_t numbXtalSamples()
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * srp16Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * tcc32Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * emptyEventFields_
void buildTrailerFields()
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * xtalFields_
DCCTBDataParser * parser_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * srp68Fields_
std::set< DCCTBDataField *, DCCTBDataFieldComparator > * towerFields_