16 #include "FairGeoNode.h"
17 #include "FairLogger.h"
18 #include "FairRootManager.h"
19 #include "FairRunAna.h"
20 #include "FairRuntimeDb.h"
25 #include "TGeoManager.h"
27 #include "TObjArray.h"
28 #include "TRefArray.h"
30 #include "TClonesArray.h"
54 using std::setprecision;
69 , fClusters(new TClonesArray(
"CbmMvdCluster", 10000))
70 , fPixelChargeHistos(NULL)
71 , fTotalChargeInNpixelsArray(NULL)
72 , fResolutionHistoX(NULL)
73 , fResolutionHistoY(NULL)
74 , fResolutionHistoCleanX(NULL)
75 , fResolutionHistoCleanY(NULL)
76 , fResolutionHistoMergedX(NULL)
77 , fResolutionHistoMergedY(NULL)
81 , fGausArrayLimit(5000)
89 , fFullClusterHisto(NULL)
97 , fShowDebugHistos(kFALSE)
101 , fLayerRadiusInner(0.)
106 , fHitPosErrX(0.0005)
107 , fHitPosErrY(0.0005)
109 , fBranchName(
"MvdHit")
110 , fDigisInCluster(-1)
111 , fAddNoise(kFALSE) {}
125 , fClusters(new TClonesArray(
"CbmMvdCluster", 10000))
126 , fPixelChargeHistos(NULL)
127 , fTotalChargeInNpixelsArray(NULL)
128 , fResolutionHistoX(NULL)
129 , fResolutionHistoY(NULL)
130 , fResolutionHistoCleanX(NULL)
131 , fResolutionHistoCleanY(NULL)
132 , fResolutionHistoMergedX(NULL)
133 , fResolutionHistoMergedY(NULL)
137 , fGausArrayLimit(5000)
145 , fFullClusterHisto(NULL)
152 , fNeighThreshold(1.)
153 , fShowDebugHistos(kFALSE)
157 , fLayerRadiusInner(0.)
162 , fHitPosErrX(0.0005)
163 , fHitPosErrY(0.0005)
165 , fBranchName(
"MvdHit")
166 , fDigisInCluster(-1)
167 , fAddNoise(kFALSE) {}
198 fHits =
new TClonesArray(
"CbmMvdHit", 10000);
225 <<
"CbmMvdSensorFindHitTask::ReInt---------------" << endl;
248 vector<Int_t>* clusterArray =
new vector<Int_t>;
257 cout <<
"-E- : CbmMvdSensorFindHitTask - Fatal: No Digits found in this "
272 <<
"CbmMvdSensorFindHitTask: Calling method AddNoiseToDigis()...\n"
275 for (iDigi = 0; iDigi < nDigis; iDigi++) {
284 cout << endl <<
"generate fake digis" << endl;
289 TArrayS* pixelUsed =
new TArrayS(nDigis);
291 for (iDigi = 0; iDigi < nDigis; iDigi++) {
292 pixelUsed->AddAt(0, iDigi);
297 for (Int_t k = 0; k < nDigis; k++) {
302 LOG(fatal) <<
"RefID of this digi is -1 this should not happend ";
319 for (iDigi = 0; iDigi < nDigis; iDigi++) {
321 if (gDebug > 0 && iDigi % 10000 == 0) {
322 cout <<
"-I- " <<
GetName() <<
" Digi:" << iDigi << endl;
341 <<
"CbmMvdSensorFindHitTask: Checking for seed pixels..." << endl;
345 && (pixelUsed->At(iDigi) == kFALSE)) {
346 clusterArray->clear();
347 clusterArray->push_back(iDigi);
350 pixelUsed->AddAt(1, iDigi);
356 for (ULong64_t iCluster = 0; iCluster < clusterArray->size();
361 <<
" CbmMvdSensorFindHitTask: Calling method "
362 "CheckForNeighbours()..."
370 TVector3
pos(0, 0, 0);
371 TVector3
dpos(0, 0, 0);
375 <<
" CbmMvdSensorFindHitTask: Calling method CreateHit()..."
401 clusterArray->clear();
416 Double_t charge = digi->
GetCharge() + noise;
483 TArrayS* pixelUsed) {
490 pair<Int_t, Int_t> a(channelX, channelY);
494 a = std::make_pair(channelX + 1, channelY);
501 clusterArray->push_back(
i);
503 pixelUsed->AddAt(1,
i);
507 a = std::make_pair(channelX - 1, channelY);
514 clusterArray->push_back(
i);
515 pixelUsed->AddAt(1,
i);
519 a = std::make_pair(channelX, channelY - 1);
525 clusterArray->push_back(
i);
526 pixelUsed->AddAt(1,
i);
530 a = std::make_pair(channelX, channelY + 1);
537 clusterArray->push_back(
i);
538 pixelUsed->AddAt(1,
i);
552 Int_t clusterSize = clusterArray->size();
557 Int_t thisRefID = pixelInCluster->
GetRefId();
558 while (thisRefID < 0 && digiIndex < clusterSize) {
561 thisRefID = pixelInCluster->
GetRefId();
565 LOG(fatal) <<
"RefID of this digi is -1 this should not happend checked "
566 << digiIndex <<
" digis in this Cluster";
573 Int_t indexX, indexY;
592 Int_t latestClusterIndex = -1;
593 Int_t digisInArray = 0;
596 Int_t nClusters = -1;
598 for (
i = 0;
i < clusterSize;
i++) {
601 digisInArray = digisInArray + 1;
607 CbmMvdCluster(digiArray, digisInArray, clusterSize, latestClusterIndex);
608 if (latestCluster) { latestCluster->SetNeighbourUp(nClusters); }
609 latestCluster = clusterNew;
610 latestClusterIndex = nClusters;
615 if (digisInArray != 0) {
618 CbmMvdCluster(digiArray, digisInArray, clusterSize, latestClusterIndex);
619 clusterNew->SetNeighbourUp(-1);
620 if (latestCluster) { latestCluster->SetNeighbourUp(nClusters); };
625 Int_t nHits =
fHits->GetEntriesFast();
627 new ((*fHits)[nHits])
636 <<
"new hit with refID " << pixelInCluster->
GetRefId() <<
" to hit "
640 new ((*fOutputBuffer)[nHits])
664 Float_t xCentralTrack = 0.0;
665 Float_t yCentralTrack = 0.0;
666 Float_t clusterCharge = 0;
668 Int_t clusterSize = clusterArray->size();
672 chargeArray3D[k][j] = gRandom->Gaus(0,
fSigmaNoise);
676 for (Int_t k = 0; k < clusterSize; k++) {
679 clusterCharge = clusterCharge + digi->
GetCharge();
681 Int_t relativeX = digi->
GetPixelX() + seedPixelOffset - seedIndexX;
682 Int_t relativeY = digi->
GetPixelY() + seedPixelOffset - seedIndexY;
688 if (relativeX >= 0 && relativeX < fChargeArraySize && relativeY >= 0
690 chargeArray3D[relativeX][relativeY] = digi->
GetCharge();
693 if ((relativeX - seedPixelOffset == 0)
694 && (relativeY - seedPixelOffset == 0)) {
715 Int_t qSeed = chargeArray3D[seedPixelOffset][seedPixelOffset];
718 for (Int_t k = seedPixelOffset - 1; k < seedPixelOffset + 1; k++) {
719 for (Int_t j = seedPixelOffset - 1; j < seedPixelOffset + 1; j++) {
720 q9 = q9 + chargeArray3D[k][j];
737 for (Int_t k = seedPixelOffset - 2; k < seedPixelOffset + 2; k++) {
738 for (Int_t j = seedPixelOffset - 2; j < seedPixelOffset + 2; j++) {
739 q25 = q25 + chargeArray3D[k][j];
744 for (Int_t k = seedPixelOffset - 3; k < seedPixelOffset + 3; k++) {
745 for (Int_t j = seedPixelOffset - 3; j < seedPixelOffset + 3; j++) {
746 q49 = q49 + chargeArray3D[k][j];
773 for (Int_t
i = 0;
i < 9;
i++) {
774 qSort += chargeArray[orderArray[
i]];
778 for (Int_t
i = 9;
i < 25;
i++) {
779 qSort += chargeArray[orderArray[
i]];
783 TH1F* histoTotalCharge;
786 qSort += chargeArray[orderArray[
i]];
789 histoTotalCharge->Fill(qSort);
797 vector<Int_t>* clusterArray,
803 Double_t pixelSizeX = 0;
804 Double_t pixelSizeY = 0;
811 Double_t
lab[3] = {0, 0, 0};
813 Int_t clusterSize = clusterArray->size();
815 for (Int_t iCluster = 0; iCluster < clusterSize; iCluster++) {
828 <<
"CbmMvdSensorFindHitTask:: iCluster= " << iCluster
829 <<
" , clusterSize= " << clusterSize << endl;
831 <<
"CbmMvdSensorFindHitTask::xIndex " <<
xIndex <<
" , yIndex "
832 <<
yIndex <<
" , charge = "
847 Double_t xc =
x * charge;
848 Double_t yc =
y * charge;
858 <<
"CbmMvdSensorFindHitTask::=========================\n " << endl;
860 <<
"CbmMvdSensorFindHitTask::numeratorX: " <<
numeratorX
877 <<
"CbmMvdSensorFindHitTask::-----------------------------------"
880 <<
"CbmMvdSensorFindHitTask::X hit= " <<
fHitPosX
884 <<
"CbmMvdSensorFindHitTask::-----------------------------------\n"
899 cout <<
"\n============================================================"
902 <<
"::Finish: Total events skipped: " <<
fCounter << endl;
903 cout <<
"============================================================"
905 cout <<
"-I- Parameters used" << endl;
906 cout <<
"Gaussian noise [electrons] : " <<
fSigmaNoise << endl;
907 cout <<
"Noise simulated [Bool] : " <<
fAddNoise << endl;
910 cout <<
"ADC - Bits : " <<
fAdcBits << endl;
911 cout <<
"ADC - Dynamic [electrons] : " <<
fAdcDynamic << endl;
912 cout <<
"ADC - Offset [electrons] : " <<
fAdcOffset << endl;
913 cout <<
"============================================================"
918 TH2F* clusterShapeHistogram;
921 TCanvas* canvas2 =
new TCanvas(
"HitFinderCharge",
"HitFinderCharge");
923 canvas2->Divide(2, 2);
928 clusterShapeHistogram =
new TH2F(
"MvdClusterShape",
939 Float_t charge = histo->GetMean();
944 clusterShapeHistogram->Fill(
951 clusterShapeHistogram->Draw(
"Lego2");