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

chore: Use new unique_ptr based SetEventHeader #1423

Merged
Merged
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
6 changes: 6 additions & 0 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -237,6 +237,12 @@
"givenName": "Barth\u00e9l\u00e9my",
"familyName": "von Haller"
},
{
"@type": "Person",
"@id": "https://orcid.org/0000-0002-7006-7986",
"givenName": "Yanzhao",
"familyName": "Wang"
},
{
"@type": "Person",
"givenName": "Sandro",
11 changes: 10 additions & 1 deletion examples/MQ/pixelDetector/macros/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
################################################################################
# Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
# #
# This software is distributed under the terms of the #
# GNU Lesser General Public Licence (LGPL) version 3, #
# copied verbatim in the file "LICENSE" #
################################################################################

set(prefix ex_pixel)

GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_sim.C)
GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_digi.C)
GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_digiToBin.C)

# Try to compile the macros as normal files
add_library(${prefix}_check_compile OBJECT
run_dAsciiSource.C
run_dBinSource.C)
target_link_libraries(${prefix}_check_compile PRIVATE
FairRoot::ExPixel)

set(maxTestTime 30)

add_test(NAME ex_pixel_sim_${pixel_simulation_engine}
51 changes: 35 additions & 16 deletions examples/MQ/pixelDetector/macros/run_dAsciiSource.C
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/

#if !defined(__CLING__) || defined(__ROOTCLING__)
// Example includes
#include "PixelDigiSource.h"
#include "PixelEventHeader.h"
#include "PixelFindHits.h"

// FairRoot includes
#include "FairParAsciiFileIo.h"
#include "FairParRootFileIo.h"
#include "FairRootFileSink.h"
#include "FairRunAna.h"
#include "FairRuntimeDb.h"
#include "FairSystemInfo.h"
#endif

#include <TStopwatch.h>
#include <TString.h>
#include <iostream>
#include <memory>

using std::cout;
using std::endl;

void run_dAsciiSource(TString mcEngine = "TGeant3")
{
// Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
Int_t iVerbose = 0; // just forget about it, for the moment

// Parameter file
TString parFile = "pixel_";
parFile = parFile + mcEngine + ".params.root";
@@ -26,19 +47,17 @@ void run_dAsciiSource(TString mcEngine = "TGeant3")
// ----- Timer --------------------------------------------------------
TStopwatch timer;

PixelEventHeader* pixelEventHeader = new PixelEventHeader();

// ----- Reconstruction run -------------------------------------------
FairRunAna* fRun = new FairRunAna();
fRun->SetEventHeader(pixelEventHeader);
fRun->SetSink(new FairRootFileSink(outFile));
FairRunAna run{};
run.SetEventHeader(std::make_unique<PixelEventHeader>());
run.SetSink(std::make_unique<FairRootFileSink>(outFile));

PixelDigiSource* digiSource = new PixelDigiSource("Pixel Digi Source");
digiSource->SetInputFileName("digis.p0.dat");

fRun->SetSource(digiSource);
run.SetSource(digiSource);

FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
FairRuntimeDb* rtdb = run.GetRuntimeDb();
FairParRootFileIo* parInput1 = new FairParRootFileIo();
parInput1->open(parFile.Data());

@@ -50,15 +69,15 @@ void run_dAsciiSource(TString mcEngine = "TGeant3")

// ----- TorinoDetector hit producers ---------------------------------
// PixelDigiReadFromFile* digiRead = new PixelDigiReadFromFile();
// fRun->AddTask(digiRead);
// run->AddTask(digiRead);

PixelFindHits* hitFinderTask = new PixelFindHits();
fRun->AddTask(hitFinderTask);
auto hitFinderTask = std::make_unique<PixelFindHits>();
run.AddTask(std::move(hitFinderTask));

fRun->Init();
run.Init();

timer.Start();
fRun->Run();
run.Run();

// ----- Finish -------------------------------------------------------

51 changes: 35 additions & 16 deletions examples/MQ/pixelDetector/macros/run_dBinSource.C
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/

#if !defined(__CLING__) || defined(__ROOTCLING__)
// Example includes
#include "PixelDigiBinSource.h"
#include "PixelEventHeader.h"
#include "PixelFindHits.h"

// FairRoot includes
#include "FairParAsciiFileIo.h"
#include "FairParRootFileIo.h"
#include "FairRootFileSink.h"
#include "FairRunAna.h"
#include "FairRuntimeDb.h"
#include "FairSystemInfo.h"
#endif

#include <TStopwatch.h>
#include <TString.h>
#include <iostream>
#include <memory>

using std::cout;
using std::endl;

void run_dBinSource(TString mcEngine = "TGeant3")
{
// Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
Int_t iVerbose = 0; // just forget about it, for the moment

// Parameter file
TString parFile = "pixel_";
parFile = parFile + mcEngine + ".params.root";
@@ -26,19 +47,17 @@ void run_dBinSource(TString mcEngine = "TGeant3")
// ----- Timer --------------------------------------------------------
TStopwatch timer;

PixelEventHeader* pixelEventHeader = new PixelEventHeader();

// ----- Reconstruction run -------------------------------------------
FairRunAna* fRun = new FairRunAna();
fRun->SetEventHeader(pixelEventHeader);
fRun->SetSink(new FairRootFileSink(outFile));
FairRunAna run{};
run.SetEventHeader(std::make_unique<PixelEventHeader>());
run.SetSink(std::make_unique<FairRootFileSink>(outFile));

PixelDigiBinSource* digiSource = new PixelDigiBinSource("Pixel Digi Source");
digiSource->SetInputFileName("digisBin.dat");

fRun->SetSource(digiSource);
run.SetSource(digiSource);

FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
FairRuntimeDb* rtdb = run.GetRuntimeDb();
FairParRootFileIo* parInput1 = new FairParRootFileIo();
parInput1->open(parFile.Data());

@@ -50,15 +69,15 @@ void run_dBinSource(TString mcEngine = "TGeant3")

// ----- TorinoDetector hit producers ---------------------------------
// PixelDigiReadFromFile* digiRead = new PixelDigiReadFromFile();
// fRun->AddTask(digiRead);
// run->AddTask(digiRead);

PixelFindHits* hitFinderTask = new PixelFindHits();
fRun->AddTask(hitFinderTask);
auto hitFinderTask = std::make_unique<PixelFindHits>();
run.AddTask(std::move(hitFinderTask));

fRun->Init();
run.Init();

timer.Start();
fRun->Run();
run.Run();

// ----- Finish -------------------------------------------------------

1 change: 1 addition & 0 deletions fairroot/base/steer/FairRun.h
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ class FairRun : public TNamed
/**
* Add a FAIRTask to the simulation or analysis
*/
void AddTask(std::unique_ptr<FairTask> task) { AddTask(task.release()); }
virtual void AddTask(FairTask* t);
virtual void StoreTaskNames(const FairTask* t);
virtual void SetTask(FairTask* t);