reorganization of sources, moving cmt pertaining structures into HEP folder

This commit is contained in:
AndreaRigoni
2026-03-07 08:58:31 +00:00
parent 49cf0aeedd
commit e8f8e96521
70 changed files with 1468 additions and 1627 deletions

View File

@@ -0,0 +1,22 @@
################################################################################
##### Vtk/HEP/Detectors - VTK wrappers for HEP Detectors objects ##############
################################################################################
## Sources and headers are exported to parent scope so they get compiled
## into the single mutomVtk shared library.
set(HEP_DETECTORS_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/vtkMuonScatter.cxx
${CMAKE_CURRENT_SOURCE_DIR}/vtkMuonEvent.cxx
PARENT_SCOPE)
set(HEP_DETECTORS_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/vtkMuonScatter.h
${CMAKE_CURRENT_SOURCE_DIR}/vtkMuonEvent.h
PARENT_SCOPE)
if(BUILD_TESTING)
include(uLibTargetMacros)
add_subdirectory(testing)
endif()

View File

@@ -0,0 +1,14 @@
# TESTS
set(TESTS
vtkMuonScatterTest
)
set(LIBRARIES
${PACKAGE_LIBPREFIX}Core
${PACKAGE_LIBPREFIX}Detectors
${PACKAGE_LIBPREFIX}Vtk
${VTK_LIBRARIES}
Boost::unit_test_framework
)
uLib_add_tests(VtkDetectors)

View File

@@ -0,0 +1,62 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
#include "HEP/Detectors/MuonScatter.h"
#include "Vtk/uLibVtkViewer.h"
#define BOOST_TEST_MODULE VtkMuonScatterTest
#include <boost/test/unit_test.hpp>
using namespace uLib;
BOOST_AUTO_TEST_CASE(vtkMuonScatterTest) {
MuonScatter event;
event.LineIn().direction << 0, -1, 1, 0;
event.LineIn().origin << 0, 1, -1, 1;
event.LineOut().direction << 0, -1, 0, 0;
event.LineOut().origin << 0, -1, 0, 1;
Vtk::vtkMuonScatter v_event(event);
v_event.AddPocaPoint(HPoint3f(0, 0, 0));
v_event.SaveToXMLFile("vtk_testing_muonevent.vtp");
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
Vtk::Viewer viewer;
// Vtk::Tie<Vtk::vtkMuonScatter> tms;
// tms.DoAction();
// Vtk::Tie<Vtk::Viewer> vms;
// vms.DoAction();
viewer.AddPuppet(v_event);
viewer.Start();
}
BOOST_CHECK(true); // reached here without crash
}

View File

@@ -0,0 +1,145 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Math/Dense.h"
#include "Vtk/HEP/Detectors/vtkMuonEvent.h"
namespace uLib {
namespace Vtk {
///// CALLBACK /////////////////////////////////////////////////////////////////
class vtkWidgetCallback : public vtkCommand {
public:
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
void SetParent(uLib::Vtk::vtkMuonEvent *parent) { this->parent = parent; }
virtual void Execute(vtkObject *caller, unsigned long, void *) {
vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New();
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget *>(caller);
widget->GetTransform(t);
// parent->SetTransform(t);
// std::cout << "event\n";
}
private:
uLib::Vtk::vtkMuonEvent *parent;
};
////////////////////////////////////////////////////////////////////////////////
///// VTK MUON EVENT /////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkMuonEvent::vtkMuonEvent(MuonEventData &content)
: m_PolyData(NULL), m_Appender(vtkAppendPolyData::New()),
content(&content) {
InstallPipe();
}
vtkMuonEvent::vtkMuonEvent(const MuonEventData &content)
: m_PolyData(NULL), m_Appender(vtkAppendPolyData::New()),
content(const_cast<MuonEventData *>(&content)) {
InstallPipe();
}
vtkMuonEvent::~vtkMuonEvent() {}
vtkMuonEvent::Content &vtkMuonEvent::GetContent() { return *content; }
void vtkMuonEvent::PrintSelf(std::ostream &o) const {
o << "..:: MuonEvent ::..\n"
"\t[in] Origin > "
<< content->LineIn().origin.transpose() << "\n"
<< "\t[in] Direction > " << content->LineIn().direction.transpose() << "\n"
<< "\t[out] Origin > " << content->LineOut().origin.transpose() << "\n"
<< "\t[out] Direction > " << content->LineOut().direction.transpose()
<< "\n"
<< "\tMomentum > " << content->GetMomentum() << "\n"
<< "...................\n";
}
void vtkMuonEvent::InstallPipe() {
vtkAppendPolyData *appender = m_Appender;
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
if (content) {
vtkSmartPointer<vtkLineSource> line_in =
vtkSmartPointer<vtkLineSource>::New();
vtkSmartPointer<vtkLineSource> line_out =
vtkSmartPointer<vtkLineSource>::New();
float distance =
(content->LineIn().origin - content->LineOut().origin).norm() / 10;
HPoint3f pt;
pt = content->LineIn().origin;
line_in->SetPoint1(pt(0), pt(1), pt(2));
pt = content->LineIn().origin + content->LineIn().direction * distance;
line_in->SetPoint2(pt(0), pt(1), pt(2));
pt = content->LineOut().origin;
line_out->SetPoint1(pt(0), pt(1), pt(2));
pt = content->LineOut().origin + content->LineOut().direction * distance;
line_out->SetPoint2(pt(0), pt(1), pt(2));
appender->AddInputConnection(line_in->GetOutputPort());
appender->AddInputConnection(line_out->GetOutputPort());
}
appender->Update();
mapper->SetInputConnection(appender->GetOutputPort());
mapper->Update();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
this->SetProp(actor);
}
vtkPolyData *vtkMuonEvent::GetPolyData() const {
return m_Appender->GetOutput();
}
void vtkMuonEvent::AddPocaPoint(HPoint3f poca) {
m_Poca = poca;
vtkSmartPointer<vtkSphereSource> sphere =
vtkSmartPointer<vtkSphereSource>::New();
float size =
(content->LineIn().origin - content->LineOut().origin).head(3).norm();
size /= 100;
sphere->SetRadius(size);
sphere->SetCenter(poca(0), poca(1), poca(2));
sphere->Update();
m_Appender->AddInputConnection(sphere->GetOutputPort());
m_Appender->Update();
}
HPoint3f vtkMuonEvent::GetPocaPoint() { return m_Poca; }
} // namespace Vtk
} // namespace uLib

View File

@@ -0,0 +1,87 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef VTKMUONEVENT_H
#define VTKMUONEVENT_H
#include <vtkActor.h>
#include <vtkAppendPolyData.h>
#include <vtkLineSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtk3DWidget.h>
#include <vtkBoxWidget.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCommand.h>
#include <vtkTransform.h>
#include "Math/Dense.h"
#include "HEP/Detectors/MuonEvent.h"
#include "Vtk/uLibVtkInterface.h"
namespace uLib {
namespace Vtk {
class vtkMuonEvent : public Puppet, public Polydata {
typedef MuonEventData Content;
public:
vtkMuonEvent(const MuonEventData &content);
vtkMuonEvent(MuonEventData &content);
~vtkMuonEvent();
Content &GetContent();
void PrintSelf(std::ostream &o) const;
virtual vtkPolyData *GetPolyData() const;
void AddPocaPoint(HPoint3f poca);
HPoint3f GetPocaPoint();
void vtkStartInteractive();
private:
void InstallPipe();
vtkMuonEvent::Content *content;
vtkPolyData *m_PolyData;
vtkAppendPolyData *m_Appender;
vtkBoxWidget *m_WidgetIN;
vtkBoxWidget *m_WidgetOUT;
HPoint3f m_Poca;
};
} // namespace Vtk
} // namespace uLib
#endif // VTKMUONEVENT_H

View File

@@ -0,0 +1,144 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "Math/Dense.h"
#include "Vtk/HEP/Detectors/vtkMuonScatter.h"
namespace uLib {
namespace Vtk {
////////////////////////////////////////////////////////////////////////////////
///// VTK MUON Scatter ///////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkMuonScatter::vtkMuonScatter(MuonScatter &content)
: m_Content(&content), m_LineIn(vtkLineSource::New()),
m_LineOut(vtkLineSource::New()), m_PolyData(vtkPolyData::New()),
m_SpherePoca(NULL) {
InstallPipe();
}
vtkMuonScatter::vtkMuonScatter(const MuonScatter &content)
: m_Content(const_cast<MuonScatter *>(&content)),
m_LineIn(vtkLineSource::New()), m_LineOut(vtkLineSource::New()),
m_PolyData(vtkPolyData::New()), m_SpherePoca(NULL) {
InstallPipe();
}
vtkMuonScatter::~vtkMuonScatter() {
m_LineIn->Delete();
m_LineOut->Delete();
if (m_SpherePoca)
m_SpherePoca->Delete();
}
vtkMuonScatter::Content &vtkMuonScatter::GetContent() { return *m_Content; }
void vtkMuonScatter::PrintSelf(std::ostream &o) const {}
void vtkMuonScatter::InstallPipe() {
if (m_Content) {
vtkLineSource *line_in = m_LineIn;
vtkLineSource *line_out = m_LineOut;
float distance =
(m_Content->LineIn().origin - m_Content->LineOut().origin).norm() / 10;
HPoint3f pt;
pt = m_Content->LineIn().origin;
line_in->SetPoint1(pt(0), pt(1), pt(2));
pt = m_Content->LineIn().origin + m_Content->LineIn().direction * distance;
line_in->SetPoint2(pt(0), pt(1), pt(2));
pt = m_Content->LineOut().origin;
line_out->SetPoint1(pt(0), pt(1), pt(2));
pt =
m_Content->LineOut().origin + m_Content->LineOut().direction * distance;
line_out->SetPoint2(pt(0), pt(1), pt(2));
}
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(m_LineIn->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
this->SetProp(actor);
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(m_LineOut->GetOutputPort());
actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
this->SetProp(actor);
}
vtkPolyData *vtkMuonScatter::GetPolyData() const {
vtkSmartPointer<vtkAppendPolyData> append =
vtkSmartPointer<vtkAppendPolyData>::New();
append->AddInputConnection(m_LineIn->GetOutputPort());
append->AddInputConnection(m_LineOut->GetOutputPort());
if (m_SpherePoca)
append->AddInputConnection(m_SpherePoca->GetOutputPort());
append->Update();
m_PolyData->DeepCopy(append->GetOutput());
return m_PolyData;
}
void vtkMuonScatter::AddPocaPoint(HPoint3f poca) {
vtkSphereSource *sphere = vtkSphereSource::New();
float size =
(m_Content->LineIn().origin - m_Content->LineOut().origin).head(3).norm();
size /= 100;
sphere->SetRadius(size);
sphere->SetCenter(poca(0), poca(1), poca(2));
sphere->Update();
m_SpherePoca = sphere;
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(m_SpherePoca->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
this->SetProp(actor);
}
HPoint3f vtkMuonScatter::GetPocaPoint() {
double center[3];
if (m_SpherePoca) {
m_SpherePoca->GetCenter(center);
return HPoint3f(center[0], center[1], center[2]);
} else {
return HPoint3f(0, 0, 0);
}
}
void vtkMuonScatter::ConnectInteractor(vtkRenderWindowInteractor *interactor) {
// TODO
}
} // namespace Vtk
} // namespace uLib

View File

@@ -0,0 +1,92 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef VTKMUONSCATTER_H
#define VTKMUONSCATTER_H
#include <vtkActor.h>
#include <vtkAppendPolyData.h>
#include <vtkLineSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkVersion.h>
#include <vtk3DWidget.h>
#include <vtkBoxWidget.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCommand.h>
#include <vtkTransform.h>
#include "Math/Dense.h"
#include "HEP/Detectors/MuonScatter.h"
#include "Vtk/uLibVtkInterface.h"
class vtkRenderWindowInteractor;
namespace uLib {
namespace Vtk {
class vtkMuonScatter : public Puppet, public Polydata {
typedef MuonScatter Content;
public:
vtkMuonScatter(const MuonScatter &content);
vtkMuonScatter(MuonScatter &content);
~vtkMuonScatter();
Content &GetContent();
void PrintSelf(std::ostream &o) const;
virtual vtkPolyData *GetPolyData() const;
void AddPocaPoint(HPoint3f poca);
HPoint3f GetPocaPoint();
void vtkStartInteractive();
protected:
void ConnectInteractor(vtkRenderWindowInteractor *interactor);
private:
void InstallPipe();
vtkMuonScatter::Content *m_Content;
vtkLineSource *m_LineIn;
vtkLineSource *m_LineOut;
vtkSphereSource *m_SpherePoca;
vtkPolyData *m_PolyData;
};
} // namespace Vtk
} // namespace uLib
#endif // VTKMUONSCATTER_H