21 #include "TClonesArray.h"
22 #include "TObjArray.h"
27 #include "FairRuntimeDb.h"
30 #include "FairEventHeader.h"
31 #include "FairLogger.h"
32 #include "FairMCEventHeader.h"
33 #include "FairRunAna.h"
34 #include "FairRunSim.h"
51 using std::setprecision;
59 , fcurrentFrameNumber(0)
61 , fSegmentLength(0.0001)
62 , fDiffusionCoefficient(0.0055)
63 , fElectronsPerKeV(276.)
64 , fWidthOfCluster(3.5)
67 , fCutOnDeltaRays(0.00169720)
68 , fChargeThreshold(100.)
69 , fFanoSilicium(0.115)
72 , fCurrentTotalCharge(0.)
73 , fCurrentParticleMass(0.)
74 , fCurrentParticleMomentum(0.)
75 , fCurrentParticlePdg(0)
76 , fRandomGeneratorTestHisto(NULL)
81 , fSegResolutionHistoX(NULL)
82 , fSegResolutionHistoY(NULL)
83 , fSegResolutionHistoZ(NULL)
84 , fTotalChargeHisto(NULL)
85 , fTotalSegmentChargeHisto(NULL)
92 , fLandauSigma(204.93)
94 , fLandauRandom(new TRandom3())
100 , fResolutionHistoX(NULL)
101 , fResolutionHistoY(NULL)
102 , fNumberOfSegments(0)
108 , fPixelCharge(new TClonesArray(
"CbmMvdPixelCharge"))
112 , fproduceNoise(kFALSE)
113 , fPixelChargeShort()
114 , fPixelScanAccelerator(NULL)
117 , fsensorDataSheet(NULL)
121 , fReadoutTime(0.00005)
127 , fDeltaBufferSize(0)
133 , fPoints(new TRefArray())
136 , fPileupManager(NULL)
137 , fDeltaManager(NULL)
147 , h_trackLength(NULL)
148 , h_numSegments(NULL)
149 , h_LengthVsAngle(NULL)
150 , h_LengthVsEloss(NULL)
151 , h_ElossVsMomIn(NULL) {
153 frand =
new TRandom3(0);
162 , fcurrentFrameNumber(0)
164 , fSegmentLength(0.0001)
165 , fDiffusionCoefficient(0.0055)
166 , fElectronsPerKeV(276.)
167 , fWidthOfCluster(3.5)
168 , fPixelSizeX(0.0030)
169 , fPixelSizeY(0.0030)
170 , fCutOnDeltaRays(0.00169720)
171 , fChargeThreshold(100.)
172 , fFanoSilicium(0.115)
175 , fCurrentTotalCharge(0.)
176 , fCurrentParticleMass(0.)
177 , fCurrentParticleMomentum(0.)
178 , fCurrentParticlePdg(0)
179 , fRandomGeneratorTestHisto(NULL)
184 , fSegResolutionHistoX(NULL)
185 , fSegResolutionHistoY(NULL)
186 , fSegResolutionHistoZ(NULL)
187 , fTotalChargeHisto(NULL)
188 , fTotalSegmentChargeHisto(NULL)
195 , fLandauSigma(204.93)
197 , fLandauRandom(new TRandom3())
203 , fResolutionHistoX(NULL)
204 , fResolutionHistoY(NULL)
205 , fNumberOfSegments(0)
211 , fPixelCharge(new TClonesArray(
"CbmMvdPixelCharge", 100000))
215 , fproduceNoise(kFALSE)
216 , fPixelChargeShort()
217 , fPixelScanAccelerator(NULL)
220 , fsensorDataSheet(NULL)
224 , fReadoutTime(0.00005)
230 , fDeltaBufferSize(0)
232 , fBranchName(
"MvdPoint")
236 , fPoints(new TRefArray())
239 , fPileupManager(NULL)
240 , fDeltaManager(NULL)
250 , h_trackLength(NULL)
251 , h_numSegments(NULL)
252 , h_LengthVsAngle(NULL)
253 , h_LengthVsEloss(NULL)
254 , h_ElossVsMomIn(NULL) {
255 cout <<
"Starting CbmMvdSensorDigitizerTask::CbmMvdSensorDigitizerTask() "
308 frand =
new TRandom3(0);
338 if (!sensorData) {
return kERROR; }
379 Int_t nInputs = inputStream->GetEntriesFast();
380 while (nInputs >
i) {
417 for (Int_t iPoint = 0; iPoint <
fInputPoints->GetEntriesFast(); iPoint++) {
422 cout <<
"-W-" <<
GetName() <<
":: Exec:" << endl;
423 cout <<
" -received bad MC-Point. Ignored." << endl;
427 cout <<
"-W-" <<
GetName() <<
":: Exec:" << endl;
428 cout <<
" -received bad MC-Point which doesn't belong here. Ignored."
435 if (TMath::Abs(point->
GetZOut() - point->GetZ()) < 0.9 *
fEpiTh) {
436 LOG(debug) <<
"hit not on chip with thickness "
438 LOG(debug) <<
"hit not on chip with length "
439 << TMath::Abs(point->
GetZOut() - point->GetZ());
443 if (point->
GetPdgCode() > 100000) {
continue; }
453 Double_t eventTime = .0;
463 nDigis =
fDigis->GetEntriesFast();
484 new ((*fDigiMatch)[nDigis])
CbmMatch();
520 Double_t& eventTime) {
523 eventNr = FairRootManager::Instance()->GetEntryNr();
526 if (FairRunAna::Instance()) {
527 FairEventHeader*
event = FairRunAna::Instance()->GetEventHeader();
528 inputNr =
event->GetInputFileId();
529 eventTime =
event->GetEventTime();
534 if (!FairRunSim::Instance())
535 LOG(fatal) <<
GetName() <<
": neither SIM nor ANA run.";
556 Double_t globalPositionIn[3] = {point->GetX(), point->GetY(), point->GetZ()};
557 Double_t globalPositionOut[3] = {
560 Double_t localPositionIn[3] = {0, 0, 0};
562 Double_t localPositionOut[3] = {0, 0, 0};
567 Int_t pixelX, pixelY;
572 Double_t entryX = localPositionIn[0];
573 Double_t exitX = localPositionOut[0];
574 Double_t entryY = localPositionIn[1];
575 Double_t exitY = localPositionOut[1];
576 Double_t entryZ = localPositionIn[2];
577 Double_t exitZ = localPositionOut[2];
598 Double_t entryZepi = -
fEpiTh / 2;
599 Double_t exitZepi =
fEpiTh / 2;
602 TVector3 a(entryX, entryY, entryZ);
603 TVector3 b(exitX, exitY, exitZ);
611 Double_t scale1 = (entryZepi - entryZ) / (exitZ - entryZ);
612 Double_t scale2 = (exitZepi - entryZ) / (exitZ - entryZ);
618 TVector3 entryEpiCoord;
619 TVector3 exitEpiCoord;
621 entryEpiCoord =
d + a;
622 exitEpiCoord = e + a;
626 Double_t entryXepi = entryEpiCoord.X();
627 Double_t entryYepi = entryEpiCoord.Y();
628 entryZepi = entryEpiCoord.Z();
631 Double_t exitXepi = exitEpiCoord.X();
632 Double_t exitYepi = exitEpiCoord.Y();
633 exitZepi = exitEpiCoord.Z();
636 Double_t lx = -(entryXepi - exitXepi);
637 Double_t ly = -(entryYepi - exitYepi);
638 Double_t lz = -(entryZepi - exitZepi);
645 sqrt(lx * lx + ly * ly
647 Double_t trackLength = 0;
649 if (rawLength < 1.0e+3) {
650 trackLength = rawLength;
654 cout <<
"-W- " <<
GetName() <<
" : rawlength > 1.0e+3 : " << rawLength
656 trackLength = 1.0e+3;
681 * ((Double_t) trackLength /
fEpiTh);
704 <<
" Length of track in detector (z-direction) is 0!!!" << endl;
708 Double_t
x = 0,
y = 0, z = 0;
710 Double_t xDebug = 0, yDebug = 0, zDebug = 0;
711 Float_t totalSegmentCharge = 0;
716 + ((double) (
i) + 0.5)
720 + ((double) (
i) + 0.5)
726 + ((double) (
i) + 0.5)
740 sPoint->
eloss = dEmean;
750 totalSegmentCharge = totalSegmentCharge + charge;
756 - (point->GetX() + point->
GetXOut()) / 2
759 - (point->GetY() + point->
GetYOut()) / 2
762 - (point->GetZ() + point->
GetZOut()) / 2
780 Float_t xCharge = 0., yCharge = 0., totClusterCharge = 0.;
783 pair<Int_t, Int_t> thispoint;
785 Double_t xCentre, yCentre, sigmaX, sigmaY, xLo, xUp, yLo, yUp;
801 Fatal(
"-E- CbmMvdDigitizer: ",
802 "fNumberOfSegments < 2, this makes no sense, check parameters.");
810 Int_t ixLo, ixUp, iyLo, iyUp;
813 Double_t minCoord[] = {xLo, yLo};
814 Double_t maxCoord[] = {xUp, yUp};
821 if (lowerXArray[0] < 0) lowerXArray[0] = 0;
822 if (lowerYArray[0] < 0) lowerYArray[0] = 0;
826 ixLo = lowerXArray[0];
827 iyLo = lowerYArray[0];
828 ixUp = upperXArray[0];
829 iyUp = upperYArray[0];
847 if (lowerXArray[
i] < 0) lowerXArray[
i] = 0;
848 if (lowerYArray[
i] < 0) lowerYArray[
i] = 0;
853 if (ixLo > lowerXArray[
i]) { ixLo = lowerXArray[
i]; }
854 if (ixUp < upperXArray[
i]) { ixUp = upperXArray[
i]; }
855 if (iyLo > lowerYArray[
i]) { iyLo = lowerYArray[
i]; }
856 if (iyUp < upperYArray[
i]) { iyUp = upperYArray[
i]; }
867 for (ix = ixLo; ix < ixUp + 1; ix++) {
869 for (iy = iyLo; iy < iyUp + 1; iy++) {
881 if (ix < lowerXArray[
i]) {
continue; }
882 if (iy < lowerYArray[
i]) {
continue; }
883 if (ix > upperXArray[
i]) {
continue; }
884 if (iy > upperYArray[
i]) {
continue; }
900 (((Current[0] - xCentre) * (Current[0] - xCentre))
901 + ((Current[1] - yCentre) * (Current[1] - yCentre)))
914 thispoint = std::make_pair(ix, iy);
921 pixel =
new ((*fPixelCharge)[
fPixelCharge->GetEntriesFast()])
927 (point->GetX() + point->
GetXOut()) / 2,
928 (point->GetY() + point->
GetXOut()) / 2,
955 xCharge = xCharge + Current[0] * totCharge;
956 yCharge = yCharge + Current[1] * totCharge;
957 totClusterCharge = totClusterCharge + totCharge;
965 std::vector<CbmMvdPixelCharge*>::size_type vectorSize =
968 for (ULong64_t
f = 0;
f < vectorSize;
f++) {
972 ((
float) (point->GetX() + point->
GetXOut()) / 2),
973 ((float) (point->GetY() + point->
GetYOut()) / 2),
975 point->GetTrackID());
977 cout << endl <<
"Warning working on broken pixel " << endl;
984 TVector3 momentum, position;
986 point->Position(position);
987 point->Momentum(momentum);
988 fPosXY->Fill(position.X(), position.Y());
989 fpZ->Fill(momentum.Z());
991 fAngle->Fill(TMath::ATan(momentum.Pt() / momentum.Pz()) * 180
995 delete[] lowerXArray;
996 delete[] upperXArray;
997 delete[] lowerYArray;
998 delete[] upperYArray;
1007 Int_t fmaxNoise = 100;
1008 Int_t noiseHits = (Int_t)(
frand->Rndm(fmaxNoise) * fmaxNoise);
1011 pair<Int_t, Int_t> thispoint;
1013 for (Int_t
i = 0;
i <= noiseHits;
i++) {
1017 Double_t Current[3];
1020 thispoint = std::make_pair(xPix, yPix);
1025 pixel =
new ((*fPixelCharge)[
fPixelCharge->GetEntriesFast()])
1057 fDigis =
new TClonesArray(
"CbmMvdDigi", 10000);
1058 fDigiMatch =
new TClonesArray(
"CbmMatch", 10000);
1065 "Fatal error: Init(CbmMvdSensor*) called without valid pointer, "
1066 "don't know how to proceed.");
1074 cout << endl <<
"Show debug histos in this Plugin" << endl;
1076 new TH1F(
"TestHisto",
"TestHisto", 1000, 0, 12000);
1078 new TH1F(
"DigiResolutionX",
"DigiResolutionX", 1000, -.005, .005);
1080 new TH1F(
"DigiResolutionY",
"DigiResolutionY", 1000, -.005, .005);
1081 fPosXY =
new TH2F(
"DigiPointXY",
"DigiPointXY", 100, -6, 6, 100, -6, 6);
1082 fpZ =
new TH1F(
"DigiPointPZ",
"DigiPointPZ", 1000, -0.5, 0.5);
1083 fPosXinIOut =
new TH1F(
"DigiZInOut",
"Digi Z InOut", 1000, -0.04, 0.04);
1084 fAngle =
new TH1F(
"DigiAngle",
"DigiAngle", 1000, 0, 90);
1086 new TH1F(
"SegmentResolutionX",
"SegmentResolutionX", 1000, -.005, .005);
1088 new TH1F(
"SegmentResolutionY",
"SegmentResolutionY", 1000, -.005, .005);
1090 new TH1F(
"SegmentResolutionZ",
"SegmentResolutionZ", 1000, -.005, .005);
1092 new TH1F(
"TotalChargeHisto",
"TotalChargeHisto", 1000, 0, 12000);
1094 "TotalSegmentChargeHisto",
"TotalSegmentChargeHisto", 1000, 0, 12000);
1126 TCanvas* c =
new TCanvas(
"DigiCanvas",
"DigiCanvas", 150, 10, 800, 600);
1159 cout <<
"-I- CbmMvdDigitizerL::Finish - Fit of the total cluster charge"
1162 cout <<
"=============================================================="
1179 cout.setf(ios_base::fixed, ios_base::floatfield);
1180 cout <<
"============================================================"
1182 cout <<
"============== Parameters of the Lorentz - Digitizer ======="
1184 cout <<
"============================================================"
1188 cout <<
"Pixel Size X : " << setw(8) << setprecision(2)
1190 cout <<
"Pixel Size Y : " << setw(8) << setprecision(2)
1192 cout <<
"Epitaxial layer thickness : " << setw(8) << setprecision(2)
1193 <<
fEpiTh * 10000. <<
" mum" << endl;
1194 cout <<
"Segment Length : " << setw(8) << setprecision(2)
1196 cout <<
"Diffusion Coefficient : " << setw(8) << setprecision(2)
1198 cout <<
"Width of Cluster : " << setw(8) << setprecision(2)
1200 cout <<
"ElectronsPerKeV 3.62 eV/eh : " << setw(8) << setprecision(2)
1202 cout <<
"CutOnDeltaRays : " << setw(8) << setprecision(8)
1204 cout <<
"ChargeThreshold : " << setw(8) << setprecision(2)
1206 cout <<
"Pileup: " <<
fNPileup << endl;
1208 cout <<
"=============== End Parameters Digitizer ==================="