Execute method.
set container pointers to nullptr if size is 0 (avoid checking again the size in many places)
202{
203
205
206
209
210 unsigned long long thisevent =
evt->eventNumber();
211 unsigned short thislb =
evt->lumiBlock();
212
213
214 unsigned long thisbcid =
evt->bcid();
215 unsigned long thisELVL1Id = 0;
216 unsigned long thisttype =
evt->level1TriggerType();
217
219 bool hasDigitContainer=true;
220 const LArDigitContainer *DigitContainer = nullptr;
222 SG::ReadHandle<LArDigitContainer> hdlDigit(
m_contKey, ctx);
223 if(!hdlDigit.isValid()) {
225 hasDigitContainer=false;
226 } else {
228 DigitContainer = hdlDigit.cptr();
229 }
230 } else hasDigitContainer=false;
231
232 bool hasAccCalibDigitContainer=true;
233 const LArAccumulatedCalibDigitContainer *AccCalibDigitContainer = nullptr;
235 SG::ReadHandle<LArAccumulatedCalibDigitContainer> hdlAccDigit(
m_accCalibContKey, ctx);
236 if(!hdlAccDigit.isValid()) {
238 hasAccCalibDigitContainer=false;
239 } else {
241 AccCalibDigitContainer = hdlAccDigit.cptr();
242 }
243 } else hasAccCalibDigitContainer=false;
244
245 bool hasAccDigitContainer=true;
246 const LArAccumulatedDigitContainer *AccDigitContainer = nullptr;
248 SG::ReadHandle<LArAccumulatedDigitContainer> hdlAccDigit(
m_accContKey, ctx);
249 if(!hdlAccDigit.isValid()) {
251 hasAccDigitContainer=false;
252 } else {
254 AccDigitContainer = hdlAccDigit.cptr();
255 }
256 } else hasAccDigitContainer=false;
257
258 const LArDigitContainer* DigitContainer_next = nullptr;
259 const LArRawSCContainer* etcontainer = nullptr;
260 const LArRawSCContainer* etcontainer_next = nullptr;
263 std::map<unsigned int, const LArLATOMEHeader*> LATOMEHeadMap;
265
267 sc =
evtStore()->retrieve(RawChannelContainer,
"LArRawChannels");
268 if (
sc.isFailure()) {
269 ATH_MSG_WARNING(
"Unable to retrieve LArRawChannelContainer with key LArRawChannels from DetectorStore. " );
270 }
271 else
272 ATH_MSG_DEBUG(
"Got LArRawChannelContainer with key LArRawChannels" );
273 }
274
276 ATH_MSG_WARNING(
"Asked for ETThresholdMain, but no LArRawChannelContainer, will not apply ! " );
278 }
279
281 sc =
evtStore()->retrieve(DigitContainer_next,
"SC_ADC_BAS");
282 if (
sc.isFailure()) {
283 ATH_MSG_WARNING(
"Unable to retrieve LArDigitContainer with key SC_ADC_BAS from DetectorStore. " );
284 }
285 else
286 ATH_MSG_DEBUG(
"Got additional LArDigitContainer with key SC_ADC_BAS " );
287 }
288
290 sc =
evtStore()->retrieve(etcontainer,
"SC_ET");
291 if (
sc.isFailure()) {
292 ATH_MSG_WARNING(
"Unable to retrieve LArRawSCContainer with key SC_ET from DetectorStore. " );
293 }
294 else
296 }
297
299 sc =
evtStore()->retrieve(etcontainer_next,
"SC_ET_ID");
300 if (
sc.isFailure()) {
301 ATH_MSG_WARNING(
"Unable to retrieve LArRawSCContainer with key SC_ET_ID from DetectorStore. " );
302 }
303 else
305 }
306
308 if (! hdrCont.isValid()) {
310 } else {
312 headcontainer=&*hdrCont;
313 if(headcontainer != nullptr && *hdrCont->begin()) thisELVL1Id = (*hdrCont->begin())->L1Id();
314 ATH_MSG_DEBUG(
" ELVL1I FROM LATOME HEADER " << thisELVL1Id );
315 }
316
317 if (headcontainer){
318 for (const LArLATOMEHeader* hit : *headcontainer) {
319 LATOMEHeadMap.try_emplace ( hit->SourceId(), hit );
320 }
321 }
323 for (const LArRawChannel& raw : *RawChannelContainer) {
324 rawChannelMap.try_emplace( raw.channelID(), &raw );
325 }
326 }
327 const LArOnOffIdMapping*
cabling=
nullptr;
328 const LArOnOffIdMapping* cablingROD=nullptr;
330 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
cablingKey(), ctx};
332 if(!cabling) {
334 return StatusCode::FAILURE;
335 }
337 cablingROD=*cablingHdlROD;
338 if(!cablingROD) {
340 return StatusCode::FAILURE;
341 }
342 }
343
345 if( DigitContainer_next && DigitContainer_next->
empty() ) DigitContainer_next =
nullptr;
346
347 if( etcontainer && etcontainer->
empty() ) etcontainer =
nullptr;
348
349 if( etcontainer_next && etcontainer_next->
empty() ) etcontainer_next =
nullptr;
350
351 int cellsno = 0;
352 if (hasDigitContainer) {
353 if( !DigitContainer->
empty() ) cellsno = DigitContainer->
size();
354 else {
355 ATH_MSG_WARNING(
"DigitContainer has zero size, but asked, will be not filled... ");
356 return StatusCode::SUCCESS;
357 }
358 }
359 ATH_MSG_DEBUG(
"DigitContainer has size: "<<cellsno<<
" hasDigitContainer: "<<hasDigitContainer);
360
361 if(
m_ETThresh > 0. && !etcontainer && !etcontainer_next) {
362 ATH_MSG_WARNING(
"Asked for ETThreshold, but no SC_ET* container, will not apply ! " );
364 }
365
367 SG::ReadCondHandle<CaloSuperCellDetDescrManager> caloMgrHandle{
m_caloSCMgrKey, ctx};
370 }
371
372 if(
m_ADCThresh > 0. && ! DigitContainer&& !DigitContainer_next) {
373 ATH_MSG_WARNING(
"Asked for ADCThreshold, but no digits container, will not apply ! " );
375 }
376
377 if (hasAccCalibDigitContainer) {
378 if( !AccCalibDigitContainer->
empty() ) {
379 cellsno = AccCalibDigitContainer->
size();
380 ATH_MSG_DEBUG(
"AccCalibDigitContainer has size: "<<cellsno<<
" hasAccCalibDigitContainer: "<<hasAccCalibDigitContainer);
381 } else {
382 ATH_MSG_WARNING(
"AccCalibDigitContainer has zero size, but asked, will be not filled... ");
383 return StatusCode::SUCCESS;
384 }
385 }
386 if (hasAccDigitContainer) {
387 if( !AccDigitContainer->
empty() ) {
388 cellsno = AccDigitContainer->
size();
389 ATH_MSG_DEBUG(
"AccDigitContainer has size: "<<cellsno<<
" hasAccDigitContainer: "<<hasAccDigitContainer);
390 } else {
391 ATH_MSG_WARNING(
"AccDigitContainer has zero size, but asked, will be not filled... ");
392 return StatusCode::SUCCESS;
393 }
394 }
395
396 if (DigitContainer_next){
397 if ( cellsno == 0 ){
398 cellsno = DigitContainer_next->
size();
399 }
else if(DigitContainer_next->
size() != (
unsigned)cellsno ){
ATH_MSG_WARNING(
" NOOOOOOO! Different number of entries in DigitContainer_next"<< cellsno <<
" " << DigitContainer_next->
size() );
400 return StatusCode::SUCCESS;
401 }
402 }
403 if (etcontainer){
404 if ( cellsno == 0 ){
405 cellsno = etcontainer->
size();
406 }
else if(etcontainer->
size() != (
unsigned)cellsno ){
ATH_MSG_WARNING(
" NOOOOOOO! Different number of entries in etcontainer"<< cellsno <<
" " << etcontainer->
size() );
407 return StatusCode::SUCCESS;
408 }
409 }
410 if (etcontainer_next){
411 if ( cellsno == 0 ){
412 cellsno = etcontainer_next->
size();
413 }
else if(etcontainer_next->
size() != (
unsigned)cellsno ){
ATH_MSG_WARNING(
" NOOOOOOO! Different number of entries in etcontainer_next"<< cellsno <<
" " << etcontainer_next->
size() );
414 return StatusCode::SUCCESS;
415 }
416 }
417 unsigned cellCounter = 0;
419
420 for(
int c = 0;
c<cellsno;++
c ){
422
426
427 bool acceptETMain = true;
428
429 if( hasAccDigitContainer ){
430
431 const LArAccumulatedDigit* digi = AccDigitContainer->
at(c);
432
433
434
435 unsigned int trueMaxSample = digi->
nsample();
436
439 ATH_MSG_DEBUG(
"The number of samples in data is larger than the one specified by JO: " << trueMaxSample <<
" > " <<
m_Nsamples <<
" --> only " <<
m_Nsamples <<
" will be available in the ntuple " );
441 }
443 }
445
447
448 float adcmax=-1.;
449 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
453 }
455
456 }
457
458 if( hasAccCalibDigitContainer ){
459
460 const LArAccumulatedCalibDigit* digi = AccCalibDigitContainer->
at(c);
461
462
463
464 unsigned int trueMaxSample = digi->
nsamples();
465
468 ATH_MSG_DEBUG(
"The number of samples in data is larger than the one specified by JO: " << trueMaxSample <<
" > " <<
m_Nsamples <<
" --> only " <<
m_Nsamples <<
" will be available in the ntuple " );
470 }
472 }
474
476
477 float adcmax=-1.;
478 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
482 }
487
488 }
489
490 if( hasDigitContainer ){
491
492 const LArDigit* digi = DigitContainer->
at(c);
493
494
495 unsigned int trueMaxSample = digi->
nsamples();
496
499 ATH_MSG_DEBUG(
"The number of samples in data is larger than the one specified by JO: " << trueMaxSample <<
" > " <<
m_Nsamples <<
" --> only " <<
m_Nsamples <<
" will be available in the ntuple " );
501 }
503 }
505
507
510 continue;
511 }
512 }
513
516 if(!acceptETMain) continue;
517 }
518
519 short adcmax=0;
520 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
523 }
525
526 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
527 if(!scdigi){
529 }else{
530 if (headcontainer){
532 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->
SourceId()];
533 if(headmap){
536 }
537 }
539 unsigned int trueMaxBcid = trueMaxSample;
540 if(trueMaxBcid > scdigi->
BCId().size()) trueMaxBcid=scdigi->
BCId().size();
541 for(
unsigned i = 0;
i<trueMaxBcid; ++
i){
543 }
545 }
546
547
548 }
550
551
552
553 if( DigitContainer_next ){
554
555 const LArDigit* digi = DigitContainer_next->
at(c);
556
557 unsigned int trueMaxSample = digi->
nsamples();
558
561 ATH_MSG_DEBUG(
"The number of samples in data is larger than the one specified by JO: " << trueMaxSample <<
" > " <<
m_Nsamples <<
" --> only " <<
m_Nsamples <<
" will be available in the ntuple " );
563 }
565 }
567
568 if( !hasDigitContainer){
572 if(!acceptETMain) continue;
573 }
574 }
575
576 short adcmax=0;
577 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
580 }
582
583 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
584 if(!scdigi){
ATH_MSG_DEBUG(
" Can't cast digi to LArSCDigit*");
585 }else{
586 if (headcontainer){
587 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->
SourceId()];
588 if(headmap){
591 }
592 }
594 for(
unsigned i = 0;
i<trueMaxSample;++
i){
596 }
598 }
599
600 }
602
603
604
605
606 if( etcontainer ){
607 const LArRawSC*rawSC = etcontainer->
at(c);
608
609 if ( !hasDigitContainer && !DigitContainer_next ){
612 if (headcontainer){
613 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->
SourceId()];
614 if(headmap){
617 }
618 }
621 if(!acceptETMain) continue;
622 }
623 }
624 unsigned int truenet =
m_Net;
625 if(truenet > rawSC->
bcids().size()) truenet=rawSC->
bcids().size();
626 for(
unsigned i=0;
i<truenet;++
i){
628 }
631 for( i=0;
i<truenet;++
i){
633 if(rawSC->
bcids().size()) {
636 }
637 } else {
640 }
641 }
642 }
643 if(i<truenet) continue;
644
645 if(truenet > rawSC->
satur().size()) truenet=rawSC->
satur().size();
646 for(
unsigned i = 0;
i<truenet;++
i){
648 }
651
652 }
654
655 if( etcontainer_next ){
656 const LArRawSC*rawSC = etcontainer_next->
at(c);
657
658 if ( !hasDigitContainer && !DigitContainer_next && !etcontainer ){
661 if (headcontainer){
662 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->
SourceId()];
663 if(headmap){
666 }
667 }
670 if(!acceptETMain) continue;
671 }
672 }
676 }
680 if(rawSC->
bcids().size()) {
683 }
684 } else {
687 }
688 }
689 }
690 if(i<rawSC->energies().
size()) {
691 continue;
692 }
693
696 }
697 }
699
701 if (
sc != StatusCode::SUCCESS) {
704 }
705 cellCounter++;
706 }
707
713
715 if( !
m_trigDec->getListOfTriggers(
x).empty() ){
717 }
718 }
723
724 }
725
727 const DataVector<LVL1::TriggerTower>* TTVector = nullptr;
730 } else {
740 if(
count==20000)
break;
741 }
743 }
744 }
745
748 if (
sc != StatusCode::SUCCESS) {
751 }
752 }
753
754 ATH_MSG_DEBUG(
"LArSC2Ntuple has finished, filled " << cellCounter <<
" cells");
755 return StatusCode::SUCCESS;
756}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old LArRawChannelContainer
Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Old LArLATOMEHeaderContainer
size_t size() const
Number of registered mappings.
ServiceHandle< StoreGateSvc > & evtStore()
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const T * at(size_type n) const
Access an element, as an rvalue.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
int delay() const
return the setting of the delay
const HWIdentifier & hardwareID() const
Return HWIdentifier.
uint16_t getIsPulsedInt() const
get the four bit int that tells which lines pulsed
int DAC() const
return the number of samples
std::vector< float > RMS() const
Calculates and returns the RMS value of each ADC sample.
std::vector< float > mean() const
Calculates and returns the Mean value of each ADC sample.
size_t nsamples() const
return number of samples
const HWIdentifier & hardwareID() const
Return HWIdentifier.
float RMS(int n_min=-1, int n_max=-1) const
Calculates and returns the RMS value of ADC samples.
float mean(int n_min=-1, int n_max=-1) const
Calculates and returns the Mean value of ADC samples.
int nsample() const
return number of samples
const SG::ReadCondHandleKey< LArOnOffIdMapping > & cablingKey() const
NTuple::Item< long > m_FT
bool fillFromIdentifier(const HWIdentifier &id)
const HWIdentifier & hardwareID() const
const std::vector< short > & samples() const
NTuple::Array< short > m_samples
Gaudi::Property< bool > m_fillBCID
NTuple::Item< unsigned int > m_delay
SG::ReadHandleKey< LArDigitContainer > m_contKey
NTuple::Array< float > m_RMS
NTuple::Item< short > m_LB
NTuple::Array< float > m_mean
Gaudi::Property< std::vector< unsigned int > > m_FTlist
Gaudi::Property< unsigned int > m_Nsamples
NTuple::Item< long > m_ntNsamples
NTuple::Item< short > m_bcid
NTuple::Item< unsigned long long > m_IEvent
SG::ReadHandleKey< LArAccumulatedDigitContainer > m_accContKey
NTuple::Item< unsigned long > m_ELVL1Id
NTuple::Item< unsigned int > m_pulsed
SG::ReadHandleKey< LArAccumulatedCalibDigitContainer > m_accCalibContKey
NTuple::Item< unsigned long long > m_IEventEvt
NTuple::Item< unsigned int > m_dac
unsigned int SourceId() const
const std::vector< bool > & satur() const
const std::vector< unsigned short > & bcids() const
const std::vector< int > & energies() const
const HWIdentifier & hardwareID() const
NTuple::Array< bool > m_saturVec_ET_ID
Gaudi::Property< float > m_ETThresh
NTuple::Array< int > m_energyVec_ET_ID
std::map< std::string, NTuple::Item< unsigned int > > m_trigNameMap
NTuple::Array< bool > m_saturVec_ET
std::map< HWIdentifier, const LArRawChannel * > rawChanMap_t
NTuple::Array< unsigned short > m_bcidVec_ET
Gaudi::Property< std::string > m_triggerTowerKey
Gaudi::Property< bool > m_fillRawChan
Gaudi::Property< bool > m_fillTType
NTuple::Array< short > m_samples_ADC_BAS
NTuple::Array< unsigned short > m_bcidVec
Gaudi::Property< std::vector< std::string > > m_contKeys
void fillRODEnergy(HWIdentifier SCId, rawChanMap_t &rawChanMap, const LArOnOffIdMapping *cabling, const LArOnOffIdMapping *cablingROD, bool &acceptMain)
NTuple::Item< uint32_t > m_latomeSourceId
Gaudi::Property< float > m_ETThreshMain
NTuple::Item< short > m_LArInError
NTuple::Array< int > m_TTEem
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSCMgrKey
NTuple::Item< uint32_t > m_ntNTT
Gaudi::Property< float > m_ADCThresh
Gaudi::Property< bool > m_fillCaloTT
Gaudi::Property< std::vector< std::string > > m_trigNames
NTuple::Item< unsigned int > m_TType
NTuple::Array< double > m_TTeta
SG::ReadHandleKey< LArLATOMEHeaderContainer > m_LArLatomeHeaderContainerKey
NTuple::Array< unsigned short > m_bcidVec_ET_ID
Gaudi::Property< bool > m_overwriteEventNumber
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Gaudi::Property< unsigned int > m_Net
NTuple::Item< uint32_t > m_LArEventBits
NTuple::Array< double > m_TTphi
NTuple::Array< int > m_TTEhad
NTuple::Item< short > m_latomeChannel
NTuple::Array< int > m_energyVec_ET
NTuple::Item< uint32_t > m_ntNet
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeyAdditional
ToolHandle< Trig::TrigDecisionTool > m_trigDec
NTuple::Item< uint16_t > m_bcidLATOMEHEAD
unsigned int SourceId() const
const std::vector< unsigned short > & BCId() const
@ LAr
The LAr calorimeter.
@ Warning
The sub-detector issued a warning.
@ Error
The sub-detector issued an error.
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
::StatusCode StatusCode
StatusCode definition for legacy code.