18 #include <THashList.h>
21 #if !defined(RINGER_STANDALONE) && !defined(XAOD_STANDALONE)
22 # include "GaudiKernel/SystemOfUnits.h"
23 using namespace Gaudi::Units;
26 #define protected public
27 #define private public
28 # include "RingerSelectorTools/AsgElectronRingerSelector.h"
34 #include "RingerSelectorTools/AsgElectronRingerSelector.h"
36 MsgStream
msg(
"testRead");
40 "================================================================================"
45 #include "RingerSelectorTools/procedures/NeuralNetwork.h"
46 #include "RingerSelectorTools/procedures/Thresholds.h"
47 #include "RingerSelectorTools/tools/IOHelperFcns.h"
48 #include "RingerSelectorTools/tools/cxx/remove_pointer.h"
55 template<
class wrapper_t >
62 template<
typename wrapperBase_t>
74 msg << MSG::INFO <<
"Reading discriminator using interface "
75 "without using normalization." <<
endmsg;
87 typename Ringer::remove_pointer<decltype(basicWrapper)>
::type
88 >( basicWrapper,
"basicWrapper.root" );
97 typename Ringer::remove_pointer<decltype(basicEtaDepWrapper)>
::type
98 >( basicEtaDepWrapper,
"basicEtaDepWrapper.root");
107 typename Ringer::remove_pointer<decltype(basicEtDepWrapper)>
::type
108 >( basicEtDepWrapper,
"basicEtDepWrapper.root");
117 typename Ringer::remove_pointer<decltype(basicEtaEtDepWrapper)>
::type
118 >( basicEtaEtDepWrapper,
"basicEtaEtDepWrapper.root");
121 msg.setLevel(MSG::ERROR);
124 msg << MSG::INFO <<
"Reading discriminator with wrong types!" <<
endmsg;
134 typename Ringer::remove_pointer<decltype(basicWrapperWrong)>
::type
135 >( basicWrapperWrong,
"basicWrapper.root" );
144 typename Ringer::remove_pointer<decltype(basicEtaDepWrapperWrong)>
::type
145 >( basicEtaDepWrapperWrong,
"basicEtaDepWrapper.root");
154 typename Ringer::remove_pointer<decltype(basicEtDepWrapperWrong)>
::type
155 >( basicEtDepWrapperWrong,
"basicEtDepWrapper.root");
164 typename Ringer::remove_pointer<decltype(basicEtaEtDepWrapperWrong)>
::type
165 >( basicEtaEtDepWrapperWrong,
"basicEtaEtDepWrapper.root");
170 msg << MSG::INFO <<
"Reading pre-processings!" <<
endmsg;
181 typename Ringer::remove_pointer<decltype(basicPPWrapper)>
::type
182 >( basicPPWrapper,
"basicPPWrapper.root");
191 typename Ringer::remove_pointer<decltype(basicEtaDepPPWrapper)>
::type
192 >( basicEtaDepPPWrapper,
"basicEtaDepPPWrapper.root");
201 typename Ringer::remove_pointer<decltype(basicEtDepPPWrapper)>
::type
202 >( basicEtDepPPWrapper,
"basicEtDepPPWrapper.root");
211 typename Ringer::remove_pointer<decltype(basicEtEtaDepPPWrapper)>
::type
212 >( basicEtEtaDepPPWrapper,
"basicEtEtaDepPPWrapper.root");
221 typename Ringer::remove_pointer<decltype(basicEtEtaTrackCalDepPPWrapper)>
::type
222 >( basicEtEtaTrackCalDepPPWrapper,
"basicEtEtaTrackCalDepPPWrapper.root");
231 typename Ringer::remove_pointer<decltype(basicEtEtaTrackCalPatTypeDepPPWrapper)>
::type
232 >( basicEtEtaTrackCalPatTypeDepPPWrapper,
"basicEtEtaTrackCalPatTypeDepPPWrapper.root");
241 typename Ringer::remove_pointer<decltype(basicEtaEtSectionDepPPWrapper)>
::type
242 >( basicEtaEtSectionDepPPWrapper,
"basicEtaEtSectionDepPPWrapper.root");
251 typename Ringer::remove_pointer<decltype(basicEtaEtLayerDepPPWrapper)>
::type
252 >( basicEtaEtLayerDepPPWrapper,
"basicEtaEtLayerDepPPWrapper.root");
261 typename Ringer::remove_pointer<decltype(basicNorm1Wrapper)>
::type
262 >( basicNorm1Wrapper,
"basicNorm1Wrapper.root");
271 typename Ringer::remove_pointer<decltype(basicLayerDepNorm1Wrapper)>
::type
272 >( basicLayerDepNorm1Wrapper,
"basicLayerDepNorm1Wrapper.root");
281 typename Ringer::remove_pointer<decltype(basicNorm2Wrapper)>
::type
282 >( basicNorm2Wrapper,
"basicNorm2Wrapper.root");
291 typename Ringer::remove_pointer<decltype(basicSqrtWrapper)>
::type
292 >( basicSqrtWrapper,
"basicSqrtWrapper.root");
301 typename Ringer::remove_pointer<decltype(basicConstantValueWrapper)>
::type
302 >( basicConstantValueWrapper,
"basicConstantValueWrapper.root");
311 typename Ringer::remove_pointer<decltype(basicMevToGevWrapper)>
::type
312 >( basicMevToGevWrapper,
"basicMevToGevWrapper.root");
321 typename Ringer::remove_pointer<decltype(basicSequentialWrapper)>
::type
322 >( basicSequentialWrapper,
"basicSequentialWrapper.root");
331 typename Ringer::remove_pointer<decltype(basicSpherizationWrapper)>
::type
332 >( basicSpherizationWrapper,
"basicSpherizationWrapper.root");
341 typename Ringer::remove_pointer<decltype(basicMinMaxWrapper)>
::type
342 >( basicMinMaxWrapper,
"basicMinMaxWrapper.root");
347 msg << MSG::INFO <<
"Reading discriminators with pre-processings!" <<
endmsg;
359 typename Ringer::remove_pointer<decltype(randomNorm1PPDiscrWrapper)>
::type
360 >( randomNorm1PPDiscrWrapper,
"randomNorm1PPDiscrWrapper.root");
369 typename Ringer::remove_pointer<decltype(randomDepPPrandomDepPPDiscrWrapper)>
::type
370 >( randomDepPPrandomDepPPDiscrWrapper,
"randomDepPPrandomDepPPDiscrWrapper.root");
375 msg << MSG::INFO <<
"Reading segmented discriminator PP wrappers:" <<
endmsg;
387 typename Ringer::remove_pointer<decltype(randomDepPPrandomDepPPDiscrSegmentedWrapper)>
::type
388 >( randomDepPPrandomDepPPDiscrSegmentedWrapper,
"randomDepPPrandomDepPPDiscrSegmentedWrapper.root");
392 msg << MSG::INFO <<
"Reading specialized discriminator:" <<
endmsg;
404 typename Ringer::remove_pointer<decltype(NNWrapper)>
::type
405 >( NNWrapper,
"NNWrapper.root");
414 typename Ringer::remove_pointer<decltype(FullDepNNWrapper)>
::type
415 >( FullDepNNWrapper,
"FullDepNNWrapper.root");
419 msg << MSG::INFO <<
"Reading specialized discriminator with PP wrappers:" <<
endmsg;
431 typename Ringer::remove_pointer<decltype(Norm1NNWrapper)>
::type
432 >( Norm1NNWrapper,
"Norm1NNWrapper.root");
441 typename Ringer::remove_pointer<decltype(Norm1Norm1FullDepNNWrapper)>
::type
442 >( Norm1Norm1FullDepNNWrapper,
"Norm1Norm1FullDepNNWrapper.root");
446 msg << MSG::INFO <<
"Reading threshold wrappers:" <<
endmsg;
457 typename Ringer::remove_pointer<decltype(basicThres)>
::type
458 >( basicThres,
"basicThres.root");
466 typename Ringer::remove_pointer<decltype(basicEtaDepThres)>
::type
467 >( basicEtaDepThres,
"basicEtaDepThres.root");
475 typename Ringer::remove_pointer<decltype(basicEtDepThres)>
::type
476 >( basicEtDepThres,
"basicEtDepThres.root");
484 typename Ringer::remove_pointer<decltype(basicEtaEtDepThres)>
::type
485 >( basicEtaEtDepThres,
"basicEtaEtDepThres.root");
489 msg << MSG::INFO <<
"Reading specialized threshold wrappers:" <<
endmsg;
500 typename Ringer::remove_pointer<decltype(uniqueThres)>
::type
501 >( uniqueThres,
"uniqueThres.root");
509 typename Ringer::remove_pointer<decltype(uniqueEtaDepThres)>
::type
510 >( uniqueEtaDepThres,
"uniqueEtaDepThres.root");
518 typename Ringer::remove_pointer<decltype(uniqueEtDepThres)>
::type
519 >( uniqueEtDepThres,
"uniqueEtDepThres.root");
527 typename Ringer::remove_pointer<decltype(uniqueEtaEtDepThres)>
::type
528 >( uniqueEtaEtDepThres,
"uniqueEtaEtDepThres.root");
533 msg << MSG::INFO <<
"Special reading" <<
endmsg;
539 readCollectionFromFile<IDiscrWrapper>(
"Norm1NNWrapper.root");
541 readCollectionFromFile<IDiscrWrapper>(
"Norm1Norm1FullDepNNWrapper.root");
547 msg << MSG::INFO <<
"Finished!" <<
endmsg;
554 template<
class wrapper_t >
558 msg << MSG::INFO <<
"Reading wrapper: " << wrapper_t::staticFullName()
562 TFile wrapperFile(
fileName,
"READ");
563 wrapperFile.ReadAll();
564 TDirectory *baseDir = wrapperFile.GetDirectory(
"");
566 std::shared_ptr<THashList> wrapperDirList(
nullptr);
567 if ( !( wrapperDirList = IOHelperFcns::getDirList(baseDir) ) ) {
568 throw std::runtime_error(std::string(
"There are no directories available"));
571 msg << MSG::INFO <<
"Number(s) of folder(s) within this TFile is "
572 << wrapperDirList->GetSize()
577 TIter iter( wrapperDirList.get() );
578 TDirectory* wrapperDir(
nullptr);
580 bool foundDir =
false;
582 while ( (wrapperDir =
static_cast<TDirectoryFile*
>(iter())) ){
583 if ( wrapperDir->GetName() ==
584 ( std::string(wrapper_t::wrapName) +
585 IOHelperFcns::makeIdxStr(0) ) )
587 msg << MSG::INFO <<
"Found directory named "
588 << wrapperDir->GetName() <<
endmsg;
595 throw std::runtime_error(std::string(
"Couldn't find the wrapper directory"));
600 if (wrapper ==
nullptr){
601 throw std::runtime_error(std::string(
"Returned void pointer."));
605 wrapper->setMsgStream(&
msg);
607 msg << MSG::INFO <<
"Printing wrapper " <<
endmsg;
612 }
catch (
const std::runtime_error &
e){
613 msg << MSG::ERROR <<
"Couldn't read due to error: "
622 template<
typename wrapperBase_t>
629 typename wrapperBase_t::WrapperCollection
col;
633 for (
auto *wrapper :
col ) {
635 msg << MSG::INFO <<
"Printing wrapper " << wrapper->fullName()
636 <<
" at position " << IOHelperFcns::makeIdxStr(
counter++) <<
endmsg;
637 wrapper->setMsgStream(&
msg);wrapper->print();
643 msg << MSG::INFO <<
"File configuration: " <<
endmsg;
644 AsgElectronRingerSelector::IOConfStruct ioConf;
645 AsgElectronRingerSelector::retrieveFileConf(
fileName, ioConf );
646 AsgElectronRingerSelector::printConf(ioConf, &
msg);
657 IThresWrapper *wrapper;
659 if (wrapper) {wrapper->setMsgStream(&
msg); wrapper->print();}
660 else msg << MSG::ERROR <<
"Couldn't print wrapper on file " <<
fileName <<
endmsg;