32#include <FairEventHeader.h>
33#include <FairRootManager.h>
34#include <FairRunAna.h>
35#include <FairRunSim.h>
39#include <TClonesArray.h>
58using std::setprecision;
65 , fcurrentFrameNumber(0)
67 , fSegmentLength(0.0001)
68 , fDiffusionCoefficient(0.0055)
69 , fElectronsPerKeV(276.)
70 , fWidthOfCluster(3.5)
73 , fCutOnDeltaRays(0.00169720)
74 , fChargeThreshold(100.)
75 , fFanoSilicium(0.115)
78 , fCurrentTotalCharge(0.)
79 , fCurrentParticleMass(0.)
80 , fCurrentParticleMomentum(0.)
81 , fCurrentParticlePdg(0)
82 , fRandomGeneratorTestHisto(nullptr)
85 , fPosXinIOut(nullptr)
87 , fSegResolutionHistoX(nullptr)
88 , fSegResolutionHistoY(nullptr)
89 , fSegResolutionHistoZ(nullptr)
90 , fTotalChargeHisto(nullptr)
91 , fTotalSegmentChargeHisto(nullptr)
98 , fLandauSigma(204.93)
100 , fLandauRandom(new TRandom3())
106 , fResolutionHistoX(nullptr)
107 , fResolutionHistoY(nullptr)
108 , fNumberOfSegments(0)
114 , fPixelCharge(new TClonesArray(
"CbmMvdPixelCharge"))
116 , fDigiMatch(nullptr)
117 , fproduceNoise(kFALSE)
118 , fPixelChargeShort()
119 , fPixelScanAccelerator(nullptr)
122 , fSensorDataSheet(nullptr)
126 , fReadoutTime(0.00005)
132 , fDeltaBufferSize(0)
137 , fInputPoints(nullptr)
138 , fPoints(new TRefArray())
141 , fPileupManager(nullptr)
142 , fDeltaManager(nullptr)
152 , h_trackLength(nullptr)
153 , h_numSegments(nullptr)
154 , h_LengthVsAngle(nullptr)
155 , h_LengthVsEloss(nullptr)
156 , h_ElossVsMomIn(nullptr)
168 , fcurrentFrameNumber(0)
170 , fSegmentLength(0.0001)
171 , fDiffusionCoefficient(0.0055)
172 , fElectronsPerKeV(276.)
173 , fWidthOfCluster(3.5)
174 , fPixelSizeX(0.0030)
175 , fPixelSizeY(0.0030)
176 , fCutOnDeltaRays(0.00169720)
177 , fChargeThreshold(100.)
178 , fFanoSilicium(0.115)
181 , fCurrentTotalCharge(0.)
182 , fCurrentParticleMass(0.)
183 , fCurrentParticleMomentum(0.)
184 , fCurrentParticlePdg(0)
185 , fRandomGeneratorTestHisto(nullptr)
188 , fPosXinIOut(nullptr)
190 , fSegResolutionHistoX(nullptr)
191 , fSegResolutionHistoY(nullptr)
192 , fSegResolutionHistoZ(nullptr)
193 , fTotalChargeHisto(nullptr)
194 , fTotalSegmentChargeHisto(nullptr)
201 , fLandauSigma(204.93)
203 , fLandauRandom(new TRandom3())
209 , fResolutionHistoX(nullptr)
210 , fResolutionHistoY(nullptr)
211 , fNumberOfSegments(0)
217 , fPixelCharge(new TClonesArray(
"CbmMvdPixelCharge", 100000))
219 , fDigiMatch(nullptr)
220 , fproduceNoise(kFALSE)
221 , fPixelChargeShort()
222 , fPixelScanAccelerator(nullptr)
225 , fSensorDataSheet(nullptr)
229 , fReadoutTime(0.00005)
235 , fDeltaBufferSize(0)
237 , fBranchName(
"MvdPoint")
240 , fInputPoints(nullptr)
241 , fPoints(new TRefArray())
244 , fPileupManager(nullptr)
245 , fDeltaManager(nullptr)
255 , h_trackLength(nullptr)
256 , h_numSegments(nullptr)
257 , h_LengthVsAngle(nullptr)
258 , h_LengthVsEloss(nullptr)
259 , h_ElossVsMomIn(nullptr)
263 LOG(debug) <<
"Starting CbmMvdSensorDigitizerTask::CbmMvdSensorDigitizerTask() ";
382 Int_t nInputs = inputStream->GetEntriesFast();
383 while (nInputs > i) {
427 for (Int_t iPoint = 0; iPoint <
fInputPoints->GetEntriesFast(); iPoint++) {
432 LOG(warning) <<
" -received bad MC-Point. Ignored.";
436 LOG(warning) <<
" -received bad MC-Point which doesn't belong here. Ignored.";
442 if (TMath::Abs(point->
GetZOut() - point->GetZ()) < 0.9 *
fEpiTh) {
443 LOG(debug) <<
"hit not on chip with thickness " <<
fEpiTh * 10000 <<
"µm";
444 LOG(debug) <<
"hit not on chip with length " << TMath::Abs(point->
GetZOut() - point->GetZ()) * 10000 <<
"µm";
490 LOG(debug) <<
"CbmMvdSensorDigitizerTask::ProduceDigis() - NumberOfPixelCharge = " <<
fPixelCharge->GetEntriesFast();
493 for (Int_t i = 0; i <
fPixelCharge->GetEntriesFast(); i++) {
521 pair<Int_t, Int_t> thispoint;
527 Int_t numberOfContributorCausingHit =
CheckForHit(pixel);
529 LOG(debug) <<
" CbmMvdSensorDigitizerTask::ProduceDigis() - PixelCharge >" << pixel->
GetEarliestHitCharge();
531 if (numberOfContributorCausingHit == -1) {
532 thispoint = std::make_pair(pixel->
GetX(), pixel->
GetY());
535 LOG(debug) <<
" CbmMvdSensorDigitizerTask::ProduceDigis() - PixelCharge " << i <<
" deleted (to few charge).";
543 Int_t diodeCharge = pixel->
GetCharge()[numberOfContributorCausingHit]
548 LOG(debug) <<
" --- CbmMvdSensorDigitizerTask::ProduceDigis() - DiodeCharge0 = " << pixel->
GetCharge()[0];
549 LOG(debug) <<
" --- CbmMvdSensorDigitizerTask::ProduceDigis() - Full diode charge = " << diodeCharge;
551 Double_t analogHitTime =
556 nDigis =
fDigis->GetEntriesFast();
562 new ((*fOutputBuffer)[nDigis])
569 new ((*fDigiMatch)[nDigis])
CbmMatch();
583 thispoint = std::make_pair(pixel->
GetX(), pixel->
GetY());
586 LOG(debug) <<
" CbmMvdSensorDigitizerTask::ProduceDigis() - PixelCharge " << i <<
" deleted (digi produced).";
632 std::cout <<
" - E - CbmMvdSensorDigitizerTask::CheckForHit : Missing Datasheet." << std::endl;
653 for (Int_t i = 1; i < nContributors; i++) {
675 Int_t pixelCharge = 0;
680 for (Int_t hitNr = 0; hitNr < nHits; hitNr++) {
681 Int_t hitTime = myPixel->
GetTime()[hitNr];
682 if (hitTime > readoutTime) {
685 Int_t hitCharge = myPixel->
GetCharge()[hitNr];
690 pixelCharge = pixelCharge
693 - TMath::Exp(-(readoutTime - hitTime)
694 / pixelSignalRiseTime));
695 pixelCharge = pixelCharge
698 - TMath::Exp(-(readoutTime - hitTime)
699 / pixelSignalFallTime));
733 eventNr = FairRootManager::Instance()->GetEntryNr();
736 if (FairRunAna::Instance()) {
737 FairEventHeader*
event = FairRunAna::Instance()->GetEventHeader();
738 inputNr =
event->GetInputFileId();
739 eventNr =
event->GetMCEntryNumber();
740 eventTime =
event->GetEventTime();
745 if (!FairRunSim::Instance()) LOG(fatal) <<
GetName() <<
": neither SIM nor ANA run.";
767 Double_t globalPositionIn[3] = {point->GetX(), point->GetY(), point->GetZ()};
770 Double_t localPositionIn[3] = {0, 0, 0};
772 Double_t localPositionOut[3] = {0, 0, 0};
777 Int_t pixelX, pixelY;
782 Double_t entryX = localPositionIn[0];
783 Double_t exitX = localPositionOut[0];
784 Double_t entryY = localPositionIn[1];
785 Double_t exitY = localPositionOut[1];
786 Double_t entryZ = localPositionIn[2];
787 Double_t exitZ = localPositionOut[2];
808 Double_t entryZepi = -
fEpiTh / 2;
809 Double_t exitZepi =
fEpiTh / 2;
812 TVector3 a(entryX, entryY, entryZ);
813 TVector3 b(exitX, exitY, exitZ);
821 Double_t scale1 = (entryZepi - entryZ) / (exitZ - entryZ);
822 Double_t scale2 = (exitZepi - entryZ) / (exitZ - entryZ);
828 TVector3 entryEpiCoord;
829 TVector3 exitEpiCoord;
831 entryEpiCoord = d + a;
832 exitEpiCoord = e + a;
836 Double_t entryXepi = entryEpiCoord.X();
837 Double_t entryYepi = entryEpiCoord.Y();
838 entryZepi = entryEpiCoord.Z();
841 Double_t exitXepi = exitEpiCoord.X();
842 Double_t exitYepi = exitEpiCoord.Y();
843 exitZepi = exitEpiCoord.Z();
846 Double_t lx = -(entryXepi - exitXepi);
847 Double_t ly = -(entryYepi - exitYepi);
848 Double_t lz = -(entryZepi - exitZepi);
854 Double_t rawLength =
sqrt(lx * lx + ly * ly + lz * lz);
855 Double_t trackLength = 0;
857 if (rawLength < 1.0e+3) {
858 trackLength = rawLength;
862 LOG(warning) <<
GetName() <<
" : rawlength > 1.0e+3 : " << rawLength;
863 trackLength = 1.0e+3;
869 LOG(debug) <<
"CbmMvdSensorTask:: ProduceIonisationPoints() : LandauCharge = " << charge << endl;
885 dEmean = dEmean * ((Double_t) trackLength /
fEpiTh);
905 LOG(warning) <<
GetName() <<
" Length of track in detector (z-direction) is 0!!!";
909 Double_t
x = 0,
y = 0, z = 0;
911 Double_t xDebug = 0, yDebug = 0, zDebug = 0;
912 Float_t totalSegmentCharge = 0;
931 sPoint->
eloss = dEmean;
940 totalSegmentCharge = totalSegmentCharge + charge;
965 Float_t xCharge = 0., yCharge = 0., totClusterCharge = 0.;
968 pair<Int_t, Int_t> thispoint;
970 Double_t xCentre, yCentre, sigmaX, sigmaY, xLo, xUp, yLo, yUp;
986 LOG(fatal) <<
"fNumberOfSegments < 2, this makes no sense, check parameters.";
994 Int_t ixLo, ixUp, iyLo, iyUp;
997 Double_t minCoord[] = {xLo, yLo};
998 Double_t maxCoord[] = {xUp, yUp};
1005 if (lowerXArray[0] < 0) lowerXArray[0] = 0;
1006 if (lowerYArray[0] < 0) lowerYArray[0] = 0;
1010 ixLo = lowerXArray[0];
1011 iyLo = lowerYArray[0];
1012 ixUp = upperXArray[0];
1013 iyUp = upperYArray[0];
1031 if (lowerXArray[i] < 0) lowerXArray[i] = 0;
1032 if (lowerYArray[i] < 0) lowerYArray[i] = 0;
1037 if (ixLo > lowerXArray[i]) {
1038 ixLo = lowerXArray[i];
1040 if (ixUp < upperXArray[i]) {
1041 ixUp = upperXArray[i];
1043 if (iyLo > lowerYArray[i]) {
1044 iyLo = lowerYArray[i];
1046 if (iyUp < upperYArray[i]) {
1047 iyUp = upperYArray[i];
1059 for (ix = ixLo; ix < ixUp + 1; ix++) {
1061 for (iy = iyLo; iy < iyUp + 1; iy++) {
1065 Double_t Current[3];
1073 if (ix < lowerXArray[i]) {
1076 if (iy < lowerYArray[i]) {
1079 if (ix > upperXArray[i]) {
1082 if (iy > upperYArray[i]) {
1089 xCentre = sPoint->
x;
1090 yCentre = sPoint->
y;
1107 if (totCharge < 1) {
1115 thispoint = std::make_pair(ix, iy);
1145 totClusterCharge = totClusterCharge + totCharge;
1147 xCharge = xCharge + Current[0] * totCharge;
1148 yCharge = yCharge + Current[1] * totCharge;
1149 totClusterCharge = totClusterCharge + totCharge;
1157 std::vector<CbmMvdPixelCharge*>::size_type vectorSize =
fPixelChargeShort.size();
1159 for (ULong64_t f = 0; f < vectorSize; f++) {
1163 ((
float) (point->GetY() + point->
GetYOut()) / 2),
fEventTime + point->GetTime(),
1172 Double_t endOfBusyTime =
1189 LOG(debug) <<
"CbmMvdSensorDigitizerTask: Produced pixelCharge with charge " << latestHitCharge;
1192 LOG(warning) <<
"Warning working on broken pixel ";
1195 LOG(debug) <<
"CbmMvdSensorDigitizerTask: Produced cluster with " <<
fPixelChargeShort.size()
1196 <<
" active pixels and with total charge of " << totClusterCharge;
1199 TVector3 momentum, position;
1201 point->Position(position);
1202 point->Momentum(momentum);
1203 fPosXY->Fill(position.X(), position.Y());
1204 fpZ->Fill(momentum.Z());
1206 fAngle->Fill(TMath::ATan(momentum.Pt() / momentum.Pz()) * 180 / TMath::Pi());
1209 delete[] lowerXArray;
1210 delete[] upperXArray;
1211 delete[] lowerYArray;
1212 delete[] upperYArray;
1222 Int_t fmaxNoise = 100;
1223 Int_t noiseHits = (Int_t)(gRandom->Rndm(fmaxNoise) * fmaxNoise);
1226 pair<Int_t, Int_t> thispoint;
1228 for (Int_t i = 0; i <= noiseHits; i++) {
1232 Double_t Current[3];
1235 thispoint = std::make_pair(xPix, yPix);
1275 fDigis =
new TClonesArray(
"CbmMvdDigi", 100);
1276 fDigiMatch =
new TClonesArray(
"CbmMatch", 100);
1282 LOG(fatal) <<
"Init(CbmMvdSensor*) called without valid pointer, don't know how to proceed.";
1291 LOG(info) <<
"Show debug histos in this Plugin";
1293 fResolutionHistoX =
new TH1F(
"DigiResolutionX",
"DigiResolutionX", 1000, -.005, .005);
1294 fResolutionHistoY =
new TH1F(
"DigiResolutionY",
"DigiResolutionY", 1000, -.005, .005);
1295 fPosXY =
new TH2F(
"DigiPointXY",
"DigiPointXY", 100, -6, 6, 100, -6, 6);
1296 fpZ =
new TH1F(
"DigiPointPZ",
"DigiPointPZ", 1000, -0.5, 0.5);
1297 fPosXinIOut =
new TH1F(
"DigiZInOut",
"Digi Z InOut", 1000, -0.04, 0.04);
1298 fAngle =
new TH1F(
"DigiAngle",
"DigiAngle", 1000, 0, 90);
1299 fSegResolutionHistoX =
new TH1F(
"SegmentResolutionX",
"SegmentResolutionX", 1000, -.005, .005);
1300 fSegResolutionHistoY =
new TH1F(
"SegmentResolutionY",
"SegmentResolutionY", 1000, -.005, .005);
1301 fSegResolutionHistoZ =
new TH1F(
"SegmentResolutionZ",
"SegmentResolutionZ", 1000, -.005, .005);
1302 fTotalChargeHisto =
new TH1F(
"TotalChargeHisto",
"TotalChargeHisto", 1000, 0, 12000);
1321 LOG(info) <<
GetName() <<
" initialised with parameters: ";
1351 LOG(debug) <<
"CbmMvdSensorDigitizerTask::Finish() - NumberOfPixelCharge = " <<
fPixelCharge->GetEntriesFast();
1353 for (Int_t i = 0; i <
fPixelCharge->GetEntriesFast(); i++) {
1363 TCanvas* c =
new TCanvas(
"DigiCanvas",
"DigiCanvas", 150, 10, 800, 600);
1396 LOG(info) <<
"CbmMvdDigitizerL::Finish - Fit of the total cluster charge";
1415 std::stringstream ss;
1416 ss.setf(ios_base::fixed, ios_base::floatfield);
1417 ss <<
"============================================================" << endl;
1418 ss <<
"============== Parameters of the Lorentz - Digitizer =======" << endl;
1419 ss <<
"============================================================" << endl;
1422 ss <<
"Pixel Size X : " << setw(8) << setprecision(2) <<
fPixelSizeX * 10000. <<
" mum" << endl;
1423 ss <<
"Pixel Size Y : " << setw(8) << setprecision(2) <<
fPixelSizeY * 10000. <<
" mum" << endl;
1424 ss <<
"Epitaxial layer thickness : " << setw(8) << setprecision(2) <<
fEpiTh * 10000. <<
" mum" << endl;
1425 ss <<
"Segment Length : " << setw(8) << setprecision(2) <<
fSegmentLength * 10000. <<
" mum" << endl;
1426 ss <<
"Diffusion Coefficient : " << setw(8) << setprecision(2) <<
fDiffusionCoefficient * 10000. <<
" mum"
1428 ss <<
"Width of Cluster : " << setw(8) << setprecision(2) <<
fWidthOfCluster <<
" * sigma " << endl;
1429 ss <<
"ElectronsPerKeV 3.62 eV/eh : " << setw(8) << setprecision(2) <<
fElectronsPerKeV << endl;
1430 ss <<
"CutOnDeltaRays : " << setw(8) << setprecision(8) <<
fCutOnDeltaRays <<
" MeV " << endl;
1431 ss <<
"ChargeThreshold : " << setw(8) << setprecision(2) <<
fChargeThreshold << endl;
1432 ss <<
"Pileup: " <<
fNPileup << endl;
1434 ss <<
"=============== End Parameters Digitizer ===================" << endl;
ClassImp(CbmMvdSensorDigitizerTask)
friend fvec sqrt(const fvec &a)
void AddLink(const CbmLink &newLink)
std::vector< Int_t > & GetEventNr()
Short_t GetNContributors()
Float_t GetEarliestHitCharge()
Float_t GetEndOfBusyTime()
void SetEndOfBusyTime(Double_t endOfBusyTime)
std::vector< Int_t > & GetInputNr()
std::vector< Double_t > & GetTime()
void DigestCharge(Float_t pointX, Float_t pointY, Double_t time, Int_t PointId, Int_t trackId, Int_t inputNr, Int_t eventNr)
Float_t GetLatestHitCharge()
void AddCharge(Float_t charge)
std::vector< Int_t > & GetPointID()
std::vector< Int_t > & GetTrackID()
std::vector< Float_t > & GetPointWeight()
std::vector< Float_t > & GetCharge()
int32_t GetPointId() const
int32_t GetStationNr() const
int32_t GetPdgCode() const
virtual Double_t GetSignalRiseTime()
virtual Double_t GetEpiThickness()
virtual Float_t GetShaperNormalisationFactor()
virtual Double_t GetLorentzPar1()
virtual Int_t GetNPixelsX()
virtual Double_t GetPixelPitchX()
virtual Double_t ComputeCCE(Float_t chargePointX, Float_t chargePointY, Float_t chargePointZ, Float_t diodeX, Float_t diodeY, Float_t diodeZ)
virtual Double_t GetLandauMPV()
virtual Int_t GetAnalogThreshold()
virtual Int_t GetNPixelsY()
virtual Double_t GetPixelPitchY()
virtual Double_t GetLandauSigma()
virtual Double_t GetChargeThreshold()
virtual Double_t GetLandauGain()
virtual Double_t GetSignalFallTime()
virtual Double_t GetLorentzPar0()
virtual Double_t GetLorentzPar2()
CbmMvdSensorDataSheet * fSensorDataSheet
CbmMvdSensorDigitizerTask()
std::map< std::pair< Int_t, Int_t >, CbmMvdPixelCharge * >::iterator fChargeMapIt
Double_t fCurrentParticleMass
Double_t fElectronsPerKeV
TH1F * fRandomGeneratorTestHisto
CbmMvdPileupManager * fPileupManager
Int_t CheckForHit(CbmMvdPixelCharge *pixel)
CbmMvdPileupManager * fDeltaManager
Int_t fcurrentFrameNumber
void ProduceIonisationPoints(CbmMvdPoint *point)
Double_t fDiffusionCoefficient
virtual void InitTask(CbmMvdSensor *mySensor)
TClonesArray * fPixelCharge
virtual void ReInit(CbmMvdSensor *mySensor)
Int_t GetPixelCharge(CbmMvdPixelCharge *myPixel, Double_t readoutTime)
void CleanPixelChargeList()
std::vector< CbmMvdPixelCharge * > fPixelChargeShort
Double_t fCurrentTotalCharge
TH1F * fSegResolutionHistoY
TClonesArray * fDigiMatch
Double_t fCurrentParticleMomentum
void GetEventInfo(Int_t &inputNr, Int_t &eventNr, Double_t &eventTime)
void FlushBuffer(CbmMvdPixelCharge *pixel, Int_t i)
std::map< std::pair< Int_t, Int_t >, CbmMvdPixelCharge * > fChargeMap
TClonesArray * fInputPoints
TH1F * fSegResolutionHistoX
Bool_t GetSignalAboveThreshold(CbmMvdPixelCharge *myPixel, Double_t readoutTime)
std::string ToString() const
void PrintParameters() const
TH1F * fSegResolutionHistoZ
virtual void SetParContainers()
InitStatus ReadSensorInformation()
SignalPointVec fSignalPoints
void SetInputArray(TClonesArray *inputStream)
TH1F * fTotalSegmentChargeHisto
void ProducePixelCharge(CbmMvdPoint *point)
TObjArray * fPixelScanAccelerator
virtual ~CbmMvdSensorDigitizerTask()
virtual TClonesArray * GetOutputArray()
CbmMvdSensorPlugin * fPreviousPlugin
virtual const char * GetName() const
TClonesArray * fOutputBuffer
Int_t GetFrameNumber(Double_t absoluteTime, Int_t pixelNumberY=0) const
void TopToLocal(Double_t *lab, Double_t *local)
Int_t GetSensorNr() const
void PixelToLocal(Int_t pixelNumberX, Int_t pixelNumberY, Double_t *local)
void LocalToPixel(Double_t *local, Int_t &pixelNumberX, Int_t &pixelNumberY)
Double_t ComputeEndOfBusyTime(Double_t hitMCTime, Float_t diodeCharge, Int_t pixelNumberY)
Double_t ComputeIndecatedAnalogTime(Double_t hitMCTime, Float_t diodeCharge)
CbmMvdSensorDataSheet * GetDataSheet()