diff --git a/CMakeLists.txt b/CMakeLists.txt index 82cc609..0a8ef88 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,4 +17,6 @@ if(WITH_UCESB) add_subdirectory(asysource) endif(WITH_UCESB) add_subdirectory(chimera) +add_subdirectory(krab) add_subdirectory(asydata) +add_subdirectory(asyonline) diff --git a/asydata/CMakeLists.txt b/asydata/CMakeLists.txt index 47d1fef..128b0b9 100644 --- a/asydata/CMakeLists.txt +++ b/asydata/CMakeLists.txt @@ -10,6 +10,7 @@ ${R3BROOT_SOURCE_DIR}/r3bdata/califaData ${R3BROOT_SOURCE_DIR}/r3bdata/neulandData ${R3BASY_SOURCE_DIR}/asydata ${R3BASY_SOURCE_DIR}/asydata/chimeraData +${R3BASY_SOURCE_DIR}/asydata/krabData ) include_directories( ${INCLUDE_DIRECTORIES}) @@ -22,6 +23,9 @@ link_directories( ${LINK_DIRECTORIES}) set(SRCS chimeraData/R3BAsyChimeraPoint.cxx chimeraData/R3BAsyChimeraHitData.cxx +chimeraData/R3BAsyChimeraMappedData.cxx +krabData/R3BAsyKrabPoint.cxx +krabData/R3BAsyKrabHitData.cxx ) diff --git a/asydata/R3BAsyDataLinkDef.h b/asydata/R3BAsyDataLinkDef.h index 442bc0f..2bf086d 100644 --- a/asydata/R3BAsyDataLinkDef.h +++ b/asydata/R3BAsyDataLinkDef.h @@ -9,5 +9,7 @@ // Point classes for simulation #pragma link C++ class R3BAsyChimeraPoint+; #pragma link C++ class R3BAsyChimeraHitData+; - +#pragma link C++ class R3BAsyChimeraMappedData+; +#pragma link C++ class R3BAsyKrabPoint+; +#pragma link C++ class R3BAsyKrabHitData+; #endif diff --git a/asydata/chimeraData/R3BAsyChimeraMappedData.cxx b/asydata/chimeraData/R3BAsyChimeraMappedData.cxx new file mode 100644 index 0000000..e39e93c --- /dev/null +++ b/asydata/chimeraData/R3BAsyChimeraMappedData.cxx @@ -0,0 +1,48 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "R3BAsyChimeraMappedData.h" + +R3BAsyChimeraMappedData::R3BAsyChimeraMappedData() + : fDetector(-1) + , fSide(-1) + , fStrip(-1) + , fEnergy(-1) + , fTime(-1) +{ +} + +R3BAsyChimeraMappedData::R3BAsyChimeraMappedData(UInt_t detector, + UInt_t side, + UInt_t strip, + UInt_t energy, + UInt_t time) + : fDetector(detector) + , fSide(side) + , fStrip(strip) + , fEnergy(energy) + , fTime(time) +{ +} + +UInt_t R3BAsyChimeraMappedData::GetDetectorId() const { return fDetector; } + +UInt_t R3BAsyChimeraMappedData::GetSideId() const { return fSide; } + +UInt_t R3BAsyChimeraMappedData::GetStripId() const { return fStrip; } + +UInt_t R3BAsyChimeraMappedData::GetEnergy() const { return fEnergy; } + +UInt_t R3BAsyChimeraMappedData::GetTime() const { return fTime; } + +ClassImp(R3BAsyChimeraMappedData) diff --git a/asydata/chimeraData/R3BAsyChimeraMappedData.h b/asydata/chimeraData/R3BAsyChimeraMappedData.h new file mode 100644 index 0000000..fdcabb3 --- /dev/null +++ b/asydata/chimeraData/R3BAsyChimeraMappedData.h @@ -0,0 +1,42 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#ifndef R3BASYCHIMERAMAPPEDITEM_H +#define R3BASYCHIMERAMAPPEDITEM_H + +#include "TObject.h" + +class R3BAsyChimeraMappedData : public TObject +{ + public: + R3BAsyChimeraMappedData(); + R3BAsyChimeraMappedData(UInt_t, UInt_t, UInt_t, UInt_t, UInt_t); + + UInt_t GetDetectorId() const; + UInt_t GetSideId() const; + UInt_t GetStripId() const; + UInt_t GetEnergy() const; + UInt_t GetTime() const; + + private: + UInt_t fDetector; // 1..n + UInt_t fSide; // 1 = front, 2 = back + UInt_t fStrip; // 0..31 + UInt_t fEnergy; + UInt_t fTime; + + public: + ClassDef(R3BAsyChimeraMappedData, 1) +}; + +#endif diff --git a/asydata/krabData/R3BAsyKrabHitData.cxx b/asydata/krabData/R3BAsyKrabHitData.cxx new file mode 100644 index 0000000..c931be4 --- /dev/null +++ b/asydata/krabData/R3BAsyKrabHitData.cxx @@ -0,0 +1,17 @@ +// --------------------------------------------------------------------------- +// ----- R3BAsyKrabHitData source file ------ +// --------------------------------------------------------------------------- + +#include "R3BAsyKrabHitData.h" + +// ----- Default constructor ------------------------------------------- +R3BAsyKrabHitData::R3BAsyKrabHitData() + : fCellId(0), fELoss(0.), fLight(0.), fToF(0.) {} + +// ----- Standard constructor ------------------------------------------ +R3BAsyKrabHitData::R3BAsyKrabHitData(Int_t ncell, Double_t eloss, + Double_t light, Double_t tof) + : fCellId(ncell), fELoss(eloss), fLight(light), fToF(tof) {} +// ------------------------------------------------------------------------- + +ClassImp(R3BAsyKrabHitData) diff --git a/asydata/krabData/R3BAsyKrabHitData.h b/asydata/krabData/R3BAsyKrabHitData.h new file mode 100644 index 0000000..ffe64b6 --- /dev/null +++ b/asydata/krabData/R3BAsyKrabHitData.h @@ -0,0 +1,45 @@ +// ------------------------------------------------------------------- +// ----- R3BAsyKrabHitData header file ------ +// ----- Created 24/10/23 by E. De Filippo and P. Russotto ------ +// ------------------------------------------------------------------- + +#ifndef R3BAsyKrabHitData_H +#define R3BAsyKrabHitData_H +#include "TObject.h" + +class R3BAsyKrabHitData : public TObject { + public: + /** Default constructor **/ + R3BAsyKrabHitData(); + + /** Constructor with arguments + *@param fCellId Cell number + *@param fEloss Energy Loss in [MeV] + *@param fLight Light in arb. units + *@param fToF Tof in [ns] + **/ + R3BAsyKrabHitData(Int_t CellId, Double_t ELoss, Double_t Light, Double_t ToF); + + /** Destructor **/ + virtual ~R3BAsyKrabHitData() {} + + /** Accessors **/ + Int_t GetCellId() const { return fCellId; } + Double_t GetEloss() const { return fELoss; } + Double_t GetLight() const { return fLight; } + Double_t GetToF() const { return fToF; } + + /** Modifiers **/ + void SetCellID(Int_t ncell) { fCellId = ncell; }; + void SetELoss(Double_t eloss) { fELoss = eloss; }; + void SetLight(Double_t light) { fLight = light; }; + void SetTof(Double_t t) { fToF = t; }; + + private: + Int_t fCellId; + Double_t fELoss, fLight, fToF; + + ClassDef(R3BAsyKrabHitData, 1) +}; + +#endif diff --git a/asydata/krabData/R3BAsyKrabPoint.cxx b/asydata/krabData/R3BAsyKrabPoint.cxx new file mode 100644 index 0000000..fd42edb --- /dev/null +++ b/asydata/krabData/R3BAsyKrabPoint.cxx @@ -0,0 +1,85 @@ +// -------------------------------------------------------------------------- +// ----- R3BAsyKrabPoint source file ------ +// -------------------------------------------------------------------------- + +#include "R3BAsyKrabPoint.h" + +#include + +using std::cout; +using std::endl; +using std::flush; + +// ----- Default constructor ------------------------------------------- +R3BAsyKrabPoint::R3BAsyKrabPoint() : FairMCPoint() { + fX_out = fY_out = fZ_out = 0.; + fPx_out = fPy_out = fPz_out = 0.; + fZFF = fAFF = 0.; +} +// ------------------------------------------------------------------------- + +// ----- Standard constructor ------------------------------------------ +R3BAsyKrabPoint::R3BAsyKrabPoint(Int_t trackID, Int_t detID, Int_t detCopyID, + Double_t Z, Double_t A, TVector3 posIn, + TVector3 posOut, TVector3 momIn, + TVector3 momOut, Double_t tof, Double_t length, + Double_t eLoss, Double_t lightYield) + : FairMCPoint(trackID, detID, posIn, momIn, tof, length, eLoss) { + fDetCopyID = detCopyID; + fX_out = posOut.X(); + fY_out = posOut.Y(); + fZ_out = posOut.Z(); + fPx_out = momOut.Px(); + fPy_out = momOut.Py(); + fPz_out = momOut.Pz(); + fZFF = Z; + fAFF = A; + fLightYield = lightYield; +} +// ------------------------------------------------------------------------- + +// ----- Destructor ---------------------------------------------------- +R3BAsyKrabPoint::~R3BAsyKrabPoint() {} +// ------------------------------------------------------------------------- + +// ----- Public method Print ------------------------------------------- +// void R3BAsyKrabPoint::Print(const Option_t* opt) const +//{ +// cout << "-I- R3BAsyKrabPoint: STS Point for track " << fTrackID << " in +// detector " << fDetectorID << endl; cout << " Position (" << fX << ", " +// << fY << ", " << fZ << ") cm" << endl; cout << " Momentum (" << fPx << +// ", " << fPy << ", " << fPz << ") GeV" << endl; cout << " Time " << +// fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss +// * 1.0e06 << " keV"; cout << " lightYield " << fLightYield * 1.0e03 << " +// MeVeq" +// << endl; +//} +// ------------------------------------------------------------------------- + +// ----- Point x coordinate from linear extrapolation ------------------ +Double_t R3BAsyKrabPoint::GetX(Double_t z) const { + // cout << fZ << " " << z << " " << fZ_out << endl; + if ((fZ_out - z) * (fZ - z) >= 0.) return (fX_out + fX) / 2.; + Double_t dz = fZ_out - fZ; + return (fX + (z - fZ) / dz * (fX_out - fX)); +} +// ------------------------------------------------------------------------- + +// ----- Point y coordinate from linear extrapolation ------------------ +Double_t R3BAsyKrabPoint::GetY(Double_t z) const { + if ((fZ_out - z) * (fZ - z) >= 0.) return (fY_out + fY) / 2.; + Double_t dz = fZ_out - fZ; + // if ( TMath::Abs(dz) < 1.e-3 ) return (fY_out+fY)/2.; + return (fY + (z - fZ) / dz * (fY_out - fY)); +} +// ------------------------------------------------------------------------- + +// ----- Public method IsUsable ---------------------------------------- +Bool_t R3BAsyKrabPoint::IsUsable() const { + Double_t dz = fZ_out - fZ; + if (TMath::Abs(dz) < 1.e-4) return kFALSE; + return kTRUE; +} +// ------------------------------------------------------------------------- + +ClassImp(R3BAsyKrabPoint) diff --git a/asydata/krabData/R3BAsyKrabPoint.h b/asydata/krabData/R3BAsyKrabPoint.h new file mode 100644 index 0000000..fdef20f --- /dev/null +++ b/asydata/krabData/R3BAsyKrabPoint.h @@ -0,0 +1,102 @@ +// -------------------------------------------------------------------------- +// ----- R3BAsyKrabPoint header file ------ +// ----- Created 24/10/23 by E. De Filippo and P. Russotto ------ +// -------------------------------------------------------------------------- + +/** R3BAsyKrabPoint.h + **/ + +#ifndef R3BAsyKrabPoint_H +#define R3BAsyKrabPoint_H + +#include "FairMCPoint.h" +#include "TObject.h" +#include "TVector3.h" + +class R3BAsyKrabPoint : public FairMCPoint { + public: + /** Default constructor **/ + R3BAsyKrabPoint(); + + /** Constructor with arguments + *@param trackID Index of MCTrack + *@param detID Detector ID + *@param detVolID Detector Copy ID + *@param Z Atomic number fragment + *@param A Mass number fragment + *@param posIn Ccoordinates at entrance to active volume [cm] + *@param posOut Coordinates at exit of active volume [cm] + *@param momIn Momentum of track at entrance [GeV] + *@param momOut Momentum of track at exit [GeV] + *@param tof Time since event start [ns] + *@param length Track length since creation [cm] + *@param eLoss Energy deposit [GeV] + **/ + R3BAsyKrabPoint(Int_t trackID, Int_t detID, Int_t detCopyID, Double_t Z, + Double_t A, TVector3 posIn, TVector3 posOut, TVector3 momIn, + TVector3 momOut, Double_t tof, Double_t length, + Double_t eLoss, Double_t lightYield); + + /** Copy constructor **/ + R3BAsyKrabPoint(const R3BAsyKrabPoint& point) { *this = point; }; + + /** Destructor **/ + virtual ~R3BAsyKrabPoint(); + + /** Accessors **/ + Int_t GetDetCopyID() const { return fDetCopyID; } + Double_t GetXIn() const { return fX; } + Double_t GetYIn() const { return fY; } + Double_t GetZIn() const { return fZ; } + Double_t GetXOut() const { return fX_out; } + Double_t GetYOut() const { return fY_out; } + Double_t GetZOut() const { return fZ_out; } + Double_t GetPxOut() const { return fPx_out; } + Double_t GetPyOut() const { return fPy_out; } + Double_t GetPzOut() const { return fPz_out; } + Double_t GetZFF() const { return fZFF; } + Double_t GetAFF() const { return fAFF; } + Double_t GetLightYield() const { return fLightYield; } + + void PositionIn(TVector3& pos) { pos.SetXYZ(fX, fY, fZ); } + void PositionOut(TVector3& pos) { pos.SetXYZ(fX_out, fY_out, fZ_out); } + void MomentumOut(TVector3& mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); } + + /** Point coordinates at given z from linear extrapolation **/ + Double_t GetX(Double_t z) const; + Double_t GetY(Double_t z) const; + + /** Check for distance between in and out **/ + Bool_t IsUsable() const; + + /** Modifiers **/ + void SetPositionOut(TVector3 pos); + void SetMomentumOut(TVector3 mom); + void SetDetCopyID(Int_t id) { fDetCopyID = id; }; + + /** Output to screen **/ + // virtual void Print(const Option_t* opt) const; + + private: + Double32_t fX_out, fY_out, fZ_out; + Double32_t fPx_out, fPy_out, fPz_out; + Int_t fDetCopyID; + Double32_t fZFF, fAFF; + Double_t fLightYield; + + ClassDef(R3BAsyKrabPoint, 1) +}; + +inline void R3BAsyKrabPoint::SetPositionOut(TVector3 pos) { + fX_out = pos.X(); + fY_out = pos.Y(); + fZ_out = pos.Z(); +} + +inline void R3BAsyKrabPoint::SetMomentumOut(TVector3 mom) { + fPx_out = mom.Px(); + fPy_out = mom.Py(); + fPz_out = mom.Pz(); +} + +#endif diff --git a/asyonline/AsyOnlineLinkDef.h b/asyonline/AsyOnlineLinkDef.h new file mode 100644 index 0000000..543289e --- /dev/null +++ b/asyonline/AsyOnlineLinkDef.h @@ -0,0 +1,9 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class R3BAsyChimeraOnlineSpectra+; + +#endif diff --git a/asyonline/CMakeLists.txt b/asyonline/CMakeLists.txt new file mode 100644 index 0000000..4e81d0c --- /dev/null +++ b/asyonline/CMakeLists.txt @@ -0,0 +1,36 @@ +# Create a library called "libR3BAsyOnline" which includes the source files given in +# the array . +# The extension is already found. Any number of sources could be listed here. + +Set(SYSTEM_INCLUDE_DIRECTORIES ${SYSTEM_INCLUDE_DIRECTORIES} ${BASE_INCLUDE_DIRECTORIES} ) + +set(INCLUDE_DIRECTORIES +#put here all directories where header files are located +${R3BROOT_SOURCE_DIR}/r3bbase +${R3BROOT_SOURCE_DIR}/r3bdata +${R3BASY_SOURCE_DIR}/asydata +${R3BASY_SOURCE_DIR}/asydata/chimeraData +${R3BASY_SOURCE_DIR}/asyonline +) + +include_directories( ${INCLUDE_DIRECTORIES}) +include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) + +set(LINK_DIRECTORIES ${ROOT_LIBRARY_DIR} ${FAIRROOT_LIBRARY_DIR} ) + +link_directories( ${LINK_DIRECTORIES}) + +set(SRCS +R3BAsyChimeraOnlineSpectra.cxx +) + +# fill list of header files from list of source files +# by exchanging the file extension +CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") + +set(LINKDEF AsyOnlineLinkDef.h) +set(LIBRARY_NAME R3BAsyOnline) +set(DEPENDENCIES + Spectrum Base FairTools R3BBase R3BData) + +GENERATE_LIBRARY() diff --git a/asyonline/R3BAsyChimeraOnlineSpectra.cxx b/asyonline/R3BAsyChimeraOnlineSpectra.cxx new file mode 100644 index 0000000..9369c98 --- /dev/null +++ b/asyonline/R3BAsyChimeraOnlineSpectra.cxx @@ -0,0 +1,226 @@ +// ------------------------------------------------------------ +// ----- R3BAsyChimeraOnlineSpectra ----- +// ----- Fill SOFIA online histograms ----- +// ------------------------------------------------------------ + +/* + * This task should fill histograms with SOFIA online data + */ + +#include "R3BAsyChimeraOnlineSpectra.h" + +#include +#include +#include +#include +#include +#include + +#include "FairLogger.h" +#include "FairRootManager.h" +#include "FairRunAna.h" +#include "FairRunOnline.h" +#include "FairRuntimeDb.h" +#include "R3BAsyChimeraMappedData.h" +#include "R3BEventHeader.h" +#include "TCanvas.h" +#include "TClonesArray.h" +#include "TFolder.h" +#include "TH1.h" +#include "TH2.h" +#include "THttpServer.h" +#include "TLegend.h" +#include "TLegendEntry.h" +#include "TMath.h" +#include "TRandom.h" +#include "TVector3.h" + +#define verbose 0 + +R3BAsyChimeraOnlineSpectra::R3BAsyChimeraOnlineSpectra() + : FairTask("AsyChimeraOnlineSpectra", 1), + fMappedItemsChimera(NULL), + fNEvents(0) {} + +R3BAsyChimeraOnlineSpectra::R3BAsyChimeraOnlineSpectra(const char* name, + Int_t iVerbose) + : FairTask(name, iVerbose), fMappedItemsChimera(NULL), fNEvents(0) {} + +R3BAsyChimeraOnlineSpectra::~R3BAsyChimeraOnlineSpectra() { + LOG(info) << "R3BAsyChimeraOnlineSpectra::Delete instance"; + if (fMappedItemsChimera) delete fMappedItemsChimera; +} + +InitStatus R3BAsyChimeraOnlineSpectra::Init() { + LOG(info) << "R3BAsyChimeraOnlineSpectra::Init "; + + // try to get a handle on the EventHeader. EventHeader may not be + // present though and hence may be null. Take care when using. + + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + LOG(fatal) << "R3BAsyChimeraOnlineSpectra::Init FairRootManager not found"; + // header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader"); + + if (verbose) LOG(info) << "R3BAsyChimeraOnlineSpectra::Init line 72"; + + FairRunOnline* run = FairRunOnline::Instance(); + run->GetHttpServer()->Register("", this); + + // Register command to reset histograms + // run->GetHttpServer()->RegisterCommand("Reset_Chimera", + // Form("/Objects/%s/->Reset_Histo()", GetName())); + + // --- ------------------------------------- --- // + // --- get access to mapped data of the TofW --- // + // --- ------------------------------------- --- // + if (verbose) LOG(info) << "R3BAsyChimeraOnlineSpectra::Init line 80"; + + fMappedItemsChimera = (TClonesArray*)mgr->GetObject("AsyChimeraMappedData"); + if (!fMappedItemsChimera) { + // return kFATAL; + } + if (verbose) LOG(info) << "R3BAsyChimeraOnlineSpectra::Init line 87"; + + // --- ------------------------------- --- // + // --- Create histograms for detectors --- // + // --- ------------------------------- --- // + + char Name1[255]; + char Name2[255]; + char Name3[255]; + + // Chimera/Farcos main folder + TFolder* mainfol = new TFolder("Chimera", "Si Strips"); + TFolder* mapfol = new TFolder("Map", "Map Si Strips"); + mainfol->Add(mapfol); + + c_1_rawEnergy_front = + new TCanvas("c_1_rawEnergy_front", "1_rawEnergy_front", 0, 0, 2400, 1200); + c_1_rawEnergy_front->Divide(8, 4); + c_1_rawTime_front = + new TCanvas("c_1_rawTime_front", "1_rawTime_front", 0, 0, 2400, 1200); + c_1_rawTime_front->Divide(8, 4); + c_1_rawEnergy_vs_rawTime_front = + new TCanvas("c_1_rawEnergy_vs_rawTime_front", + "1_rawEnergy_vs_rawTime_front", 0, 0, 2400, 1200); + c_1_rawEnergy_vs_rawTime_front->Divide(8, 4); + + c_1_multi_front = + new TCanvas("c_1_multi_front", "1_multi_front", 0, 0, 800, 800); + c_1_multi_front->Divide(2, 2); + mapfol->Add(c_1_multi_front); + + int nch = 500; + int xymin = -0.5; + int xymax = 4199.5; + + for (Int_t j = 0; j < Nstrips; j++) { + sprintf(Name1, "AsyChimera_1_rawEnergy_front_%i", j); + fh1_1_rawEnergy_front[j] = new TH1I(Name1, Name1, nch, xymin, xymax); + fh1_1_rawEnergy_front[j]->GetXaxis()->SetTitle("raw Energy (ch)"); + fh1_1_rawEnergy_front[j]->GetYaxis()->SetTitle("Yield"); + c_1_rawEnergy_front->cd(j + 1); + fh1_1_rawEnergy_front[j]->Draw(); + + sprintf(Name2, "AsyChimera_1_rawTime_front_%i", j); + fh1_1_rawTime_front[j] = new TH1I(Name2, Name2, nch, xymin, xymax); + fh1_1_rawTime_front[j]->GetXaxis()->SetTitle("raw Time (ch)"); + fh1_1_rawTime_front[j]->GetYaxis()->SetTitle("Yield"); + c_1_rawTime_front->cd(j + 1); + fh1_1_rawTime_front[j]->Draw(); + + sprintf(Name3, "AsyChimera_1_rawEnergy_vs_rawTime_front_%i", j); + fh2_1_rawEnergy_vs_rawTime_front[j] = + new TH2F(Name3, Name3, nch, xymin, xymax, nch, xymin, xymax); + fh2_1_rawEnergy_vs_rawTime_front[j]->GetXaxis()->SetTitle("raw Time (ch)"); + fh2_1_rawEnergy_vs_rawTime_front[j]->GetYaxis()->SetTitle( + "raw Energy (ch)"); + c_1_rawEnergy_vs_rawTime_front->cd(j + 1); + fh2_1_rawEnergy_vs_rawTime_front[j]->Draw("Zcol"); + } + + fh1_1_multi_front = new TH1I("AsyChimera_1_multi_front", + "AsyChimera_1_multi_front", 32, -0.5, 31.5); + c_1_multi_front->cd(1); + fh1_1_multi_front->Draw(); + + run->AddObject(mainfol); + LOG(info) << "R3BAsyChimeraOnlineSpectra::Init DONE"; + return kSUCCESS; +} + +void R3BAsyChimeraOnlineSpectra::Reset_Histo() { + LOG(info) << "R3BAsyChimeraOnlineSpectra::Reset_Histo"; + // reset mapped data (for defined spectra) + for (Int_t i = 0; i < Nstrips; i++) { + fh1_1_rawEnergy_front[i]->Reset(); + fh1_1_rawTime_front[i]->Reset(); + fh2_1_rawEnergy_vs_rawTime_front[i]->Reset(); + } + // Multiplicity reset + fh1_1_multi_front->Reset(); +} + +void R3BAsyChimeraOnlineSpectra::Exec(Option_t* option) { + FairRootManager* mgr = FairRootManager::Instance(); + if (NULL == mgr) + LOG(fatal) << "R3BAsyChimeraOnlineSpectra::Exec FairRootManager not found"; + + Int_t nHits; + UShort_t iDet; + UShort_t iSide; + UShort_t iCh; + UShort_t rawEnergy; + UShort_t rawTime; + UShort_t multi_front_1 = 0; + + if (fMappedItemsChimera && fMappedItemsChimera->GetEntriesFast()) { + // --- --------------------- --- // + // --- loop over mapped data --- // + // --- --------------------- --- // + nHits = fMappedItemsChimera->GetEntriesFast(); + for (Int_t ihit = 0; ihit < nHits; ihit++) { + R3BAsyChimeraMappedData* hitmapped = + (R3BAsyChimeraMappedData*)fMappedItemsChimera->At(ihit); + if (!hitmapped) continue; + iDet = hitmapped->GetDetectorId(); + iSide = hitmapped->GetSideId(); + iCh = hitmapped->GetStripId(); + rawEnergy = hitmapped->GetEnergy(); + rawTime = hitmapped->GetTime(); + // std::cout << iDet << " " << iSide << " " << iCh << std::endl; + if (iDet == 1 && iSide == 1 && iCh < Nstrips) { + if (rawEnergy > 0) fh1_1_rawEnergy_front[iCh]->Fill(rawEnergy); + if (rawTime > 0) fh1_1_rawTime_front[iCh]->Fill(rawTime); + if (rawEnergy > 0 && rawTime > 0) { + fh2_1_rawEnergy_vs_rawTime_front[iCh]->Fill(rawTime, rawEnergy); + multi_front_1++; + } + } + } + } + fh1_1_multi_front->Fill(multi_front_1); + + fNEvents += 1; +} + +void R3BAsyChimeraOnlineSpectra::FinishEvent() { + if (fMappedItemsChimera) { + fMappedItemsChimera->Clear(); + } +} + +void R3BAsyChimeraOnlineSpectra::FinishTask() { + LOG(info) << "Double click (somewhere) into c_1_rawEnergy_vs_rawTime_front " + "canvas to terminate...."; + c_1_rawEnergy_vs_rawTime_front->WaitPrimitive(); + + if (fMappedItemsChimera) { + c_1_rawEnergy_front->Write(); + c_1_rawTime_front->Write(); + c_1_rawEnergy_vs_rawTime_front->Write(); + c_1_multi_front->Write(); + } +} +ClassImp(R3BAsyChimeraOnlineSpectra) diff --git a/asyonline/R3BAsyChimeraOnlineSpectra.h b/asyonline/R3BAsyChimeraOnlineSpectra.h new file mode 100644 index 0000000..3185dc2 --- /dev/null +++ b/asyonline/R3BAsyChimeraOnlineSpectra.h @@ -0,0 +1,111 @@ +// ------------------------------------------------------------ +// ----- R3BAsyChimeraOnlineSpectra ----- +// ----- Fill SOFIA online histograms ----- +// ------------------------------------------------------------ + +#ifndef R3BAsyChimeraOnlineSpectra_H +#define R3BAsyChimeraOnlineSpectra_H + +#include + +#include +#include +#include +#include +#include + +#include "FairTask.h" +#include "TCanvas.h" +#include "TH1.h" +#include "TH2F.h" +#include "TMath.h" + +// to be fixed +#define Nstrips 32 +#define NbChs 2 + +class TClonesArray; +class R3BEventHeader; + +/** + * This taks reads mapped data and plots online histograms + */ +class R3BAsyChimeraOnlineSpectra : public FairTask { + public: + /** + * Default constructor. + * Creates an instance of the task with default parameters. + */ + R3BAsyChimeraOnlineSpectra(); + + /** + * Standard constructor. + * Creates an instance of the task. + * @param name a name of the task. + * @param iVerbose a verbosity level. + */ + R3BAsyChimeraOnlineSpectra(const char* name, Int_t iVerbose = 1); + + /** + * Destructor. + * Frees the memory used by the object. + */ + virtual ~R3BAsyChimeraOnlineSpectra(); + + /** + * Method for task initialization. + * This function is called by the framework before + * the event loop. + * @return Initialization status. kSUCCESS, kERROR or kFATAL. + */ + virtual InitStatus Init(); + + /** + * Method for event loop implementation. + * Is called by the framework every time a new event is read. + * @param option an execution option. + */ + virtual void Exec(Option_t* option); + + /** + * A method for finish of processing of an event. + * Is called by the framework for each event after executing + * the tasks. + */ + virtual void FinishEvent(); + + /** + * Method for finish of the task execution. + * Is called by the framework after processing the event loop. + */ + virtual void FinishTask(); + + /** + * Methods to clean histograms. + */ + virtual void Reset_Histo(); + + private: + TClonesArray* fMappedItemsChimera; /**< Array with chimera mapped items. */ + + // check for trigger should be done globablly (somewhere else) + R3BEventHeader* header; /**< Event header. */ + Int_t fNEvents; /**< Event counter. */ + + // Canvas + TCanvas* c_1_rawEnergy_front; + TCanvas* c_1_rawTime_front; + TCanvas* c_1_rawEnergy_vs_rawTime_front; + TCanvas* c_1_multi_front; + + // Histograms for Mapped data : Fine Time and Mult + TH1I* fh1_1_rawEnergy_front[Nstrips]; + TH1I* fh1_1_rawTime_front[Nstrips]; + TH2F* fh2_1_rawEnergy_vs_rawTime_front[Nstrips]; + TH1I* fh1_1_multi_front; + + public: + ClassDef(R3BAsyChimeraOnlineSpectra, 1) +}; + +#endif diff --git a/asysource/AsyChimeraReader.cxx b/asysource/AsyChimeraReader.cxx new file mode 100644 index 0000000..abd9948 --- /dev/null +++ b/asysource/AsyChimeraReader.cxx @@ -0,0 +1,122 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#include "AsyChimeraReader.h" + +#include +#include +#include + +#include + +#include "R3BAsyChimeraMappedData.h" +#include "R3BLogger.h" + +extern "C" { +#include "ext_data_client.h" +#include "ext_h101_chimera.h" +} + +AsyChimeraReader::AsyChimeraReader(EXT_STR_h101_ASYCHIMERA_onion* data, + size_t offset) + : R3BReader("AsyChimeraReader"), + fData(data), + fOffset(offset), + fArray(new TClonesArray("R3BAsyChimeraMappedData")), + fArrayTrigger(new TClonesArray("R3BAsyChimeraMappedData")) {} + +AsyChimeraReader::~AsyChimeraReader() { + if (fArray) { + delete fArray; + } + if (fArrayTrigger) { + delete fArrayTrigger; + } +} + +Bool_t AsyChimeraReader::Init(ext_data_struct_info* a_struct_info) { + Int_t ok; + R3BLOG(info, ""); + EXT_STR_h101_ASYCHIMERA_ITEMS_INFO(ok, *a_struct_info, fOffset, + EXT_STR_h101_ASYCHIMERA, 0); + if (!ok) { + R3BLOG(error, "Failed to setup structure information"); + return kFALSE; + } + + // Register output array in tree + FairRootManager::Instance()->Register( + "AsyChimeraMappedData", "AsyChimera mapped data", fArray, !fOnline); + + if (!fSkiptriggertimes) { + FairRootManager::Instance()->Register("AsyChimeraTriggerMapped", + "AsyChimera trigger mapped data", + fArrayTrigger, !fOnline); + } else { + fArrayTrigger = nullptr; + } + Reset(); + // initial clear (set number of hits to 0) + auto* data = reinterpret_cast(fData); + + return kTRUE; +} + +Bool_t AsyChimeraReader::R3BRead() { + R3BLOG(debug1, "Event data."); + // Convert plain raw data to multi-dimensional array + auto* data = reinterpret_cast(fData); + + // S1 detector + auto const& numchae = data->S[0].FRONTDE; + auto const& numchat = data->S[0].FRONTTOF; + + uint32_t ener[32]; + uint32_t tof[32]; + // clearing data + for (int i = 0; i < 32; i++) { + ener[i] = 0; + tof[i] = 0; + } + // decoding zero suppressed data + for (int i = 0; i < numchae; i++) { + uint32_t ch = data->S[0].FRONTDEI[i]; + ener[ch - 1] = data->S[0].FRONTDEv[i]; + // std::cout<S[0].FRONTTOFI[i]; + tof[ch - 1] = data->S[0].FRONTTOFv[i]; + } + + // filling mapped data of detector 1 (S[0] mapping-> DE FRONT) + uint32_t detector = 1; // de silicon + uint32_t side = 1; // front + for (int strip = 0; strip < 32; strip++) { + if (ener[strip] > 0 || tof[strip] > 0) { + new ((*fArray)[fArray->GetEntriesFast()]) R3BAsyChimeraMappedData( + detector, side, strip, ener[strip], tof[strip]); + } + } + + return kTRUE; +} + +void AsyChimeraReader::Reset() { + // Reset the output array + fArray->Clear(); + if (fArrayTrigger) fArrayTrigger->Clear(); +} + +ClassImp(AsyChimeraReader) diff --git a/asysource/AsyChimeraReader.h b/asysource/AsyChimeraReader.h new file mode 100644 index 0000000..d8d3e35 --- /dev/null +++ b/asysource/AsyChimeraReader.h @@ -0,0 +1,65 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +#pragma once + +#include + +#include "R3BReader.h" + +class TClonesArray; + +struct EXT_STR_h101_ASYCHIMERA_t; +typedef struct EXT_STR_h101_ASYCHIMERA_t EXT_STR_h101_ASYCHIMERA; +typedef struct EXT_STR_h101_ASYCHIMERA_onion_t EXT_STR_h101_ASYCHIMERA_onion; +class ext_data_struct_info; + +class AsyChimeraReader : public R3BReader { + public: + // Standard constructor + AsyChimeraReader(EXT_STR_h101_ASYCHIMERA_onion*, size_t); + + // Destructor + virtual ~AsyChimeraReader(); + + // Setup structure information + Bool_t Init(ext_data_struct_info*) override; + + // Read data from full event structure + Bool_t R3BRead() override; + + // Reset + void Reset() override; + + // Accessor to select online mode + inline void SetOnline(bool option) { fOnline = option; } + + // Accessor to skip trigger times + inline void SetSkipTriggerTimes() { fSkiptriggertimes = true; } + + private: + // Reader specific data structure from ucesb + EXT_STR_h101_ASYCHIMERA_onion* fData; + // Data offset + size_t fOffset; + // Don't store data for online + bool fOnline = false; + // Skip trigger times + bool fSkiptriggertimes = false; + // Output array + TClonesArray* fArray; /**< Output array. */ + TClonesArray* fArrayTrigger; /**< Output array for triggers. */ + + public: + ClassDefOverride(AsyChimeraReader, 0); +}; diff --git a/asysource/AsySourceLinkDef.h b/asysource/AsySourceLinkDef.h new file mode 100644 index 0000000..364b0d8 --- /dev/null +++ b/asysource/AsySourceLinkDef.h @@ -0,0 +1,13 @@ +// clang-format off + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class AsyChimeraReader + ; + +#pragma link C++ class EXT_STR_h101_ASYCHIMERA_onion_t; + +#endif diff --git a/asysource/CMakeLists.txt b/asysource/CMakeLists.txt index cd22419..b0de0fc 100755 --- a/asysource/CMakeLists.txt +++ b/asysource/CMakeLists.txt @@ -5,11 +5,13 @@ set(SYSTEM_INCLUDE_DIRECTORIES ${SYSTEM_INCLUDE_DIRECTORIES} ${BASE_INCLUDE_DIRE set(INCLUDE_DIRECTORIES #put here all directories where header files are located -#${R3BROOT_SOURCE_DIR}/r3bsource -#${R3BROOT_SOURCE_DIR}/r3bsource/base -#${R3BROOT_SOURCE_DIR}/asydata/chimeraData +${R3BROOT_SOURCE_DIR}/r3bsource +${R3BROOT_SOURCE_DIR}/r3bsource/base +${R3BROOT_SOURCE_DIR}/r3bsource/base/utils +${R3BROOT_SOURCE_DIR}/r3bbase +${R3BASY_SOURCE_DIR}/asydata/chimeraData ${R3BASY_SOURCE_DIR}/asysource -#${R3BASY_SOURCE_DIR}/asysource/chimera +${R3BASY_SOURCE_DIR}/asysource/ext ) set(LINK_DIRECTORIES ${ROOT_LIBRARY_DIR} ${FAIRROOT_LIBRARY_DIR} ${ucesb_LIBRARY_DIR} ) @@ -18,10 +20,14 @@ include_directories( ${INCLUDE_DIRECTORIES}) include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) link_directories( ${LINK_DIRECTORIES}) -#file(GLOB SRCS *.cxx) +file(GLOB SRCS *.cxx) + +#set(SRCS +#./chimera/AsyChimeraReader.cxx +#) Set(STRUCT_HEADERS -#ext/ext_h101_chimera.h +ext/ext_h101_chimera.h ) # fill list of header files from list of source files @@ -29,7 +35,7 @@ Set(STRUCT_HEADERS CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") Set(HEADERS ${STRUCT_HEADERS} ${HEADERS}) -set(LINKDEF SourceLinkDef.h) +set(LINKDEF AsySourceLinkDef.h) set(DEPENDENCIES R3BBase Base R3BAsyData R3Bsource ${ucesb_LIBRARY_SHARED} FairTools) set(LIBRARY_NAME R3BAsySource) diff --git a/asysource/ext/ext_h101_chimera.h b/asysource/ext/ext_h101_chimera.h new file mode 100644 index 0000000..c4e4d0e --- /dev/null +++ b/asysource/ext/ext_h101_chimera.h @@ -0,0 +1,178 @@ +/******************************************************** + * + * Structure for ext_data_fetch_event() filling. + * + * Do not edit - automatically generated. + */ + +#ifndef __GUARD_H101_ASYCHIMERA_EXT_H101_H__ +#define __GUARD_H101_ASYCHIMERA_EXT_H101_H__ + +#ifndef __CINT__ +# include +#else +/* For CINT (old version trouble with stdint.h): */ +# ifndef uint32_t +typedef unsigned int uint32_t; +typedef int int32_t; +# endif +#endif +#ifndef EXT_STRUCT_CTRL +# define EXT_STRUCT_CTRL(x) +#endif + +/******************************************************** + * + * Plain structure (layout as ntuple/root file): + */ + +typedef struct EXT_STR_h101_ASYCHIMERA_t +{ + /* INFO */ + uint32_t TRIGGER /* [0,15] */; + uint32_t EVENTNO /* [-1,-1] */; + uint32_t TSTAMPLO /* [-1,-1] */; + uint32_t TSTAMPHI /* [-1,-1] */; + uint32_t TSTAMPSRCID /* [-1,-1] */; + uint32_t MERGE_STATUS /* [-1,-1] */; + uint32_t MERGE_IDMASK /* [-1,-1] */; + /* RAW */ + uint32_t TIMESTAMP_MASTER_ID /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T1 /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T2 /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T3 /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T4 /* [0,65535] */; + uint32_t S1FRONTDE /* [0,32] */; + uint32_t S1FRONTDEI[32 EXT_STRUCT_CTRL(S1FRONTDE)] /* [1,32] */; + uint32_t S1FRONTDEv[32 EXT_STRUCT_CTRL(S1FRONTDE)] /* [0,65535] */; + uint32_t S1BACKDE /* [0,32] */; + uint32_t S1BACKDEI[32 EXT_STRUCT_CTRL(S1BACKDE)] /* [1,32] */; + uint32_t S1BACKDEv[32 EXT_STRUCT_CTRL(S1BACKDE)] /* [0,65535] */; + uint32_t S1FRONTTOF /* [0,32] */; + uint32_t S1FRONTTOFI[32 EXT_STRUCT_CTRL(S1FRONTTOF)] /* [1,32] */; + uint32_t S1FRONTTOFv[32 EXT_STRUCT_CTRL(S1FRONTTOF)] /* [0,65535] */; + uint32_t S1BACKTOF /* [0,32] */; + uint32_t S1BACKTOFI[32 EXT_STRUCT_CTRL(S1BACKTOF)] /* [1,32] */; + uint32_t S1BACKTOFv[32 EXT_STRUCT_CTRL(S1BACKTOF)] /* [0,65535] */; + +} EXT_STR_h101_ASYCHIMERA; + +/******************************************************** + * + * Structure with multiple levels of arrays (partially) + * recovered (recommended): + */ + +typedef struct EXT_STR_h101_ASYCHIMERA_onion_t +{ + /* INFO */ + uint32_t TRIGGER; + uint32_t EVENTNO; + uint32_t TSTAMPLO; + uint32_t TSTAMPHI; + uint32_t TSTAMPSRCID; + uint32_t MERGE_STATUS; + uint32_t MERGE_IDMASK; + /* RAW */ + uint32_t TIMESTAMP_MASTER_ID; + uint32_t TIMESTAMP_MASTER_WR_T[4]; + struct { + uint32_t FRONTDE; + uint32_t FRONTDEI[32 /* FRONTDE */]; + uint32_t FRONTDEv[32 /* FRONTDE */]; + uint32_t BACKDE; + uint32_t BACKDEI[32 /* BACKDE */]; + uint32_t BACKDEv[32 /* BACKDE */]; + uint32_t FRONTTOF; + uint32_t FRONTTOFI[32 /* FRONTTOF */]; + uint32_t FRONTTOFv[32 /* FRONTTOF */]; + uint32_t BACKTOF; + uint32_t BACKTOFI[32 /* BACKTOF */]; + uint32_t BACKTOFv[32 /* BACKTOF */]; + } S[1]; + +} EXT_STR_h101_ASYCHIMERA_onion; + +/*******************************************************/ + +#define EXT_STR_h101_ASYCHIMERA_ITEMS_INFO(ok,si,offset,struct_t,printerr) do { \ + ok = 1; \ + /* INFO */ \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TRIGGER, UINT32,\ + "TRIGGER",15,0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + EVENTNO, UINT32,\ + "EVENTNO",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + TSTAMPLO, UINT32,\ + "TSTAMPLO",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + TSTAMPHI, UINT32,\ + "TSTAMPHI",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + TSTAMPSRCID, UINT32,\ + "TSTAMPSRCID",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + MERGE_STATUS, UINT32,\ + "MERGE_STATUS",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + MERGE_IDMASK, UINT32,\ + "MERGE_IDMASK",0/*flags*/); \ + /* RAW */ \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_ID, UINT32,\ + "TIMESTAMP_MASTER_ID",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T1, UINT32,\ + "TIMESTAMP_MASTER_WR_T1",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T2, UINT32,\ + "TIMESTAMP_MASTER_WR_T2",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T3, UINT32,\ + "TIMESTAMP_MASTER_WR_T3",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T4, UINT32,\ + "TIMESTAMP_MASTER_WR_T4",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + S1FRONTDE, UINT32,\ + "S1FRONTDE",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTDEI, UINT32,\ + "S1FRONTDEI", "S1FRONTDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTDEv, UINT32,\ + "S1FRONTDEv", "S1FRONTDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + S1BACKDE, UINT32,\ + "S1BACKDE",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1BACKDEI, UINT32,\ + "S1BACKDEI", "S1BACKDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1BACKDEv, UINT32,\ + "S1BACKDEv", "S1BACKDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + S1FRONTTOF, UINT32,\ + "S1FRONTTOF",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTTOFI, UINT32,\ + "S1FRONTTOFI", "S1FRONTTOF",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTTOFv, UINT32,\ + "S1FRONTTOFv", "S1FRONTTOF",0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + S1BACKTOF, UINT32,\ + "S1BACKTOF",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1BACKTOFI, UINT32,\ + "S1BACKTOFI", "S1BACKTOF",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1BACKTOFv, UINT32,\ + "S1BACKTOFv", "S1BACKTOF",0/*flags*/); \ + \ +} while (0); + +#endif/*__GUARD_H101_ASYCHIMERA_EXT_H101_H__*/ +/*******************************************************/ diff --git a/asysource/ext/ext_h101_chimera.h.old b/asysource/ext/ext_h101_chimera.h.old new file mode 100644 index 0000000..de6b81e --- /dev/null +++ b/asysource/ext/ext_h101_chimera.h.old @@ -0,0 +1,179 @@ +/******************************************************** + * + * Structure for ext_data_fetch_event() filling. + * + * Do not edit - automatically generated. + */ + +#ifndef __GUARD_H101_ASYCHIMERA_EXT_H101_H__ +#define __GUARD_H101_ASYCHIMERA_EXT_H101_H__ + +#ifndef __CINT__ +# include +#else +/* For CINT (old version trouble with stdint.h): */ +# ifndef uint32_t +typedef unsigned int uint32_t; +typedef int int32_t; +# endif +#endif +#ifndef EXT_STRUCT_CTRL +# define EXT_STRUCT_CTRL(x) +#endif + +/******************************************************** + * + * Plain structure (layout as ntuple/root file): + */ + +typedef struct EXT_STR_h101_ASYCHIMERA_t +{ + /* INFO */ + uint32_t TRIGGER /* [0,15] */; + uint32_t EVENTNO /* [-1,-1] */; + uint32_t TSTAMPLO /* [-1,-1] */; + uint32_t TSTAMPHI /* [-1,-1] */; + uint32_t TSTAMPSRCID /* [-1,-1] */; + uint32_t MERGE_STATUS /* [-1,-1] */; + uint32_t MERGE_IDMASK /* [-1,-1] */; + /* RAW */ + uint32_t TIMESTAMP_MASTER_ID /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T1 /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T2 /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T3 /* [0,65535] */; + uint32_t TIMESTAMP_MASTER_WR_T4 /* [0,65535] */; + uint32_t FRONTDE /* [0,32] */; + uint32_t FRONTDEI[32 EXT_STRUCT_CTRL(FRONTDE)] /* [1,32] */; + uint32_t FRONTDEv[32 EXT_STRUCT_CTRL(FRONTDE)] /* [0,65535] */; + uint32_t S1FRONTDE /* [0,32] */; + uint32_t S1FRONTDEI[32 EXT_STRUCT_CTRL(S1FRONTDE)] /* [1,32] */; + uint32_t S1FRONTDEv[32 EXT_STRUCT_CTRL(S1FRONTDE)] /* [0,65535] */; + uint32_t S1FRONTTOF /* [0,32] */; + uint32_t S1FRONTTOFI[32 EXT_STRUCT_CTRL(S1FRONTTOF)] /* [1,32] */; + uint32_t S1FRONTTOFv[32 EXT_STRUCT_CTRL(S1FRONTTOF)] /* [0,65535] */; + uint32_t S1BACKTOF /* [0,32] */; + uint32_t S1BACKTOFI[32 EXT_STRUCT_CTRL(S1BACKTOF)] /* [1,32] */; + uint32_t S1BACKTOFv[32 EXT_STRUCT_CTRL(S1BACKTOF)] /* [0,65535] */; + +} EXT_STR_h101_ASYCHIMERA; + +/******************************************************** + * + * Structure with multiple levels of arrays (partially) + * recovered (recommended): + */ + +typedef struct EXT_STR_h101_ASYCHIMERA_onion_t +{ + /* INFO */ + uint32_t TRIGGER; + uint32_t EVENTNO; + uint32_t TSTAMPLO; + uint32_t TSTAMPHI; + uint32_t TSTAMPSRCID; + uint32_t MERGE_STATUS; + uint32_t MERGE_IDMASK; + /* RAW */ + uint32_t TIMESTAMP_MASTER_ID; + uint32_t TIMESTAMP_MASTER_WR_T[4]; + uint32_t FRONTDE; + uint32_t FRONTDEI[32 /* FRONTDE */]; + uint32_t FRONTDEv[32 /* FRONTDE */]; + struct { + uint32_t FRONTDE; + uint32_t FRONTDEI[32 /* FRONTDE */]; + uint32_t FRONTDEv[32 /* FRONTDE */]; + uint32_t FRONTTOF; + uint32_t FRONTTOFI[32 /* FRONTTOF */]; + uint32_t FRONTTOFv[32 /* FRONTTOF */]; + uint32_t BACKTOF; + uint32_t BACKTOFI[32 /* BACKTOF */]; + uint32_t BACKTOFv[32 /* BACKTOF */]; + } S[1]; + +} EXT_STR_h101_ASYCHIMERA_onion; + +/*******************************************************/ + +#define EXT_STR_h101_ASYCHIMERA_ITEMS_INFO(ok,si,offset,struct_t,printerr) do { \ + ok = 1; \ + /* INFO */ \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TRIGGER, UINT32,\ + "TRIGGER",15,0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + EVENTNO, UINT32,\ + "EVENTNO",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + TSTAMPLO, UINT32,\ + "TSTAMPLO",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + TSTAMPHI, UINT32,\ + "TSTAMPHI",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + TSTAMPSRCID, UINT32,\ + "TSTAMPSRCID",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + MERGE_STATUS, UINT32,\ + "MERGE_STATUS",0/*flags*/); \ + EXT_STR_ITEM_INFO2 (ok,si,offset,struct_t,printerr,\ + MERGE_IDMASK, UINT32,\ + "MERGE_IDMASK",0/*flags*/); \ + /* RAW */ \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_ID, UINT32,\ + "TIMESTAMP_MASTER_ID",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T1, UINT32,\ + "TIMESTAMP_MASTER_WR_T1",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T2, UINT32,\ + "TIMESTAMP_MASTER_WR_T2",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T3, UINT32,\ + "TIMESTAMP_MASTER_WR_T3",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + TIMESTAMP_MASTER_WR_T4, UINT32,\ + "TIMESTAMP_MASTER_WR_T4",65535,0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + FRONTDE, UINT32,\ + "FRONTDE",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + FRONTDEI, UINT32,\ + "FRONTDEI", "FRONTDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + FRONTDEv, UINT32,\ + "FRONTDEv", "FRONTDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + S1FRONTDE, UINT32,\ + "S1FRONTDE",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTDEI, UINT32,\ + "S1FRONTDEI", "S1FRONTDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTDEv, UINT32,\ + "S1FRONTDEv", "S1FRONTDE",0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + S1FRONTTOF, UINT32,\ + "S1FRONTTOF",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTTOFI, UINT32,\ + "S1FRONTTOFI", "S1FRONTTOF",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1FRONTTOFv, UINT32,\ + "S1FRONTTOFv", "S1FRONTTOF",0/*flags*/); \ + EXT_STR_ITEM_INFO2_LIM(ok,si,offset,struct_t,printerr,\ + S1BACKTOF, UINT32,\ + "S1BACKTOF",32,0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1BACKTOFI, UINT32,\ + "S1BACKTOFI", "S1BACKTOF",0/*flags*/); \ + EXT_STR_ITEM_INFO2_ZZP(ok,si,offset,struct_t,printerr,\ + S1BACKTOFv, UINT32,\ + "S1BACKTOFv", "S1BACKTOF",0/*flags*/); \ + \ +} while (0); + +#endif/*__GUARD_H101_ASYCHIMERA_EXT_H101_H__*/ + +/*******************************************************/ diff --git a/geometry/chimera_pro.geo.root b/geometry/chimera_pro.geo.root new file mode 100644 index 0000000..19437ff Binary files /dev/null and b/geometry/chimera_pro.geo.root differ diff --git a/geometry/chimera_prova.geo.root b/geometry/chimera_prova.geo.root new file mode 100644 index 0000000..65013a2 Binary files /dev/null and b/geometry/chimera_prova.geo.root differ diff --git a/krab/AsyKrabLinkDef.h b/krab/AsyKrabLinkDef.h new file mode 100644 index 0000000..b979201 --- /dev/null +++ b/krab/AsyKrabLinkDef.h @@ -0,0 +1,13 @@ +#ifdef __CINT__ +// clang-format off +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class R3BAsyKrab + ; +#pragma link C++ class R3BAsyKrabContFact + ; +//#pragma link C++ class R3BAsyChimeraDigi+ ; +#pragma link C++ class R3BAsyKrabCalPar + ; +#pragma link C++ class R3BAsyKrabHitPar + ; + +#endif diff --git a/krab/CMakeLists.txt b/krab/CMakeLists.txt new file mode 100755 index 0000000..05a37a7 --- /dev/null +++ b/krab/CMakeLists.txt @@ -0,0 +1,39 @@ +# Create a library called "libR3BAsyKrab" which includes the source files given in +# the array. +# The extension is already found. Any number of sources could be listed here. + +Set(SYSTEM_INCLUDE_DIRECTORIES ${SYSTEM_INCLUDE_DIRECTORIES} ${BASE_INCLUDE_DIRECTORIES} ) + +set(INCLUDE_DIRECTORIES +#put here all directories where header files are located +${R3BROOT_SOURCE_DIR}/r3bbase +${R3BROOT_SOURCE_DIR}/r3bdata +${R3BROOT_SOURCE_DIR}/tracking +${R3BASY_SOURCE_DIR}/asydata +${R3BASY_SOURCE_DIR}/asydata/krabData +${R3BASY_SOURCE_DIR}/krab +${R3BASY_SOURCE_DIR}/krab/sim +${R3BASY_SOURCE_DIR}/krab/pars +) + +include_directories( ${INCLUDE_DIRECTORIES}) +include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES}) + +set(LINK_DIRECTORIES ${ROOT_LIBRARY_DIR} ${FAIRROOT_LIBRARY_DIR} ) + +link_directories( ${LINK_DIRECTORIES}) + +file(GLOB SRCS ./sim/*.cxx ./pars/*.cxx ) + + + +# fill list of header files from list of source files +# by exchanging the file extension +CHANGE_FILE_EXTENSION(*.cxx *.h HEADERS "${SRCS}") + +set(LINKDEF AsyKrabLinkDef.h) +set(LIBRARY_NAME R3BAsyKrab) +set(DEPENDENCIES + Base R3BBase R3BData R3BAsyData) + +GENERATE_LIBRARY() diff --git a/krab/pars/R3BAsyKrabCalPar.cxx b/krab/pars/R3BAsyKrabCalPar.cxx new file mode 100644 index 0000000..3bc927a --- /dev/null +++ b/krab/pars/R3BAsyKrabCalPar.cxx @@ -0,0 +1,75 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// ------------------------------------------------------------------ +// ----- R3BKrabCalPar source file ------ +// ------------------------------------------------------------------ + +#include "R3BAsyKrabCalPar.h" + +#include "FairDetParIo.h" +#include "FairLogger.h" +#include "FairParamList.h" +#include "R3BLogger.h" +#include "TArrayF.h" +#include "TArrayI.h" +#include "TMath.h" +#include "TString.h" + +// ---- Standard Constructor --------------------------------------------------- +R3BAsyKrabCalPar::R3BAsyKrabCalPar(const char *name, const char *title, + const char *context) + : FairParGenericSet(name, title, context) + +{ + // just template, start version +} + +// ---- Destructor ------------------------------------------------------------ +R3BAsyKrabCalPar::~R3BAsyKrabCalPar() { clear(); } + +// ---- Method clear ---------------------------------------------------------- +void R3BAsyKrabCalPar::clear() { + status = kFALSE; + resetInputVersions(); +} + +// ---- Method putParams ------------------------------------------------------ +void R3BAsyKrabCalPar::putParams(FairParamList *list) { + R3BLOG(info, "called"); + if (!list) { + R3BLOG(fatal, "Could not find FairParamList"); + return; + } +} + +// ---- Method getParams ------------------------------------------------------ +Bool_t R3BAsyKrabCalPar::getParams(FairParamList *list) { + R3BLOG(info, "called"); + if (!list) { + R3BLOG(fatal, "Could not find FairParamList"); + return kFALSE; + } + + return kTRUE; +} + +// ---- Method print ---------------------------------------------------------- +void R3BAsyKrabCalPar::print() { printParams(); } + +// ---- Method printParams ---------------------------------------------------- +void R3BAsyKrabCalPar::printParams() { + R3BLOG(info, "Krab parameters not yet defined"); +} + +ClassImp(R3BAsyKrabCalPar); diff --git a/krab/pars/R3BAsyKrabCalPar.h b/krab/pars/R3BAsyKrabCalPar.h new file mode 100644 index 0000000..999786f --- /dev/null +++ b/krab/pars/R3BAsyKrabCalPar.h @@ -0,0 +1,68 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// ---------------------------------------------------------------- +// ----- R3BKrabCalPar header file ------ +// ----- Created 24/10/23 by E. De Filippo and P. Russotto ------ +// ---------------------------------------------------------------- + +#ifndef R3BAsyKrabCalPar_H +#define R3BAsyKrabCalPar_H 1 + +#include +#include + +#include + +#include "FairParGenericSet.h" +#include "TArrayF.h" +#include "TArrayI.h" + +class FairParamList; + +class R3BAsyKrabCalPar : public FairParGenericSet { + public: + /** Standard constructor **/ + R3BAsyKrabCalPar(const char* name = "KrabCalPar", + const char* title = "Krab Cal Parameters", + const char* context = "KrabCalParContext"); + + /** Destructor **/ + virtual ~R3BAsyKrabCalPar(); + + /** Method to reset all parameters **/ + virtual void clear(); + + /** Method to store all parameters using FairRuntimeDB **/ + virtual void putParams(FairParamList* list); + + /** Method to retrieve all parameters using FairRuntimeDB**/ + Bool_t getParams(FairParamList* list); + + /** Method to print values of parameters to the standard output **/ + virtual void print(); + void printParams(); + + /** Accessor functions **/ + // not yet defined + + private: + // private params not yet defined + const R3BAsyKrabCalPar& operator=(const R3BAsyKrabCalPar&); + R3BAsyKrabCalPar(const R3BAsyKrabCalPar&); + + public: + ClassDef(R3BAsyKrabCalPar, 1); +}; + +#endif /* R3BAsyKrabCalPar_H */ diff --git a/krab/pars/R3BAsyKrabContFact.cxx b/krab/pars/R3BAsyKrabContFact.cxx new file mode 100644 index 0000000..26cb9c1 --- /dev/null +++ b/krab/pars/R3BAsyKrabContFact.cxx @@ -0,0 +1,73 @@ +// ----------------------------------------------------------------------- +// ------ +// Factory for the parameter containers in libR3BAsyKrab ------ +// ------ +// ----------------------------------------------------------------------- + +#include "R3BAsyKrabContFact.h" + +#include "FairLogger.h" +#include "FairRuntimeDb.h" +#include "R3BAsyKrabCalPar.h" +#include "R3BAsyKrabHitPar.h" +#include "R3BLogger.h" +#include "R3BTGeoPar.h" +#include "TClass.h" + +static R3BAsyKrabContFact gR3BAsyKrabContFact; + +R3BAsyKrabContFact::R3BAsyKrabContFact() { + // Constructor (called when the library is loaded) + fName = "R3BAsyKrabContFact"; + fTitle = "Factory for parameter containers in libR3BAsyKrab"; + setAllContainers(); + FairRuntimeDb::instance()->addContFactory(this); +} + +void R3BAsyKrabContFact::setAllContainers() { + // Creates the Container objects with all accepted contexts and adds them to + // the list of containers for the STS library. + + FairContainer *p1 = new FairContainer("KrabCalPar", "Krab Cal Parameters", + "KrabCalParContext"); + p1->addContext("KrabCalParContext"); + containers->Add(p1); + + FairContainer *p2 = new FairContainer("KrabHitPar", "Krab Hit Parameters", + "KrabHitParContext"); + p2->addContext("KrabHitParContext"); + containers->Add(p2); + + FairContainer *p3 = new FairContainer( + "KrabGeoPar", "Krab geometry parameters", "GeometryParameterContext"); + p3->addContext("GeometryParameterContext"); + containers->Add(p3); +} + +FairParSet *R3BAsyKrabContFact::createContainer(FairContainer *c) { + // Trals the constructor of the corresponding parameter container. + // For an actual context, which is not an empty string and not the default + // context of this container, the name is concatinated with the context. + + const char *name = c->GetName(); + R3BLOG(info, "Create container name: " << name); + FairParSet *p = 0; + if (strcmp(name, "KrabCalPar") == 0) { + p = new R3BAsyKrabCalPar(c->getConcatName().Data(), c->GetTitle(), + c->getContext()); + } + + if (strcmp(name, "KrabHitPar") == 0) { + p = new R3BAsyKrabHitPar(c->getConcatName().Data(), c->GetTitle(), + c->getContext()); + } + + if (strcmp(name, "KrabGeoPar") == 0) { + p = new R3BTGeoPar(c->getConcatName().Data(), c->GetTitle(), + c->getContext()); + } + + return p; +} + +ClassImp(R3BAsyKrabContFact) diff --git a/krab/pars/R3BAsyKrabContFact.h b/krab/pars/R3BAsyKrabContFact.h new file mode 100644 index 0000000..6a54de7 --- /dev/null +++ b/krab/pars/R3BAsyKrabContFact.h @@ -0,0 +1,25 @@ +// ----------------------------------------------------------------------- +// ------ +// Factory for the parameter containers in libR3BAsyKrab ------ +// created 24/10/2023 by E. De Filippo and P. Russotto ------ +// ----------------------------------------------------------------------- + +#ifndef R3BAsyKrabContFact_H +#define R3BAsyKrabContFact_H 1 + +#include "FairContFact.h" + +class FairContainer; + +class R3BAsyKrabContFact : public FairContFact { + private: + void setAllContainers(); + + public: + R3BAsyKrabContFact(); + ~R3BAsyKrabContFact() {} + FairParSet* createContainer(FairContainer*); + ClassDef(R3BAsyKrabContFact, 0) // Factory for all Krab parameter containers +}; + +#endif /* R3BAsyKrabContFact_H */ diff --git a/krab/pars/R3BAsyKrabHitPar.cxx b/krab/pars/R3BAsyKrabHitPar.cxx new file mode 100644 index 0000000..7cb09ab --- /dev/null +++ b/krab/pars/R3BAsyKrabHitPar.cxx @@ -0,0 +1,71 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// ------------------------------------------------------------------- +// ----- R3BAsyKrabHitPar source file ------ +// ------------------------------------------------------------------- + +#include "R3BAsyKrabHitPar.h" + +#include + +#include "FairDetParIo.h" +#include "FairLogger.h" +#include "FairParamList.h" +#include "R3BLogger.h" +#include "TArrayF.h" +#include "TMath.h" +#include "TString.h" + +// ---- Standard Constructor --------------------------------------------------- +R3BAsyKrabHitPar::R3BAsyKrabHitPar(const char *name, const char *title, + const char *context) + : FairParGenericSet(name, title, context) {} + +// ---- Destructor ------------------------------------------------------------ +R3BAsyKrabHitPar::~R3BAsyKrabHitPar() { clear(); } + +// ---- Method clear ---------------------------------------------------------- +void R3BAsyKrabHitPar::clear() { + status = kFALSE; + resetInputVersions(); +} + +// ---- Method putParams ------------------------------------------------------ +void R3BAsyKrabHitPar::putParams(FairParamList *list) { + R3BLOG(info, "R3BAsyKrabHitPar::putParams() called"); + if (!list) { + return; + } +} + +// ---- Method getParams ------------------------------------------------------ +Bool_t R3BAsyKrabHitPar::getParams(FairParamList *list) { + R3BLOG(info, "R3BAsyKrabHitPar::getParams() called"); + if (!list) { + R3BLOG(fatal, "Could not find FairParamList"); + return kFALSE; + } + + return kTRUE; +} + +// ---- Method print ---------------------------------------------------------- +void R3BAsyKrabHitPar::print() { printParams(); } + +// ---- Method printParams ---------------------------------------------------- +void R3BAsyKrabHitPar::printParams() { + R3BLOG(info, "R3BAsyKrabHitPar::printParams() AsyKrab detector Parameters"); +} + +ClassImp(R3BAsyKrabHitPar); diff --git a/krab/pars/R3BAsyKrabHitPar.h b/krab/pars/R3BAsyKrabHitPar.h new file mode 100644 index 0000000..3af8eb5 --- /dev/null +++ b/krab/pars/R3BAsyKrabHitPar.h @@ -0,0 +1,75 @@ +/****************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 Members of R3B Collaboration * + * * + * This software is distributed under the terms of the * + * GNU General Public Licence (GPL) version 3, * + * copied verbatim in the file "LICENSE". * + * * + * In applying this license GSI does not waive the privileges and immunities * + * granted to it by virtue of its status as an Intergovernmental Organization * + * or submit itself to any jurisdiction. * + ******************************************************************************/ + +// --------------------------------------------------------------- +// ----- R3BAsyKrabHitPar header file ------ +// ----- Created 24/10/23 by E. De Filippo and P. Russotto ------ +// --------------------------------------------------------------- + +#ifndef R3BAsyKrabHitPar_H +#define R3BAsyKrabHitPar_H 1 + +#include + +#include +#include + +#include "FairDetParIo.h" +#include "FairLogger.h" +#include "FairParGenericSet.h" +#include "FairParamList.h" +#include "R3BTsplinePar.h" +#include "TArrayF.h" +#include "TArrayI.h" +#include "TMath.h" +#include "TObjArray.h" +#include "TObject.h" +#include "TSpline.h" +#include "TString.h" + +class FairParamList; + +class R3BAsyKrabHitPar : public FairParGenericSet { + public: + /** Standard constructor **/ + R3BAsyKrabHitPar(const char* name = "AsyKrabHitPar", + const char* title = "AsyKrab Hit Parameters", + const char* context = "AsyKrabHitParContext"); + + /** Destructor **/ + virtual ~R3BAsyKrabHitPar(); + + /** Method to reset all parameters **/ + virtual void clear(); + + /** Method to store all parameters using FairRuntimeDB **/ + virtual void putParams(FairParamList* list); + + /** Method to retrieve all parameters using FairRuntimeDB**/ + Bool_t getParams(FairParamList* list); + + /** Method to print values of parameters to the standard output **/ + virtual void print(); + void printParams(); + + // Create more Methods if you need them! + + private: + const R3BAsyKrabHitPar& operator=( + const R3BAsyKrabHitPar&); /*< an assignment operator>*/ + R3BAsyKrabHitPar(const R3BAsyKrabHitPar&); /*< a copy constructor >*/ + + ClassDef(R3BAsyKrabHitPar, 1); +}; + +#endif diff --git a/krab/sim/R3BAsyKrab.cxx b/krab/sim/R3BAsyKrab.cxx new file mode 100644 index 0000000..c90c6a8 --- /dev/null +++ b/krab/sim/R3BAsyKrab.cxx @@ -0,0 +1,199 @@ +// -------------------------------------------------------------------------- +// ----- R3BAsyKrab source file ------ +// -------------------------------------------------------------------------- +#include "R3BAsyKrab.h" + +#include "FairRootManager.h" +#include "FairRun.h" +#include "FairVolume.h" +#include "R3BAsyKrabPoint.h" +#include "R3BLogger.h" +#include "R3BMCStack.h" +#include "TClonesArray.h" +#include "TGeoManager.h" +#include "TParticle.h" +#include "TVirtualMC.h" +#include "TVirtualMCStack.h" + +#define U_MEV 931.4940954 + +R3BAsyKrab::R3BAsyKrab() : R3BAsyKrab("") {} + +R3BAsyKrab::R3BAsyKrab(const TString &geoFile, const TGeoTranslation &trans, + const TGeoRotation &rot) + : R3BAsyKrab(geoFile, {trans, rot}) {} + +R3BAsyKrab::R3BAsyKrab(const TString &geoFile, const TGeoCombiTrans &combi) + : R3BDetector("R3BAsyKrab", kKRAB, geoFile, combi), + fAsyKrabCollection(new TClonesArray("R3BAsyKrabPoint")), + fPosIndex(0) { + ResetParameters(); +} + +R3BAsyKrab::~R3BAsyKrab() { + if (fAsyKrabCollection) { + fAsyKrabCollection->Delete(); + delete fAsyKrabCollection; + } +} + +void R3BAsyKrab::Initialize() { + FairDetector::Initialize(); + + R3BLOG(info, "R3BAsyKrab: initialisation"); + R3BLOG(debug, "R3BAsyKrab: Vol (McId) def"); +} + +// ----- Public method ProcessHits -------------------------------------- +Bool_t R3BAsyKrab::ProcessHits(FairVolume *vol) { + /** This method is called from the MC stepping */ + + // Set parameters at entrance of volume. Reset ELoss. + if (TVirtualMC::GetMC()->IsTrackEntering()) { + fELoss = 0.; + fLightYield = 0.; + fNSteps = 0; // FIXME + fTime = TVirtualMC::GetMC()->TrackTime() * 1.0e09; + fLength = TVirtualMC::GetMC()->TrackLength(); + TVirtualMC::GetMC()->TrackPosition(fPosIn); + TVirtualMC::GetMC()->TrackMomentum(fMomIn); + fEinc = TVirtualMC::GetMC()->Etot() - + TVirtualMC::GetMC()->TrackMass(); // be aware!! Relativistic mass! + } + + // Sum energy loss for all steps in the active volume + fELoss += TVirtualMC::GetMC()->Edep() * 1000.; // in MeV; + + Double_t M_in = TVirtualMC::GetMC()->TrackMass() * 1000.; + // Charge and mass are now obtained from PDG Code + // Double_t fZ_in = int(TVirtualMC::GetMC()->TrackPid() / 10000) - 100000.; + // Double_t fA_in = 0.1 * (TVirtualMC::GetMC()->TrackPid() - (100000 + + // fZ_in) * 10000.); + + Double_t fA_in = M_in / U_MEV; + Double_t fZ_in = TVirtualMC::GetMC()->TrackCharge(); + + Double_t dE = TVirtualMC::GetMC()->Edep() * 1000.; // in MeV + TString ptype = TVirtualMC::GetMC()->GetStack()->GetCurrentTrack()->GetName(); + + Double_t lightYield = dE; + + Double_t MCTrackCharge = TVirtualMC::GetMC()->TrackCharge(); + + if (MCTrackCharge != 0) { + Double_t dedxcm = 0.; + Double_t lightYieldxcm = 0.; + Double_t MCstep = TVirtualMC::GetMC()->TrackStep(); + if (MCstep > 0) { + dedxcm = 1000. * TVirtualMC::GetMC()->Edep() / (MCstep * 1.00); + lightYield = lightYield; + fLightYield = fLightYield + lightYield; + lightYieldxcm = lightYield / MCstep; + } + } + + if (fELoss > 0) { + fNSteps++; + // Set additional parameters at exit of active volume. Create + // R3BAsyKrabPoint. + if (TVirtualMC::GetMC()->IsTrackExiting() || + TVirtualMC::GetMC()->IsTrackStop() || + TVirtualMC::GetMC()->IsTrackDisappeared()) { + fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber(); + fParentTrackID = + TVirtualMC::GetMC()->GetStack()->GetCurrentParentTrackNumber(); + fVolumeID = vol->getMCid(); + fDetCopyID = vol->getCopyNo(); + fTrackPID = TVirtualMC::GetMC()->TrackPid(); + fUniqueID = + TVirtualMC::GetMC()->GetStack()->GetCurrentTrack()->GetUniqueID(); + fLength = gMC->TrackLength(); + gMC->TrackPosition(fPosOut); + gMC->TrackMomentum(fMomOut); + + if (fELoss == 0.) { + return kFALSE; + } + AddPoint(fTrackID, fVolumeID, fDetCopyID, fZ_in, fA_in, + TVector3(fPosIn.X(), fPosIn.Y(), fPosIn.Z()), + TVector3(fPosOut.X(), fPosOut.Y(), fPosOut.Z()), + TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), + TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime, + fLength, fELoss, fLightYield); + + // Increment number of AsyKrabPoints for this track + R3BStack *stack = + static_cast(TVirtualMC::GetMC()->GetStack()); + stack->AddPoint(kKRAB); + ResetParameters(); + } + } + return kTRUE; +} + +// ----- Public method EndOfEvent ----------------------------------------- +void R3BAsyKrab::EndOfEvent() { + if (fVerboseLevel) { + Print(); + } + Reset(); +} + +// ----- Public method Register ------------------------------------------- +void R3BAsyKrab::Register() { + FairRootManager::Instance()->Register("AsyKrabPoint", GetName(), + fAsyKrabCollection, kTRUE); +} + +// ----- Public method GetCollection -------------------------------------- +TClonesArray *R3BAsyKrab::GetCollection(Int_t iColl) const { + if (iColl == 0) + return fAsyKrabCollection; + else { + return nullptr; + } +} + +// ----- Public method Print ---------------------------------------------- +void R3BAsyKrab::Print(Option_t *option) const { + Int_t nHits = fAsyKrabCollection->GetEntriesFast(); + R3BLOG(info, nHits << " points registered in this event"); +} + +// ----- Public method Reset ---------------------------------------------- +void R3BAsyKrab::Reset() { + fAsyKrabCollection->Clear(); + ResetParameters(); +} + +// ----- Private method AddPoint -------------------------------------------- +R3BAsyKrabPoint *R3BAsyKrab::AddPoint(Int_t trackID, Int_t detID, Int_t volid, + Double_t Z, Double_t A, TVector3 posIn, + TVector3 posOut, TVector3 momIn, + TVector3 momOut, Double_t time, + Double_t length, Double_t eLoss, + Double_t LightYield) { + TClonesArray &clref = *fAsyKrabCollection; + Int_t size = clref.GetEntriesFast(); + if (fVerboseLevel > 1) { + R3BLOG(info, "Adding point at (" + << posIn.X() << ", " << posIn.Y() << ", " << posIn.Z() + << ") cm, detector " << detID << ", track " << trackID + << ", energy loss " << eLoss * 1e06 << " keV " + << ", LightYield " << LightYield * 1e03 << " MeVeq "); + } + return new (clref[size]) + R3BAsyKrabPoint(trackID, detID, volid, Z, A, posIn, posOut, momIn, momOut, + time, length, eLoss, LightYield); +} + +// ----- Public method CheckIfSensitive ---------------------------------- +Bool_t R3BAsyKrab::CheckIfSensitive(std::string name) { + if (TString(name).Contains("Fib")) { + R3BLOG(info, "Found KRAB geometry from ROOT file: " << name); + return kTRUE; + } + return kFALSE; +} + +ClassImp(R3BAsyKrab) diff --git a/krab/sim/R3BAsyKrab.h b/krab/sim/R3BAsyKrab.h new file mode 100644 index 0000000..b0e64a4 --- /dev/null +++ b/krab/sim/R3BAsyKrab.h @@ -0,0 +1,142 @@ +// ------------------------------------------------------------------ +// ----- R3BAsyKrab header file ----- +// ----- Created 24/10/23 by E. De Filippo and P. Russotto ----- +// ------------------------------------------------------------------ + +#ifndef R3BAsyKrab_H +#define R3BAsyKrab_H + +#include + +#include "R3BDetector.h" +#include "TLorentzVector.h" + +class TClonesArray; +class R3BAsyKrabPoint; +class FairVolume; +class TGeoRotation; + +class R3BAsyKrab : public R3BDetector { + public: + /** Default constructor */ + R3BAsyKrab(); + + /** Standard constructor. + *@param geoFile name of the ROOT geometry file + *@param trans position + *@param rot rotation + */ + R3BAsyKrab(const TString& geoFile, const TGeoTranslation& trans, + const TGeoRotation& rot = TGeoRotation()); + + /** Standard constructor. + *@param geoFile name of the ROOT geometry file + *@param combi position + rotation + */ + R3BAsyKrab(const TString& geoFile, + const TGeoCombiTrans& combi = TGeoCombiTrans()); + + /** Destructor **/ + ~R3BAsyKrab() override; + + /** Virtual method ProcessHits + ** + ** Defines the action to be taken when a step is inside the + ** active volume. Creates a R3BAsyKrabPoint and adds it + ** to the collection. + *@param vol Pointer to the active volume + **/ + Bool_t ProcessHits(FairVolume* vol = 0) override; + + /** Virtual method EndOfEvent + ** + ** If verbosity level is set, print hit collection at the + ** end of the event and resets it afterwards. + **/ + void EndOfEvent() override; + + /** Virtual method Register + ** + ** Registers the hit collection in the ROOT manager. + **/ + void Register() override; + + /** Gets the produced collection **/ + virtual TClonesArray* GetCollection(Int_t iColl) const override; + + /** Virtual method Print + ** + ** Screen output of hit collection. + **/ + void Print(Option_t* option = "") const override; + + /** has to be called after each event to reset the containers */ + void Reset() override; + + Bool_t CheckIfSensitive(std::string name) override; + + virtual void Initialize() override; + virtual void SetSpecialPhysicsCuts() override { ; } + + private: + /** Track information to be stored until the track leaves the + active volume. **/ + Int_t fTrackID; //! track index + Int_t fTrackPID; //! particle identification + Int_t fVolumeID; //! volume id + Int_t fDetCopyID; //! Det volume id + Double_t fZ; //! atomic number fragment + Double_t fA; //! mass number fragment + Int_t fParentTrackID; //! parent track index + Int_t + fUniqueID; //! particle unique id (e.g. if Delta electron, fUniqueID=9) + TLorentzVector fPosIn, fPosOut; //! position + TLorentzVector fMomIn, fMomOut; //! momentum + Double32_t fTime; //! time + Double32_t fLength; //! length + Double32_t fELoss; //! energy loss + Double32_t fLightYield; //! light yield + Int_t fPosIndex; //! + Int_t fNSteps; //! Number of steps in the active volume + Double32_t fEinc; //! Total incident energy + Bool_t kGeoSaved; //! + // TList* flGeoPar; //! + + TClonesArray* fAsyKrabCollection; // The point collection + + /** Private method AddPoint + ** + ** Adds a AsyKrabPoint to the HitCollection + **/ + R3BAsyKrabPoint* AddPoint(Int_t trackID, Int_t detID, Int_t volid, Double_t Z, + Double_t A, TVector3 posIn, TVector3 pos_out, + TVector3 momIn, TVector3 momOut, Double_t time, + Double_t length, Double_t eLoss, + Double_t lightYield); + + /** Private method ResetParameters + ** + ** Resets the private members for the track parameters + **/ + void ResetParameters(); + + // TGeoRotation* createMatrix(Double_t phi, Double_t theta, Double_t psi); + R3BAsyKrab(const R3BAsyKrab&); + R3BAsyKrab& operator=(const R3BAsyKrab&); + + public: + ClassDefOverride(R3BAsyKrab, 1); +}; + +inline void R3BAsyKrab::ResetParameters() { + fTrackID = fVolumeID = fParentTrackID = fTrackPID = fUniqueID = 0; + fPosIn.SetXYZM(0.0, 0.0, 0.0, 0.0); + fPosOut.SetXYZM(0.0, 0.0, 0.0, 0.0); + fMomIn.SetXYZM(0.0, 0.0, 0.0, 0.0); + fMomOut.SetXYZM(0.0, 0.0, 0.0, 0.0); + fTime = fLength = fELoss = fEinc = fZ = fA = fLightYield = 0; + fPosIndex = 0; + fNSteps = 0; +}; + +#endif