Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New class TRestDetectorVetoReadout #81

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions inc/TRestDetectorVetoReadout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*************************************************************************
* This file is part of the REST software framework. *
* *
* Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
* For more information see http://gifna.unizar.es/trex *
* *
* REST is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* REST is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have a copy of the GNU General Public License along with *
* REST in $REST_PATH/LICENSE. *
* If not, see http://www.gnu.org/licenses/. *
* For the list of contributors see $REST_PATH/CREDITS. *
*************************************************************************/

#ifndef RestCore_TRestDetectorVetoReadout
#define RestCore_TRestDetectorVetoReadout

#include <TRestMetadata.h>

#include <iostream>

#include "TRestDetectorReadoutPlane.h"

class TRestDetectorVetoReadout : public TRestMetadata {
private:
std::string fGeometry;

std::vector<TRestDetectorReadoutPlane> fReadoutPlanes;

std::vector<std::string> fVetoVolumeNames;
std::vector<std::string> fVetoBoundaryVolumeNames; /// aux volume used to identify the readout plane
std::map<std::string, int> fVetoVolumeNamesToSignalIdMap;

public:
TRestDetectorVetoReadout();
TRestDetectorVetoReadout(const char* configFilename, const char* name);

void PrintMetadata() override;

ClassDefOverride(TRestDetectorVetoReadout, 1);
};

#endif
22 changes: 22 additions & 0 deletions src/TRestDetectorVetoReadout.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "TRestDetectorVetoReadout.h"

using namespace std;

ClassImp(TRestDetectorVetoReadout);

TRestDetectorVetoReadout::TRestDetectorVetoReadout(const char* configFilename, const char* name)
: TRestDetectorVetoReadout() {
// we call the base constructor instead of "Initialize" using constructor delegation
fConfigFileName = configFilename;
LoadConfigFromFile(fConfigFileName, name);
cout << "TRestDetectorVetoReadout::TRestDetectorVetoReadout: " << endl;
}

TRestDetectorVetoReadout::TRestDetectorVetoReadout() {
cout << "TRestDetectorVetoReadout::TRestDetectorVetoReadout: base" << endl;

SetSectionName(this->ClassName());
SetLibraryVersion(LIBRARY_VERSION);
}

void TRestDetectorVetoReadout::PrintMetadata() { cout << "Geometry: " << fGeometry << endl; }
6 changes: 6 additions & 0 deletions test/files/TRestDetectorVetoReadout.rml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<TRestDetectorVetoReadout name="vetoReadout">

<parameter name="geometry" value="/tmp/tmp.wzQlLMLurf/projects/iaxo/iaxo-geometry/gdml/IAXO-D1/Default.gdml"/>


</TRestDetectorVetoReadout>
35 changes: 35 additions & 0 deletions test/src/TRestDetectorVetoReadout.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#include <TRestDetectorVetoReadout.h>
#include <gtest/gtest.h>

#include <filesystem>

namespace fs = std::filesystem;

using namespace std;

const auto filesPath = fs::path(__FILE__).parent_path().parent_path() / "files";
const auto readoutDefaultRml = filesPath / "TRestDetectorVetoReadout.rml";

TEST(TRestDetectorVetoReadout, TestFiles) {
cout << "FrameworkCore test files path: " << filesPath << endl;

// Check dir exists and is a directory
EXPECT_TRUE(fs::is_directory(filesPath));
// Check it's not empty
EXPECT_TRUE(!fs::is_empty(filesPath));

// All used files in this tests
EXPECT_TRUE(fs::exists(readoutDefaultRml));
}

TEST(TRestDetectorVetoReadout, Default) {
TRestDetectorVetoReadout readout;

readout.PrintMetadata();
}

TEST(TRestDetectorVetoReadout, FromRml) {
TRestDetectorVetoReadout readout(readoutDefaultRml.c_str(), "vetoReadout");
readout.PrintMetadata();
}