Skip to content
Open
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
1 change: 1 addition & 0 deletions AtData/AtDataLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#pragma link C++ class AtFittedTrack + ;
#pragma link C++ class AtFissionEvent + ;
#pragma link C++ class AtGenericTrace + ;
#pragma link C++ class AtICEvent + ;

#pragma link C++ class AtPatterns::AtPattern + ;
#pragma link C++ class AtPatterns::AtPatternLine + ;
Expand Down
17 changes: 17 additions & 0 deletions AtData/AtICEvent.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "AtICEvent.h"

ClassImp(AtICEvent)

AtICEvent::AtICEvent()
: AtBaseEvent("AtICEvent")
{
}

void AtICEvent::Clear(Option_t *opt)
{
AtBaseEvent::Clear(opt);

fRawADC = -1.;
fADC = -1.;
fIsPedestalSubtracted = kFALSE;
}
41 changes: 41 additions & 0 deletions AtData/AtICEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef AtICEVENT_H
#define AtICEVENT_H

#include "AtBaseEvent.h"

#include <Rtypes.h>

#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
class TBuffer;
class TClass;
class TMemberInspector;

class AtICEvent : public AtBaseEvent {
private:
Double_t fRawADC = -1.;
Double_t fADC = -1.;
Bool_t fIsPedestalSubtracted = kFALSE;

public:
AtICEvent();
AtICEvent(const AtICEvent &) = default;
AtICEvent &operator=(const AtICEvent &) = default;
virtual ~AtICEvent() = default;

void Clear(Option_t *opt = nullptr) override;

void SetRawADC(Double_t value) { fRawADC = value; }
void SetADC(Double_t value) { fADC = value; }
void SetPedestalSubtracted(Bool_t val = kTRUE) { fIsPedestalSubtracted = val; }

Double_t GetRawADC() const { return fRawADC; }
Double_t GetADC() const { return fADC; }
Bool_t IsPedestalSubtracted() const { return fIsPedestalSubtracted; }

ClassDefOverride(AtICEvent, 1);
};

#endif
1 change: 1 addition & 0 deletions AtData/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ set(SRCS
AtTrackingEvent.cxx
AtPatternEvent.cxx
AtGenericTrace.cxx
AtICEvent.cxx

AtProtoQuadrant.cxx
AtTrack.cxx
Expand Down
111 changes: 111 additions & 0 deletions AtReconstruction/AtICTask.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include "AtICTask.h"

#include "AtAuxPad.h"
#include "AtICEvent.h"
#include "AtPad.h"
#include "AtRawEvent.h"

#include <FairLogger.h>
#include <FairRootManager.h> // for FairRootManager

#include <TClonesArray.h>
#include <TObject.h> // for TObject

#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <utility> // for move

constexpr auto cRED = "\033[1;31m";
constexpr auto cYELLOW = "\033[1;33m";
constexpr auto cNORMAL = "\033[0m";
constexpr auto cGREEN = "\033[1;32m";

AtICTask::AtICTask()
: fInputBranchName("AtRawEvent"), fOutputBranchName("AtICEvent"), fICEventArray(TClonesArray("AtICEvent", 1)),
fIsPersistence(kFALSE)
{
}

void AtICTask::SetPersistence(Bool_t value)
{
fIsPersistence = value;
}

void AtICTask::SetInputBranch(TString branchName)
{
fInputBranchName = branchName;
}

void AtICTask::SetOutputBranch(TString branchName)
{
fOutputBranchName = branchName;
}

InitStatus AtICTask::Init()
{
FairRootManager *ioMan = FairRootManager::Instance();
if (ioMan == nullptr) {
LOG(error) << "Cannot find RootManager!";
return kERROR;
}

fRawEventArray = dynamic_cast<TClonesArray *>(ioMan->GetObject(fInputBranchName));
if (fRawEventArray == nullptr) {
LOG(error) << "Cannot find AtRawEvent array in branch " << fInputBranchName << "!";
return kERROR;
}

ioMan->Register(fOutputBranchName, "AtTPC", &fICEventArray, fIsPersistence);

return kSUCCESS;
}

void AtICTask::Exec(Option_t *opt)
{
if (fRawEventArray->GetEntriesFast() == 0) {
LOG(debug) << "Skipping IC analysis because raw event array is empty";
return;
}

fICEventArray.Clear("C");

auto *rawEvent = dynamic_cast<AtRawEvent *>(fRawEventArray->At(0));
if (!rawEvent || !rawEvent->IsGood())
return;

auto *ICEvent = dynamic_cast<AtICEvent *>(fICEventArray.ConstructedAt(0));

if (!rawEvent->IsGood()) {
LOG(debug) << "Event " << rawEvent->GetEventID() << " is not good, skipping IC analysis";
return;
}

LOG(debug) << " --------------------> Staring IC analysis on event Number: " << rawEvent->GetEventID() << " with "
<< rawEvent->GetNumPads() << " valid pads";

// Get the AtAuxPads that contain the IC data and get the trace integrals.
const auto &traces = rawEvent->GetGenTraces();
int i_channel = -1;
for (auto &traceEntry : traces) {
i_channel++;
if (i_channel == 1) {
const auto &trace_rawADC = traceEntry->GetRawADC();
auto maxIt = std::max_element(trace_rawADC.begin() + 20, trace_rawADC.end() - 12);

ICEvent->SetRawADC(*maxIt);

double baseline = std::accumulate(trace_rawADC.begin(), trace_rawADC.begin() + 20, 0.0) / 20.0;
if (baseline <= 0.) {
LOG(debug) << " ---> IC analysis : error baseline";
return;
}

ICEvent->SetPedestalSubtracted(kTRUE);
ICEvent->SetADC(*maxIt - baseline);
}
}

LOG(debug) << "Finished running IC analysis";
}
38 changes: 38 additions & 0 deletions AtReconstruction/AtICTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef AtICTASK_H
#define AtICTASK_H

#include "AtPSA.h"

#include <FairTask.h>

#include <Rtypes.h> // for THashConsistencyHolder, Bool_t, ClassDef, Opti...
#include <TClonesArray.h>
#include <TString.h>

#include <memory>
class TBuffer;
class TClass;
class TMemberInspector;

class AtICTask : public FairTask {
private:
TString fInputBranchName;
TString fOutputBranchName;

TClonesArray *fRawEventArray{nullptr};
TClonesArray fICEventArray;

Bool_t fIsPersistence{false};

public:
AtICTask();
~AtICTask() = default;

void SetPersistence(Bool_t value);
void SetInputBranch(TString branchName);
void SetOutputBranch(TString branchName);
virtual InitStatus Init();
virtual void Exec(Option_t *opt);
};

#endif
1 change: 1 addition & 0 deletions AtReconstruction/AtReconstructionLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
#pragma link C++ class AtCopyTreeTask + ;
#pragma link C++ class AtLinkDAQTask + ;
#pragma link C++ class AtCopyAuxTreeTask + ;
#pragma link C++ class AtICTask + ;

#endif
1 change: 1 addition & 0 deletions AtReconstruction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ set(SRCS
AtHDF5WriteTask.cxx
AtMacroTask.cxx
AtCopyAuxTreeTask.cxx
AtICTask.cxx

AtPatternRecognition/AtPRA.cxx
AtPatternRecognition/AtSampleConsensus.cxx
Expand Down