diff --git a/sim/detectors/mvd/CbmMvdPixelCharge.cxx b/sim/detectors/mvd/CbmMvdPixelCharge.cxx index 38e47f0a0669d8003a038bcc47540a3f627495ef..75fb5641b5704fc970103ba74dc636cccfccba40 100644 --- a/sim/detectors/mvd/CbmMvdPixelCharge.cxx +++ b/sim/detectors/mvd/CbmMvdPixelCharge.cxx @@ -1,49 +1,17 @@ -/* Copyright (C) 2008-2015 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2008-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Christina Dritsa [committer], Samir Amar-Youcef, Florian Uhlig, Philipp Sitzmann */ -// ----------------------------------------------------------------------- -// ----- CbmMvdDigi source file ----- -// ----- Created 17/04/08 by C. Dritsa ----- -// ----------------------------------------------------------------------- - #include "CbmMvdPixelCharge.h" +#include <Logger.h> + #include <iostream> using std::cout; using std::endl; -// ----- Default constructor ------------------------------------------- -CbmMvdPixelCharge::CbmMvdPixelCharge() - : TObject() - , fFrame(-1) - , fCharge(-1.) - , fMaxChargeContribution(0.) - , fDominatingPointX(-1.) - , fDominatingPointY(-1.) - , fContributors(0.) - , fChannelNrX(0.) - , fChannelNrY(0.) - , fTrackCharge(0.) - , fDominatorTrackId(-1.) - , fDominatorPointId(-1.) - , fTrackId() - , fPointId() - , fPointWeight() - , fPointX() - , fPointY() - , fDominatorIndex(0) - , fPixelTime(-1.) -{ - for (Int_t i = 0; i < 5; i++) { - fTrackId[i] = -1; - fPointId[i] = -1; - fPointX[i] = 0; - fPointY[i] = 0; - } -} // ------------------------------------------------------------------------- Bool_t CbmMvdPixelCharge::TestXY(Int_t channelNrX, Int_t channelNrY) { @@ -59,37 +27,22 @@ CbmMvdPixelCharge::CbmMvdPixelCharge(Float_t charge, Int_t channelNrX, Int_t cha Float_t pointPosX, Float_t pointPosY, Float_t time, Int_t frame) : TObject() , fFrame(frame) - , fCharge(0.) - , fMaxChargeContribution(0.) - , fDominatingPointX(-1.) - , fDominatingPointY(-1.) - , fContributors(0.) + , fCharge(charge) + , fMaxChargeContribution(charge) , fChannelNrX(channelNrX) , fChannelNrY(channelNrY) , fTrackCharge(charge) - , fDominatorTrackId(-1.) - , fDominatorPointId(-1.) - , fTrackId() - , fPointId() - , fPointWeight() - , fPointX() - , fPointY() - , fDominatorIndex(0) , fPixelTime(time) { - for (Int_t i = 0; i < 5; i++) { - fTrackId[i] = -1; - fPointId[i] = -1; - fPointX[i] = 0; - fPointY[i] = 0; - fPointWeight[i] = 0; - } + fTrackId.push_back(trackId); + fPointId.push_back(pointId); + fPointWeight.push_back(charge); + fPointX.push_back(pointPosX); + fPointY.push_back(pointPosY); + fTime.push_back(time); +// fLink.push_back(); // TODO: pass link + fDominatorIndex = fPointWeight.size(); - fTrackId[0] = trackId; - fPointId[0] = pointId; - fPointX[0] = pointPosX; - fPointY[0] = pointPosY; - fPointWeight[0] = charge; } // ------- DigestCharge ----------------------------------------------------# @@ -102,52 +55,28 @@ void CbmMvdPixelCharge::DigestCharge(Float_t pointX, Float_t pointY, Int_t point { Float_t chargeContr = fTrackCharge; - for (Int_t i = 0; i < fContributors; i++) { - chargeContr -= fPointWeight[i]; + for (auto charge : fPointWeight) { + chargeContr -= charge; } - if (chargeContr > 0) { + if (chargeContr > 0.) { + fCharge = fTrackCharge; + fTrackId.push_back(trackId); + fPointId.push_back(pointId); + + fPointWeight.push_back(chargeContr); + fPointX.push_back(pointX); + fPointY.push_back(pointY); + +// fTime.push_back(time); +// fLink.push_back(); // TODO: pass link + if (chargeContr > fMaxChargeContribution) { - fDominatorIndex = fContributors; + fDominatorIndex = fPointWeight.size(); fMaxChargeContribution = chargeContr; } - if (fContributors < 5) { - fCharge = fTrackCharge; - fTrackId[fContributors] = trackId; - fPointId[fContributors] = pointId; - fPointX[fContributors] = pointX; - fPointY[fContributors] = pointY; - fPointWeight[fContributors] = chargeContr; - fContributors = fContributors + 1; - } - else { - // cout << "-W- " << GetName() << " Nr of Digi Contributors is bigger than 5!!!" << endl; - } } - - // if (fTrackCharge>0) - // { - // if (fTrackCharge>fMaxChargeContribution) - // { - // fDominatorIndex = fContributors; - // fMaxChargeContribution = fTrackCharge; - // } - // - // fCharge = fCharge+fTrackCharge; // Add charge of the track - // fTrackCharge = 0; - // fTrackId[fContributors]=trackId; - // fPointId[fContributors]=pointId; - // fPointX [fContributors]=pointX; - // fPointY [fContributors]=pointY; - // fPointWeight[fContributors]=fTrackCharge; - // fContributors = fContributors+1; - // - // } } -// ----- Destructor ---------------------------------------------------- -CbmMvdPixelCharge::~CbmMvdPixelCharge() {} -// ------------------------------------------------------------------------- - ClassImp(CbmMvdPixelCharge) diff --git a/sim/detectors/mvd/CbmMvdPixelCharge.h b/sim/detectors/mvd/CbmMvdPixelCharge.h index 87bb5f15e1c8b27af473f8beb51ff48ee1e62a68..9835af58f6b10b6c8a94284a9dfcc5ef992bbd53 100644 --- a/sim/detectors/mvd/CbmMvdPixelCharge.h +++ b/sim/detectors/mvd/CbmMvdPixelCharge.h @@ -1,16 +1,12 @@ -/* Copyright (C) 2008-2016 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 20236 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Christina Dritsa [committer], Philipp Sitzmann */ - -// ------------------------------------------------------------------------- -// ----- CbmMvdDigi header file ----- -// ----- Created 02/04/08 by C.Dritsa ----- -// ------------------------------------------------------------------------- - + Authors: Christina Dritsa [committer], Philipp Sitzmann, Florian Uhlig */ #ifndef CBMMVDPIXELCHARGE_H #define CBMMVDPIXELCHARGE_H 1 +#include "CbmLink.h" + #include <Rtypes.h> // for ClassDef #include <RtypesCore.h> // for Float_t, Int_t, Short_t, Bool_t, Option_t #include <TObject.h> // for TObject @@ -24,18 +20,18 @@ class CbmMvdPixelCharge : public TObject { public: /** Default constructor **/ - CbmMvdPixelCharge(); + CbmMvdPixelCharge() = default; /** Constructor with all variables **/ CbmMvdPixelCharge(Float_t charge, Int_t channelNrX, Int_t channelNrY, Int_t hitId, Int_t trackId, Float_t pointX, Float_t pointY, Float_t time = 0.0, Int_t frame = 0); - virtual ~CbmMvdPixelCharge(); - Bool_t TestXY(Int_t channelNrX, Int_t channelNrY); + virtual ~CbmMvdPixelCharge() = default; + Bool_t TestXY(Int_t channelNrX, Int_t channelNrY); - void DigestCharge(Float_t pointX, Float_t pointY, Int_t PointId, Int_t trackId); + void DigestCharge(Float_t pointX, Float_t pointY, Int_t PointId, Int_t trackId); // TODO: add time here void AddCharge(Float_t charge) { fTrackCharge = fTrackCharge + charge; }; @@ -45,41 +41,42 @@ public: Float_t GetMaxChargeContribution() { return fMaxChargeContribution; }; Short_t GetNContributors() { return fContributors; }; Int_t GetDominatorIndex() { return fDominatorIndex; } - Int_t* GetTrackID() { return fTrackId; } - Int_t* GetPointID() { return fPointId; } - Float_t* GetPointX() { return fPointX; } - Float_t* GetPointY() { return fPointY; } - Float_t* GetPointWeight() { return fPointWeight; } - Float_t GetTime() { return fPixelTime; } + std::vector<Int_t>& GetTrackID() { return fTrackId; } + std::vector<Int_t>& GetPointID() { return fPointId; } + std::vector<Float_t>& GetPointX() { return fPointX; } + std::vector<Float_t>& GetPointY() { return fPointY; } + std::vector<Float_t>& GetPointWeight() { return fPointWeight; } + std::vector<Double_t>& GetTime() {return fTime;} + Float_t GetPixelTime() { return fPixelTime; } Int_t GetFrame() { return fFrame; } virtual void Clear(Option_t* = "") {}; private: - Int_t fFrame; - - Float_t fCharge; - Float_t fMaxChargeContribution; - Float_t fDominatingPointX; - Float_t fDominatingPointY; - Short_t fContributors; - Int_t fChannelNrX; - Int_t fChannelNrY; - Float_t fTrackCharge; - Int_t fDominatorTrackId; - Int_t fDominatorPointId; - Int_t fTrackId[5]; - Int_t fPointId[5]; - Float_t fPointWeight[5]; - Float_t fPointX[5]; - Float_t fPointY[5]; - Short_t fDominatorIndex; - Float_t fPixelTime; - + Int_t fFrame = {-1}; + + Float_t fCharge = {-1.}; + Float_t fMaxChargeContribution = {0.}; + Float_t fDominatingPointX = {-1.}; + Float_t fDominatingPointY = {-1.}; + Short_t fContributors = {0}; + Int_t fChannelNrX = {0}; + Int_t fChannelNrY = {0}; + Float_t fTrackCharge = {0.}; + Int_t fDominatorTrackId = {-1}; + Int_t fDominatorPointId = {-1}; + Short_t fDominatorIndex = {0}; + Float_t fPixelTime = {-1.}; + std::vector<Int_t> fTrackId = {}; + std::vector<Int_t> fPointId = {}; + std::vector<Float_t> fPointWeight = {}; + std::vector<Float_t> fPointX = {}; + std::vector<Float_t> fPointY = {}; + std::vector<Double_t> fTime = {}; + std::vector<CbmLink> fLink = {}; ClassDef(CbmMvdPixelCharge, 1); }; - #endif diff --git a/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx b/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx index 9d597b6aa8fd37a662d6c8dca6b6aba6ec1705c8..6ee8a79bd3b73eb309a844d766ba546d2af79b46 100644 --- a/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx +++ b/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx @@ -455,12 +455,12 @@ void CbmMvdSensorDigitizerTask::Exec() nDigis = fDigis->GetEntriesFast(); new ((*fDigis)[nDigis]) CbmMvdDigi(fSensor->GetSensorNr(), pixel->GetX(), pixel->GetY(), pixel->GetCharge(), - fPixelSizeX, fPixelSizeY, fEventTime+ pixel->GetTime(), pixel->GetFrame()); + fPixelSizeX, fPixelSizeY, fEventTime+pixel->GetPixelTime(), pixel->GetFrame()); new ((*fOutputBuffer)[nDigis]) CbmMvdDigi(fSensor->GetSensorNr(), pixel->GetX(), pixel->GetY(), pixel->GetCharge(), fPixelSizeX, fPixelSizeY, - fEventTime+pixel->GetTime(), pixel->GetFrame()); + fEventTime+pixel->GetPixelTime(), pixel->GetFrame()); new ((*fDigiMatch)[nDigis]) CbmMatch(); CbmMatch* match = (CbmMatch*) fDigiMatch->At(nDigis); @@ -786,7 +786,7 @@ void CbmMvdSensorDigitizerTask::ProducePixelCharge(CbmMvdPoint* point) yUp = sPoint->y + fWidthOfCluster * sigmaY; if (fNumberOfSegments < 2) { - Fatal("-E- CbmMvdDigitizer: ", "fNumberOfSegments < 2, this makes no sense, check parameters."); + LOG(fatal) << "fNumberOfSegments < 2, this makes no sense, check parameters."; } Int_t* lowerXArray = new Int_t[fNumberOfSegments]; @@ -859,9 +859,9 @@ void CbmMvdSensorDigitizerTask::ProducePixelCharge(CbmMvdPoint* point) Double_t Current[3]; fSensor->PixelToLocal(ix, iy, Current); - pixel = 0; //decouple pixel-pointer from previous pixel - //loop over segments, check if the pad received some charge - + pixel = nullptr; //decouple pixel-pointer from previous pixel + + //loop over segments, check if the pad received some charge for (Int_t i = 0; i < fNumberOfSegments; ++i) { // cout << endl << "check segment nr. " << i << " from " << fNumberOfSegments << endl; // ignore pads, which are out of reach for this segments @@ -956,7 +956,6 @@ void CbmMvdSensorDigitizerTask::ProducePixelCharge(CbmMvdPoint* point) } } - if (fShowDebugHistos) { //cout << endl << "produced " << fPixelChargeShort.size() << " Digis with total charge of " << totClusterCharge << endl; TVector3 momentum, position; @@ -1001,13 +1000,13 @@ void CbmMvdSensorDigitizerTask::ProduceNoise() if (fChargeMapIt == fChargeMap.end()) { pixel = new ((*fPixelCharge)[fPixelCharge->GetEntriesFast()]) - CbmMvdPixelCharge(1000, xPix, yPix, 0, -4, Current[0], Current[1]); + CbmMvdPixelCharge(1000, xPix, yPix, 0, -4, Current[0], Current[1]); // TODO: Add time pixel->DigestCharge(Current[0], Current[1], 0, -4); fChargeMap[thispoint] = pixel; } else { pixel = fChargeMapIt->second; - pixel->AddCharge(1000); + pixel->AddCharge(1000); // TODO: Add time pixel->DigestCharge(Current[0], Current[1], 0, -4); } } @@ -1042,8 +1041,7 @@ void CbmMvdSensorDigitizerTask::InitTask(CbmMvdSensor* mySensor) fInputPoints = new TClonesArray("CbmMvdPoint", 100); if (!fSensor) { - Fatal(GetName(), "Fatal error: Init(CbmMvdSensor*) called without valid pointer, " - "don't know how to proceed."); + LOG(fatal) << "Init(CbmMvdSensor*) called without valid pointer, don't know how to proceed."; }; ReadSensorInformation();