CMS 3D CMS Logo

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  if (pTP_) (*tps_)->push_back(*pTP_);
71  else edm::LogError("IncorrectBlock")<<"trigger primitive digi was not aquired";
72  }
73 
74 
75  if(processTPG2){
76 
77  // Unpack TPG2 pseudostrip input block
78  if(ps_){
79  for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
80  if (i<=NUMB_TTS_TPG2_DUPL) continue;
81  //fill pseudostrip container
82  pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
83  if(!pPS_) continue;
84  pPS_->setSampleValue(0, *tccP_ );
85  (*pss_)->push_back(*pPS_);
86  }
87  }
88 
89 
90  // Unpack TPG2 trigger primitive block
91  for(unsigned int i = 1; i<= NUMB_TTS_TPG2; i++, tccP_++){//12
92  unsigned int tt = i+NUMB_TTS_TPG1;
93 
94  if( tt <= nTTs_){
96  if(pTP_) pTP_->setSample(0, *tccP_ );
97  }
98  else break;
99  // adding trigger primitive digi to the collection
100  (*tps_)->push_back(*pTP_);
101  }
102 
103  }// end if(processTPG2)
104 
105  }// end FOV==0
106 
108  // real data since ever FOV was initialized; only 2 used >= June 09
109  else if (dccFOV == dcc_FOV_1 || dccFOV == dcc_FOV_2)
110  {
111 
112  // Unpack TPG1 pseudostrip input block
113  if(ps_){
114  for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
115  pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
116  if(!pPS_) continue;
117  pPS_->setSampleValue(0, *tccP_ );
118  (*pss_)->push_back(*pPS_);
119  }
120  }
121 
122  int offset(0);
123  // Unpack TPG1 trigger primitive block
124  // loop over tp_counter=i and navigate forward in raw (tccP_)
125  for(unsigned int i = 1; i<= NUMB_TTS_TPG1; i++, tccP_++){//16
126 
127  if( i<= nTTs_){
129  if(i>8 && i<=16 ) continue; // skip blank tp's [9,16]
130  if(i>8 ) offset=8; //
131  if(i>24 ) continue; // skip blank tp's [25, 28]
132  }
133 
134  pTP_ = mapper_->getTPPointer(tccId_,i-offset); // pointer to tp digi container
135  if(pTP_) pTP_->setSample(0, *tccP_ ); // fill it
136 
137  }else {
138  processTPG2 = false;
139  break;
140  }
141  // adding trigger primitive digi to the collection
142  if (pTP_) (*tps_)->push_back(*pTP_);
143  else edm::LogError("IncorrectBlock")<<"trigger primitive digi was not aquired";
144  }
145 
146  if(processTPG2){
147 
148  // Unpack TPG2 pseudostrip input block
149  if(ps_){
150  for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
151  if (i<=NUMB_TTS_TPG2_DUPL) continue;
152  //fill pseudostrip container
153  pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
154  if(!pPS_) continue;
155  pPS_->setSampleValue(0, *tccP_ );
156  (*pss_)->push_back(*pPS_);
157  }
158  }
159 
160 
161  // Unpack TPG2 trigger primitive block
162  for(unsigned int i = 1; i<= NUMB_TTS_TPG2; i++, tccP_++){//12
163  unsigned int tt = i+NUMB_TTS_TPG1;
164 
165  if( i<= nTTs_){
167  if(tt>8 && tt<=16 ) continue; // skip blank tp's [9,16]
168  if(tt>8 ) offset=8; //
169  if(tt>24 ) continue; // skip blank tp's [25, 28]
170  }
171 
172  pTP_ = mapper_->getTPPointer(tccId_,tt-offset);
173  if(pTP_) pTP_->setSample(0, *tccP_ );
174  }
175  else break;
176  // adding trigger primitive digi to the collection
177  (*tps_)->push_back(*pTP_);
178  }
179  }// end if(processTPG2)
180  }// end FOV==1 or 2
181 }
182 
183 
185 
186 
187  bool tccFound(false);
188  bool errorOnNumbOfTTs(false);
189  const int activeDCC = mapper_->getActiveSM();
190  std::vector<unsigned int> * m = mapper_->getTccs(activeDCC);
191  std::vector<unsigned int>::iterator it;
192  for(it= m->begin();it!=m->end();it++){
193  if((*it) == tccId_){
194  tccFound=true;
195 
196  /*
197  expNumbTTs_= 28; //separate from inner and outer tcc
198  For inner TCCs you expect 28 TTs (4 in phi, 7 in eta).
199  For outer TCCs you expect 16 TTs (4 in phi, 4 in eta).
200  to implement : map tccid-> number of tts
201 
202  Pascal P.: For outer board, only 16 TPs are meaningful but 28 are sent.
203  - [1,8] are meaningful
204  - [9,16] are empty ie should be skipped by unpacker
205  - [17, 24] are meaningful
206  - [25, 28] are empty ie should be skipped by unpacker
207  */
208 
209  if( nTTs_ != 28 && nTTs_ !=16 ){
211  edm::LogWarning("IncorrectBlock")
212  <<"Error on event "<<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
213  <<"\n TCC id "<<tccId_<<" has "<<nTTs_<<" Trigger Towers (only 28 or 16 are the expected values in EE)"
214  <<"\n => Skipping to next fed block...";
215  errorOnNumbOfTTs = true;
216  //todo : add to error collection
217  }
218  }
219  }
220  }
221 
222  if(!tccFound){
223 
225  edm::LogWarning("IncorrectBlock")
226  <<"Error on event "<<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
227  <<"\n TCC id "<<tccId_<<" is not valid for this dcc "
228  <<"\n => Skipping to next fed block...";
229  //todo : add to error collection
230  }
231  }
232 
233 
234  return (tccFound || errorOnNumbOfTTs);
235 
236 }
237 
238 
240 
241  const uint64_t * temp = data_;
242  temp++;
243 
244  ps_ = ( *temp>>TCC_PS_B ) & B_MASK;
245 
246  unsigned int numbTps = (NUMB_TTS_TPG1 + NUMB_TTS_TPG2);
247  if(ps_){ numbTps += 2*NUMB_PSEUDOSTRIPS;}
248 
249  unsigned int length = numbTps/4 + 2; //header and trailer
250  if(numbTps%4) length++ ;
251 
252 
253  return length;
254 
255 }
256 
257 
std::vector< unsigned int > * getTccs(unsigned int smId)
unsigned int getLength() override
EcalPseudoStripInputDigi * pPS_
Definition: DCCTCCBlock.h:68
std::unique_ptr< EcalPSInputDigiCollection > * ecalPSsCollection()
std::unique_ptr< EcalTrigPrimDigiCollection > * tps_
Definition: DCCTCCBlock.h:69
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
static std::atomic< bool > silentMode_
DCCEETCCBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpacking)
Definition: DCCEETCCBlock.cc:7
std::unique_ptr< EcalPSInputDigiCollection > * pss_
Definition: DCCTCCBlock.h:70
unsigned int bx()
Definition: DCCEventBlock.h:55
EcalTriggerPrimitiveDigi * pTP_
Definition: DCCTCCBlock.h:67
unsigned int fov()
Definition: DCCEventBlock.h:52
bool checkTccIdAndNumbTTs() override
EcalPseudoStripInputDigi * getPSInputDigiPointer(unsigned int tccId, unsigned int towerId, unsigned int psId)
unsigned long long uint64_t
Definition: Time.h:15
void addTriggerPrimitivesToCollection() override
void updateCollectors() override
unsigned int tccId_
Definition: DCCTCCBlock.h:55
DCCDataUnpacker * unpacker_
unsigned int nTTs_
Definition: DCCTCCBlock.h:60
EcalTriggerPrimitiveDigi * getTPPointer(unsigned int tccId, unsigned int tower)
bool isTCCExternal(unsigned int TCCId)
EcalElectronicsMapper * mapper_
std::unique_ptr< EcalTrigPrimDigiCollection > * ecalTpsCollection()
void setSampleValue(int i, uint16_t value)
unsigned int ps_
Definition: DCCTCCBlock.h:64
unsigned int l1A()
Definition: DCCEventBlock.h:54