468 TStopwatch *timer_array =
new TStopwatch();
470 if (
fVerbose > 0) timer_array->Start();
477 if (nPixelHits < 2) {
479 cout <<
"Evt finsihed: too less hits-----" << endl << endl;
483 std::vector<std::vector<Int_t> > hitsd(
492 std::cout <<
"Algorithm depend on sensor type! Please, set it via "
493 "SetSensStripFlag(bool fS) or SetSensPixelFlag(bool fS)"
500 cout <<
"Evt finsihed: too less planes-----" << endl << endl;
505 TVector3 start, tmp,
vec, dstart, dvec;
507 for (Int_t iPlane = 0; iPlane <
nP; iPlane++) {
508 if (hitsd.at(iPlane).size() > 0) {
509 for (
unsigned int i = 0;
i < hitsd.at(iPlane).size();
i++) {
513 cout <<
" Hit#" << hitsd.at(iPlane).at(
i) <<
" Plane" << iPlane
514 <<
" Hit=(" << hit->GetX() <<
", " << hit->GetY() <<
", "
515 << hit->GetZ() <<
") with err=(" << hit->GetDx() <<
", "
516 << hit->GetDy() <<
", " << hit->GetDz() <<
")"
517 <<
", MChitID = " << hit->GetRefIndex() << endl;
523 cout <<
"array preparation: " << endl;
525 timer_array->
Print();
532 TStopwatch *timer_cook_cells =
new TStopwatch();
533 if (
fVerbose > 0) timer_cook_cells->Start();
544 for (
int pl0 = 0; pl0 < 2; pl0++) {
559 for (
int icell0 = 0; icell0 <
fCellArray->GetEntries(); icell0++) {
572 for (
int pl0 = 1; pl0 < 3; pl0++) {
578 for (
int icell0 = 0; icell0 <
fCellArray->GetEntries(); icell0++) {
610 for (
int icell0 = 0; icell0 <
fCellArray->GetEntries(); icell0++) {
616 cout <<
"Cells cooking:" << endl;
617 timer_cook_cells->Stop();
618 timer_cook_cells->Print();
621 TStopwatch *timer_neighbors_cells =
new TStopwatch();
622 if (
fVerbose > 0) timer_cook_cells->Start();
630 TStopwatch *timer_build_trk_combinations =
new TStopwatch();
632 if (
fVerbose > 0) timer_build_trk_combinations->Start();
636 for (
int cid = 1; cid < nCells; cid++) {
638 int tag_cur = cell->
GetPV();
639 if (tag_cur > pcmax) pcmax = tag_cur;
641 if (
fVerbose > 4) cout <<
"track can contain " << pcmax <<
"+1 cells" << endl;
642 const unsigned int trk_arr_size = pcmax + 1;
643 std::vector<std::vector<int> > trk_cells(trk_arr_size);
646 for (
unsigned int newpcmax = pcmax; newpcmax > 0;
648 unsigned int cur_max_tag = newpcmax;
650 cout <<
"Now we are looking for trk with max " << cur_max_tag + 1
651 <<
" cells among " << nCells <<
" cells" << endl;
653 for (
int icell0 = 0; icell0 < nCells; icell0++) {
655 if (cell0->
GetPV() ==
657 for (
int icell1 = 0; icell1 < nCells; icell1++) {
662 bool isNeighbor =
Neighbor(cell1, cell0);
665 cout <<
"trk #" << trk_count <<
" " << cell0->
GetPV() <<
", "
666 << cell1->
GetPV() <<
"; ";
667 if (cell1->
GetPV() > 0) {
671 for (
int icell2 = 0; icell2 < nCells; icell2++) {
676 bool isNeighbor2 =
Neighbor(cell2, cell1);
690 if ((cell0->
GetPV() + 1) == pcmax) {
695 if (
fVerbose > 2) cout <<
"" << endl;
703 timer_build_trk_combinations->Stop();
704 cout <<
"Build trks combinations: " << endl;
705 timer_build_trk_combinations->Print();
708 cout <<
"Before filtering number of trk-cands = " << trk_cells.at(0).size()
712 TStopwatch *timer_filter_trk_combinations =
new TStopwatch();
714 if (
fVerbose > 0) timer_filter_trk_combinations->Start();
716 if (
fVerbose > 4) cout <<
"--- filter trk-cand array: " << endl;
718 cout <<
" Attention each trk candidate with repeated cells, but smaller "
719 "cells number will be deleted!"
721 vector<unsigned int> cell_parts;
722 vector<bool> trk_accept;
723 for (
unsigned int itrk = 0; itrk < trk_cells.at(0).size(); itrk++) {
724 int maxcellnum = trk_arr_size;
725 int curr_arr = trk_arr_size;
726 while (curr_arr > 0) {
729 cout <<
" we have: trk_cells.at(" << curr_arr <<
").at(" << itrk
730 <<
")=" << trk_cells.at(curr_arr).at(itrk) << endl;
731 if (trk_cells.at(curr_arr).at(itrk) < 0) maxcellnum--;
733 cell_parts.push_back(maxcellnum);
735 trk_accept.push_back(
true);
737 trk_accept.push_back(
false);
738 if (
fVerbose > 4) cout <<
" with:" << maxcellnum <<
" cells" << endl;
741 for (
int itrc = (cell_parts.size() - 1); itrc >= 0; itrc--) {
742 if (!trk_accept[itrc])
continue;
744 for (
int itrc2 = cup; itrc2 >= 0; itrc2--) {
745 if (!trk_accept[itrc])
break;
746 if (!trk_accept[itrc2])
continue;
749 if (cell_parts[itrc] < cell_parts[itrc2]) {
750 unsigned int count_re = 0;
751 unsigned int count_hits = 0;
753 int curr_arr = trk_arr_size;
754 while (curr_arr > 0) {
756 int cellnum1 = trk_cells.at(curr_arr).at(itrc);
757 int cellnum2 = trk_cells.at(curr_arr).at(itrc2);
759 if (cellnum1 < 0 || cellnum2 < 0)
continue;
760 if (cellnum1 == cellnum2) count_re++;
768 if (hit0_0 == hit0_1) count_hits++;
769 if (hit1_0 == hit1_1) count_hits++;
770 if (hit0_0 == hit1_1) count_hits++;
771 if (hit1_0 == hit0_1) count_hits++;
774 cout <<
"Cand.No" << itrc
775 <<
": Number of repeating cells = " << count_re
776 <<
" and cells in tot = " << cell_parts[itrc]
777 <<
" Number of repeating hits = " << count_hits << endl;
778 if (count_re > 0.55 * cell_parts[itrc] || count_hits > 2) {
779 trk_accept[itrc] =
false;
781 cout <<
"Delete: trk-cand#" << itrc <<
" because it contains ("
782 << count_re <<
") more then 55% cells from trk-cand#" << itrc2
791 timer_filter_trk_combinations->Stop();
792 cout <<
"Filter: " << endl;
793 timer_filter_trk_combinations->Print();
798 for (
unsigned int itrk = 0; itrk < trk_accept.size(); itrk++) {
799 if (!trk_accept[itrk])
continue;
800 bool firstHit =
true;
803 if (
fVerbose > 2) cout <<
"Trk-cand contains hits:";
804 for (
unsigned int icell = 0; icell < trk_arr_size; icell++) {
805 int cellNum = trk_cells.at(icell).at(itrk);
806 if (cellNum < 0)
continue;
816 dir *= 1. / dir.Mag();
824 if (
fVerbose > 2) cout <<
" " << endl;
826 new ((*fTrackCandArray)[NtrkRec++])
829 if (
fVerbose > 3) cout <<
"Ntrk No. " << NtrkRec << endl;
833 hitsd.erase(hitsd.begin(), hitsd.end());
836 cout <<
"Number of Trk-Cands is " << ntcandFin << endl;
837 cout <<
"Evt finsihed--------------" << endl << endl;
844 delete timer_cook_cells;
845 delete timer_neighbors_cells;
846 delete timer_build_trk_combinations;
847 delete timer_filter_trk_combinations;
virtual void Print(const Option_t *opt=0) const
TVector3 GetPosition() const
TClonesArray * fCellArray
labels push_back("electron")
bool SortHitsByDetSimple(std::vector< std::vector< Int_t > > &hitsd, Int_t nStripHits)
bool Neighbor(int &icell0, int &icell1)
TClonesArray * ForwardEvolution(TClonesArray *fCellArray, int niter=100)
void AddHit(UInt_t detId, UInt_t hitId, Double_t rho)
TClonesArray * fTrackCandArray
TClonesArray * fStripHitArray
bool SortHitsByDetSimple2(std::vector< std::vector< Int_t > > &hitsd, Int_t nStripHits)
TClonesArray * CookCells(std::vector< std::vector< Int_t > > hitsd, int &pl0, int &pl1, TClonesArray *tCellArray)