In case of overlap merge signal and background collections.
loop over the SPU - collecting thr data by layer do the overlay by igas layer in a chamber
for the non-precision strips, all the 4 layers in a chamber are in the same SPU, we need to recover the data by chamber layer
290{
292
293
294 unsigned int nSigSamples = bkgCollection->
numSamples();
295 unsigned int nOvlSamples = signalCollection->
numSamples();
296
297
298 unsigned int dataSamplingTime = bkgCollection->
rate();
299 unsigned int ovlSamplingTime = signalCollection->
rate();
300
301 if ( dataSamplingTime != ovlSamplingTime ) {
302 ATH_MSG_ERROR(
"Overlay of inconsistent data - sampling times not the same "
303 << dataSamplingTime << " ns " << ovlSamplingTime << " ns");
304 throw std::runtime_error("mergeCollections(): sampling time mismatch");
305 }
306
307 if ( nSigSamples != nOvlSamples ) {
308 ATH_MSG_ERROR(
"Overlay of inconsistent data - number of samples not the same "
309 << nSigSamples << " " << nOvlSamples);
310 throw std::runtime_error("mergeCollections(): number of samples mismatch");
311 }
312
315 uint16_t clusterCounts[] = {0,0,0,0,0,0,0,0,0,0};
317 for ( uint16_t spuID=0; spuID<10; ++spuID) {
318
319 std::vector<const CscRawData*> sigData;
320 this->
spuData(bkgCollection, spuID, sigData);
321
322 std::vector<const CscRawData*> ovlData;
323 this->
spuData(signalCollection, spuID, ovlData);
324
328 if ( spuID == 4 || spuID == 9 )
layer=4;
329 for (
int j=0;
j<=
layer; ++
j ) {
330 std::map< int,std::vector<uint16_t> > sigSamples;
331 std::map< int,std::vector<uint16_t> > ovlSamples;
335 uint32_t ovlAddress = this->
stripData( ovlData, nOvlSamples, ovlSamples, ovlHash, spuID, j ,
false);
336 if (sigSamples.size()==0 && ovlSamples.size()==0) continue;
337
339 uint32_t address = std::min( sigAddress, ovlAddress );
340 if (sigSamples.size()!=0 && ovlSamples.size()!=0 &&
needtoflip(address)){
341 ATH_MSG_DEBUG(
"Looking for overlap of hashes and addresses within widths because needtoflip");
342 msg() << MSG::VERBOSE ;
343 std::set<int>
sig;
int lastindex=-1;
344 for (std::map< int,std::vector<uint16_t> >::const_iterator si=sigSamples.begin(); si!=sigSamples.end(); ++si) {
345 if (si!=sigSamples.begin() && si->first-lastindex!=1) break;
346 lastindex=si->first;
347 sig.insert(si->first);
msg() << si->first <<
" ";
348 }
350 bool overlap=false;
351 msg() <<MSG::VERBOSE ;
352 for (std::map< int,std::vector<uint16_t> >::const_iterator so=ovlSamples.begin(); so!=ovlSamples.end(); ++so) {
353
354 msg() << (so->first)-1 <<
" ";
355 if (
sig.find((so->first)-1)!=
sig.end()) {overlap=
true;
msg() <<
"!!";}
356 msg() << (so->first) <<
" ";
357 if (
sig.find((so->first))!=
sig.end()) {overlap=
true;
msg() <<
"!!";}
358 msg() << (so->first)+1 <<
" ";
359 if (
sig.find((so->first)+1)!=
sig.end()) {overlap=
true;
msg() <<
"!!";}
360 }
362 if (!overlap){
363 ATH_MSG_DEBUG(
"Taking max of hashes and addresses because needtoflip and no overlap");
364 hash = std::max( sigHash, ovlHash );
365 address = std::max( sigAddress, ovlAddress );
366 }
367 }
368
369
370 std::set<int> insertedstrips, readstrips;
371 for (std::map<
int,std::vector<uint16_t> >::const_iterator s=sigSamples.begin(); s!=sigSamples.end(); ++s){readstrips.insert(
s->first);}
372 for (std::map< int,std::vector<uint16_t> >::const_iterator si=ovlSamples.begin(); si!=ovlSamples.end(); ++si){readstrips.insert(si->first);}
373
374 std::vector<CscRawData*> datums = this->
overlay(sigSamples, ovlSamples,address, spuID,
outputCollection->identify(), hash, rndmEngine);
376 for (unsigned int di=0; di<datums.size(); ++di){
380 int stripstart = ( address & 0x000000FF) + 1 + 0;
381 ATH_MSG_DEBUG(
"Datum in layer="<<j<<
" has hash="<<hash<<
" address="<<address<<
" stripstart="<<stripstart<<
", "<< *datum );
382 if (datum->
width()==0) {
384 continue;
385 }
386
387
388 int stationName = ( ( address & 0x00010000) >> 16 ) + 50;
389 int stationEta = ( ((address & 0x00001000) >> 12 ) == 0x0) ? -1 : 1;
390 int stationPhi = ( ( address & 0x0000E000) >> 13 ) + 1;
391 Identifier me=
m_idHelperSvc->cscIdHelper().elementID(stationName,stationEta,stationPhi);
392 ATH_MSG_VERBOSE(
"stationName,Eta,Phi="<<stationName<<
","<<stationEta<<
","<<stationPhi<<
" - me="<<me);
394 for (
unsigned int j=0;
j<datum->
width(); ++
j) {
395 int chamberLayer = ( (address & 0x00000800) >> 11) + 1;
396 int wireLayer = ( (address & 0x00000600) >> 9) + 1;
397 int measuresPhi = ( (address & 0x00000100) >> 8);
398 int strip = ( address & 0x000000FF) + 1 + j;
399 ATH_MSG_VERBOSE(
"chamberlayer,wirelayer,measuresphi,strip="<<chamberLayer<<
","<<wireLayer<<
","<<measuresPhi<<
","<<
strip);
400
401 if (measuresPhi) {
402 int stationEta = ( ((address & 0x00001000) >> 12 ) == 0x0) ? -1 : 1;
403 if (stationEta>0) {
406 }
407 }
408 insertedstrips.insert(
strip);
409 Identifier mechan=
m_idHelperSvc->cscIdHelper().channelID(me,chamberLayer,wireLayer,measuresPhi,
strip);
413 ATH_MSG_WARNING(
"Invalid CSC Identifier in merge! - skipping " << channelId );
415 }
416 else{
ATH_MSG_DEBUG(
"Valid CSC Identifier in merge " << channelId);}
417 }
419 else{ continue; }
420
421
422 if (spuID <10) clusterCounts[spuID] += 1;
423 if ( spuID <= 4 ) rpuCount[0] = 5;
424 else if ( spuID > 4 && spuID <= 9 ) rpuCount[1] = 11;
425 }
426
427
428 if (readstrips!=insertedstrips){
430 std::ostringstream readstream;
431 for (std::set<int>::const_iterator i = readstrips.begin(); i!=readstrips.end(); ++i){readstream<<*
i<<
" ";}
433 std::ostringstream insertstream;
434 for (std::set<int>::const_iterator i = insertedstrips.begin(); i!=insertedstrips.end(); ++i){insertstream<<*
i<<
" ";}
436 }
437
438 }
439 }
441 for (
unsigned int i=0;
i<2; ++
i) {
if (rpuCount[i] != 0)
outputCollection->addRPU(rpuCount[i]); }
442
444}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
void spuData(const CscRawDataCollection *coll, const uint16_t spuID, std::vector< const CscRawData * > &data) const
get the data in one SPU of a chamber
uint32_t stripData(const std::vector< const CscRawData * > &data, const unsigned int numSamples, std::map< int, std::vector< uint16_t > > &samples, uint32_t &hash, const uint16_t spuID, const int gasLayer, bool isdata) const
data in one gas lauer
bool needtoflip(const int address) const
Gaudi::Property< bool > m_isDataOverlay
uint16_t numSamples() const
uint8_t rate() const
the rate could be 25 or 50 ns
constexpr uint8_t stationPhi
station Phi 1 to 8
constexpr uint8_t stationEta
1 to 3
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)