10 #include <TGeoManager.h>
11 #include <TGeoVolume.h>
13 #include <TGeoMaterial.h>
14 #include <TGeoNavigator.h>
15 #include <TClonesArray.h>
16 #include <Math/DistFunc.h>
32 #include <EicGeoParData.h>
37 #define GCBANK_SIZE 30000000
42 #define GCBANK COMMON_BLOCK(GCBANK, gcbank)
64 #define _MG_CELL_SIZE_ ( 2.0)
65 #define _MG_WIDTH_ (80.0)
87 assert(csystem && fsystem);
89 for(
int xy=
_X_; xy<=
_Y_; xy++)
101 min[
_Z_] = z0 - 1./2.; max[
_Z_] = z0 + 1./2.;
104 for(
int ik=0; ik<3; ik++)
112 printf(
"\n !!! Most likely you ran out of memory !!!\n\n");
135 for(
unsigned ip=0;
ip<3;
ip++)
136 cell->
B[
ip] = bff[
ip];
149 double rtheta = theta*TMath::Pi()/180., rphi = phi*TMath::Pi()/180.;
152 TVector3(sin(rtheta)*
cos(rphi), sin(rtheta)*sin(rphi),
cos(rtheta));
160 t_3d_line zaxis(TVector3(0.0, 0.0, 0.0), TVector3(0.0, 0.0, 1.0));
178 printf(
"Starting media scan ...\n");
183 TGeoNavigator *navi = (TGeoNavigator *)gGeoManager->GetListOfNavigators()->At(0);
187 double x0[3], nx0[3];
189 for(
unsigned iq=0; iq<3; iq++) {
194 gGeoManager->SetCurrentPoint ( x0);
195 gGeoManager->SetCurrentDirection(nx0);
198 for(TGeoNode *node = gGeoManager->GetCurrentNode(); ; ) {
201 gGeoManager->FindNextBoundary();
204 node = gGeoManager->Step();
205 assert(gGeoManager->IsEntering());
219 TIter next( gGeoManager->GetListOfVolumes() );
222 while ((volume=(TGeoVolume*)next())) {
223 TObjArray *arr = volume->GetNodes();
if (!arr)
continue;
225 for(
unsigned iq=0; iq<arr->GetEntriesFast(); iq++) {
226 TGeoNode *node = (TGeoNode*)arr->At(iq);
233 if (!lNode)
continue;
238 double local[3] = {0,0,0};
241 double z0 = global[2];
252 snprintf(buffer, 128-1,
"%s-%02d-%02d", dgroup->
dname->
Name().Data(),
259 dynamic_cast<TrKalmanNode*
>(kfnode)->SetSensitiveVolume(sv);
262 printf(
"%s -> %7.2f cm; %p\n", buffer, kfnode->GetZ(), kftmpl);
289 double x[3] = {xx[0], xx[1], xx[2]}, BB[3];
292 field->GetFieldValue(x, BB);
294 for(
unsigned iq=0; iq<3; iq++)
304 unsigned counter = 0;
317 counter += location->GetSensitiveVolumeNodeWrapperCount();
336 bool equal_flag =
true;
338 char buffer[16384] =
"fired-node-min";
347 unsigned len = strlen(buffer);
348 snprintf(buffer+len, 16384-len-1,
"%c%s:%d",
349 equal_flag ?
'=' :
',', group->
dname->
Name().Data(), group->ndCounter);
358 unsigned len = strlen(buffer);
359 snprintf(buffer+len, 16384-len-1,
"%c%s",
360 equal_flag ?
'=' :
'+', group->
dname->
Name().Data());
363 unsigned len = strlen(buffer);
375 const char *rk_cfg[] = {
377 "small-step-limit=1.8cm",
378 "small-step-order=4",
379 "cell-width-max=2.0cm",
380 "interpolation=3x3x1"
382 int rk_dim =
sizeof(rk_cfg) /
sizeof(rk_cfg[0]);
383 char **rk_argv = (
char **)malloc(rk_dim *
sizeof(
char*)); assert(rk_argv);
384 for(
int ik=0; ik<rk_dim; ik++)
385 rk_argv[ik] = strdup(rk_cfg[ik]);
439 std::cout <<
"-E- Eic"<< group->
dname->
Name() <<
" hit producer: no map found!" << std::endl;
460 fin.GetObject(group->
dname->
Name() +
"TrackingDigiHitProducer", group->
mDigi);
463 if (group->
mDigi)
break;
469 std::cout <<
"-E- Eic"<< group->
dname->
Name() <<
470 " hit producer: no digi layout found!" << std::endl;
500 Error(
"EicRecoKalmanFit::Init",
"RootManager not instantiated!");
533 double S[5] = {0.0, 0.0, 0.0, 0.0, 0.0};
537 A->invert(_ARBITRARY_);
538 kfm_multiply(x0, A, b);
563 int charge = momentum > 0.0 ? 1 : -1;
565 for(
unsigned iq=0; iq<4; iq++)
570 TVector3
x(line.x [0], line.x [1], line.x [2]), dummy(0.1, 0.1, 0.1);
571 TVector3
n(line.nx[0], line.nx[1], line.nx[2]);
573 FairTrackParP tpp(
x, fabs(momentum) * n, dummy, dummy, charge, dummy, dummy, dummy);
583 static unsigned evCounter;
586 if (!(evCounter%10))
printf(
"-I- EicHtcTask::Exec() -> event %6d\n", evCounter);
591 TTree *outputTree =
new TTree(
_EIC_HTC_TREE_,
"A tree of HTC-reconstructed tracks");
609 A->
Reset(); b->Reset();
611 unsigned firedNodeCounter = 0;
626 if (!group->
_fHits)
continue;
628 unsigned hnum = group->
_fHits->GetEntriesFast();
631 for(
unsigned ih=0; ih<hnum; ih++)
649 if (trknode->
IsFired())
return;
661 if (resolutionByHand) {
662 V.
KFM(0,0) = resolutionByHand * resolutionByHand;
680 if (!firedNodeCounter)
return;
707 printf(
"@FIT: K-fit (head) -> %7.3f, %7.3f, %7.3f, %7.3f\n\n",
725 for(
unsigned xy=0; xy<2; xy++) {
742 if (!group->
_fHits)
continue;
744 unsigned hnum = group->
_fHits->GetEntriesFast();
746 for(
unsigned ih=0; ih<hnum; ih++)
761 htchit->mSmootherProbability =
773 for(
unsigned iq=0; iq<trknode->
GetMdim(); iq++) {
787 if (trknode->
GetRS(iq,iq) < 0.0 || trknode->
GetRM(iq,iq) < 0.0)
goto _next_hit;
789 comp->
mSigmaRS = residualScale * sqrt(trknode->
GetRS(iq,iq));
791 comp->
mSigmaRM = residualScale * sqrt(trknode->
GetRM(iq,iq));
795 for(
unsigned xy=0; xy<2; xy++)
796 htchit->mGlobalCoordXY[xy] =
803 std::pair<unsigned, unsigned>(iz, hit->
GetKfNodeID()));
821 Int_t size = trkRef.GetEntriesFast();
834 if (!group->
_fHits)
continue;
836 unsigned hnum = group->
_fHits->GetEntriesFast();
839 for(
unsigned ih=0; ih<hnum; ih++)
851 if (group->
dname->
NAME().EqualTo(
"TRK") && iz == 1) {
854 for(
unsigned xy=
_X_; xy<=
_Y_; xy++) {
878 double global[3] = {trknode->getX0(0) + trknode->getXs(0),
879 trknode->getX0(1) + trknode->getXs(1),
880 trknode->getZ()}, local[3];
886 node->
mGeoMtx->MasterToLocal(global, local);
889 value = 1E4*(local[1] - hit->fLocalCoord[1]);
937 mHtcBranch->GetTree()->GetCurrentFile()->cd();
953 printf(
"Forced particle type: %s; momentum seed: %8.2f [GeV/c]\n",
961 int ret = strcmp(lh.first, rh.first);
968 std::pair<unsigned, unsigned> &lhh = lh.second, &rhh = rh.second;
970 if (lhh.first == rhh.first)
971 return lhh.second < rhh.second;
973 return lhh.first < rhh.first;
981 kEntry key =
kEntry(detName, std::pair<unsigned, unsigned>(group, node));
983 if (
mHits->find(key) ==
mHits->end())
return 0;
985 return (*
mHits)[key];