diff --git a/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv.h b/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv.h index 1fc0359eeedae29dc1ee62513b262f8ef3eda634..325b346789ea0996ebfa0d9bc0186dc9e3f3dfa8 100644 --- a/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv.h +++ b/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv/AFP_ByteStream2RawCnv.h @@ -60,8 +60,12 @@ public: StatusCode fillCollection(const ROBFragment *robFrag, AFP_RawDataContainer *rdoCont, std::vector<unsigned int> *vecHash = NULL); - AFP_RawDataCollection *getCollection(unsigned int MotherBoardId, - AFP_RawDataContainer *cont); + + AFP_RawDataCollection* getCollection(const unsigned int columnNum, + const unsigned int robID, + AFP_RawDataContainer *cont); + + AFP_RawData *getRawData(unsigned int Link, AFP_RawDataCollection *coll); // const eformat::FullEventFragment<const uint32_t*> getEvent(); diff --git a/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_ByteStream2RawCnv.cxx b/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_ByteStream2RawCnv.cxx index 13e8f1917062a688692e2dab6f6eaaf61a865ae2..c782121f2732770f597a266f92783926a5487509 100644 --- a/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_ByteStream2RawCnv.cxx +++ b/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_ByteStream2RawCnv.cxx @@ -100,7 +100,7 @@ StatusCode AFP_ByteStream2RawCnv::finalize() { StatusCode AFP_ByteStream2RawCnv::fillCollection(const ROBFragment *robFrag, AFP_RawDataContainer *rdoCont, std::vector<unsigned int> *) { - ATH_MSG_DEBUG("AFP_ByteStream2RawCnv::fillColelction"); + ATH_MSG_DEBUG("AFP_ByteStream2RawCnv::fillColelction rob_source_id: in decimal="<<std::dec<<robFrag->rob_source_id()<<", in hex=0x"<<std::hex<<robFrag->rob_source_id()<<std::dec); try { robFrag->check(); @@ -163,12 +163,11 @@ StatusCode AFP_ByteStream2RawCnv::fillCollection(const ROBFragment *robFrag, rdoCont->SetBCId(BC_ID); rdoCont->SetLumiBlock(LumiBlock_ID); rdoCont->SetLvl1Id(Lvl1_ID); - AFP_RawDataCollection *collection = 0; + AFP_RawDataCollection *collection = nullptr; unsigned int collection_number = 0; const uint32_t noHitMarker = 15; - int first_BCID = 0; int current_BCID = 0; int hitLvl1 = 0; @@ -178,7 +177,7 @@ int hitLvl1 = 0; m_AFP_RawDataCollectionReadOut->decodeWord(vint[i]); if (m_AFP_RawDataCollectionReadOut->is_BOB()) { - collection = getCollection(collection_number, rdoCont); + collection = getCollection(collection_number, robFrag->rob_source_id(), rdoCont); if (!collection) { ATH_MSG_WARNING( @@ -193,6 +192,7 @@ int hitLvl1 = 0; collection->Set_flag(m_AFP_RawDataCollectionReadOut->flag()); collection->Set_bcid(m_AFP_RawDataCollectionReadOut->bcid()); collection->Set_header(collection_number); + collection->Set_robID(robFrag->rob_source_id()); collection_number++; if(collection_number == 1) {first_BCID = m_AFP_RawDataCollectionReadOut->bcid();} current_BCID = m_AFP_RawDataCollectionReadOut->bcid(); @@ -203,8 +203,6 @@ int hitLvl1 = 0; else if (first_BCID > current_BCID) {hitLvl1 = 1024 + (current_BCID - first_BCID);} - - } else if (m_AFP_RawDataCollectionReadOut->is_LWC() && collection) { @@ -255,27 +253,23 @@ int hitLvl1 = 0; ////////////////////////// AFP_RawDataCollection * -AFP_ByteStream2RawCnv::getCollection(unsigned int ColumnNum, +AFP_ByteStream2RawCnv::getCollection(const unsigned int columnNum, const unsigned int robID, AFP_RawDataContainer *cont) { if (!cont) { ATH_MSG_WARNING( "NULL pointer passed in argument: cont. NULL pointer returned"); - return NULL; + return nullptr; } - AFP_RawDataContainer::const_iterator it = cont->begin(); - AFP_RawDataContainer::const_iterator itE = cont->end(); - - for (; it != itE; ++it) { - if ((*it)->Get_header_number_POT() == ColumnNum) { - ATH_MSG_WARNING( - "Collection already in container, although it should not be there."); - return NULL; + for (const AFP_RawDataCollection* collection : *cont) { + if (collection->Get_header_number_POT() == columnNum && collection->Get_robID() == robID) { + ATH_MSG_WARNING("Collection already in container, although it should not be there."); + return nullptr; } } - AFP_RawDataCollection *coll = new AFP_RawDataCollection(ColumnNum); + AFP_RawDataCollection *coll = new AFP_RawDataCollection(columnNum); cont->push_back(coll); return coll; } diff --git a/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_RawDataProvider.cxx b/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_RawDataProvider.cxx index d6a1b65020dbdc04899a1c564d76551c90dbc4ef..dc8dd5f5e544e0b050f6de824bd312323e5e3e22 100644 --- a/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_RawDataProvider.cxx +++ b/ForwardDetectors/AFP/AFP_ByteStream2RawCnv/src/AFP_RawDataProvider.cxx @@ -2,6 +2,9 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ +// AFP includes +#include "AFP_RawEv/AFP_ROBID.h" + // AFP_ByteStream2RawCnv includes #include "AFP_ByteStream2RawCnv/AFP_RawDataProvider.h" @@ -55,11 +58,11 @@ StatusCode AFP_RawDataProvider::execute() { std::vector<const ROBFragment *> listOfRobf; std::vector<unsigned int> ROBIDs; - ROBIDs.push_back(0x00850000); - ROBIDs.push_back(0x00850001); + ROBIDs.push_back(AFP_ROBID::sideA); + ROBIDs.push_back(AFP_ROBID::sideC); m_robDataProvider->getROBData(ROBIDs, listOfRobf); - ATH_MSG_DEBUG(" ROB ID " << std::hex << ROBIDs); + ATH_MSG_DEBUG(" ROB ID " << std::hex << ROBIDs<<std::dec); ATH_MSG_DEBUG(" Number of ROB fragments is " << listOfRobf.size()); if (m_rawDataTool->convert(listOfRobf, container).isFailure()) { diff --git a/ForwardDetectors/AFP/AFP_Raw2Digi/src/AFP_Raw2DigiTool.cxx b/ForwardDetectors/AFP/AFP_Raw2Digi/src/AFP_Raw2DigiTool.cxx index 82b38e50ffeb98395a2e74ada78a776c69d1c757..5e2e496d872eda2e13303300ca0a07b9c553a078 100644 --- a/ForwardDetectors/AFP/AFP_Raw2Digi/src/AFP_Raw2DigiTool.cxx +++ b/ForwardDetectors/AFP/AFP_Raw2Digi/src/AFP_Raw2DigiTool.cxx @@ -4,6 +4,8 @@ #include "AFP_Raw2DigiTool.h" #include "AFP_RawEv/AFP_RawDataContainer.h" +#include "AFP_RawEv/AFP_ROBID.h" +#include "xAODForward/AFPStationID.h" #include "xAODForward/AFPSiHit.h" #include "xAODForward/AFPSiHitContainer.h" #include "xAODForward/AFPSiHitAuxContainer.h" @@ -45,70 +47,67 @@ StatusCode AFP_Raw2DigiTool::recoSiHits(){ else ATH_MSG_DEBUG("AFP_Raw2DigiTool: Raw data container retrieved"); - ATH_MSG_DEBUG("Reading raw data container"); for (const AFP_RawDataCollection* const collection: *container) { for (const AFP_RawData* const data : *collection) { - const uint32_t hitLink = data->Get_link(); - - xAOD::AFPSiHit* xAODSiHit = new xAOD::AFPSiHit(); - ATH_MSG_DEBUG("Dynamically created xAODSiHit object"); - siHitContainer->push_back(xAODSiHit); - - ATH_MSG_DEBUG("Added xAOD::AFPSiHit to a xAOD::AFPSiHitContainer"); - - switch (hitLink) { - case 0: - xAODSiHit->setStationID(2); - xAODSiHit->setPixelLayerID(0); - break; - case 1: - xAODSiHit->setStationID(2); - xAODSiHit->setPixelLayerID(1); - break; - case 2: - xAODSiHit->setStationID(2); - xAODSiHit->setPixelLayerID(2); - break; - case 3: - xAODSiHit->setStationID(2); - xAODSiHit->setPixelLayerID(3); - break; - case 8: - xAODSiHit->setStationID(3); - xAODSiHit->setPixelLayerID(0); - break; - case 9: - xAODSiHit->setStationID(3); - xAODSiHit->setPixelLayerID(1); - break; - case 10: - xAODSiHit->setStationID(3); - xAODSiHit->setPixelLayerID(2); - break; - case 11: - xAODSiHit->setStationID(3); - xAODSiHit->setPixelLayerID(3); - break; - default: - ATH_MSG_WARNING("Unrecognised value in hitLink = " << hitLink); - delete xAODSiHit; - return StatusCode::SUCCESS; - } // end of switch - - ATH_MSG_DEBUG("Filled information about station and detector in xAODSiHit object"); - - xAODSiHit->setPixelColIDChip( data->Get_column() ); - xAODSiHit->setPixelRowIDChip( data->Get_row() ); - - const unsigned int ToT_value = data->Get_ToT(); - xAODSiHit->setTimeOverThreshold(ToT_value); - xAODSiHit->setDepositedCharge(1909 + ToT_value * 363 + ToT_value * ToT_value * 141); - - ATH_MSG_DEBUG("Filled xAOD::AFPSiHit"); - - }// end of for over RawData_Collection_Beg using p_RawData_Beg + + if (hitLink == 12 || hitLink == 13) { + // fill time-of-flight information + } + else { + // fill tracking information + xAOD::AFPSiHit* xAODSiHit = new xAOD::AFPSiHit(); + siHitContainer->push_back(xAODSiHit); + + // decoding according to Outlink numbers in: https://twiki.cern.ch/twiki/bin/view/Atlas/AFPRunning#Tracker + if (hitLink <=3) { // not checking if larger or equal 0, because this is uint, which is always positive + // set near station ID selecting side based on ROB + if (collection->Get_robID() == AFP_ROBID::sideA) + xAODSiHit->setStationID(xAOD::AFPStationID::nearA); + else if (collection->Get_robID() == AFP_ROBID::sideC) + xAODSiHit->setStationID(xAOD::AFPStationID::nearC); + else { + ATH_MSG_WARNING("Unrecognised robID: in dec="<<std::dec<<collection->Get_robID()<<", in hex=0x"<<std::hex<<collection->Get_robID()<<std::dec); + xAODSiHit->setStationID(-1); + } + + // set pixel layer ID + xAODSiHit->setPixelLayerID(hitLink%4); + + } else if (hitLink >= 8 && hitLink <= 11) { + // set far station ID selecting side based on ROB + if (collection->Get_robID() == AFP_ROBID::sideA) + xAODSiHit->setStationID(xAOD::AFPStationID::farA); + else if (collection->Get_robID() == AFP_ROBID::sideC) + xAODSiHit->setStationID(xAOD::AFPStationID::farC); + else { + ATH_MSG_WARNING("Unrecognised robID: in dec="<<std::dec<<collection->Get_robID()<<", in hex=0x"<<std::hex<<collection->Get_robID()<<std::dec); + xAODSiHit->setStationID(-1); + } + + // set pixel layer ID + xAODSiHit->setPixelLayerID(hitLink%4); + + } else { + ATH_MSG_WARNING("Unrecognised value in hitLink = " << hitLink); + xAODSiHit->setStationID(-1); + xAODSiHit->setPixelLayerID(-1); + } // end of switch + + ATH_MSG_DEBUG("Filled information about station and detector in xAODSiHit object"); + + xAODSiHit->setPixelColIDChip( data->Get_column() ); + xAODSiHit->setPixelRowIDChip( data->Get_row() ); + + const unsigned int ToT_value = data->Get_ToT(); + xAODSiHit->setTimeOverThreshold(ToT_value); + xAODSiHit->setDepositedCharge(1909 + ToT_value * 363 + ToT_value * ToT_value * 141); + + ATH_MSG_DEBUG("Filled xAOD::AFPSiHit"); + } // end of if else (hitLink == 12 || hitLink == 13) + + } // end of for over RawData_Collection_Beg using p_RawData_Beg } // end of for over container using RawData_Collection_Beg