set container pointers to nullptr if size is 0 (avoid checking again the size in many places)
202{
203
205
206 const EventContext& ctx = Gaudi::Hive::currentContext();
207
210
211 unsigned long long thisevent =
evt->eventNumber();
212 unsigned short thislb =
evt->lumiBlock();
213
214
215 unsigned long thisbcid =
evt->bcid();
216 unsigned long thisELVL1Id = 0;
217 unsigned long thisttype =
evt->level1TriggerType();
218
220 bool hasDigitContainer=true;
221 const LArDigitContainer *DigitContainer = nullptr;
223 SG::ReadHandle<LArDigitContainer> hdlDigit(
m_contKey, ctx);
224 if(!hdlDigit.isValid()) {
226 hasDigitContainer=false;
227 } else {
229 DigitContainer = hdlDigit.cptr();
230 }
231 } else hasDigitContainer=false;
232
233 bool hasAccCalibDigitContainer=true;
234 const LArAccumulatedCalibDigitContainer *AccCalibDigitContainer = nullptr;
236 SG::ReadHandle<LArAccumulatedCalibDigitContainer> hdlAccDigit(
m_accCalibContKey, ctx);
237 if(!hdlAccDigit.isValid()) {
239 hasAccCalibDigitContainer=false;
240 } else {
242 AccCalibDigitContainer = hdlAccDigit.cptr();
243 }
244 } else hasAccCalibDigitContainer=false;
245
246 bool hasAccDigitContainer=true;
247 const LArAccumulatedDigitContainer *AccDigitContainer = nullptr;
249 SG::ReadHandle<LArAccumulatedDigitContainer> hdlAccDigit(
m_accContKey, ctx);
250 if(!hdlAccDigit.isValid()) {
252 hasAccDigitContainer=false;
253 } else {
255 AccDigitContainer = hdlAccDigit.cptr();
256 }
257 } else hasAccDigitContainer=false;
258
259 const LArDigitContainer* DigitContainer_next = nullptr;
260 const LArRawSCContainer* etcontainer = nullptr;
261 const LArRawSCContainer* etcontainer_next = nullptr;
264 std::map<unsigned int, const LArLATOMEHeader*> LATOMEHeadMap;
266
268 sc =
evtStore()->retrieve(RawChannelContainer,
"LArRawChannels");
269 if (
sc.isFailure()) {
270 ATH_MSG_WARNING(
"Unable to retrieve LArRawChannelContainer with key LArRawChannels from DetectorStore. " );
271 }
272 else
273 ATH_MSG_DEBUG(
"Got LArRawChannelContainer with key LArRawChannels" );
274 }
275
277 ATH_MSG_WARNING(
"Asked for ETThresholdMain, but no LArRawChannelContainer, will not apply ! " );
279 }
280
282 sc =
evtStore()->retrieve(DigitContainer_next,
"SC_ADC_BAS");
283 if (
sc.isFailure()) {
284 ATH_MSG_WARNING(
"Unable to retrieve LArDigitContainer with key SC_ADC_BAS from DetectorStore. " );
285 }
286 else
287 ATH_MSG_DEBUG(
"Got additional LArDigitContainer with key SC_ADC_BAS " );
288 }
289
291 sc =
evtStore()->retrieve(etcontainer,
"SC_ET");
292 if (
sc.isFailure()) {
293 ATH_MSG_WARNING(
"Unable to retrieve LArRawSCContainer with key SC_ET from DetectorStore. " );
294 }
295 else
297 }
298
300 sc =
evtStore()->retrieve(etcontainer_next,
"SC_ET_ID");
301 if (
sc.isFailure()) {
302 ATH_MSG_WARNING(
"Unable to retrieve LArRawSCContainer with key SC_ET_ID from DetectorStore. " );
303 }
304 else
306 }
307
309 if (! hdrCont.isValid()) {
311 } else {
313 headcontainer=&*hdrCont;
314 if(headcontainer != nullptr && *hdrCont->begin()) thisELVL1Id = (*hdrCont->begin())->L1Id();
315 ATH_MSG_DEBUG(
" ELVL1I FROM LATOME HEADER " << thisELVL1Id );
316 }
317
318 if (headcontainer){
319 for (
const LArLATOMEHeader*
hit : *headcontainer) {
320 LATOMEHeadMap.try_emplace (
hit->SourceId(),
hit );
321 }
322 }
324 for (const LArRawChannel& raw : *RawChannelContainer) {
325 rawChannelMap.try_emplace( raw.channelID(), &raw );
326 }
327 }
328 const LArOnOffIdMapping*
cabling=
nullptr;
329 const LArOnOffIdMapping* cablingROD=nullptr;
331 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
cablingKey()};
333 if(!cabling) {
335 return StatusCode::FAILURE;
336 }
338 cablingROD=*cablingHdlROD;
339 if(!cablingROD) {
341 return StatusCode::FAILURE;
342 }
343 }
344
346 if( DigitContainer_next && DigitContainer_next->
empty() ) DigitContainer_next =
nullptr;
347
348 if( etcontainer && etcontainer->
empty() ) etcontainer =
nullptr;
349
350 if( etcontainer_next && etcontainer_next->
empty() ) etcontainer_next =
nullptr;
351
352 int cellsno = 0;
353 if (hasDigitContainer) {
354 if( !DigitContainer->
empty() ) cellsno = DigitContainer->
size();
355 else {
356 ATH_MSG_WARNING(
"DigitContainer has zero size, but asked, will be not filled... ");
357 return StatusCode::SUCCESS;
358 }
359 }
360 ATH_MSG_DEBUG(
"DigitContainer has size: "<<cellsno<<
" hasDigitContainer: "<<hasDigitContainer);
361
362 if(
m_ETThresh > 0. && !etcontainer && !etcontainer_next) {
363 ATH_MSG_WARNING(
"Asked for ETThreshold, but no SC_ET* container, will not apply ! " );
365 }
366
368 SG::ReadCondHandle<CaloSuperCellDetDescrManager> caloMgrHandle{
m_caloSCMgrKey};
371 }
372
373 if(
m_ADCThresh > 0. && ! DigitContainer&& !DigitContainer_next) {
374 ATH_MSG_WARNING(
"Asked for ADCThreshold, but no digits container, will not apply ! " );
376 }
377
378 if (hasAccCalibDigitContainer) {
379 if( !AccCalibDigitContainer->
empty() ) {
380 cellsno = AccCalibDigitContainer->
size();
381 ATH_MSG_DEBUG(
"AccCalibDigitContainer has size: "<<cellsno<<
" hasAccCalibDigitContainer: "<<hasAccCalibDigitContainer);
382 } else {
383 ATH_MSG_WARNING(
"AccCalibDigitContainer has zero size, but asked, will be not filled... ");
384 return StatusCode::SUCCESS;
385 }
386 }
387 if (hasAccDigitContainer) {
388 if( !AccDigitContainer->
empty() ) {
389 cellsno = AccDigitContainer->
size();
390 ATH_MSG_DEBUG(
"AccDigitContainer has size: "<<cellsno<<
" hasAccDigitContainer: "<<hasAccDigitContainer);
391 } else {
392 ATH_MSG_WARNING(
"AccDigitContainer has zero size, but asked, will be not filled... ");
393 return StatusCode::SUCCESS;
394 }
395 }
396
397 if (DigitContainer_next){
398 if ( cellsno == 0 ){
399 cellsno = DigitContainer_next->
size();
400 }
else if(DigitContainer_next->
size() != (
unsigned)cellsno ){
ATH_MSG_WARNING(
" NOOOOOOO! Different number of entries in DigitContainer_next"<< cellsno <<
" " << DigitContainer_next->
size() );
401 return StatusCode::SUCCESS;
402 }
403 }
404 if (etcontainer){
405 if ( cellsno == 0 ){
406 cellsno = etcontainer->
size();
407 }
else if(etcontainer->
size() != (
unsigned)cellsno ){
ATH_MSG_WARNING(
" NOOOOOOO! Different number of entries in etcontainer"<< cellsno <<
" " << etcontainer->
size() );
408 return StatusCode::SUCCESS;
409 }
410 }
411 if (etcontainer_next){
412 if ( cellsno == 0 ){
413 cellsno = etcontainer_next->
size();
414 }
else if(etcontainer_next->
size() != (
unsigned)cellsno ){
ATH_MSG_WARNING(
" NOOOOOOO! Different number of entries in etcontainer_next"<< cellsno <<
" " << etcontainer_next->
size() );
415 return StatusCode::SUCCESS;
416 }
417 }
418 unsigned cellCounter = 0;
420
421 for(
int c = 0;
c<cellsno;++
c ){
423
427
428 bool acceptETMain = true;
429
430 if( hasAccDigitContainer ){
431
432 const LArAccumulatedDigit* digi = AccDigitContainer->
at(c);
433
434
435
436 unsigned int trueMaxSample = digi->
nsample();
437
440 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 " );
442 }
444 }
446
448
449 float adcmax=-1.;
450 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
454 }
456
457 }
458
459 if( hasAccCalibDigitContainer ){
460
461 const LArAccumulatedCalibDigit* digi = AccCalibDigitContainer->
at(c);
462
463
464
465 unsigned int trueMaxSample = digi->
nsamples();
466
469 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 " );
471 }
473 }
475
477
478 float adcmax=-1.;
479 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
483 }
488
489 }
490
491 if( hasDigitContainer ){
492
493 const LArDigit* digi = DigitContainer->
at(c);
494
495
496 unsigned int trueMaxSample = digi->
nsamples();
497
500 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 " );
502 }
504 }
506
508
511 continue;
512 }
513 }
514
517 if(!acceptETMain) continue;
518 }
519
520 short adcmax=0;
521 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
524 }
526
527 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
528 if(!scdigi){
530 }else{
531 if (headcontainer){
533 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->
SourceId()];
534 if(headmap){
537 }
538 }
540 unsigned int trueMaxBcid = trueMaxSample;
541 if(trueMaxBcid > scdigi->
BCId().size()) trueMaxBcid=scdigi->
BCId().size();
542 for(
unsigned i = 0;
i<trueMaxBcid; ++
i){
544 }
546 }
547
548
549 }
551
552
553
554 if( DigitContainer_next ){
555
556 const LArDigit* digi = DigitContainer_next->
at(c);
557
558 unsigned int trueMaxSample = digi->
nsamples();
559
562 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 " );
564 }
566 }
568
569 if( !hasDigitContainer){
573 if(!acceptETMain) continue;
574 }
575 }
576
577 short adcmax=0;
578 for(
unsigned i = 0;
i<trueMaxSample;++
i) {
581 }
583
584 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(digi);
585 if(!scdigi){
ATH_MSG_DEBUG(
" Can't cast digi to LArSCDigit*");
586 }else{
587 if (headcontainer){
588 const LArLATOMEHeader*headmap = LATOMEHeadMap[scdigi->
SourceId()];
589 if(headmap){
592 }
593 }
595 for(
unsigned i = 0;
i<trueMaxSample;++
i){
597 }
599 }
600
601 }
603
604
605
606
607 if( etcontainer ){
608 const LArRawSC*rawSC = etcontainer->
at(c);
609
610 if ( !hasDigitContainer && !DigitContainer_next ){
613 if (headcontainer){
614 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->
SourceId()];
615 if(headmap){
618 }
619 }
622 if(!acceptETMain) continue;
623 }
624 }
625 unsigned int truenet =
m_Net;
626 if(truenet > rawSC->
bcids().size()) truenet=rawSC->
bcids().size();
627 for(
unsigned i=0;
i<truenet;++
i){
629 }
632 for( i=0;
i<truenet;++
i){
634 if(rawSC->
bcids().size()) {
637 }
638 } else {
641 }
642 }
643 }
644 if(i<truenet) continue;
645
646 if(truenet > rawSC->
satur().size()) truenet=rawSC->
satur().size();
647 for(
unsigned i = 0;
i<truenet;++
i){
649 }
652
653 }
655
656 if( etcontainer_next ){
657 const LArRawSC*rawSC = etcontainer_next->
at(c);
658
659 if ( !hasDigitContainer && !DigitContainer_next && !etcontainer ){
662 if (headcontainer){
663 const LArLATOMEHeader*headmap = LATOMEHeadMap[rawSC->
SourceId()];
664 if(headmap){
667 }
668 }
671 if(!acceptETMain) continue;
672 }
673 }
675 for(
unsigned i=0;
i<rawSC->
bcids().size();++
i){
677 }
681 if(rawSC->
bcids().size()) {
684 }
685 } else {
688 }
689 }
690 }
691 if(i<rawSC->energies().size()) {
692 continue;
693 }
694
695 for(
unsigned i = 0;
i<rawSC->
satur().size();++
i){
697 }
698 }
700
702 if (
sc != StatusCode::SUCCESS) {
705 }
706 cellCounter++;
707 }
708
714
716 if( !
m_trigDec->getListOfTriggers(
x).empty() ){
718 }
719 }
724
725 }
726
728 const DataVector<LVL1::TriggerTower>* TTVector = nullptr;
731 } else {
741 if(
count==20000)
break;
742 }
744 }
745 }
746
749 if (
sc != StatusCode::SUCCESS) {
752 }
753 }
754
755 ATH_MSG_DEBUG(
"LArSC2Ntuple has finished, filled " << cellCounter <<
" cells");
756 return StatusCode::SUCCESS;
757}
#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
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.