CbmRoot
Loading...
Searching...
No Matches
CbmMvdSensorClusterfinderTask.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2020 Institut fuer Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Philipp Sitzmann [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmMvdSensorClusterfinderTask source file -----
7// ----- Created 03.12.2014 by P. Sitzmann -----
8// -------------------------------------------------------------------------
9
11
12#include "TClonesArray.h"
13#include "TObjArray.h"
14
15#include <Logger.h>
16
17using std::endl;
18using std::pair;
19using std::vector;
20
21// ----- Default constructor -------------------------------------------
28// -------------------------------------------------------------------------
29
30// -------------------------------------------------------------------------
32// -------------------------------------------------------------------------
33
34// -------------------------------------------------------------------------
37 , fAdcDynamic(200)
38 , fAdcOffset(0)
39 , fAdcBits(1)
40 , fAdcSteps(-1)
41 , fAddress(0)
42 , fAdcStepSize(-1.)
43 , fDigis(nullptr)
44 , fPixelChargeHistos(nullptr)
45 , fTotalChargeInNpixelsArray(nullptr)
46 , fResolutionHistoX(nullptr)
47 , fResolutionHistoY(nullptr)
48 , fResolutionHistoCleanX(nullptr)
49 , fResolutionHistoCleanY(nullptr)
50 , fResolutionHistoMergedX(nullptr)
51 , fResolutionHistoMergedY(nullptr)
52 , fBadHitHisto(nullptr)
53 , fGausArray(nullptr)
54 , fGausArrayIt(-1)
55 , fGausArrayLimit(5000)
56 , fDigiMap()
57 , fDigiMapIt()
58 , h(nullptr)
59 , h3(nullptr)
60 , h1(nullptr)
61 , h2(nullptr)
62 , Qseed(nullptr)
63 , fFullClusterHisto(nullptr)
64 , c1(nullptr)
65 , fNEvent(0)
66 , fMode(iMode)
67 , fCounter(0)
68 , fVerbose(iVerbose)
69 , fSigmaNoise(15.)
70 , fSeedThreshold(1.)
71 , fNeighThreshold(1.)
72 , fUseMCInfo(kFALSE)
73 , inputSet(kFALSE)
74 , ftempPixelMap()
75 , fLayerRadius(0.)
76 , fLayerRadiusInner(0.)
77 , fLayerPosZ(0.)
78 , fHitPosX(0.)
79 , fHitPosY(0.)
80 , fHitPosZ(0.)
81 , fHitPosErrX(0.0005)
82 , fHitPosErrY(0.0005)
83 , fHitPosErrZ(0.0)
84 , fBranchName("MvdHit")
85 , fAddNoise(kFALSE)
86{
87 fPluginIDNumber = 200;
90 fPixelUsed = 0;
91}
92// -------------------------------------------------------------------------
93
94// ----- Virtual private method Init ----------------------------------
96{
97
98
99 fSensor = mysensor;
100 LOG(debug) << "CbmMvdSensorClusterfinderTask : Initialisation of sensor " << fSensor->GetName();
101 fInputBuffer = new TClonesArray("CbmMvdDigi", 100);
102 fOutputBuffer = new TClonesArray("CbmMvdCluster", 100);
103 fInputFrameBuffer = new TClonesArray("CbmMvdDigi", 100);
104 fOutputFrameBuffer = new TClonesArray("CbmMvdCluster", 100);
105
106 //Add charge collection histograms
107 fPixelChargeHistos = new TObjArray();
108
109 fTotalChargeInNpixelsArray = new TObjArray();
110
111 fAdcSteps = (Int_t) TMath::Power(2, fAdcBits);
113
115
116 initialized = kTRUE;
117
118 if (fShowDebugHistos) {
119
120 fHistoArray = new TObjArray();
121
122 fResolutionHistoX = new TH1F("SinglePointResolution_X", "SinglePointResolution_X", 10000, -0.0100, 0.0100);
123 fResolutionHistoY = new TH1F("SinglePointResolution_Y", "SinglePointResolution_Y", 10000, -0.0100, 0.0100);
125 new TH1F("SinglePointResolution_X_Clean", "SinglePointResolution_X_Clean", 10000, -0.0100, 0.0100);
127 new TH1F("SinglePointResolution_Y_Clean", "SinglePointResolution_Y_Clean", 10000, -0.0100, 0.0100);
129 new TH1F("SinglePointResolution_X_Merged", "SinglePointResolution_X_Merged", 10000, -0.0100, 0.0100);
131 new TH1F("SinglePointResolution_Y_Merged", "SinglePointResolution_Y_Merged", 10000, -0.0100, 0.0100);
132 fBadHitHisto = new TH2F("BadHits", "Hits above 0.003cm", 1000, -2.5, 2.5, 1000, -2.5, 2.5);
133 fFullClusterHisto = new TH1F("ChargeOfAllPixels", "ChargeOfAllPixels", 12000, 0, 12000);
134
141 fHistoArray->AddLast(fBadHitHisto);
143
144
145 //}
146
147
148 //Add charge collection histograms
149 fPixelChargeHistos = new TObjArray();
150 size_t buf_size = 20;
151 char* histoName = new char[buf_size];
152 TH1F* histo;
153 for (Int_t i = 0; i < 49; i++) {
154 snprintf(histoName, buf_size - 1, "ChargePixel%i", i + 1);
155 histo = new TH1F(histoName, histoName, 200, 0, 200);
156 fPixelChargeHistos->AddLast(histo);
157 };
158 delete[] histoName;
159
160 fTotalChargeInNpixelsArray = new TObjArray();
161 buf_size = 50;
162 char* histoTotalChargeName = new char[buf_size];
163 TH1F* histoTotalCharge;
164 for (Int_t i = 0; i < 49; i++) {
165
166 snprintf(histoTotalChargeName, buf_size - 1, "totalChargeInNPixels%i", i + 1);
167 histoTotalCharge = new TH1F(histoTotalChargeName, histoTotalChargeName, 12000, 0, 12000);
168 fTotalChargeInNpixelsArray->AddLast(histoTotalCharge);
169 };
170 delete[] histoTotalChargeName;
171
172 //Number 49
173 histo = new TH1F("ChargePixelSeed", "ChargePixelSeed", 200, 0, 14000);
174 fPixelChargeHistos->AddLast(histo);
175 //Number 50
176 histo = new TH1F("ChargePixel9of49", "ChargePixel 9 Of 49", 200, 0, 14000);
177 fPixelChargeHistos->AddLast(histo);
178 //Number 51
179 histo = new TH1F("ChargePixel25of49", "ChargePixel 25 Of 49", 200, 0, 14000);
180 fPixelChargeHistos->AddLast(histo);
181 //Number 52
182 histo = new TH1F("ChargePixel49of49", "ChargePixel 49 Of 49", 200, 0, 14000);
183 fPixelChargeHistos->AddLast(histo);
184 //Number 53
185 histo = new TH1F("ChargePixel9of49Sorted", "ChargePixel 9 Of 49 Sorted", 200, 0, 14000);
186 fPixelChargeHistos->AddLast(histo);
187 //Number 54
188 histo = new TH1F("ChargePixel25of49Sorted", "ChargePixel 25 Of 49 Sorted", 200, 0, 14000);
189 fPixelChargeHistos->AddLast(histo);
190 //Number 55
191 histo = new TH1F("ChargePixel49of49Sorted", "ChargePixel 49 Of 49 Sorted", 49, 0.5, 49.5);
192 fPixelChargeHistos->AddLast(histo);
193 }
194 //LOG(debug) << "-Finished- " << GetName() << ": Initialisation of sensor " << fSensor->GetName();
195
196 //Copy histograms in fPixelChargeHistos to fHistoArray (the array for external communications)
197 for (Int_t i = 0; i < fPixelChargeHistos->GetEntriesFast(); i++) {
198 fHistoArray->AddLast(fPixelChargeHistos->At(i));
199 }
200}
201// -------------------------------------------------------------------------
202
203// ----- Virtual public method Reinit ----------------------------------
205{
206 LOG(info) << "CbmMvdSensorClusterfinderTask::ReInt---------------";
207 return kTRUE;
208}
209// -------------------------------------------------------------------------
210
211// ----- Virtual public method ExecChain --------------
213// -------------------------------------------------------------------------
214
216{
217
218
219 // Detect relevant frame numbers from digis in the input fInputBuffer
220
221 LOG(debug) << "CbmMvdSensorClusterfinderTask::Exec starting" << endl;
222 LOG(debug) << "Detected " << fInputBuffer->GetEntriesFast() << " digis for sensor " << fSensor->GetName();
223
224
225 if (!fInputBuffer) {
226 Fatal("CbmMvdSensorClusterfinderTask::Exec - fInputBuffer missing",
227 "CbmMvdSensorClusterfinderTask::Exec - fInputBuffer missing");
228 }
229
230 if (fInputBuffer->GetEntriesFast() == 0) {
231 return;
232 }
233
234 CbmMvdDigi* digi = (CbmMvdDigi*) fInputBuffer->At(0);
235 Int_t minFrame = digi->GetFrameNumber();
236 Int_t maxFrame = digi->GetFrameNumber();
237
238
239 for (Int_t i = 0; i < fInputBuffer->GetEntriesFast(); i++) {
240
241 digi = (CbmMvdDigi*) fInputBuffer->At(i);
242 if (digi->GetFrameNumber() > maxFrame) {
243 maxFrame = digi->GetFrameNumber();
244 };
245 if (digi->GetFrameNumber() < minFrame) {
246 minFrame = digi->GetFrameNumber();
247 };
248 }
249
250
251 //Fill frameBuffer for the first frame of interest
252
253 for (Int_t i = fInputBuffer->GetEntriesFast() - 1; i >= 0; --i) {
254 digi = (CbmMvdDigi*) fInputBuffer->At(i);
255 if (digi->GetFrameNumber() == minFrame) {
256 fInputFrameBuffer->AbsorbObjects(fInputBuffer, i, i);
257 }
258 }
259
260 delete fPixelUsed;
261 fPixelUsed = nullptr;
262
263 // Continue filling starting from the 2nd frame. Two frames are processed by ExecFrame in order to avoid handle time walk
264 // Work on all frames of the input. Independent of running in time or event based
265 // mode the data should be written to the output. Any further data either
266 // belongs to the next event or the next timeslice. Since both events and
267 // time slices are independent of each other all data needs to be written
268 // to the output
269 Int_t currentFrame{minFrame};
270 for (currentFrame = minFrame; currentFrame < maxFrame + 1; currentFrame++) {
271
272 LOG(debug) << "CbmMvdSensorClusterfinderTask::Exec() - Running frame " << currentFrame;
273
274 CleanBuffers(currentFrame);
275 delete fPixelUsed;
276
277 // Add data from the next frame. Note: This is the second of two valid frames.
278
279 for (Int_t i = fInputBuffer->GetEntriesFast() - 1; i >= 0; --i) {
280 digi = (CbmMvdDigi*) fInputBuffer->At(i);
281 if (digi->GetFrameNumber() == currentFrame + 1) {
282 fInputFrameBuffer->AbsorbObjects(fInputBuffer, i, i);
283 }
284 }
285
286 fPixelUsed = new TArrayS(fInputFrameBuffer->GetEntriesFast());
287
288 for (Int_t iDigi = 0; iDigi < fPixelUsed->GetSize(); iDigi++) {
289 fPixelUsed->AddAt(0, iDigi);
290 // Reset fPixelUsed-Array. All entries are set to 0 (not used)
291 }
292
293 ExecFrame(currentFrame);
294
295 fOutputBuffer->AbsorbObjects(fOutputFrameBuffer);
296 fOutputFrameBuffer->Clear();
297 }
298
299 CleanBuffers(currentFrame);
300}
301
303{
304 TString sensorName{fSensor->GetName()};
305 CbmMvdDigi* digi{nullptr};
306
307 // Clean up input buffer from possible digis, which were already associated to a cluster while processing the previous frame
308 if (fPixelUsed) {
309 for (Int_t i = fPixelUsed->GetSize() - 1; i >= 0; i--) {
310 if (fPixelUsed->At(i)) {
311 fInputFrameBuffer->RemoveAt(i);
312 }
313 }
314 }
315
316 // Clean up input buffer from possible digis of the previous frame, which were not associated to a cluster.
317 // With MIMOSIS, this should not happen.
318 // Note that always two frames should be present in the buffer, therefore the currentFrame remains and the consecutive Frame will
319 // be added in a next step.
320
321 fInputFrameBuffer->Compress();
322
323 for (Int_t i = fInputFrameBuffer->GetEntriesFast() - 1; i >= 0; --i) {
324 digi = (CbmMvdDigi*) fInputFrameBuffer->At(i);
325 if (digi->GetFrameNumber() < currentFrame - 1) {
326 LOG(error) << "We should never see this message";
327 fInputFrameBuffer->RemoveAt(i);
328 }
329 }
330
331 fInputFrameBuffer->Compress(); //Eliminate possible empty slots in the TClonesArray
332}
333
334// ----- Public method Exec --------------
336{
337 LOG(debug) << "CbmMvdSensorClusterfinderTask::Exec - Running Sensor " << fSensor->GetName();
338 LOG(debug) << "CbmMvdSensorClusterfinderTask::Exec - InputBufferSize " << fInputFrameBuffer->GetEntriesFast();
339
340 if (fInputFrameBuffer->GetEntriesFast() > 0) {
341 inputSet = kFALSE;
342 vector<Int_t>* clusterArray = new vector<Int_t>;
343
344 CbmMvdDigi* digi;
345
346 Int_t iDigi = 0;
347 digi = (CbmMvdDigi*) fInputFrameBuffer->At(iDigi);
348
349
350 if (!digi) {
351 LOG(error) << "CbmMvdSensorFindHitTask - Fatal: No Digits found in this event.";
352 }
353
354 Int_t nDigis = fInputFrameBuffer->GetEntriesFast();
355 //LOG(debug) << "CbmMvdClusterTrask::Exec(): Received following number of digis: " << nDigis;
356
357
358 fDigiMap.clear();
359
360 Int_t refId;
361
362 // Sort digis into a map in order to access them later by x-y coordinate.
363 // No double entries are possible (max 1 digi per pixel)
364
365 for (Int_t k = 0; k < nDigis; k++) {
366
367 digi = (CbmMvdDigi*) fInputFrameBuffer->At(k);
368 refId = digi->GetRefId();
369 if (refId < 0) {
370 LOG(fatal) << "RefID of this digi is -1 this should not happend ";
371 }
372 //apply fNeighThreshold
373
374 if (GetAdcCharge(digi->GetCharge()) < fNeighThreshold) {
375 /*
376 LOG(info) << "Digi Charge: " << digi->GetCharge();
377 LOG(info) << "ADC Charge: " << GetAdcCharge(digi->GetCharge());
378*/
379 fPixelUsed->AddAt(1, k);
380 continue;
381 }
382
383 pair<Int_t, Int_t> a(digi->GetPixelX(), digi->GetPixelY());
384 //LOG(debug) << "registerde pixel x:" << digi->GetPixelX() << " y:" << digi->GetPixelY();
385
386
387 fDigiMap[a] = k;
388 };
389
390
391 LOG(debug) << GetName() << ": VolumeId " << fSensor->GetVolumeId();
392
393 //LOG(debug) <<"CbmMvdSensorClusterfinderTask: Working with " << nDigis << " digis";
394
395 //cout<<"CbmMvdSensorClusterfinderTask: Working with " << nDigis << " digis" << endl;
396
397 for (iDigi = 0; iDigi < nDigis; iDigi++) {
398
399 LOG_IF(debug, iDigi % 10000 == 0) << GetName() << " Digi:" << iDigi;
400
401 digi = (CbmMvdDigi*) fInputFrameBuffer->At(iDigi);
402 //LOG(debug) << "working with pixel x:" << digi->GetPixelX() << " y:" << digi->GetPixelY();
403
404
405 /*
406 ---------------------------------------------------------
407 check if digi is above threshold (define seed pixel)
408 then check for neighbours.
409 Once the cluster is created (seed and neighbours)
410 calculate the position of the hit
411 using center of gravity (CoG) method.
412 ---------------------------------------------------------
413 */
414
415 LOG(debug) << "CbmMvdSensorClusterfinderTask: Checking for seed pixels...";
416
417 if ((GetAdcCharge(digi->GetCharge()) >= fSeedThreshold) && (fPixelUsed->At(iDigi) == kFALSE)
418 && digi->GetFrameNumber() == currentFrame) {
419 clusterArray->clear();
420 clusterArray->push_back(iDigi);
421
422 fPixelUsed->AddAt(1, iDigi);
423
424 pair<Int_t, Int_t> a(digi->GetPixelX(), digi->GetPixelY());
425 fDigiMapIt = fDigiMap.find(a);
426
427
428 if (fDigiMapIt != fDigiMap.end()) {
429 fDigiMap.erase(fDigiMapIt);
430 };
431 // This triggers a re-sort of the map. Performance?
432
433 for (ULong64_t iCluster = 0; iCluster < clusterArray->size(); iCluster++) {
434
435 LOG(debug) << " CbmMvdSensorClusterfinderTask: Calling method CheckForNeighbours()...";
436
437 CheckForNeighbours(clusterArray, iCluster, fPixelUsed);
438 //LOG(debug) << "checked for neighbours, create cluster";
439 }
440
441 Int_t i = 0;
442 Int_t pixelCharge;
443
444
445 pair<Int_t, Int_t> pixelCoords;
446 Int_t clusterSize = clusterArray->size();
447 Int_t nClusters = fOutputFrameBuffer->GetEntriesFast();
448 //LOG(debug) << "new cluster: " << nClusters;
449 CbmMvdCluster* clusterNew = new ((*fOutputFrameBuffer)[nClusters]) CbmMvdCluster();
450 clusterNew->SetAddress(fAddress);
451
452 CbmMvdDigi* digiInCluster = (CbmMvdDigi*) fInputFrameBuffer->At(clusterArray->at(0));
453 Int_t earliestFrame = digiInCluster->GetFrameNumber();
454
455 for (i = 0; i < clusterSize; i++) {
456 digiInCluster = (CbmMvdDigi*) fInputFrameBuffer->At(clusterArray->at(i));
457
458 if (digiInCluster->GetFrameNumber() < earliestFrame) {
459 earliestFrame = digiInCluster->GetFrameNumber();
460 } //fixme retundant for i==0
461
462 clusterNew->AddDigi(digiInCluster->GetRefId());
463 pixelCoords = std::make_pair(digiInCluster->GetPixelX(), digiInCluster->GetPixelY());
464 pixelCharge = digiInCluster->GetCharge();
465 ftempPixelMap[pixelCoords] = pixelCharge;
466 }
467 clusterNew->SetPixelMap(ftempPixelMap);
468 clusterNew->SetEarliestFrameNumber(earliestFrame);
469 ftempPixelMap.clear();
470
471 if (fShowDebugHistos) UpdateDebugHistos(clusterNew);
472
473 } // if AdcCharge>threshold
474 else { //LOG(debug) << "pixel is with " << digi->GetCharge() << " under Threshold or used";
475 }
476 } // loop on digis
477
478
479 clusterArray->clear();
480 delete clusterArray;
481
482 fDigiMap.clear();
483 }
484 else { //LOG(debug) << "No input found.";
485 }
486 // fInputFrameBuffer->Clear();
487}
488// -------------------------------------------------------------------------
489
490// -------------------------------------------------------------------------
491void CbmMvdSensorClusterfinderTask::CheckForNeighbours(vector<Int_t>* clusterArray, Int_t clusterDigi,
492 TArrayS* pixelUsed)
493{
494 CbmMvdDigi* seed = (CbmMvdDigi*) fInputFrameBuffer->At(clusterArray->at(clusterDigi));
495 //LOG(debug) << "pixel nr. " << clusterDigi << " is seed";
496
497
498 // Remove Seed Pixel from list of non-used pixels
499 Int_t channelX = seed->GetPixelX();
500 Int_t channelY = seed->GetPixelY();
501 pair<Int_t, Int_t> a(channelX, channelY);
502
503 // Find first neighbour
504
505 a = std::make_pair(channelX + 1, channelY);
506 fDigiMapIt = fDigiMap.find(a);
507
508 if (!(fDigiMapIt == fDigiMap.end())) {
509 Int_t i = fDigiMap[a];
510 //LOG(debug) << "pixel nr. " << i << " is used";
511 // Only digis depassing fNeighThreshold are in the map, no cut required
512 clusterArray->push_back(i);
513
514 pixelUsed->AddAt(1, i); // block pixel for the seed pixel scanner
515 fDigiMap.erase(fDigiMapIt); // block pixel for the neighbour pixel scanner
516 }
517
518 a = std::make_pair(channelX - 1, channelY);
519 fDigiMapIt = fDigiMap.find(a);
520
521 if (!(fDigiMapIt == fDigiMap.end())) {
522 Int_t i = fDigiMap[a];
523 //LOG(debug) << "pixel nr. " << i << " is used";
524 // Only digits depassing fNeighThreshold are in the map, no cut required
525 clusterArray->push_back(i);
526 pixelUsed->AddAt(1, i); // block pixel for the seed pixel scanner
527 fDigiMap.erase(fDigiMapIt); // block pixel for the neighbour pixel scanner
528 }
529
530 a = std::make_pair(channelX, channelY - 1);
531 fDigiMapIt = fDigiMap.find(a);
532 if (!(fDigiMapIt == fDigiMap.end())) {
533 Int_t i = fDigiMap[a];
534 // Only digits depassing fNeighThreshold are in the map, no cut required
535 //LOG(debug) << "pixel nr. " << i << " is used";
536 clusterArray->push_back(i);
537 pixelUsed->AddAt(1, i); // block pixel for the seed pixel scanner
538 fDigiMap.erase(fDigiMapIt); // block pixel for the neighbour pixel scanner
539 }
540
541 a = std::make_pair(channelX, channelY + 1);
542 fDigiMapIt = fDigiMap.find(a);
543
544 if (!(fDigiMapIt == fDigiMap.end())) {
545 Int_t i = fDigiMap[a];
546 //LOG(debug) << "pixel nr. " << i << " is used";
547 // Only digis depassing fNeighThreshold are in the map, no cut required
548 clusterArray->push_back(i);
549 pixelUsed->AddAt(1, i); // block pixel for the seed pixel scanner
550 fDigiMap.erase(fDigiMapIt); // block pixel for the neighbour pixel scanner
551 }
552}
553// -------------------------------------------------------------------------
554
555// -------------------------------------------------------------------------
557{
558
559 Int_t adcCharge;
560
561 if (charge < fAdcOffset) {
562 return 0;
563 };
564
565 adcCharge = int((charge - fAdcOffset) / fAdcStepSize);
566 if (adcCharge > fAdcSteps - 1) {
567 adcCharge = fAdcSteps - 1;
568 }
569
570 return adcCharge;
571}
572// -------------------------------------------------------------------------
573
575{
576 /************************************************************
577 Algorithm for cluster shapes
578
579 ************************************************************/
580 Float_t chargeArray3D[fChargeArraySize][fChargeArraySize];
581 Float_t chargeArray[fChargeArraySize * fChargeArraySize];
582 Short_t seedPixelOffset = fChargeArraySize / 2; // 3 for 7, 2 for 5
583 Int_t seedIndexX = 0, seedIndexY = 0;
584 Float_t seedCharge = 0.;
585 Float_t clusterCharge = cluster->GetClusterCharge();
586 std::map<std::pair<Int_t, Int_t>, Int_t> clusterMap = cluster->GetPixelMap();
587
588 for (Int_t k = 0; k < fChargeArraySize; k++) {
589 for (Int_t j = 0; j < fChargeArraySize; j++) {
590 chargeArray3D[k][j] = gRandom->Gaus(0, fSigmaNoise);
591 }
592 }
593 for (std::map<std::pair<Int_t, Int_t>, Int_t>::iterator iter = clusterMap.begin(); iter != clusterMap.end(); iter++) {
594 if (iter->second > seedCharge) {
595 seedCharge = iter->second;
596 seedIndexX = iter->first.first;
597 seedIndexY = iter->first.second;
598 }
599 }
600 //LOG(debug) << "seed pixel with " << seedCharge << " charge";
601 for (std::map<std::pair<Int_t, Int_t>, Int_t>::iterator iter = clusterMap.begin(); iter != clusterMap.end(); iter++) {
602
603 Int_t relativeX = iter->first.first + seedPixelOffset - seedIndexX;
604 Int_t relativeY = iter->first.second + seedPixelOffset - seedIndexY;
605
606 if (fVerbose > 1) LOG(debug) << relativeX << " " << relativeY << " " << iter->first.first << " " << seedIndexX;
607
608
609 if (relativeX >= 0 && relativeX < fChargeArraySize && relativeY >= 0 && relativeY < fChargeArraySize) {
610 chargeArray3D[relativeX][relativeY] = iter->second;
611 }
612
613 if ((relativeX - seedPixelOffset == 0) && (relativeY - seedPixelOffset == 0)) { //seed digiArray
614 }
615 }
616
617 if (fVerbose > 1) {
618 std::stringstream ss;
619 for (Int_t i = 0; i < fChargeArraySize; i++) {
620 for (Int_t j = 0; j < fChargeArraySize; j++) {
621 ss << chargeArray3D[i][j] << " ";
622 }
623 ss << endl;
624 }
625 LOG(info) << ss.str();
626 }
627 fFullClusterHisto->Fill(clusterCharge);
628
629 for (Int_t k = 0; k < fChargeArraySize; k++) {
630 for (Int_t j = 0; j < fChargeArraySize; j++) {
631 chargeArray[fChargeArraySize * k + j] = chargeArray3D[k][j];
632 }
633 }
634
635 Int_t qSeed = chargeArray3D[seedPixelOffset][seedPixelOffset];
636 Int_t q9 = 0;
637
638 for (Int_t k = seedPixelOffset - 1; k < seedPixelOffset + 1; k++) {
639 for (Int_t j = seedPixelOffset - 1; j < seedPixelOffset + 1; j++) {
640 q9 = q9 + chargeArray3D[k][j];
641 }
642 };
643
644
645 if (fChargeArraySize <= 7) {
646 for (Int_t i = 0; i < (fChargeArraySize * fChargeArraySize); i++) {
647 ((TH1F*) fPixelChargeHistos->At(i))->Fill(chargeArray[i]);
648 //LOG(debug) << counter++<<" Charge: " << chargeArray[i];
649 };
650 };
651
652 //LOG(debug) << "End of Cluster: "<<fChargeArraySize*fChargeArraySize;
653
654 Int_t q25 = 0;
655 Int_t q49 = 0;
656
657
658 for (Int_t k = seedPixelOffset - 2; k < seedPixelOffset + 2; k++) {
659 for (Int_t j = seedPixelOffset - 2; j < seedPixelOffset + 2; j++) {
660 q25 = q25 + chargeArray3D[k][j];
661 }
662 };
663
664 if (fChargeArraySize >= 7) {
665 for (Int_t k = seedPixelOffset - 3; k < seedPixelOffset + 3; k++) {
666 for (Int_t j = seedPixelOffset - 3; j < seedPixelOffset + 3; j++) {
667 q49 = q49 + chargeArray3D[k][j];
668 }
669 }
670 }
671
672 ((TH1F*) fPixelChargeHistos->At(49))->Fill(qSeed);
673 ((TH1F*) fPixelChargeHistos->At(50))->Fill(q9);
674 ((TH1F*) fPixelChargeHistos->At(51))->Fill(q25);
675 ((TH1F*) fPixelChargeHistos->At(52))->Fill(q49);
676
677
678 //Prepare selection of crowns for charge bow histograms
679
680
681 Int_t orderArray[fChargeArraySize * fChargeArraySize];
682
683 TMath::Sort(fChargeArraySize * fChargeArraySize, chargeArray, orderArray, kTRUE);
684
685 Float_t qSort = 0;
686 for (Int_t i = 0; i < 9; i++) {
687 qSort += chargeArray[orderArray[i]];
688 };
689 ((TH1F*) fPixelChargeHistos->At(53))->Fill(qSort);
690
691 for (Int_t i = 9; i < 25; i++) {
692 qSort += chargeArray[orderArray[i]];
693 };
694 ((TH1F*) fPixelChargeHistos->At(54))->Fill(qSort);
695
696 TH1F* histoTotalCharge;
697 qSort = 0;
698 for (Int_t i = 0; i < fChargeArraySize * fChargeArraySize; i++) {
699 qSort += chargeArray[orderArray[i]];
700 ((TH1F*) fPixelChargeHistos->At(55))->Fill(i + 1, qSort);
701 histoTotalCharge = (TH1F*) fTotalChargeInNpixelsArray->At(i);
702 histoTotalCharge->Fill(qSort);
703 }
704}
705
706//--------------------------------------------------------------------------
708{
709
710 if (
711 kFALSE
712 && fShowDebugHistos) { //Reaction to ShowHistograms at the finish of the initial FairTask. Obsolete, thus switched off for now
713 LOG(info) << "============================================================";
714 LOG(info) << GetName() << "::Finish: Total events skipped: " << fCounter;
715 LOG(info) << "============================================================";
716 LOG(info) << "Parameters used";
717 LOG(info) << "Gaussian noise [electrons] : " << fSigmaNoise;
718 LOG(info) << "Noise simulated [Bool] : " << fAddNoise;
719 LOG(info) << "Threshold seed [ADC] : " << fSeedThreshold;
720 LOG(info) << "Threshold neighbours [ADC] : " << fNeighThreshold;
721 LOG(info) << "ADC - Bits : " << fAdcBits;
722 LOG(info) << "ADC - Dynamic [electrons] : " << fAdcDynamic;
723 LOG(info) << "ADC - Offset [electrons] : " << fAdcOffset;
724 LOG(info) << "============================================================";
725
726
727 TH1F* histo;
728 TH2F* clusterShapeHistogram;
729 TCanvas* canvas2 = new TCanvas("HitFinderCharge", "HitFinderCharge");
730 canvas2->Divide(2, 2);
731 canvas2->cd(1);
732 if (fChargeArraySize <= 7) {
733 clusterShapeHistogram = new TH2F("MvdClusterShape", "MvdClusterShape", fChargeArraySize, 0, fChargeArraySize,
735 for (Int_t i = 0; i < fChargeArraySize * fChargeArraySize; i++) {
736 histo = (TH1F*) fPixelChargeHistos->At(i);
737 Float_t charge = histo->GetMean();
738 //LOG(debug) <<i << " Charge " << charge << " xCluster: " << i%fChargeArraySize << " yCluster: " << i/fChargeArraySize;
739 //histo->Fit("landau");
740 //TF1* fitFunction= histo->GetFunction("landau");
741 //Double_t MPV=fitFunction->GetParameter(1);
742 clusterShapeHistogram->Fill(i % fChargeArraySize, i / fChargeArraySize, charge);
743 }
744 }
745 clusterShapeHistogram->Draw("Lego2");
746 canvas2->cd(2);
747 histo = (TH1F*) fPixelChargeHistos->At(50);
748 histo->Draw();
749 canvas2->cd(3);
750 histo = (TH1F*) fPixelChargeHistos->At(51);
751 histo->Draw();
752 canvas2->cd(4);
753 //fFullClusterHisto->Draw();
754 }
755}
756//--------------------------------------------------------------------------
757
ClassImp(CbmConverterManager)
const constexpr Int_t fCounter(0)
void AddDigi(int32_t index)
Add digi to cluster.
Definition CbmCluster.h:51
void SetAddress(int32_t address)
Definition CbmCluster.h:94
void SetEarliestFrameNumber(Int_t frameNumber)
float GetClusterCharge()
void SetPixelMap(std::map< std::pair< int32_t, int32_t >, int32_t > PixelMap)
std::map< std::pair< int32_t, int32_t >, int32_t > GetPixelMap()
int32_t GetPixelY()
int32_t GetFrameNumber()
Definition CbmMvdDigi.h:58
int32_t GetPixelX()
double GetCharge() const
Definition CbmMvdDigi.h:47
int32_t GetRefId() const
Definition CbmMvdDigi.h:61
void UpdateDebugHistos(CbmMvdCluster *cluster)
std::map< std::pair< Int_t, Int_t >, Int_t > fDigiMap
void CheckForNeighbours(std::vector< Int_t > *clusterArray, Int_t clusterDigi, TArrayS *pixelUsed)
std::map< std::pair< Int_t, Int_t >, Int_t >::iterator fDigiMapIt
std::map< std::pair< Int_t, Int_t >, Int_t > ftempPixelMap
virtual const char * GetName() const
CbmMvdSensor * fSensor
TClonesArray * fOutputBuffer
TClonesArray * fInputBuffer
Int_t GetSensorNr() const
Int_t GetVolumeId() const
Int_t GetStationNr() const
Data class with information on a STS local track.