CMS 3D CMS Logo

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