10 #include "FairBaseParSet.h"
11 #include "FairField.h"
12 #include "FairGeoNode.h"
13 #include "FairRunAna.h"
19 #include "FairRuntimeDb.h"
21 #include "TGeoManager.h"
22 #include "TGeoMaterial.h"
23 #include "TGeoMatrix.h"
25 #include "TGeoShape.h"
27 #include "TGeoVolume.h"
28 #include "TObjArray.h"
50 : FairTask(name, iVerbose)
72 , MuchMCID2StationMap()
73 , MuchStation2MCIDMap()
78 , fMaterialID2IndexMap() {
79 if (!fInstance) fInstance =
this;
85 FairRunAna* ana = FairRunAna::Instance();
86 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
87 rtdb->getContainer(
"FairBaseParSet");
88 rtdb->getContainer(
"CbmFieldPar");
122 FairRunAna* Run = FairRunAna::Instance();
125 if (fVerbose) cout <<
"KALMAN FILTER : === INIT MAGNETIC FIELD ===" << endl;
128 if (fVerbose &&
fMagneticField) cout <<
"Magnetic field done" << endl;
145 assert(mvdStationPar);
147 if (fVerbose) cout <<
"KALMAN FILTER : === READ MVD MATERIAL ===" << endl;
151 for (Int_t ist = 0; ist <
NStations; ist++) {
154 tube.
ID = 1101 + ist;
163 tube.
rr = tube.
r * tube.
r;
164 tube.
RR = tube.
R * tube.
R;
172 cout <<
" Mvd material ( id, z, dz, r, R, RadL, dz/RadL )= ( "
173 << tube.
ID <<
", " << tube.
z <<
", " << tube.
dz <<
", " << tube.
r
174 <<
", " << tube.
R <<
", " << tube.
RadLength <<
", "
183 if (fVerbose) cout <<
"KALMAN FILTER : === READ STS MATERIAL ===" << endl;
187 for (Int_t ist = 0; ist <
NStations; ist++) {
190 if (!station)
continue;
194 tube.
ID = 1000 + ist;
196 tube.
z = station->
GetZ();
202 tube.
rr = tube.
r * tube.
r;
203 tube.
RR = tube.
R * tube.
R;
211 cout <<
" Sts material ( id, z, dz, r, R, RadL, dz/RadL )= ( " << tube.
ID
212 <<
", " << tube.
z <<
", " << tube.
dz <<
", " << tube.
r <<
", "
270 TGeoNode* topNode = gGeoManager->GetTopNode();
272 TObjArray* nodes = topNode->GetNodes();
281 TGeoMatrix* matrix =
fTarget->GetMatrix();
282 const Double_t* translation = matrix->GetTranslation();
283 target.x = translation[0];
284 target.y = translation[1];
285 target.z = translation[2];
287 TGeoVolume* volume =
fTarget->GetVolume();
289 TGeoShape*
shape = volume->GetShape();
290 if (
shape->TestShapeBit(TGeoShape::kGeoTube)) {
291 target.r =
static_cast<TGeoTube*
>(
shape)->GetRmin();
292 target.R =
static_cast<TGeoTube*
>(
shape)->GetRmax();
293 target.dz = 2. *
static_cast<TGeoTube*
>(
shape)->GetDz();
295 LOG(fatal) <<
"Only a target of a tube shape is supported";
298 TGeoMaterial* material = volume->GetMaterial();
299 Double_t radlength = material->GetRadLen();
300 target.RadLength = radlength;
303 target.rr = target.r * target.r;
304 target.RR = target.R * target.R;
305 target.ZThickness = target.dz;
306 target.ZReference = target.z;
309 LOG(info) <<
"Target info: " << target.KFInfo();
311 LOG(fatal) <<
"Could not find the target.";
316 for (Int_t iNode = 0; iNode < nodes->GetEntriesFast(); iNode++) {
317 TGeoNode* node =
static_cast<TGeoNode*
>(nodes->At(iNode));
318 TString nodeName = node->GetName();
319 if (nodeName.Contains(
"target")) {
323 TObjArray* subnodes = node->GetNodes();
339 TString name = node->getName();
340 TString Sname = node->getShapePointer()->GetName();
341 FairGeoVector nodeV = node->getLabTransform()->getTranslation();
342 FairGeoVector centerV = node->getCenterPosition().getTranslation();
343 TArrayD* P = node->getParameters();
344 Int_t NP = node->getShapePointer()->getNumParam();
345 FairGeoMedium* material = node->getMedium();
346 material->calcRadiationLength();
348 tube.
ID = node->getMCid();
349 tube.
RadLength = material->getRadiationLength();
353 TString Mname = material->GetName();
354 if (Mname ==
"MUCHWolfram") {
356 }
else if (Mname ==
"MUCHiron") {
358 }
else if (Mname ==
"carbon") {
362 tube.
x = nodeV.X() + centerV.X();
363 tube.
y = nodeV.Y() + centerV.Y();
364 tube.
z = nodeV.Z() + centerV.Z();
373 if (Sname ==
"TUBS" || Sname ==
"TUBE") {
376 tube.
dz = 2. * P->At(2);
377 }
else if (Sname ==
"TRAP") {
380 tube.
dz = 2. * P->At(0);
381 }
else if (Sname ==
"SPHE") {
384 tube.
z += 0.5 * (P->At(0) + P->At(1));
385 tube.
dz = (P->At(1) - P->At(0));
386 }
else if (Sname ==
"PCON") {
387 Int_t Nz = (NP - 3) / 3;
388 double Z = -100000, R = -100000, z = 100000, r = 100000;
389 for (Int_t
i = 0;
i < Nz;
i++) {
390 double z1 = P->At(3 +
i * 3 + 0);
391 double r1 = P->At(3 +
i * 3 + 1);
392 double R1 = P->At(3 +
i * 3 + 2);
401 tube.
z += (z + Z) / 2.;
403 }
else if (Sname ==
"PGON") {
404 Int_t Nz = (NP - 4) / 3;
405 double Z = -100000, R = -100000, z = 100000, r = 100000;
406 for (Int_t
i = 0;
i < Nz;
i++) {
407 double z1 = P->At(4 +
i * 3 + 0);
408 double r1 = P->At(4 +
i * 3 + 1);
409 double R1 = P->At(4 +
i * 3 + 2);
417 tube.
z += (z + Z) / 2.;
419 }
else if (Sname ==
"BOX ") {
420 double dx = 2 * P->At(0);
421 double dy = 2 * P->At(1);
422 double dz = 2 * P->At(2);
424 tube.
R = TMath::Sqrt(dx * dx + dy * dy);
427 cout <<
" -E- unknown shape : " << Sname << endl;
428 cout <<
" -E- It does not make sense to go on" << endl;
429 cout <<
" -E- Stop execution here" << endl;
430 Fatal(
"CbmKF::ReadTube",
"Unknown Shape");
432 tube.
rr = tube.
r * tube.
r;
433 tube.
RR = tube.
R * tube.
R;
444 TString name = node->getName();
445 TString Sname = node->getShapePointer()->GetName();
447 FairGeoTransform trans(*node->getLabTransform());
448 FairGeoNode* nxt = node;
449 while ((nxt = nxt->getMotherNode())) {
450 FairGeoTransform* tm = nxt->getLabTransform();
452 trans.transFrom(*tm);
458 FairGeoVector nodeV = trans.getTranslation();
459 FairGeoVector centerV = nodeV + node->getCenterPosition().getTranslation();
461 TArrayD* P = node->getParameters();
462 Int_t NP = node->getShapePointer()->getNumParam();
463 FairGeoMedium* material = node->getMedium();
464 material->calcRadiationLength();
466 Int_t
ID = node->getMCid();
467 Double_t RadLength = material->getRadiationLength();
469 Double_t x0 = centerV.X();
470 Double_t y0 = centerV.Y();
471 Double_t z0 = centerV.Z();
475 if (Sname ==
"TUBS" || Sname ==
"TUBE") {
477 ID, x0, y0, z0, 2. * P->At(2), P->At(0), P->At(1), RadLength);
480 }
else if (Sname ==
"SPHE") {
484 z0 + 0.5 * (P->At(0) + P->At(1)),
485 (P->At(1) - P->At(0)),
491 }
else if (Sname ==
"PCON") {
492 Int_t Nz = (NP - 3) / 3;
493 double Z = -100000, R = -100000, z = 100000, r = 100000;
494 for (Int_t
i = 0;
i < Nz;
i++) {
495 double z1 = P->At(3 +
i * 3 + 0);
496 double r1 = P->At(3 +
i * 3 + 1);
497 double R1 = P->At(3 +
i * 3 + 2);
503 CbmKFTube tube(
ID, x0, y0, z0 + 0.5 * (z + Z), (Z - z), r, R, RadLength);
506 }
else if (Sname ==
"PGON") {
507 Int_t Nz = (NP - 4) / 3;
508 double Z = -100000, R = -100000, z = 100000, r = 100000;
509 for (Int_t
i = 0;
i < Nz;
i++) {
510 double z1 = P->At(4 +
i * 3 + 0);
511 double r1 = P->At(4 +
i * 3 + 1);
512 double R1 = P->At(4 +
i * 3 + 2);
518 CbmKFTube tube(
ID, x0, y0, z0 + 0.5 * (z + Z), (Z - z), r, R, RadLength);
521 }
else if (Sname ==
"BOX ") {
523 ID, x0, y0, z0, 2 * P->At(0), 2 * P->At(1), 2 * P->At(2), RadLength);
526 }
else if (Sname ==
"TRAP") {
527 int np = node->getNumPoints();
528 FairGeoVector vMin = *node->getPoint(0), vMax = vMin;
529 for (
int i = 0;
i < np;
i++) {
530 FairGeoVector*
v = node->getPoint(
i);
531 for (
int j = 0; j < 3; j++) {
532 if (vMin(j) > (*v)(j)) (&vMin.X())[j] = (*
v)(j);
533 if (vMax(j) < (*v)(j)) (&vMax.X())[j] = (*
v)(j);
536 FairGeoVector v0 = (vMin + vMax);
538 FairGeoVector dv = vMax - vMin;
541 ID, x0 + v0(0), y0 + v0(1), z0 + v0(2), dv(0), dv(1), dv(2), RadLength);
545 cout <<
" -E- unknown shape : " << Sname << endl;
546 cout <<
" -E- It does not make sense to go on" << endl;
547 cout <<
" -E- Stop execution here" << endl;
548 Fatal(
"CbmKF::ReadPassive",
"Unknown Shape");
556 if (
fabs(T[5] - z_out) < 1.e-5)
return 0;
563 if (z_out < 300. && 300 <= T[5])
566 if (T[5] < 300. && 300. < z_out) { zz = 300.; }
568 while (!err && repeat) {
569 const Double_t max_step = 5.;
571 if (
fabs(T[5] - zz) > max_step)
572 zzz = T[5] + ((zz > T[5]) ? max_step : -max_step);
626 Bool_t downstream = (ilst > ifst);
628 Int_t iend = downstream ? ilst + 1 : ilst - 1;
629 for (Int_t
i = ifst;
i != iend; downstream ? ++
i : --
i) {
630 err = err ||
vMaterial[
i]->Pass(track, downstream, QP0);
639 Bool_t downstream = (ilst > ifst);
641 Int_t istart = downstream ? ifst + 1 : ifst - 1;
642 for (Int_t
i = istart;
i != ilst; downstream ? ++
i : --
i) {
643 err = err ||
vMaterial[
i]->Pass(track, downstream, QP0);