From 967c990a3e8d75ef2f5899150e911189a47a3404 Mon Sep 17 00:00:00 2001
From: Michael Deveaux <deveaux@physik.uni-frankfurt.de>
Date: Wed, 30 Aug 2023 15:46:37 +0200
Subject: [PATCH] Move CCE calculation to CbmMvdDataSheet - 2nd try

---
 .../CbmMvdSensorDataSheet.cxx                 | 30 ++++++++++++++++++-
 .../SensorDataSheets/CbmMvdSensorDataSheet.h  |  1 +
 .../tasks/CbmMvdSensorDigitizerTask.cxx       |  4 ++-
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.cxx b/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.cxx
index c1e9df33f9..be3780053e 100644
--- a/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.cxx
+++ b/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.cxx
@@ -106,7 +106,35 @@ std::string CbmMvdSensorDataSheet::ToString() const
   ss << "Data card properly initialized: " << fValidData << endl;
   return ss.str();
 }
-// -------------------------------------------------------------------------
+
+// ----------- Methode ComputeCCE ----------------------------------
+// ----------- Computes the relative number of electrons being deposited at chargePointXYZ and collected by a diode at diodeXYZ
+// ----------- Standard implementation for backward compatibility based on Lorentz-Model.
+// ----------- See PhD Christina Dritsa for scientific details on this model.
+
+Double_t CbmMvdSensorDataSheet::ComputeCCE(Float_t chargePointX, Float_t chargePointY,Float_t chargePointZ,Float_t diodeX,Float_t diodeY,Float_t diodeZ) {
+
+  return
+
+  (0.5 * fLorentzPar0 * fLorentzPar1 / TMath::Pi()
+  /TMath::Max(1.e-10,
+
+
+               ((chargePointX - diodeX) * (chargePointX - diodeX)/ fPixelPitchX / fPixelPitchX) +
+               ((chargePointY - diodeY) * (chargePointY - diodeY)/ fPixelPitchY / fPixelPitchY) +
+               0.25 * fLorentzPar1 * fLorentzPar1
+             )
+  + fLorentzPar2);
+
+  // Original Equation
+  //      Float_t totCharge = (sPoint->charge * fLorentzNorm * (0.5 * fPar0 * fPar1 / TMath::Pi())
+  //                             / TMath::Max(1.e-10, (((Current[0] - xCentre) * (Current[0] - xCentre))
+  //                                                   + ((Current[1] - yCentre) * (Current[1] - yCentre)))
+  //                                                      / fPixelSize / fPixelSize
+  //                                                    + 0.25 * fPar1 * fPar1)
+  //                           + fPar2);
+
+}
 
 
 ClassImp(CbmMvdSensorDataSheet)
diff --git a/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.h b/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.h
index 261b85ab7c..78a9757799 100644
--- a/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.h
+++ b/core/detectors/mvd/SensorDataSheets/CbmMvdSensorDataSheet.h
@@ -156,6 +156,7 @@ public:
   virtual Double_t ComputeHitDeadTime(Float_t charge){return charge * 0.;}; // Multiplication only to suppress "variable not used" warning.
   virtual Double_t ComputeHitDelay(Float_t charge){return charge * 0.;};
   virtual Double_t ComputeHitJitter  (Float_t charge){return charge * 0.;};
+  virtual Double_t ComputeCCE(Float_t chargePointX, Float_t chargePointY,Float_t chargePointZ,Float_t diodeX,Float_t diodeY,Float_t diodeZ);
 //>>>>>>> ddd5fbbb (Time response added)
 
   /** ADC description **/
diff --git a/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx b/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx
index 4b5cd47be2..e3fa340f6d 100644
--- a/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx
+++ b/sim/detectors/mvd/plugins/tasks/CbmMvdSensorDigitizerTask.cxx
@@ -1053,7 +1053,9 @@ void CbmMvdSensorDigitizerTask::ProducePixelCharge(CbmMvdPoint* point)
                                                         / fPixelSize / fPixelSize
                                                       + 0.25 * fPar1 * fPar1)
                              + fPar2);
-        //Todo: Equation wrong, hardcoded pixel size is set to wrong number.
+
+        totCharge= sPoint->charge * fLorentzNorm *
+                           fSensorDataSheet-> ComputeCCE(xCentre, yCentre, 0, Current[0], Current[1],0);
 
         if (totCharge < 1) {
 
-- 
GitLab