diff --git a/macro/geometry/check_media.C b/macro/geometry/check_media.C index 06ecdaf43472ca81f16a0ab2d9508be8a8474799..76bf0bf3eb0af10ff559a45c4ca68d3249a31e7b 100644 --- a/macro/geometry/check_media.C +++ b/macro/geometry/check_media.C @@ -10,8 +10,10 @@ // a node gets a wrong media information. // Forward declaration -std::pair<int, int> loop_over_nodes(const std::vector<std::pair<TString, TString>>&, TString&, TString&); -std::pair<int, int> CheckGeometry(TString); +std::pair<int, int> loop_over_nodes(const std::vector<std::pair<TString, TString>>&, TString&, TString&, + TString mvdPrefix = ""); +std::pair<int, int> CheckGeometry(TString, TString mvdPrefix = ""); +std::pair<int, int> CheckMvd(TGeoNode* pipeNode, TString pipeName); void check_media(const char* dataset = "test") { @@ -35,6 +37,7 @@ void check_media(const char* dataset = "test") TGeoNode* node = static_cast<TGeoNode*>(nodes->At(iNode)); TString nodename = node->GetName(); if (nodename.Contains("target")) continue; + std::cout << std::endl; std::cout << "Checking node " << nodename << std::endl; std::pair<int, int> retval = CheckGeometry(nodename); if (-1 == retval.second) { @@ -44,6 +47,16 @@ void check_media(const char* dataset = "test") wrong_media += retval.second; std::cout << "Checked " << retval.first << " sub nodes from " << nodename << " and found " << retval.second << " with wrongly assigned media" << std::endl; + + // Special handling of MVD which is attached inside the vaccuum of one of the beampipes + if (nodename.Contains("pipe")) { + std::pair<int, int> retval = CheckMvd(node, nodename); + if (-1 == retval.second) { + ++missing_file; + continue; + } + wrong_media += retval.second; + } } if (0 == wrong_media && 0 == missing_file) { @@ -60,7 +73,7 @@ void check_media(const char* dataset = "test") RemoveGeoManager(); } -std::pair<int, int> CheckGeometry(TString geoname) +std::pair<int, int> CheckGeometry(TString geoname, TString mvdPrefix) { // All TOF geometries v16c have the equal internal structure, // only the position in the cave is different so we use the @@ -98,7 +111,7 @@ std::pair<int, int> CheckGeometry(TString geoname) infile->GetObject("CbmMediaList", matlistPtr); const std::vector<std::pair<TString, TString>>& matlist = matlistPtr->GetVector(); - std::pair<int, int> retval = loop_over_nodes(matlist, substitution, toReplace); + std::pair<int, int> retval = loop_over_nodes(matlist, substitution, toReplace, mvdPrefix); infile->Close(); @@ -106,17 +119,16 @@ std::pair<int, int> CheckGeometry(TString geoname) } std::pair<int, int> loop_over_nodes(const std::vector<std::pair<TString, TString>>& matlist, TString& substitution, - TString& toReplace) + TString& toReplace, TString mvdPrefix) { int media_checked {0}; int wrong_media {0}; TGeoNode* node {nullptr}; TString medName {""}; TString nodename {""}; - std::cout << std::endl; for (auto material : matlist) { media_checked++; - nodename = material.first; + nodename = mvdPrefix + material.first; if (toReplace.Length() > 0) { nodename = material.first.ReplaceAll(toReplace, substitution); } if (gGeoManager->cd(nodename)) { node = gGeoManager->GetCurrentNode(); @@ -135,3 +147,42 @@ std::pair<int, int> loop_over_nodes(const std::vector<std::pair<TString, TString } return std::make_pair(media_checked, wrong_media); } + +std::pair<int, int> CheckMvd(TGeoNode* pipeNode, TString pipeName) +{ + int media_checked {0}; + int wrong_media {0}; + + TObjArray* nodes = pipeNode->GetNodes(); + for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) { + TGeoNode* node = static_cast<TGeoNode*>(nodes->At(iNode)); + TString nodename = node->GetName(); + if (nodename.Contains("pipevac1")) { + TObjArray* subnodes = node->GetNodes(); + Int_t iNbSubNodes = (subnodes ? subnodes->GetEntriesFast() : 0); + for (Int_t iSubNode = 0; iSubNode < iNbSubNodes; ++iSubNode) { + TGeoNode* subnode = static_cast<TGeoNode*>(subnodes->At(iSubNode)); + TString subnodename = subnode->GetName(); + if (subnodename.Contains("MVD") || subnodename.Contains("Mvd") || subnodename.Contains("mvd")) { + TString sMvdNodePath = pipeName + "/" + nodename + "/" + subnodename; + std::cout << std::endl; + std::cout << "MVD geometry found under node " << sMvdNodePath << std::endl; + std::cout << "Checking node " << subnodename << std::endl; + std::cout << "Not handled/checked properly for now as no way to extract version tag" << std::endl; + + /// TODO: find a way to load/detect the MDV geometry tag, maybe from setup file? + std::cout << "Checking node " << subnodename << std::endl; + TString sMvdMother = gGeoManager->GetTopNode()->GetName(); + sMvdMother += "/" + pipeName + "/" + nodename + "/"; + std::pair<int, int> retval = CheckGeometry(subnodename, sMvdMother); + media_checked += retval.first; + wrong_media += retval.second; + + std::cout << "Checked " << media_checked << " sub-nodes from " << sMvdNodePath << " and found " << wrong_media + << " with wrongly assigned media" << std::endl; + } + } + } + } + return std::make_pair(media_checked, wrong_media); +} diff --git a/macro/geometry/create_medialist.C b/macro/geometry/create_medialist.C index f083944b023bc35986a9c240b690e2ed18f105cf..d77a2efca510d163711a57a63a5b1a3fa1f76584 100644 --- a/macro/geometry/create_medialist.C +++ b/macro/geometry/create_medialist.C @@ -16,6 +16,10 @@ void create_medialist(TString inFileName = "", bool removegeomgr = true) return; } gGeoManager = (TGeoManager*) f->Get("FAIRGeom"); + if (!gGeoManager) { + std::cout << "create_tgeonode_list: FAIRGeom not found in geometry file " << inFileName << std::endl; + return; + } } CbmMediaList matlist; @@ -31,9 +35,17 @@ void create_medialist(TString inFileName = "", bool removegeomgr = true) } TGeoNode* node = static_cast<TGeoNode*>(nodes->At(0)); TString TopNodeName {node->GetName()}; + + // Detect MVD geometries which need special treatment to be later checked while in pipe vacuum + bool bMvd = false; + if (TopNodeName.Contains("MVD") || TopNodeName.Contains("Mvd") || TopNodeName.Contains("mvd")) { + std::cout << "MVD detected, stripping path until top node as later attached in pipe vaccuum" << std::endl; + bMvd = true; + } + // Replace the trailing _1 by _0 which is the correct number in the full geometry TopNodeName.Replace(TopNodeName.Length() - 1, 1, "0"); - Path = Path + TopNodeName + "/"; + Path = (bMvd ? "" : Path) + TopNodeName + "/"; std::cout << "{\"" << Path << "\", \"" << node->GetMedium()->GetName() << "\"}," << std::endl; matlist.AddEntry(Path, node->GetMedium()->GetName()); diff --git a/macro/run/CMakeLists.txt b/macro/run/CMakeLists.txt index 7a382ad69d1ab63f8dd5a1ae8beae10b7cdb5f74..1afe4f8cdcad5863c7efdca8fbf8ca9a55022593 100644 --- a/macro/run/CMakeLists.txt +++ b/macro/run/CMakeLists.txt @@ -8,6 +8,8 @@ GENERATE_ROOT_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/run/run_qa.C) GENERATE_EXE_SCRIPT(${CBMROOT_BINARY_DIR}/bin cbmreco_offline) Set(MACRO_DIR ${CMAKE_CURRENT_BINARY_DIR}) + +GENERATE_CBM_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/macro/geometry/check_media.C ${MACRO_DIR}) # ============================================================================ @@ -44,11 +46,11 @@ math(EXPR nBeam "${nEvents} * 3") # ===== Define the different setups to be tested with ==================== if(NOT ${CBM_TEST_MODEL} MATCHES Experimental ) List(APPEND cbm_setup - sis100_hadron + sis100_hadron sis100_electron - sis100_muon_lmvm + sis100_muon_lmvm sis100_muon_jpsi - sis300_electron + sis300_electron ) else() List(APPEND cbm_setup sis100_electron sis100_muon_jpsi) @@ -75,13 +77,13 @@ foreach(setup IN LISTS cbm_setup) elseif(setup MATCHES sis100_electron) set(sname s100e) elseif(setup MATCHES sis100_muon_lmvm) - set(sname s100m2) + set(sname s100m2) elseif(setup MATCHES sis100_muon_jpsi) - set(sname s100m3) + set(sname s100m3) elseif(setup MATCHES sis300_electron) - set(sname s300e) + set(sname s300e) else() - set(sname test) + set(sname test) endif() # --- Test run_tra_coll @@ -91,12 +93,22 @@ foreach(setup IN LISTS cbm_setup) add_test(${testname} ${MACRO_DIR}/run_tra_file.sh \"${input}\" ${nEvents} \"data/${sname}_coll\" \"${setup}\" kGeant3 ${randomSeed} kTRUE) set_tests_properties(${testname} PROPERTIES - TIMEOUT ${timeOutTime} - FAIL_REGULAR_EXPRESSION "segmentation violation" - PASS_REGULAR_EXPRESSION "Macro finished successfully" + TIMEOUT ${timeOutTime} + FAIL_REGULAR_EXPRESSION "segmentation violation" + PASS_REGULAR_EXPRESSION "Macro finished successfully" FIXTURES_REQUIRED run_cleanup - FIXTURES_SETUP fixt_tra_coll_${setup} - RESOURCE_LOCK collParDb_${setup} + FIXTURES_SETUP fixt_tra_coll_${setup} + RESOURCE_LOCK collParDb_${setup} + ) + + set(testname run_check_media_${sname}) + Add_Test(${testname} ${MACRO_DIR}/check_media.sh \"data/${sname}_coll\") + set_tests_properties(${testname} PROPERTIES + TIMEOUT ${timeOutTime} + FAIL_REGULAR_EXPRESSION "segmentation violation" + PASS_REGULAR_EXPRESSION "Test Passed;All ok" + FIXTURES_REQUIRED fixt_tra_coll_${setup} + FIXTURES_SETUP fixt_check_media_${setup} ) # --- Test run_tra_sign @@ -137,7 +149,7 @@ foreach(setup IN LISTS cbm_setup) TIMEOUT ${timeOutTime} FAIL_REGULAR_EXPRESSION "segmentation violation" PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_REQUIRED fixt_tra_coll_${setup} + FIXTURES_REQUIRED fixt_check_media_${setup} FIXTURES_SETUP fixt_digi_ev_${setup} RESOURCE_LOCK collParDb_${setup} ) @@ -155,7 +167,7 @@ foreach(setup IN LISTS cbm_setup) TIMEOUT ${timeOutTime} FAIL_REGULAR_EXPRESSION "segmentation violation" PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_REQUIRED "fixt_tra_coll_${setup};fixt_tra_sign_${setup};fixt_tra_beam_${setup}" + FIXTURES_REQUIRED "fixt_check_media_${setup};fixt_tra_sign_${setup};fixt_tra_beam_${setup}" FIXTURES_SETUP fixt_digi_ts_${setup} RESOURCE_LOCK collParDb_${setup} ) @@ -307,7 +319,7 @@ foreach(setup IN LISTS cbm_setup) TIMEOUT ${timeOutTime} FAIL_REGULAR_EXPRESSION "segmentation violation" PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_REQUIRED "fixt_tra_coll_${setup};fixt_digi_ts_${setup};fixt_reco_ts_eb_real_${setup}" + FIXTURES_REQUIRED "fixt_check_media_${setup};fixt_digi_ts_${setup};fixt_reco_ts_eb_real_${setup}" FIXTURES_SETUP fixt_qa_${setup} RESOURCE_LOCK collParDb_${setup} )