CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DCCEETCCBlock.cc
Go to the documentation of this file.
5 
6 
8 DCCTCCBlock(u,m,e,unpack)
9 {
10  blockLength_ = 0;
11 
12 }
13 
17 }
18 
20 
21  //point to trigger data
22  data_++;
23 
24  bool processTPG2(true) ;
25  unsigned int psInputCounter(0);
26 
27  const uint16_t * tccP_= reinterpret_cast<const uint16_t * >(data_);
28 
29 
30  int dccFOV = event_->fov();
31  if (! (dccFOV==dcc_FOV_0 || dccFOV==dcc_FOV_1 || dccFOV==dcc_FOV_2) ){
33  edm::LogWarning("IncorrectEvent")
34  <<"\n FOV value in data is: " << dccFOV <<
35  "At event: " <<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
36  <<"\n TCC id "<<tccId_<<" FOV "<< dccFOV << " which is not a foreseen value. Setting it to: " << dcc_FOV_2;
37  }
38  dccFOV=dcc_FOV_2;
39  }
40 
41 
43  // MC raw data based on CMS NOTE 2005/021
44  // (and raw data when FOV was unassigned, earlier than mid 2008)
45  if (dccFOV == dcc_FOV_0)
46  {
47 
48  // Unpack TPG1 pseudostrip input block
49  if(ps_){
50  for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
51  pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
52  if(!pPS_) continue;
53  pPS_->setSampleValue(0, *tccP_ );
54  (*pss_)->push_back(*pPS_);
55  }
56  }
57 
58  // Unpack TPG1 trigger primitive block
59  // loop over tp_counter=i and navigate forward in raw (tccP_)
60  for(unsigned int i = 1; i<= NUMB_TTS_TPG1; i++, tccP_++){//16
61 
62  if( i<= nTTs_){
63  pTP_ = mapper_->getTPPointer(tccId_,i); // pointer to tp digi container
64  if(pTP_) pTP_->setSample(0, *tccP_ ); // fill it
65  }else {
66  processTPG2 = false;
67  break;
68  }
69  // adding trigger primitive digi to the collection
70  (*tps_)->push_back(*pTP_);
71  }
72 
73 
74  if(processTPG2){
75 
76  // Unpack TPG2 pseudostrip input block
77  if(ps_){
78  for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
79  if (i<=NUMB_TTS_TPG2_DUPL) continue;
80  //fill pseudostrip container
81  pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
82  if(!pPS_) continue;
83  pPS_->setSampleValue(0, *tccP_ );
84  (*pss_)->push_back(*pPS_);
85  }
86  }
87 
88 
89  // Unpack TPG2 trigger primitive block
90  for(unsigned int i = 1; i<= NUMB_TTS_TPG2; i++, tccP_++){//12
91  unsigned int tt = i+NUMB_TTS_TPG1;
92 
93  if( tt <= nTTs_){
95  if(pTP_) pTP_->setSample(0, *tccP_ );
96  }
97  else break;
98  // adding trigger primitive digi to the collection
99  (*tps_)->push_back(*pTP_);
100  }
101 
102  }// end if(processTPG2)
103 
104  }// end FOV==0
105 
107  // real data since ever FOV was initialized; only 2 used >= June 09
108  else if (dccFOV == dcc_FOV_1 || dccFOV == dcc_FOV_2)
109  {
110 
111  // Unpack TPG1 pseudostrip input block
112  if(ps_){
113  for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
114  pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
115  if(!pPS_) continue;
116  pPS_->setSampleValue(0, *tccP_ );
117  (*pss_)->push_back(*pPS_);
118  }
119  }
120 
121  int offset(0);
122  // Unpack TPG1 trigger primitive block
123  // loop over tp_counter=i and navigate forward in raw (tccP_)
124  for(unsigned int i = 1; i<= NUMB_TTS_TPG1; i++, tccP_++){//16
125 
126  if( i<= nTTs_){
128  if(i>8 && i<=16 ) continue; // skip blank tp's [9,16]
129  if(i>8 ) offset=8; //
130  if(i>24 ) continue; // skip blank tp's [25, 28]
131  }
132 
133  pTP_ = mapper_->getTPPointer(tccId_,i-offset); // pointer to tp digi container
134  if(pTP_) pTP_->setSample(0, *tccP_ ); // fill it
135 
136  }else {
137  processTPG2 = false;
138  break;
139  }
140  // adding trigger primitive digi to the collection
141  (*tps_)->push_back(*pTP_);
142  }
143 
144  if(processTPG2){
145 
146  // Unpack TPG2 pseudostrip input block
147  if(ps_){
148  for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
149  if (i<=NUMB_TTS_TPG2_DUPL) continue;
150  //fill pseudostrip container
151  pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
152  if(!pPS_) continue;
153  pPS_->setSampleValue(0, *tccP_ );
154  (*pss_)->push_back(*pPS_);
155  }
156  }
157 
158 
159  // Unpack TPG2 trigger primitive block
160  for(unsigned int i = 1; i<= NUMB_TTS_TPG2; i++, tccP_++){//12
161  unsigned int tt = i+NUMB_TTS_TPG1;
162 
163  if( i<= nTTs_){
165  if(tt>8 && tt<=16 ) continue; // skip blank tp's [9,16]
166  if(tt>8 ) offset=8; //
167  if(tt>24 ) continue; // skip blank tp's [25, 28]
168  }
169 
170  pTP_ = mapper_->getTPPointer(tccId_,tt-offset);
171  if(pTP_) pTP_->setSample(0, *tccP_ );
172  }
173  else break;
174  // adding trigger primitive digi to the collection
175  (*tps_)->push_back(*pTP_);
176  }
177  }// end if(processTPG2)
178  }// end FOV==1 or 2
179 }
180 
181 
183 
184 
185  bool tccFound(false);
186  bool errorOnNumbOfTTs(false);
187  const int activeDCC = mapper_->getActiveSM();
188  std::vector<unsigned int> * m = mapper_->getTccs(activeDCC);
189  std::vector<unsigned int>::iterator it;
190  for(it= m->begin();it!=m->end();it++){
191  if((*it) == tccId_){
192  tccFound=true;
193 
194  /*
195  expNumbTTs_= 28; //separate from inner and outer tcc
196  For inner TCCs you expect 28 TTs (4 in phi, 7 in eta).
197  For outer TCCs you expect 16 TTs (4 in phi, 4 in eta).
198  to implement : map tccid-> number of tts
199 
200  Pascal P.: For outer board, only 16 TPs are meaningful but 28 are sent.
201  - [1,8] are meaningful
202  - [9,16] are empty ie should be skipped by unpacker
203  - [17, 24] are meaningful
204  - [25, 28] are empty ie should be skipped by unpacker
205  */
206 
207  if( nTTs_ != 28 && nTTs_ !=16 ){
209  edm::LogWarning("IncorrectBlock")
210  <<"Error on event "<<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
211  <<"\n TCC id "<<tccId_<<" has "<<nTTs_<<" Trigger Towers (only 28 or 16 are the expected values in EE)"
212  <<"\n => Skipping to next fed block...";
213  errorOnNumbOfTTs = true;
214  //todo : add to error collection
215  }
216  }
217  }
218  }
219 
220  if(!tccFound){
221 
223  edm::LogWarning("IncorrectBlock")
224  <<"Error on event "<<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
225  <<"\n TCC id "<<tccId_<<" is not valid for this dcc "
226  <<"\n => Skipping to next fed block...";
227  //todo : add to error collection
228  }
229  }
230 
231 
232  return (tccFound || errorOnNumbOfTTs);
233 
234 }
235 
236 
238 
239  const uint64_t * temp = data_;
240  temp++;
241 
242  ps_ = ( *temp>>TCC_PS_B ) & B_MASK;
243 
244  unsigned int numbTps = (NUMB_TTS_TPG1 + NUMB_TTS_TPG2);
245  if(ps_){ numbTps += 2*NUMB_PSEUDOSTRIPS;}
246 
247  unsigned int length = numbTps/4 + 2; //header and trailer
248  if(numbTps%4) length++ ;
249 
250 
251  return length;
252 
253 }
254 
255 
std::vector< unsigned int > * getTccs(unsigned int smId)
int i
Definition: DBlmapReader.cc:9
EcalPseudoStripInputDigi * pPS_
Definition: DCCTCCBlock.h:67
bool checkTccIdAndNumbTTs()
void updateCollectors()
std::auto_ptr< EcalTrigPrimDigiCollection > * tps_
Definition: DCCTCCBlock.h:68
std::auto_ptr< EcalPSInputDigiCollection > * ecalPSsCollection()
static bool silentMode_
void addTriggerPrimitivesToCollection()
unsigned int getLength()
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
std::auto_ptr< EcalPSInputDigiCollection > * pss_
Definition: DCCTCCBlock.h:69
DCCEETCCBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpacking)
Definition: DCCEETCCBlock.cc:7
unsigned int bx()
Definition: DCCEventBlock.h:55
EcalTriggerPrimitiveDigi * pTP_
Definition: DCCTCCBlock.h:66
unsigned int fov()
Definition: DCCEventBlock.h:52
unsigned int offset(bool)
EcalPseudoStripInputDigi * getPSInputDigiPointer(unsigned int tccId, unsigned int towerId, unsigned int psId)
unsigned long long uint64_t
Definition: Time.h:15
unsigned int tccId_
Definition: DCCTCCBlock.h:54
DCCDataUnpacker * unpacker_
std::auto_ptr< EcalTrigPrimDigiCollection > * ecalTpsCollection()
unsigned int nTTs_
Definition: DCCTCCBlock.h:59
EcalTriggerPrimitiveDigi * getTPPointer(unsigned int tccId, unsigned int tower)
bool isTCCExternal(unsigned int TCCId)
EcalElectronicsMapper * mapper_
void setSampleValue(int i, uint16_t value)
unsigned int ps_
Definition: DCCTCCBlock.h:63
unsigned int l1A()
Definition: DCCEventBlock.h:54