18 #include "FairRootManager.h"
19 #include "TClonesArray.h"
22 #include "TStopwatch.h"
42 : FairTask(
"MuchFindHitsGem", 1)
43 , fDigiFile(digiFileName)
46 , fClusterSeparationTime(100.)
47 , fThresholdRatio(0.1)
57 , fClusters(new TClonesArray(
"CbmMuchCluster", 1000))
58 , fHits(new TClonesArray(
"CbmMuchPixelHit", 1000))
70 FairRootManager* ioman = FairRootManager::Instance();
93 fEvents =
dynamic_cast<TClonesArray*
>(
94 FairRootManager::Instance()->GetObject(
"Event"));
96 fEvents =
dynamic_cast<TClonesArray*
>(
97 FairRootManager::Instance()->GetObject(
"CbmEvent"));
100 LOG(info) << GetName() <<
": No event branch present.";
107 <<
"TimeSlice: Event-by-event mode after Event Building selected. ";
110 ioman->Register(
"MuchCluster",
113 IsOutputBranchPersistent(
"MuchCluster"));
114 ioman->Register(
"MuchPixelHit",
117 IsOutputBranchPersistent(
"MuchPixelHit"));
120 TFile* oldfile = gFile;
122 TObjArray* stations = (TObjArray*) file->Get(
"stations");
166 LOG(info) << setw(20) << left << GetName() <<
": processing time is "
171 <<
" clusters " <<
fClusters->GetEntriesFast() <<
" total hits "
172 <<
fHits->GetEntriesFast();
177 Int_t nEvents =
fEvents->GetEntriesFast();
178 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
186 LOG(debug) << setw(20) << left
190 << (nEvents == 1 ?
" event" :
" events")
191 <<
" and processing event nubmer " << iEvent <<
" digis "
194 <<
" and created cluster "
196 <<
" and created hit "
199 LOG(info) << setw(20) << left << GetName() <<
": Processing Time is "
201 <<
" with " << nEvents << (nEvents == 1 ?
" event" :
" events")
205 <<
" and event wise total "
206 <<
" clusters " <<
fClusters->GetEntriesFast() <<
" total hits "
207 <<
fHits->GetEntriesFast();
216 TStopwatch EventTimer;
223 Int_t NuOfClusterInEvent =
227 for (Int_t clusterIndex = 0; clusterIndex < NuOfClusterInEvent;
252 Fatal(
"CbmMuchFindHitsGem::Exec:",
253 "The algorithm index does not exist.");
272 <<
" event : " <<
event->GetNumber() <<
" nDigi : " << nDigis;
273 if (nDigis < 0)
return;
275 for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
310 for (UInt_t
m = 0;
m < modules.size();
m++)
311 modules[
m]->ClearDigis();
315 for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
328 Double_t time = digi->
GetTime();
336 for (UInt_t
m = 0;
m < modules.size();
m++) {
338 multimap<Double_t, Int_t> digis = modules[
m]->
GetDigis();
339 multimap<Double_t, Int_t>::iterator it, itmin, itmax;
342 vector<multimap<Double_t, Int_t>::iterator> slices;
343 Double_t tlast = -10000;
345 for (it = digis.begin(); it != digis.end(); ++it) {
346 Double_t t = it->first;
350 slices.push_back(it);
351 for (UInt_t s = 1; s < slices.size(); s++) {
353 for (it = slices[s - 1]; it != slices[s]; it++) {
354 Int_t iDigi = it->second;
370 for (UInt_t p = 0; p <
fFiredPads.size(); p++) {
409 if (digiIndex < 0)
return;
413 for (UInt_t
i = 0;
i < neighbours.size();
i++)
438 for (Int_t iDigi = 0; iDigi < cluster->
GetNofDigis(); iDigi++) {
439 Int_t digiIndex = cluster->
GetDigi(iDigi);
448 Int_t charge = digi->
GetAdc();
449 if (charge > maxCharge) maxCharge = charge;
456 for (Int_t iDigi = 0; iDigi < cluster->
GetNofDigis(); iDigi++) {
457 Int_t digiIndex = cluster->
GetDigi(iDigi);
466 if (digi->
GetAdc() <= threshold)
continue;
471 for (UInt_t p = 0; p <
fFiredPads.size(); p++) {
499 for (Int_t
i = 0;
i < nDigis;
i++) {
515 Int_t adc = digi->
GetAdc();
522 for (Int_t
i = 0;
i < nDigis;
i++) {
525 vector<Int_t> selected_neighbours;
526 for (UInt_t ip = 0; ip < neighbours.size(); ip++) {
528 vector<CbmMuchPad*>::iterator it =
531 selected_neighbours.push_back(it -
fClusterPads.begin());
537 for (Int_t
i = 0;
i < nDigis;
i++) {
548 for (Int_t
i = 0;
i < nDigis;
i++) {
556 for (UInt_t p = 0; p <
fFiredPads.size(); p++) {
573 Double_t sumq = 0, sumx = 0, sumy = 0, sumt = 0, sumdx2 = 0, sumdy2 = 0,
574 sumdxy2 = 0, sumdt2 = 0;
575 Double_t q = 0,
x = 0,
y = 0, t = 0, z = 0, dx = 0, dy = 0, dxy = 0, dt = 0;
576 Double_t nX = 0, nY = 0, nZ = 0;
583 for (Int_t
i = 0;
i < nDigis;
i++) {
611 Double_t gemDriftTimeCorrc =
613 Double_t rpcDriftTimeCorrc =
615 Double_t gemHitTimeError =
617 Double_t rpcHitTimeError =
625 t = digi->
GetTime() - gemDriftTimeCorrc + timeShift;
628 dt = gemHitTimeError;
632 t = digi->
GetTime() - rpcDriftTimeCorrc + timeShift;
633 dt = rpcHitTimeError;
636 if (tmin < 0) tmin = t;
637 if (tmin < t) tmin = t;
647 sumdx2 += q * q * dx * dx;
648 sumdy2 += q * q * dy * dy;
649 sumdxy2 += q * q * dxy * dxy;
650 sumdt2 += q * q * dt * dt;
658 dx =
sqrt(sumdx2 / 12) / sumq;
659 dy =
sqrt(sumdy2 / 12) / sumq;
660 dxy =
sqrt(sumdxy2 / 12) / sumq;
661 dt =
sqrt(sumdt2) / sumq;
662 Int_t iHit =
fHits->GetEntriesFast();
665 Double_t tX = 18.5, tY = 80.5;
672 address, nX, nY, nZ, dx, dy, 0, dxy, iCluster, planeId, t, dt);
675 address,
x,
y, z, dx, dy, 0, dxy, iCluster, planeId, t, dt);