Commit b8130c67 authored by Pascal Raisig's avatar Pascal Raisig
Browse files

Introduce shared_ptr for CbmTrdRadiator

Since, the radiator is touched within the MR, we exchange its member appearances as raw pointer with smared shared pointers.
For backward compatibility with quite some amount of macros (quite some of them seem to be obsolete) forwarding constructors of CbmTrdDigitizer and CbmTrdQa have been implemented.
parent 0e234597
......@@ -48,16 +48,21 @@
#include "CbmTrdRadiator.h"
#include "CbmTrdUtils.h"
using std::cin;
using std::cout;
using std::endl;
using std::fabs;
using std::pair;
CbmTrdQa::CbmTrdQa(CbmTrdRadiator* radiator) : CbmTrdQa("TrdQa", "", "", 1e-6, radiator) {}
CbmTrdQa::CbmTrdQa(const char* /*name*/, const char* /*title*/, const char* geo, Double_t triggerThreshold,
CbmTrdQa::CbmTrdQa(const char* name, const char* title, const char* geo, Double_t triggerThreshold,
CbmTrdRadiator* radiator)
: CbmTrdQa(name, title, geo, triggerThreshold, std::make_shared<CbmTrdRadiator>(radiator)) {};
CbmTrdQa::CbmTrdQa(std::shared_ptr<CbmTrdRadiator> radiator) : CbmTrdQa("TrdQa", "", "", 1e-6, radiator) {}
CbmTrdQa::CbmTrdQa(const char* /*name*/, const char* /*title*/, const char* geo, Double_t triggerThreshold,
std::shared_ptr<CbmTrdRadiator> radiator)
: FairTask("TrdQa")
, fMCTracks(NULL)
, fPoints(NULL)
......
......@@ -28,9 +28,11 @@ class TPolyLine;
class CbmTrdQa : public FairTask {
public:
CbmTrdQa(CbmTrdRadiator* radiator = NULL);
CbmTrdQa(std::shared_ptr<CbmTrdRadiator> radiator = nullptr);
CbmTrdQa(CbmTrdRadiator* radiator);
CbmTrdQa(const char* name, const char* title = "CBM Task", const char* geo = "", Double_t triggerThreshold = 1.0e-6,
CbmTrdRadiator* radiator = NULL);
std::shared_ptr<CbmTrdRadiator> radiator = nullptr);
CbmTrdQa(const char* name, const char* title, const char* geo, Double_t triggerThreshold, CbmTrdRadiator* radiator);
virtual ~CbmTrdQa();
virtual InitStatus ReInit();
virtual InitStatus Init();
......@@ -184,7 +186,7 @@ private:
TH2I* fPRF_2D;
//LayerView
CbmTrdRadiator* fRadiator;
std::shared_ptr<CbmTrdRadiator> fRadiator = nullptr;
ClassDef(CbmTrdQa, 1);
};
......
......@@ -43,20 +43,18 @@
#include <iomanip>
#include <iostream>
#include <memory>
#include <cmath>
using std::cout;
using std::endl;
using std::make_pair;
using std::map;
using std::max;
using std::pair;
using std::vector;
using std::shared_ptr;
using namespace std;
Int_t CbmTrdDigitizer::fConfig = 0;
//________________________________________________________________________________________
CbmTrdDigitizer::CbmTrdDigitizer(CbmTrdRadiator* radiator)
CbmTrdDigitizer::CbmTrdDigitizer(shared_ptr<CbmTrdRadiator> radiator)
: CbmDigitize<CbmTrdDigi>("TrdDigitize")
, fLastEventTime(0)
, fpoints(0)
......@@ -79,9 +77,13 @@ CbmTrdDigitizer::CbmTrdDigitizer(CbmTrdRadiator* radiator)
, fModuleMap()
, fDigiMap()
{
if (fRadiator == NULL) fRadiator = new CbmTrdRadiator(kTRUE, "tdr18");
if (fRadiator == NULL) fRadiator = make_shared<CbmTrdRadiator>(kTRUE, "tdr18");
}
//________________________________________________________________________________________
CbmTrdDigitizer::CbmTrdDigitizer(CbmTrdRadiator* radiator)
: CbmTrdDigitizer(std::make_shared<CbmTrdRadiator>(radiator)) {};
//________________________________________________________________________________________
CbmTrdDigitizer::~CbmTrdDigitizer()
......@@ -93,7 +95,6 @@ CbmTrdDigitizer::~CbmTrdDigitizer()
delete imod->second;
fModuleMap.clear();
// if (fRadiator2D) delete fRadiator2D;
delete fConverter;
delete fQA;
}
......@@ -330,7 +331,7 @@ CbmTrdModuleSim* CbmTrdDigitizer::AddModule(Int_t detId)
// 0.0025, // polyethylen sheets of 50 µm thickness
// 1.2e-3, // 12 µm aluminized polyester foil
// }; pwidth = widths;
fRadiator2D = new CbmTrdRadiator(kTRUE, "tdr18", ewin);
fRadiator2D = make_shared<CbmTrdRadiator>(kTRUE, "tdr18", ewin);
fRadiator2D->SetEWwidths(5, widths);
fRadiator2D->Init();
}
......
......@@ -22,6 +22,7 @@
#include "CbmTrdRawToDigiR.h"
#include <map>
#include <memory>
class TClonesArray;
......@@ -52,7 +53,14 @@ public:
* \brief Constructor.
* \param[in] radiator TRD radiator to be used in digitization.
*/
CbmTrdDigitizer(CbmTrdRadiator* radiator = NULL);
CbmTrdDigitizer(std::shared_ptr<CbmTrdRadiator> radiator = nullptr);
/**
* \brief Constructor.
* \param[in] radiator TRD radiator to be used in digitization.
* @remark This is needed for backward compatibility with macros not using smart pointers.
*/
CbmTrdDigitizer(CbmTrdRadiator* radiator);
/**
* \brief Destructor.
......@@ -137,8 +145,10 @@ private:
CbmTrdParSetDigi* fDigiPar; ///< parameter list for read-out geometry
CbmTrdParSetGain* fGainPar; ///< parameter list for keV->ADC gain conversion
CbmTrdParSetGeo* fGeoPar; ///< parameter list for geometry definitions
CbmTrdRadiator* fRadiator; ///< parametrization of radiator TR yield
CbmTrdRadiator* fRadiator2D; ///< parametrization of 2D radiator TR yield
/** @brief parametrization of radiator TR yield */
std::shared_ptr<CbmTrdRadiator> fRadiator = nullptr;
/** @brief parametrization of 2D radiator TR yield */
std::shared_ptr<CbmTrdRadiator> fRadiator2D = nullptr;
CbmTrdRawToDigiR* fConverter;
CbmTrdCheckUtil* fQA;
......
......@@ -10,6 +10,7 @@
#include "CbmTrdRawToDigiR.h"
#include <map>
#include <memory>
class TClonesArray;
class CbmTrdPoint;
......@@ -72,8 +73,9 @@ public:
virtual void SetEventId(Int_t id) { fEventId = id; }
virtual void SetInputId(Int_t id) { fInputId = id; }
virtual void SetPointId(Int_t id) { fPointId = id; }
virtual void SetRadiator(CbmTrdRadiator* radiator = NULL) = 0;
virtual void SetGamma(Double_t gamma = 0.) = 0;
/** @brief Set the Radiator @param radiator Defintion of the radiator to be used for this module */
virtual void SetRadiator(std::shared_ptr<CbmTrdRadiator> radiator) { fRadiator = radiator; }
virtual void SetGamma(Double_t gamma = 0.) = 0;
virtual void SetPositionMC(Double_t pos[3]) { memcpy(fXYZ, pos, 3 * sizeof(Double_t)); }
virtual void SetLinkId(Int_t input, Int_t event = -1, Int_t point = -1)
{
......@@ -94,7 +96,8 @@ protected:
CbmTrdDigitizer* fDigitizer; //! Pointer to digitizer
// calibration objects
CbmTrdRadiator* fRadiator; ///< TR description for radiator
/** @brief TR description for radiator */
std::shared_ptr<CbmTrdRadiator> fRadiator = nullptr;
std::map<Int_t, std::pair<CbmTrdDigi*, CbmMatch*>>
fDigiMap; ///< Temporary storage for complete digis for each CBM address.
......
......@@ -42,7 +42,6 @@ public:
void SetSpadicResponse(Double_t calibration, Double_t tau);
void SetPulsePars(Int_t mode);
void SetPulseMode(Bool_t pulsed);
void SetRadiator(CbmTrdRadiator* radiator) { fRadiator = radiator; }
void SetGamma(Double_t gamma) { fGamma = gamma; }
void SetTriggerThreshold(Double_t minCharge) { fMinimumChargeTH = minCharge; }
void SetPadPlaneScanArea(Int_t row);
......
......@@ -47,7 +47,6 @@ public:
**/
Bool_t MakeDigi(CbmTrdPoint* p, Double_t time, Bool_t TR);
Bool_t MakeRaw(/*CbmTrdPoint *p*/) { return kTRUE; }
void SetRadiator(CbmTrdRadiator* radiator) { fRadiator = radiator; }
void SetGamma(Double_t /*gamma*/) { ; }
void SetMessageConverter(CbmTrdRawToDigiR* conv = NULL) { (void) conv; }
void SetQA(CbmTrdCheckUtil* qa = NULL) { (void) qa; }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment