Skip to content

Commit

Permalink
Merge pull request #123 from rest-for-physics/aquintana-BiPo
Browse files Browse the repository at this point in the history
TRestRawBiPoAnalysisProcess first implementation
  • Loading branch information
jgalan committed Nov 16, 2023
2 parents 320dffd + 32c49e1 commit c9827fd
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 1 deletion.
59 changes: 59 additions & 0 deletions inc/TRestRawBiPoAnalysisProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*************************************************************************
* 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 RESTProc_TRestRawBiPoAnalysisProcess
#define RESTProc_TRestRawBiPoAnalysisProcess

#include "TRestEventProcess.h"
#include "TRestRawSignalEvent.h"

class TRestRawBiPoAnalysisProcess : public TRestEventProcess {
private:
/// A pointer to the specific TRestRawSignalEvent input event
TRestRawSignalEvent* fAnaEvent; //!

void Initialize() override;

public:
RESTValue GetInputEvent() const override { return fAnaEvent; }
RESTValue GetOutputEvent() const override { return fAnaEvent; }

void InitProcess() override;

const char* GetProcessName() const override { return "BiPoAnalysis"; }

TRestEvent* ProcessEvent(TRestEvent* eventInput) override;

void EndProcess() override;

void PrintMetadata() override {
BeginPrintProcess();

EndPrintProcess();
}

TRestRawBiPoAnalysisProcess();
~TRestRawBiPoAnalysisProcess();

ClassDefOverride(TRestRawBiPoAnalysisProcess, 1);
};
#endif
5 changes: 5 additions & 0 deletions inc/TRestRawSignalEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class TRestRawSignalEvent : public TRestEvent {
Double_t fMaxTime; //!
Double_t fMinValue; //!
Double_t fMaxValue; //!
Double_t fAuxiliar = 0;

TVector2 fBaseLineRange = TVector2(-1, -1); //!
TVector2 fRange = TVector2(-1, -1); //!
Expand Down Expand Up @@ -72,6 +73,10 @@ class TRestRawSignalEvent : public TRestEvent {
for (int n = 0; n < GetNumberOfSignals(); n++) fSignal[n].SetTailPoints(p);
}

// Set and Get a tmp variable (for BiPo)
void SetAuxiliar(Double_t aux);
auto GetAuxiliar() { return fAuxiliar; }

/// It sets the range to be used for the baseline calculation and calls
/// TRestRawSignal::CalculateBaseLine()
void SetBaseLineRange(TVector2 blRange, std::string option = "") {
Expand Down
104 changes: 104 additions & 0 deletions src/TRestRawBiPoAnalysisProcess.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*************************************************************************
* 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. *
*************************************************************************/

////////////////////////////////////////////////////////////////////////
/// The TRestRawBiPoSignalAnalysisProcess is meant to add specific BiPo
/// observables when doing the analysis.
/// For the moment it gives the observable "t1t2" which is the time distance
/// between the frist and second window in the BiPo analysis
///
///--------------------------------------------------------------------------
///
/// RESTsoft - Software for Rare Event Searches with TPCs
///
/// History of developments:
///
/// 2023-Oct: First implementation
/// Ana Quintana
///
/// \class TRestRawBiPoSignalAnalysisProcess
/// \author Ana Quintana
///
/// <hr>
///

#include "TRestRawBiPoAnalysisProcess.h"

using namespace std;

ClassImp(TRestRawBiPoAnalysisProcess);

///////////////////////////////////////////////
/// \brief Default constructor
///
TRestRawBiPoAnalysisProcess::TRestRawBiPoAnalysisProcess() { Initialize(); }

///////////////////////////////////////////////
/// \brief Default destructor
///
TRestRawBiPoAnalysisProcess::~TRestRawBiPoAnalysisProcess() {}

///////////////////////////////////////////////
/// \brief Function to initialize input/output event members and define
/// the section name
///
void TRestRawBiPoAnalysisProcess::Initialize() {
SetSectionName(this->ClassName());
SetLibraryVersion(LIBRARY_VERSION);
fAnaEvent = NULL;

// Initialize here the values of class data members if needed
}

///////////////////////////////////////////////
/// \brief Process initialization. Observable names can be re-interpreted
/// here. Any action in the process required before starting event process
/// might be added here.
///
void TRestRawBiPoAnalysisProcess::InitProcess() {
// TRestRawToSignalProcess::InitProcess();

// fEventCounter = 0;
}

///////////////////////////////////////////////
/// \brief The main processing event function
///
TRestEvent* TRestRawBiPoAnalysisProcess::ProcessEvent(TRestEvent* evInput) {
fAnaEvent = (TRestRawSignalEvent*)evInput;

// Write here the main logic of process: TRestRawBiPoAnalysisProcess
// Read data from input event, write data to output event, and save observables to tree

Int_t t1t2_BiPo = fAnaEvent->GetAuxiliar();
SetObservableValue("t1t2", t1t2_BiPo);

return fAnaEvent;
}

///////////////////////////////////////////////
/// \brief Function to include required actions after all events have been
/// processed.
///
void TRestRawBiPoAnalysisProcess::EndProcess() {
// Write here the jobs to do when all the events are processed
}
3 changes: 2 additions & 1 deletion src/TRestRawBiPoToSignalProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
using namespace std;

#include "TTimeStamp.h"
#include "zlib.h"
// #include "zlib.h"

ClassImp(TRestRawBiPoToSignalProcess);

Expand Down Expand Up @@ -529,6 +529,7 @@ Int_t TRestRawBiPoToSignalProcess::ReadBiPoEventData(std::vector<uint16_t>& mdat
}
totalBytesReaded += sizeof(int32_t);
RESTDebug << " T1-T2 distance --> " << tmp << RESTendl;
fSignalEvent->SetAuxiliar(tmp);

mdata.resize(data_size);
if (fread(&mdata[0], sizeof(uint16_t), data_size, fInputBinFile) != (size_t)data_size) {
Expand Down
5 changes: 5 additions & 0 deletions src/TRestRawSignalEvent.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ Double_t TRestRawSignalEvent::GetMaxTime() {
return maxTime;
}

// An auxiliar variable that can be used to store temporal values.
Double_t fAuxiliar = 0;
void TRestRawSignalEvent::SetAuxiliar(Double_t aux) { fAuxiliar = aux; }
auto GetAuxiliar() { return fAuxiliar; }

///////////////////////////////////////////////
/// \brief This method draws current raw signal event in a TPad.
///
Expand Down

0 comments on commit c9827fd

Please sign in to comment.