diff --git a/Detectors/FIT/T0/macros/readHitsDigits.C b/Detectors/FIT/T0/macros/readHitsDigits.C deleted file mode 100644 index 18a5cbff5eead..0000000000000 --- a/Detectors/FIT/T0/macros/readHitsDigits.C +++ /dev/null @@ -1,93 +0,0 @@ -#if !defined(__CLING__) || defined(__ROOTCLING__) -#include "DataFormatsFITT0/Digit.h" -#include "DataFormatsFITT0/HitType.h" -#include -#include -#include -void readHitsDigits() -{ - using namespace o2::t0; - // using namespace o2::t0::Digit; - - // Create histograms - TDirectory* cwd = gDirectory; - gDirectory = 0x0; - - TH2F* hMultHit = new TH2F("hMultHits", "photons Hits ", 210, 0, 210, 500, 0, 5000); - TH2F* hTimeHitA = new TH2F("hTimeAhit", "Time Hits", 210, 0, 210, 1000, 11, 12); - TH2F* hTimeHitC = new TH2F("hTimeChit", "Time Hits", 210, 0, 210, 1000, 2.8, 3.8); - TH2F* hMultDig = new TH2F("hMultDig", "photons Digits ", 210, 0, 210, 500, 0, 20); - TH2F* hTimeDig = new TH2F("hTimeDig", "Time Digits", 210, 0, 210, 100, -1, 1); - - gDirectory = cwd; - - TFile* fhit = new TFile("o2sim.root"); - TTree* hitTree = (TTree*)fhit->Get("o2sim"); - std::vector* hitArray = nullptr; - hitTree->SetBranchAddress("T0Hit", &hitArray); - Int_t nevH = hitTree->GetEntries(); // hits are stored as one event per entry - // std::cout << "Found " << nevH << " events with hits " << std::endl; - - Double_t hit_time[240]; - Int_t countE[240]; - // Event ------------------------- LOOP - for (Int_t ievent = 0; ievent < nevH; ievent++) { - hitTree->GetEntry(ievent); - for (int ii = 0; ii < 240; ii++) { - countE[ii] = 0; - hit_time[ii] = 0; - } - for (auto& hit : *hitArray) { - Int_t detID = hit.GetDetectorID(); - hit_time[detID] = hit.GetTime(); - hTimeHitA->Fill(detID, hit_time[detID]); - hTimeHitC->Fill(detID, hit_time[detID]); - countE[detID]++; - } - for (int ii = 0; ii < 208; ii++) { - if (countE[ii] > 100) { - hMultHit->Fill(ii, countE[ii]); - // std::cout<Get("o2sim"); - std::vector* digArr = new std::vector; - digTree->SetBranchAddress("T0Digit", &digArr); - Int_t nevD = digTree->GetEntries(); // digits in cont. readout may be grouped as few events per entry - // std::cout << "Found " << nevD << " events with digits " << std::endl; - Float_t cfd[208], amp[208], part[208]; - for (Int_t iev = 0; iev < nevD; iev++) { - digTree->GetEvent(iev); - for (const auto& digit : *digArr) { - for (int ii = 0; ii < 208; ii++) { - cfd[ii] = amp[ii] = 0; - } - Double_t evtime = digit.getTime(); - for (const auto& d : digit.getChDgData()) { - Int_t mcp = d.ChId; - cfd[mcp] = d.CFDTime - evtime - 12.5; - amp[mcp] = d.QTCAmpl; - part[mcp] = d.numberOfParticles; - // cout << iev << " " << mcp << " " << cfd[mcp] << " " << amp[mcp] << " " << part[mcp] << endl; - hMultDig->Fill(Float_t(mcp), amp[mcp]); - hTimeDig->Fill(Float_t(mcp), cfd[mcp]); - } - } - } - TFile* Hfile = new TFile("FigFit_hits_pp.root", "RECREATE"); - printf("Writting histograms to root file \n"); - Hfile->cd(); - //Create a canvas, set the view range, show histograms - // TCanvas *c1 = new TCanvas("c1","Alice T0 Time ",400,10,600,600); - hTimeHitA->Write(); - hTimeHitC->Write(); - hMultHit->Write(); - hTimeDig->Write(); - hMultDig->Write(); - -} // end of macro -#endif diff --git a/Detectors/FIT/T0/macros/run_reco_t0.C b/Detectors/FIT/T0/macros/run_reco_t0.C deleted file mode 100644 index ad842a3109942..0000000000000 --- a/Detectors/FIT/T0/macros/run_reco_t0.C +++ /dev/null @@ -1,71 +0,0 @@ -#if !defined(__CLING__) || defined(__ROOTCLING__) -#include -#include -#include -#include -#include -#include -#include - -#include "FairLogger.h" - -#include "T0Reconstruction/CollisionTimeRecoTask.h" -#include "DataFormatsFITT0/RecPoints.h" -#include "DataFormatsFITT0/Digit.h" -#endif - -void run_reco_t0(std::string inpudDig = "t0digits.root", - std::string outName = "o2reco_t0.root", - std::string inputGRP = "o2sim_grp.root") -{ - - // Initialize logger - FairLogger* logger = FairLogger::GetLogger(); - logger->SetLogVerbosityLevel("LOW"); - logger->SetLogScreenLevel("DEBUG"); - - // Setup timer - TStopwatch timer; - - TFile* fdig = TFile::Open("t0digits.root"); - std::cout << " Open digits file " << std::endl; - TTree* digTree = (TTree*)fdig->Get("o2sim"); - digTree->Print(); - std::vector* digits = new std::vector; - digTree->SetBranchAddress("T0Digit", &digits); - Int_t nevD = digTree->GetEntries(); // digits in cont. readout may be grouped as few events per entry - std::cout << "Found " << nevD << " events with digits " << std::endl; - - std::vector* recPointsP = new std::vector; - - TFile outFile(outName.c_str(), "recreate"); - TTree outTree("o2sim", "T0RecPoints"); - outTree.Branch("T0Cluster", &recPointsP); - - o2::t0::CollisionTimeRecoTask recoFIT; - timer.Start(); - for (int iEv = 0; iEv < nevD; iEv++) { - digTree->GetEntry(iEv); - recPointsP->resize(digits->size()); - for (size_t collID = 0; collID < digits->size(); ++collID) - recoFIT.Process((*digits)[collID], (*recPointsP)[collID]); - outTree.Fill(); - } - - outTree.Print(); - outFile.ls(); - timer.Stop(); - outTree.Write(); - Double_t rtime = timer.RealTime(); - Double_t ctime = timer.CpuTime(); - - Float_t cpuUsage = ctime / rtime; - std::cout << ""; - std::cout << cpuUsage; - std::cout << "" << std::endl; - std::cout << "Macro finished succesfully." << std::endl; - - std::cout << "Real time " << rtime << " s, CPU time " << ctime - << "s" << std::endl - << std::endl; -} diff --git a/Detectors/ITSMFT/ITS/macros/test/CMakeLists.txt b/Detectors/ITSMFT/ITS/macros/test/CMakeLists.txt index 849aed4d28116..fcd98bb2415c2 100644 --- a/Detectors/ITSMFT/ITS/macros/test/CMakeLists.txt +++ b/Detectors/ITSMFT/ITS/macros/test/CMakeLists.txt @@ -28,6 +28,11 @@ o2_add_test_root_macro(CheckDigits.C O2::DetectorsBase LABELS its) +o2_add_test_root_macro(CheckLookUp.C + PUBLIC_LINK_LIBRARIES O2::ITSMFTReconstruction + O2::DataFormatsITSMFT + LABELS its) + o2_add_test_root_macro(CheckLUtime.C PUBLIC_LINK_LIBRARIES O2::ITSMFTReconstruction O2::DataFormatsITSMFT diff --git a/cmake/O2AddTestRootMacro.cmake b/cmake/O2AddTestRootMacro.cmake index d89466e616073..6dbc5f11c59dd 100644 --- a/cmake/O2AddTestRootMacro.cmake +++ b/cmake/O2AddTestRootMacro.cmake @@ -47,7 +47,7 @@ include_guard() # give us, _transitively_, all the libraries directories. And computing them # ourselves (recursively) is quite time consuming... # -function(o2_add_test_root_macro) +function(o2_add_test_root_macro macro) if(NOT BUILD_TESTING) return() @@ -70,7 +70,8 @@ function(o2_add_test_root_macro) FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS}") endif() - get_filename_component(macroFileName ${ARGV0} ABSOLUTE) + get_filename_component(macroFileName ${macro} ABSOLUTE) + if(NOT EXISTS ${macroFileName}) message( diff --git a/cmake/O2GetListOfMacros.cmake b/cmake/O2GetListOfMacros.cmake new file mode 100644 index 0000000000000..d032e24a506ad --- /dev/null +++ b/cmake/O2GetListOfMacros.cmake @@ -0,0 +1,22 @@ +# Copyright CERN and copyright holders of ALICE O2. This software is distributed +# under the terms of the GNU General Public License v3 (GPL Version 3), copied +# verbatim in the file "COPYING". +# +# See http://alice-o2.web.cern.ch/license for full licensing information. +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization or +# submit itself to any jurisdiction. + +include_guard() + +# +# o2_get_list_of_macros fills ${varname} with the list of macros (*.C files) +# found in directory ${dir} +# +function(o2_get_list_of_macros dir varname) + file(GLOB_RECURSE listOfMacros RELATIVE ${CMAKE_SOURCE_DIR} ${dir}/*.C) + # Case sensitive filtering of .C files (to avoid .c files on Mac) + list(FILTER listOfMacros INCLUDE REGEX "^.*\\.C$") + set(${varname} ${listOfMacros} PARENT_SCOPE) +endfunction() diff --git a/cmake/O2ReportNonTestedMacros.cmake b/cmake/O2ReportNonTestedMacros.cmake index 2fd32000d4767..6a204039bff38 100644 --- a/cmake/O2ReportNonTestedMacros.cmake +++ b/cmake/O2ReportNonTestedMacros.cmake @@ -10,28 +10,49 @@ include_guard() +include(O2RootMacroExclusionList) +include(O2GetListOfMacros) + +# +# Loop over the Root macros that exists in the repository and check whether +# there is one (or two) test for that macro (i.e. the o2_add_test_root_macro +# function has been called). If the macro is not tested and is not part of a +# known exclusion list (defined in O2RootMacroExclusionList.cmake file), then a +# FATAL_ERROR is issued # -# Print a list of the Root macros that exists in the repository but for which -# the o2_add_test_root_macro function has not been called. +# (unless the DO_NOT_FAIL parameter is given, in which case those cases are +# simply reported). # function(o2_report_non_tested_macros) - file(GLOB_RECURSE listOfMacros RELATIVE ${CMAKE_SOURCE_DIR} *.C) + + cmake_parse_arguments(PARSE_ARGV + 0 + A + "DO_NOT_FAIL;QUIET" + "" + "") + + o2_get_list_of_macros(${CMAKE_SOURCE_DIR} listOfMacros) + list(LENGTH listOfMacros nmacros) foreach(m ${listOfMacros}) if(NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS) - list(APPEND notTested ${m}) + list(APPEND notTestedLoading ${m}) endif() if(NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS_COMPILED) list(APPEND notTestedCompiled ${m}) endif() endforeach() - list(LENGTH notTested n) + list(LENGTH notTestedLoading n) list(LENGTH notTestedCompiled nc) + list(LENGTH O2_ROOT_MACRO_EXCLUSION_LIST ne) if(${n} GREATER 0) - message( - STATUS - "WARNING : ${n}(L) and ${nc}(C) over ${nmacros} Root macros are NOT tested (L for loading, C for compilation) " - ) + if(NOT A_QUIET) + message( + STATUS + "WARNING : ${n}(L) and ${nc}(C) over ${nmacros} Root macros are NOT tested (L for loading, C for compilation). ${ne} are exempted (E)." + ) + endif() message(STATUS) foreach(m ${listOfMacros}) set(loading " ") @@ -42,9 +63,24 @@ function(o2_report_non_tested_macros) if(${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS_COMPILED) set(compile "C") endif() + if(${m} IN_LIST O2_ROOT_MACRO_EXCLUSION_LIST) + set(exempted "E") + endif() if(NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS_COMPILED - OR NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS) - message(STATUS "[${loading}] [${compile}] ${m}") + OR NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS + OR ${m} IN_LIST O2_ROOT_MACRO_EXCLUSION_LIST) + if(NOT A_QUIET) + message(STATUS "[${loading}] [${compile}] [${exempted}] ${m}") + endif() + endif() + if(NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS + AND NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS_COMPILED + AND NOT ${m} IN_LIST O2_ROOT_MACRO_EXCLUSION_LIST) + if(NOT A_DO_NOT_FAIL) + message(FATAL_ERROR "Macro ${m} should be tested") + else() + message(WARNING "Macro ${m} is not tested at all !!!") + endif() endif() endforeach() message(STATUS) diff --git a/cmake/O2RootMacroExclusionList.cmake b/cmake/O2RootMacroExclusionList.cmake new file mode 100644 index 0000000000000..fd0959ffe2eb4 --- /dev/null +++ b/cmake/O2RootMacroExclusionList.cmake @@ -0,0 +1,70 @@ +# Copyright CERN and copyright holders of ALICE O2. This software is distributed +# under the terms of the GNU General Public License v3 (GPL Version 3), copied +# verbatim in the file "COPYING". +# +# See http://alice-o2.web.cern.ch/license for full licensing information. +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization or +# submit itself to any jurisdiction. + +include_guard() + +include(O2GetListOfMacros) + +# +# List of macros that are allowed (hopefully temporarily) to escape testing. +# + +list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST + CCDB/example/fill_local_ocdb.C + DataFormats/simulation/test/checkStack.C + Detectors/ITSMFT/ITS/macros/EVE/rootlogon.C + Detectors/ITSMFT/ITS/macros/test/rootlogon.C + Detectors/MUON/MCH/Simulation/macros/rootlogon.C + Detectors/Passive/macro/PutFrameInTop.C + Detectors/TPC/reconstruction/macro/addInclude.C + Detectors/TPC/reconstruction/macro/getTPCTransformationExample.C + GPU/GPUTracking/Merger/macros/checkPropagation.C + GPU/GPUTracking/Merger/macros/fitPolynomialFieldIts.C + GPU/GPUTracking/Merger/macros/fitPolynomialFieldTpc.C + GPU/GPUTracking/Merger/macros/fitPolynomialFieldTrd.C + GPU/GPUTracking/Standalone/tools/createGeo.C + GPU/GPUTracking/Standalone/tools/createLUT.C + GPU/GPUTracking/Standalone/tools/dump.C + GPU/GPUTracking/TRDTracking/macros/checkDbgOutput.C + GPU/TPCFastTransformation/macro/createTPCFastTransform.C + GPU/TPCFastTransformation/macro/generateTPCDistortionNTuple.C + GPU/TPCFastTransformation/macro/initTPCcalibration.C + GPU/TPCFastTransformation/macro/loadlibs.C + GPU/TPCFastTransformation/macro/moveTPCFastTransform.C + Generators/share/external/hijing.C + macro/SetIncludePath.C + macro/loadExtDepLib.C + macro/load_all_libs.C + macro/putCondition.C + macro/rootlogon.C) + +if(NOT BUILD_SIMULATION) + # some complete sub_directories are not added to the build when not building + # simulation, so the corresponding o2_add_test_root_macro won't be called at + # all + o2_get_list_of_macros(${CMAKE_SOURCE_DIR}/macro macros) + list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST ${macros}) + o2_get_list_of_macros(${CMAKE_SOURCE_DIR}/Detectors/gconfig macros) + list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST ${macros}) +endif() + +if(NOT pythia6_FOUND) + list(APPEND O2_ROOT_MACRO_EXCLUSION_LIST Generators/share/external/pythia6.C) +endif() + +list(REMOVE_DUPLICATES O2_ROOT_MACRO_EXCLUSION_LIST) + +# check exclusion list contains only existing macros +foreach(m ${O2_ROOT_MACRO_EXCLUSION_LIST}) + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/${m}) + message(FATAL_ERROR "Exclusion list contains a non-existing macro : ${m}") + endif() +endforeach() +