36 #include "FairEventHeader.h"
37 #include "FairRunAna.h"
46 #include "TGeoBoolNode.h"
47 #include "TGeoCompositeShape.h"
48 #include "TGeoManager.h"
54 #include "TGeoManager.h"
79 #include "KFTopoPerformance.h"
104 , vMCPoints_in_Time_Slice()
131 , fTimeSlice(nullptr)
132 , fEventList(nullptr)
141 , listStsDigiMatch(0)
145 , listStsClusterMatch(0)
150 , listMvdDigiMatches(0)
151 , listMvdHitMatches(0)
155 , fMuchPoints(nullptr)
156 , listMuchHitMatches(nullptr)
157 , fDigiMatchesMuch(nullptr)
158 , fClustersMuch(nullptr)
159 , fMuchPixelHits(nullptr)
160 , fDigisMuch(nullptr)
161 , fTrdDigiPar(nullptr)
162 , fTrdModuleInfo(nullptr)
163 , fTrdPoints(nullptr)
164 , listTrdHits(nullptr)
165 , fTrdHitMatches(nullptr)
166 , fTofPoints(nullptr)
167 , fTofHitDigiMatches(nullptr)
181 , fFindParticlesMode()
182 , fStsMatBudgetFileName(
"")
183 , fMvdMatBudgetFileName(
"")
184 , fMuchMatBudgetFileName(
"")
185 , fTrdMatBudgetFileName(
"")
186 , fTofMatBudgetFileName(
"")
187 , fExtrapolateToTheEndOfSTS(false)
189 , fTopoPerformance(nullptr)
190 , fEventEfficiency() {
198 TString fSTAPDataDir_,
199 int findParticleMode_)
200 : FairTask(name, iVerbose)
213 , vMCPoints_in_Time_Slice()
221 fPerformance(_fPerformance)
222 , fSTAPDataMode(fSTAPDataMode_)
223 , fSTAPDataDir(fSTAPDataDir_)
241 , fTimeSlice(nullptr)
242 , fEventList(nullptr)
251 , listStsDigiMatch(0)
255 , listStsClusterMatch(0)
260 , listMvdDigiMatches(0)
261 , listMvdHitMatches(0)
265 , fMuchPoints(nullptr)
266 , listMuchHitMatches(nullptr)
267 , fDigiMatchesMuch(nullptr)
268 , fClustersMuch(nullptr)
269 , fMuchPixelHits(nullptr)
270 , fDigisMuch(nullptr)
271 , fTrdDigiPar(nullptr)
272 , fTrdModuleInfo(nullptr)
273 , fTrdPoints(nullptr)
274 , listTrdHits(nullptr)
275 , fTrdHitMatches(nullptr)
276 , fTofPoints(nullptr)
277 , fTofHitDigiMatches(nullptr)
291 , fFindParticlesMode(findParticleMode_)
292 , fStsMatBudgetFileName(
"")
293 , fMvdMatBudgetFileName(
"")
294 , fMuchMatBudgetFileName(
"")
295 , fTrdMatBudgetFileName(
"")
296 , fTofMatBudgetFileName(
"")
297 , fExtrapolateToTheEndOfSTS(false)
299 , fTopoPerformance(nullptr)
300 , fEventEfficiency() {
310 FairRunAna* ana = FairRunAna::Instance();
311 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
324 rtdb->getContainer(
"CbmStsParSetSensorCond"));
337 char y[20] =
" [0;33;44m";
338 char Y[20] =
" [1;33;44m";
339 char W[20] =
" [1;37;44m";
340 char o[20] =
" [0m\n";
341 Y[0] =
y[0] = W[0] = o[0] = 0x1B;
343 cout << endl << endl;
348 <<
" ===////====================================================== "
353 cout <<
" " << W <<
" = " << Y <<
"L1 on-line finder"
358 cout <<
" " << W <<
" = " << W <<
"Cellular Automaton 3.1 Vector" <<
y
359 <<
" with " << W <<
"KF Quadro" <<
y <<
" technology" << W <<
" = "
364 cout <<
" " << W <<
" = " <<
y <<
"Designed for CBM collaboration" << W
366 cout <<
" " << W <<
" = " <<
y <<
"All rights reserved" << W
372 <<
" ========================================================////= "
377 cout << endl << endl;
380 FairRootManager* fManger = FairRootManager::Instance();
382 FairRunAna* Run = FairRunAna::Instance();
386 L1_DYNAMIC_CAST<CbmStsFindTracks*>(Run->GetTask(
"STSFindTracks"));
429 LOG(info) << GetName() <<
": running in time-slice mode.";
433 LOG(fatal) << GetName() <<
": No time slice branch in tree!";
438 LOG(info) << GetName() <<
": running in event mode.";
442 L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"StsCluster"));
444 L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"StsHitMatch"));
446 L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"StsClusterMatch"));
448 listStsHits = L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"StsHit"));
463 fMuchPixelHits = (TClonesArray*) fManger->GetObject(
"MuchPixelHit");
474 listTrdHits = L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"TrdHit"));
485 fTofHits = (TClonesArray*) fManger->GetObject(
"TofHit");
491 if (NULL == mcManager) LOG(fatal) << GetName() <<
": No CbmMCDataManager!";
496 if (NULL ==
fStsPoints) LOG(fatal) << GetName() <<
": No StsPoint data!";
497 if (NULL ==
fMCTracks) LOG(fatal) << GetName() <<
": No MCTrack data!";
499 listStsPts = L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"StsPoint"));
504 LOG(fatal) << GetName() <<
": No MCEventList data!";
512 L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"MvdPoint"));
514 L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"MvdDigiMatch"));
516 L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"MvdHitMatch"));
520 <<
"No listMvdHitMatches provided, performance is not done correctly";
529 fTrdHitMatches = (TClonesArray*) fManger->GetObject(
"TrdHitMatch");
539 fDigisMuch = (TClonesArray*) fManger->GetObject(
"MuchDigi");
541 fClustersMuch = (TClonesArray*) fManger->GetObject(
"MuchCluster");
544 L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"MuchPixelHitMatch"));
554 static_cast<TClonesArray*
>(fManger->GetObject(
"TofCalDigiMatch"));
571 listMvdHits = L1_DYNAMIC_CAST<TClonesArray*>(fManger->GetObject(
"MvdHit"));
588 for (
int i = 0;
i < 3;
i++) {
589 Double_t point[3] = {0, 0, 2.5 *
i};
590 Double_t B[3] = {0, 0, 0};
593 geo.push_back(2.5 *
i);
604 TObjArray* stations = (TObjArray*) file->Get(
"stations");
605 fGeoScheme->
Init(stations, 0);
606 for (
int iStation = 0; iStation < fGeoScheme->
GetNStations(); iStation++) {
615 Int_t layerCounter = 0;
616 TObjArray* topNodes = gGeoManager->GetTopNode()->GetNodes();
617 for (Int_t iTopNode = 0; iTopNode < topNodes->GetEntriesFast();
619 TGeoNode* topNode =
static_cast<TGeoNode*
>(topNodes->At(iTopNode));
620 if (TString(topNode->GetName()).Contains(
"trd")) {
621 TObjArray* layers = topNode->GetNodes();
622 for (Int_t iLayer = 0; iLayer < layers->GetEntriesFast(); iLayer++) {
623 TGeoNode* layer =
static_cast<TGeoNode*
>(layers->At(iLayer));
624 if (TString(layer->GetName()).Contains(
"layer")) { layerCounter++; }
635 float z_min = 100000;
639 float r_min = 100000;
645 for (Int_t icell = 0; icell < nrOfCells; ++icell) {
650 Double_t
x = fCellInfo->
GetX();
651 Double_t
y = fCellInfo->
GetY();
652 Double_t z = fCellInfo->
GetZ();
656 if (z < z_min) z_min = z;
657 if (z > z_max) z_max = z;
659 if (
x < r_min) r_min =
x;
660 if (
x > r_max) r_max =
x;
662 if (
y < r_min) r_min =
y;
663 if (
y > r_max) r_max =
y;
668 z_average = z_average / nrOfCells;
672 if (!stsSetup->
IsInit()) { stsSetup->
Init(
nullptr); }
748 for (Int_t ist = 0; ist <
NStation; ist++) {
751 double Xmax = 0, Ymax = 0;
767 fscal f_phi = 0, f_sigma = mvdStationPar->
GetXRes(ist) / 10000,
768 b_phi = 3.14159265358 / 2.,
769 b_sigma = mvdStationPar->
GetYRes(ist) / 10000;
770 geo.push_back(f_phi);
771 geo.push_back(f_sigma);
772 geo.push_back(b_phi);
773 geo.push_back(b_sigma);
783 geo.push_back(station->
GetZ());
791 double Pi = 3.14159265358;
793 fscal f_phi, f_sigma, b_phi, b_sigma;
803 geo.push_back(f_phi);
804 geo.push_back(f_sigma);
805 geo.push_back(b_phi);
806 geo.push_back(b_sigma);
833 geo.push_back(layer->
GetDz());
838 fscal f_phi = 0, f_sigma = 0.1, b_phi = 3.14159265358 / 2., b_sigma = 0.1;
839 geo.push_back(f_phi);
840 geo.push_back(f_sigma);
841 geo.push_back(b_phi);
842 geo.push_back(b_sigma);
868 if (num == 0 || num == 2 || num == 4) geo.push_back(3);
869 if (num == 1 || num == 3) geo.push_back(6);
870 geo.push_back(module->
GetZ());
872 geo.push_back(2 * module->
GetSizeZ());
874 geo.push_back(2 * module->
GetSizeX());
877 fscal f_phi = 0, f_sigma = 1 / 10000, b_phi = 3.14159265358 / 2.,
879 geo.push_back(f_phi);
880 geo.push_back(f_sigma);
881 geo.push_back(b_phi);
882 geo.push_back(b_sigma);
892 geo.push_back(z_average);
893 geo.push_back(z_max - z_min);
895 geo.push_back(r_max);
898 fscal f_phi = 0, f_sigma = 1 / 10000, b_phi = 3.14159265358 / 2.,
900 geo.push_back(f_phi);
901 geo.push_back(f_sigma);
902 geo.push_back(b_phi);
903 geo.push_back(b_sigma);
910 if (dx > Xmax / N / 2) dx = Xmax / N / 4.;
911 if (dy > Ymax / N / 2) dy = Ymax / N / 4.;
913 for (
int i = 0;
i < 3;
i++)
914 for (
int k = 0; k < N; k++)
917 TVectorD b0(N), b1(N), b2(N);
918 for (
int i = 0;
i < N;
i++) {
919 for (
int j = 0; j < N; j++)
921 b0(
i) = b1(
i) = b2(
i) = 0.;
925 for (
double x = -Xmax;
x <= Xmax;
x += dx)
926 for (
double y = -Ymax;
y <= Ymax;
y += dy) {
927 double r =
sqrt(
fabs(
x *
x / Xmax / Xmax +
y / Ymax *
y / Ymax));
928 if (r > 1.)
continue;
929 Double_t w = 1. / (r * r + 1);
930 Double_t p[3] = {
x,
y, z};
931 Double_t B[3] = {0., 0., 0.};
935 for (
int i = 1;
i <= M;
i++) {
936 int k = (
i - 1) * (
i) / 2;
937 int l =
i * (
i + 1) / 2;
938 for (
int j = 0; j <
i; j++)
939 m(l + j) =
x *
m(k + j);
940 m(l +
i) =
y *
m(k +
i - 1);
944 for (
int i = 0;
i < N;
i++) {
945 for (
int j = 0; j < N; j++)
946 A(
i, j) += w *
m(
i) *
m(j);
947 b0(
i) += w * B[0] *
m(
i);
948 b1(
i) += w * B[1] *
m(
i);
949 b2(
i) += w * B[2] *
m(
i);
954 TVectorD c0 = A * b0, c1 = A * b1, c2 = A * b2;
955 for (
int i = 0;
i < N;
i++) {
962 for (
int k = 0; k < 3; k++) {
963 for (
int j = 0; j < N; j++) {
964 geo.push_back(C[k][j]);
985 int ind2, ind = geo.size();
988 LOG(error) <<
"-E- CbmL1: Read geometry from file "
999 TString stationName =
"Radiation Thickness [%], Station";
1002 TFile* oldfile = gFile;
1006 TString stationNameMvd = stationName;
1007 stationNameMvd += j;
1008 TProfile2D* hStaRadLen = (TProfile2D*) rlFile->Get(stationNameMvd);
1011 << stationNameMvd <<
"\n";
1014 const int NBins = hStaRadLen->GetNbinsX();
1016 hStaRadLen->GetXaxis()->GetXmax();
1020 for (
int iB = 0; iB < NBins; iB++) {
1022 for (
int iB2 = 0; iB2 < NBins; iB2++) {
1024 0.01 * hStaRadLen->GetBinContent(iB, iB2);
1027 <
algo->vStations[iSta].materialInfo.RadThick[0])
1028 if (iB2 > 0 && iB2 < NBins - 1)
1030 TMath::Min(0.01 * hStaRadLen->GetBinContent(iB, iB2 - 1),
1031 0.01 * hStaRadLen->GetBinContent(iB, iB2 + 1));
1043 LOG(warn) <<
"No MVD material budget file is found. Homogenious budget "
1046 cout << iSta << endl;
1052 algo->vStations[iSta].materialInfo.RadThick[0];
1057 TFile* oldfile = gFile;
1063 TString stationNameSts = stationName;
1064 stationNameSts += j;
1065 TProfile2D* hStaRadLen = (TProfile2D*) rlFile->Get(stationNameSts);
1068 << stationNameSts <<
"\n";
1071 const int NBins = hStaRadLen->GetNbinsX();
1073 hStaRadLen->GetXaxis()->GetXmax();
1077 for (
int iB = 0; iB < NBins; iB++) {
1079 for (
int iB2 = 0; iB2 < NBins; iB2++) {
1081 0.01 * hStaRadLen->GetBinContent(iB, iB2);
1083 <
algo->vStations[iSta].materialInfo.RadThick[0])
1085 algo->vStations[iSta].materialInfo.RadThick[0];
1094 LOG(warn) <<
"No STS material budget file is found. Homogenious budget "
1103 algo->vStations[iSta].materialInfo.RadThick[0];
1109 TFile* oldfile = gFile;
1116 TString stationNameSts = stationName;
1117 stationNameSts += j;
1118 TProfile2D* hStaRadLen = (TProfile2D*) rlFile->Get(stationNameSts);
1121 << stationNameSts <<
"\n";
1126 const int NBins = hStaRadLen->GetNbinsX();
1128 hStaRadLen->GetXaxis()->GetXmax();
1132 for (
int iB = 0; iB < NBins; iB++) {
1135 for (
int iB2 = 0; iB2 < NBins; iB2++) {
1137 0.01 * hStaRadLen->GetBinContent(iB, iB2);
1141 if (iB2 > 0 && iB2 < NBins - 1)
1143 TMath::Min(0.01 * hStaRadLen->GetBinContent(iB, iB2 - 1),
1144 0.01 * hStaRadLen->GetBinContent(iB, iB2 + 1));
1159 LOG(warn) <<
"No Much material budget file is found. Homogenious budget "
1168 algo->vStations[iSta].materialInfo.RadThick[0];
1174 TFile* oldfile = gFile;
1180 TString stationNameSts = stationName;
1181 stationNameSts += j;
1182 TProfile2D* hStaRadLen = (TProfile2D*) rlFile->Get(stationNameSts);
1185 << stationNameSts <<
"\n";
1190 const int NBins = hStaRadLen->GetNbinsX();
1192 hStaRadLen->GetXaxis()->GetXmax();
1196 for (
int iB = 0; iB < NBins; iB++) {
1199 for (
int iB2 = 0; iB2 < NBins; iB2++) {
1201 0.01 * hStaRadLen->GetBinContent(iB, iB2);
1205 if (iB2 > 0 && iB2 < NBins - 1)
1207 TMath::Min(0.01 * hStaRadLen->GetBinContent(iB, iB2 - 1),
1208 0.01 * hStaRadLen->GetBinContent(iB, iB2 + 1));
1223 LOG(warn) <<
"No TRD material budget file is found. Homogenious budget "
1232 algo->vStations[iSta].materialInfo.RadThick[0];
1238 TFile* oldfile = gFile;
1247 TString stationNameSts = stationName;
1248 stationNameSts += j;
1249 TProfile2D* hStaRadLen = (TProfile2D*) rlFile->Get(stationNameSts);
1252 << stationNameSts <<
"\n";
1257 const int NBins = hStaRadLen->GetNbinsX();
1259 hStaRadLen->GetXaxis()->GetXmax();
1263 for (
int iB = 0; iB < NBins; iB++) {
1265 float hole = 0.0015;
1266 for (
int iB2 = 0; iB2 < NBins; iB2++) {
1268 0.01 * hStaRadLen->GetBinContent(iB, iB2);
1272 if (iB2 > 0 && iB2 < NBins - 1)
1274 TMath::Min(0.01 * hStaRadLen->GetBinContent(iB, iB2 - 1),
1275 0.01 * hStaRadLen->GetBinContent(iB, iB2 + 1));
1290 LOG(warn) <<
"No TOF material budget file is found. Homogenious budget "
1301 algo->vStations[iSta].materialInfo.RadThick[0];
1311 static int nevent = 0;
1317 for (
int iE = 0; iE < nofEvents; iE++) {
1321 vFileEvent.insert(DFSET::value_type(fileId, eventId));
1325 Int_t iFile = FairRunAna::Instance()->GetEventHeader()->GetInputFileId();
1326 Int_t iEvent = FairRunAna::Instance()->GetEventHeader()->GetMCEntryNumber();
1327 vFileEvent.insert(DFSET::value_type(iFile, iEvent));
1332 cout << endl <<
"CbmL1::Exec event " << ++nevent <<
" ..." << endl << endl;
1334 omp_set_num_threads(1);
1356 vector<int> sF, sB, zP;
1360 for (
unsigned int iH = 0; iH < (*
algo->
vStsHits).size(); ++iH) {
1362 #ifdef USE_EVENT_NUMBER
1365 if (
vStsHits[iH].mcPointIds.size() == 0)
continue;
1369 #ifdef USE_EVENT_NUMBER
1374 if (std::find(sF.begin(), sF.end(),
h.f)
1377 const_cast<vector<unsigned char>*
>(
algo->
vSFlag)
1386 if (std::find(sB.begin(), sB.end(),
h.b) != sB.end()) {
1395 if (std::find(zP.begin(), zP.end(),
h.iz)
1398 const_cast<std::vector<float>*
>(
algo->
vStsZPos)->push_back(0);
1402 const fscal idet = 1
1403 / (sta.xInfo.sin_phi * sta.yInfo.sin_phi
1404 - sta.xInfo.cos_phi * sta.yInfo.cos_phi)[0];
1408 idet * (+sta.yInfo.sin_phi[0] * mcp.
x - sta.xInfo.cos_phi[0] * mcp.
y)
1409 + random.Gaus(0,
sqrt(sta.frontInfo.sigma2)[0]);
1411 idet * (-sta.yInfo.cos_phi[0] * mcp.
x + sta.xInfo.sin_phi[0] * mcp.
y)
1412 + random.Gaus(0,
sqrt(sta.backInfo.sigma2)[0]);
1415 idet * (+sta.yInfo.sin_phi[0] * mcp.
x - sta.xInfo.cos_phi[0] * mcp.
y)
1416 + random.Uniform(-
sqrt(sta.frontInfo.sigma2)[0] * 3.5,
1417 sqrt(sta.frontInfo.sigma2)[0] * 3.5);
1419 idet * (-sta.yInfo.cos_phi[0] * mcp.
x + sta.xInfo.sin_phi[0] * mcp.
y)
1420 + random.Uniform(-
sqrt(sta.backInfo.sigma2)[0] * 3.5,
1421 sqrt(sta.backInfo.sigma2)[0] * 3.5);
1432 for (vector<CbmL1MCTrack>::iterator it =
vMCTracks.begin();
1453 for (
unsigned int iH = 0; iH < (*
algo->
vStsHits).size(); ++iH) {
1454 #ifdef USE_EVENT_NUMBER
1458 if (
vStsHits[iH].mcPointIds.size() == 0)
continue;
1459 #ifdef USE_EVENT_NUMBER
1465 for (vector<CbmL1MCTrack>::iterator
i =
vMCTracks.begin();
1471 if (!(MC.
ID >= 0))
continue;
1473 if (MC.
StsHits.size() < 4)
continue;
1476 for (
unsigned int iH = 0; iH < MC.
StsHits.size(); iH++) {
1477 const int hitI = MC.
StsHits[iH];
1488 if (fVerbose > 1) cout <<
"L1 Track finder..." << endl;
1493 if (fVerbose > 1) cout <<
"L1 Track finder ok" << endl;
1501 if ((
fabs(fB0.
x[0]) < 0.0000001) && (
fabs(fB0.
y[0]) < 0.0000001)
1502 && (
fabs(fB0.
z[0]) < 0.0000001))
1511 if ((
fabs(fB0.
x[0]) < 0.0000001) && (
fabs(fB0.
y[0]) < 0.0000001)
1512 && (
fabs(fB0.
z[0]) < 0.0000001))
1520 if (fVerbose > 1) cout <<
"L1 Track fitter ok" << endl;
1526 for (vector<L1Track>::iterator it =
algo->
vTracks.begin();
1531 for (
int i = 0;
i < 7;
i++)
1532 t.
T[
i] = it->TFirst[
i];
1533 for (
int i = 0;
i < 21;
i++)
1534 t.
C[
i] = it->CFirst[
i];
1535 for (
int i = 0;
i < 7;
i++)
1537 for (
int i = 0;
i < 21;
i++)
1539 for (
int k = 0; k < 7; k++)
1540 t.
Tpv[k] = it->Tpv[k];
1541 for (
int k = 0; k < 21; k++)
1542 t.
Cpv[k] = it->Cpv[k];
1549 for (
int i = 0;
i < it->NHits;
i++) {
1550 int start_hit1 = start_hit;
1565 for (vector<int>::iterator ih = (prtra->
StsHits).begin();
1568 if ((*ih) > int(
vStsHits.size() - 1)) {
1572 int nMCPoints =
vStsHits[*ih].mcPointIds.size();
1573 for (
int iP = 0; iP < nMCPoints; iP++) {
1574 int iMC =
vStsHits[*ih].mcPointIds[iP];
1582 if (indd == 1)
continue;
1588 if (fVerbose > 1) cout <<
"Performance..." << endl;
1601 if (fVerbose > 1) cout <<
"End of L1" << endl;
1603 static bool ask = 0;
1606 std::cout << std::endl <<
"L1 run (any/r/q) > ";
1608 std::cin.get(symbol);
1609 if (symbol ==
'r') ask =
false;
1610 if ((symbol ==
'e') || (symbol ==
'q')) exit(0);
1611 }
while (symbol !=
'\n');
1617 TDirectory* curr = gDirectory;
1618 TFile* currentFile = gFile;
1621 TFile* outfile =
new TFile(
"L1_histo.root",
"RECREATE");
1627 gFile = currentFile;
1633 if (!obj->IsFolder())
1636 TDirectory* cur = gDirectory;
1637 TDirectory* sub = cur->mkdir(obj->GetName());
1639 TList* listSub = (L1_DYNAMIC_CAST<TDirectory*>(obj))->GetList();
1641 while (TObject* obj1 = it())
1653 for (vector<CbmL1MCTrack>::iterator
i =
vMCTracks.begin();
1659 if (!(MC.
ID >= 0))
continue;
1661 if (MC.
StsHits.size() < 4)
continue;
1668 for (
unsigned int iH = 0; iH < MC.
StsHits.size(); iH++) {
1669 const int hitI = MC.
StsHits[iH];
1673 if (iStation >= 0) hitIndices[iStation] = hitI;
1678 const int hitI = hitIndices[iH];
1679 if (hitI < 0)
continue;
1686 if (algoTr.
NHits < 3)
continue;
1689 const int hitI = hitIndices[iH];
1690 if (hitI < 0)
continue;
1714 ofstream fgeo(fgeo_name);
1715 fgeo.setf(ios::scientific, ios::floatfield);
1717 int size = geo_.size();
1718 for (
int i = 0;
i < size;
i++) {
1719 fgeo << geo_[
i] << endl;
1722 cout <<
"-I- CbmL1: Geometry data has been written in " << fgeo_name << endl;
1729 static int vNEvent = 1;
1737 fadata.open(fadata_name, fstream::out);
1739 fadata.open(fadata_name, fstream::out | fstream::app);
1743 fadata << vNEvent << endl;
1746 fadata << n << endl;
1747 for (
int i = 0;
i < n;
i++) {
1751 cout <<
"vStsStrips[" << n <<
"]"
1752 <<
" have been written." << endl;
1755 fadata << n << endl;
1756 for (
int i = 0;
i < n;
i++) {
1760 cout <<
"vStsStripsB[" << n <<
"]"
1761 <<
" have been written." << endl;
1764 fadata << n << endl;
1765 for (
int i = 0;
i < n;
i++) {
1769 cout <<
"vStsZPos[" << n <<
"]"
1770 <<
" have been written." << endl;
1773 fadata << n << endl;
1774 unsigned char element;
1775 for (
int i = 0;
i < n;
i++) {
1777 fadata << static_cast<int>(element) << endl;
1780 cout <<
"vSFlag[" << n <<
"]"
1781 <<
" have been written." << endl;
1784 fadata << n << endl;
1785 for (
int i = 0;
i < n;
i++) {
1787 fadata << static_cast<int>(element) << endl;
1790 cout <<
"vSFlagB[" << n <<
"]"
1791 <<
" have been written." << endl;
1794 fadata << n << endl;
1795 for (
int i = 0;
i < n;
i++) {
1798 #ifdef USE_EVENT_NUMBER
1799 fadata << static_cast<unsigned short int>((*
algo->
vStsHits)[
i].n) <<
" ";
1807 cout <<
"vStsHits[" << n <<
"]"
1808 <<
" have been written." << endl;
1811 for (
int i = 0;
i < n;
i++) {
1815 fadata << 0 << endl;
1817 for (
int i = 0;
i < n;
i++) {
1821 fadata << 0 << endl;
1827 cout <<
"-I- CbmL1: CATrackFinder data for event number " << vNEvent
1828 <<
" have been written in file " << fadata_name << endl;
1836 fpdata << setprecision(8);
1838 static int vNEvent = 1;
1846 fpdata.open(fpdata_name, fstream::out);
1848 fpdata.open(fpdata_name, fstream::out | fstream::app);
1850 fpdata <<
"Event: ";
1851 fpdata << vNEvent << endl;
1854 fpdata << n << endl;
1855 for (
int i = 0;
i < n;
i++) {
1879 const int nhits =
vMCPoints[
i].hitIds.size();
1880 fpdata << nhits << endl <<
" ";
1881 for (
int k = 0; k < nhits; k++) {
1887 cout <<
"vMCPoints[" << n <<
"]"
1888 <<
" have been written." << endl;
1892 fpdata << n << endl;
1893 for (
int i = 0;
i < n;
i++) {
1910 fpdata <<
" " << nhits << endl <<
" ";
1911 for (
int k = 0; k < nhits; k++) {
1916 const int nPoints =
vMCTracks[
i].Points.size();
1917 fpdata << nPoints << endl <<
" ";
1918 for (
int k = 0; k < nPoints; k++) {
1923 fpdata <<
vMCTracks[
i].nMCContStations <<
" ";
1924 fpdata <<
vMCTracks[
i].nHitContStations <<
" ";
1931 cout <<
"vMCTracks[" << n <<
"]"
1932 <<
" have been written." << endl;
1936 fpdata << n << endl;
1937 for (
int i = 0;
i < n;
i++) {
1941 cout <<
"vHitMCRef[" << n <<
"]"
1942 <<
" have been written." << endl;
1946 fpdata << n << endl;
1947 for (
int i = 0;
i < n;
i++) {
1955 cout <<
"vHitStore[" << n <<
"]"
1956 <<
" have been written." << endl;
1960 fpdata << n << endl;
1961 for (
int i = 0;
i < n;
i++) {
1965 const int nPoints =
vStsHits[
i].mcPointIds.size();
1966 fpdata << nPoints << endl <<
" ";
1967 for (
int k = 0; k < nPoints; k++) {
1968 fpdata <<
vStsHits[
i].mcPointIds[k] <<
" ";
1973 cout <<
"vStsHits[" << n <<
"]"
1974 <<
" have been written." << endl;
1978 cout <<
"-I- CbmL1: Data for performance of event number " << vNEvent
1979 <<
" have been written in file " << fpdata_name << endl;
1987 if (isspace(c) == 0) {
1999 ifstream fgeo(fgeo_name);
2001 cout <<
"-I- CbmL1: Read geometry from file " << fgeo_name << endl;
2003 for (
i = 0; !fgeo.eof();
i++) {
2006 cout <<
" geo_[" <<
i <<
"]=" << geo_[
i] <<
" tmp= " << tmp << endl;
2014 static int nEvent = 1;
2015 static fstream fadata;
2019 if (nEvent == 1) fadata.open(fadata_name, fstream::in);
2022 const_cast<std::vector<L1StsHit>*
>(
algo->
vStsHits)->clear();
2028 const_cast<std::vector<float>*
>(
algo->
vStsZPos)->clear();
2031 const_cast<vector<unsigned char>*
>(
algo->
vSFlagB)->clear();
2034 char s[] =
"Event: ";
2039 cout <<
"-E- CbmL1: Can't read event number " << nEvent <<
" from file "
2040 << fadata_name << endl;
2045 cout <<
" n " << n << endl;
2046 for (
int i = 0;
i < n;
i++) {
2049 const_cast<std::vector<L1Strip>*
>(
algo->
vStsStrips)->push_back(element);
2052 cout <<
"vStsStrips[" << n <<
"]"
2053 <<
" have been read." << endl;
2056 for (
int i = 0;
i < n;
i++) {
2059 const_cast<std::vector<L1Strip>*
>(
algo->
vStsStripsB)->push_back(element);
2062 cout <<
"vStsStripsB[" << n <<
"]"
2063 <<
" have been read." << endl;
2066 for (
int i = 0;
i < n;
i++) {
2069 const_cast<std::vector<float>*
>(
algo->
vStsZPos)->push_back(element);
2072 cout <<
"vStsZPos[" << n <<
"]"
2073 <<
" have been read." << endl;
2076 for (
int i = 0;
i < n;
i++) {
2079 const_cast<vector<unsigned char>*
>(
algo->
vSFlag)
2080 ->push_back(
static_cast<unsigned char>(element));
2083 cout <<
"vSFlag[" << n <<
"]"
2084 <<
" have been read." << endl;
2087 for (
int i = 0;
i < n;
i++) {
2091 ->push_back(
static_cast<unsigned char>(element));
2094 cout <<
"vSFlagB[" << n <<
"]"
2095 <<
" have been read." << endl;
2103 for (
int i = 0;
i < n;
i++) {
2105 fadata >> element_f >> element_b >> element_n >> element_iz >> time;
2106 element.
f =
static_cast<THitI>(element_f);
2107 element.
b =
static_cast<THitI>(element_b);
2108 element.
iz =
static_cast<TZPosI>(element_iz);
2111 const_cast<std::vector<L1StsHit>*
>(
algo->
vStsHits)->push_back(element);
2114 cout <<
"vStsHits[" << n <<
"]"
2115 <<
" have been read." << endl;
2118 for (
int i = 0;
i < n;
i++) {
2124 for (
int i = 0;
i < n;
i++) {
2131 cout <<
"-I- CbmL1: CATrackFinder data for event " << nEvent
2132 <<
" has been read from file " << fadata_name <<
" successfully."
2139 static int nEvent = 1;
2140 static fstream fpdata;
2144 if (nEvent == 1) { fpdata.open(fpdata_name, fstream::in); };
2154 char s[] =
"EVENT: ";
2160 cout <<
"-E- CbmL1: Performance: can't read event number " << nEvent
2162 <<
"data_perfo.txt" << endl;
2166 for (
int i = 0;
i < n;
i++) {
2169 fpdata >> element.
xIn;
2170 fpdata >> element.
yIn;
2171 fpdata >> element.
zIn;
2172 fpdata >> element.
pxIn;
2173 fpdata >> element.
pyIn;
2174 fpdata >> element.
pzIn;
2176 fpdata >> element.
xOut;
2177 fpdata >> element.
yOut;
2178 fpdata >> element.
zOut;
2179 fpdata >> element.
pxOut;
2180 fpdata >> element.
pyOut;
2181 fpdata >> element.
pzOut;
2183 fpdata >> element.
p;
2184 fpdata >> element.
q;
2185 fpdata >> element.
mass;
2186 fpdata >> element.
time;
2188 fpdata >> element.
pdg;
2189 fpdata >> element.
ID;
2195 for (
int k = 0; k < nhits; k++) {
2198 element.
hitIds.push_back(helement);
2204 cout <<
"vMCPoints[" << n <<
"]"
2205 <<
" have been read." << endl;
2209 for (
int i = 0;
i < n;
i++) {
2212 fpdata >> element.
x;
2213 fpdata >> element.
y;
2214 fpdata >> element.
z;
2215 fpdata >> element.
px;
2216 fpdata >> element.
py;
2217 fpdata >> element.
pz;
2218 fpdata >> element.
p;
2219 fpdata >> element.
q;
2220 fpdata >> element.
mass;
2221 fpdata >> element.
time;
2223 fpdata >> element.
pdg;
2224 fpdata >> element.
ID;
2229 for (
int k = 0; k < nhits; k++) {
2232 element.
StsHits.push_back(helement);
2235 for (
int k = 0; k < nhits; k++) {
2238 element.
Points.push_back(helement);
2252 cout <<
"vMCTracks[" << n <<
"]"
2253 <<
" have been read." << endl;
2257 for (
int i = 0;
i < n;
i++) {
2263 cout <<
"vHitMCRef[" << n <<
"]"
2264 <<
" have been read." << endl;
2268 for (
int i = 0;
i < n;
i++) {
2273 fpdata >> element.
x;
2274 fpdata >> element.
y;
2278 cout <<
"vHitStore[" << n <<
"]"
2279 <<
" have been read." << endl;
2283 for (
int i = 0;
i < n;
i++) {
2285 fpdata >> element.
hitId;
2290 for (
int k = 0; k < nPoints; k++) {
2298 cout <<
"vStsHits[" << n <<
"]"
2299 <<
" have been read." << endl;
2306 cout <<
"-I- CbmL1: L1Performance data for event " << nEvent
2307 <<
" has been read from file " << fpdata_name <<
" successfully."
2315 static bool first = 1;
2322 FileGeo.open(
"geo.dat", ios::out);
2325 FieldCheck.open(
"field.dat", ios::out);
2327 Double_t bfg[3], rfg[3];
2332 dMF->GetFieldValue(rfg, bfg);
2333 FileGeo << rfg[2] <<
" " << bfg[0] <<
" " << bfg[1] <<
" " << bfg[2] <<
" "
2339 dMF->GetFieldValue(rfg, bfg);
2340 FileGeo << rfg[2] <<
" " << bfg[0] <<
" " << bfg[1] <<
" " << bfg[2] <<
" "
2346 dMF->GetFieldValue(rfg, bfg);
2347 FileGeo << rfg[2] <<
" " << bfg[0] <<
" " << bfg[1] <<
" " << bfg[2] <<
" "
2353 const int N = (M + 1) * (M + 2) / 2;
2355 for (Int_t ist = 0; ist <
NStation; ist++) {
2356 fscal f_phi, f_sigma, b_phi, b_sigma;
2365 b_phi = 3.14159265358 / 2.;
2374 double Pi = 3.14159265358;
2381 z = station->
GetZ();
2390 if (dx > Xmax / N / 2) dx = Xmax / N / 4.;
2391 if (dy > Ymax / N / 2) dy = Ymax / N / 4.;
2393 for (
int i = 0;
i < 3;
i++)
2394 for (
int k = 0; k < N; k++)
2397 TVectorD b0(N), b1(N), b2(N);
2398 for (
int i = 0;
i < N;
i++) {
2399 for (
int j = 0; j < N; j++)
2401 b0(
i) = b1(
i) = b2(
i) = 0.;
2403 for (
double x = -Xmax;
x <= Xmax;
x += dx)
2404 for (
double y = -Ymax;
y <= Ymax;
y += dy) {
2405 double r =
sqrt(
fabs(
x *
x / Xmax / Xmax +
y / Ymax *
y / Ymax));
2406 if (r > 1.)
continue;
2407 Double_t w = 1. / (r * r + 1);
2408 Double_t p[3] = {
x,
y, z};
2409 Double_t B[3] = {0., 0., 0.};
2413 for (
int i = 1;
i <= M;
i++) {
2414 int k = (
i - 1) * (
i) / 2;
2415 int l =
i * (
i + 1) / 2;
2416 for (
int j = 0; j <
i; j++)
2417 m(l + j) =
x *
m(k + j);
2418 m(l +
i) =
y *
m(k +
i - 1);
2422 for (
int i = 0;
i < N;
i++) {
2423 for (
int j = 0; j < N; j++)
2424 A(
i, j) += w *
m(
i) *
m(j);
2425 b0(
i) += w * B[0] *
m(
i);
2426 b1(
i) += w * B[1] *
m(
i);
2427 b2(
i) += w * B[2] *
m(
i);
2432 TVectorD c0 = A * b0, c1 = A * b1, c2 = A * b2;
2433 for (
int i = 0;
i < N;
i++) {
2439 double c_f =
cos(f_phi);
2440 double s_f =
sin(f_phi);
2441 double c_b =
cos(b_phi);
2442 double s_b =
sin(b_phi);
2444 double det_m = c_f * s_b - s_f * c_b;
2452 FileGeo <<
" " << ist <<
" ";
2455 FileGeo << t.
z <<
" ";
2456 FileGeo << t.
dz <<
" ";
2461 FileGeo << station->
GetZ() <<
" ";
2465 FileGeo << f_sigma <<
" ";
2466 FileGeo << b_sigma <<
" ";
2467 FileGeo << f_phi <<
" ";
2468 FileGeo << b_phi << endl;
2469 FileGeo <<
" " << N << endl;
2471 for (
int ik = 0; ik < N; ik++)
2472 FileGeo << C[0][ik] <<
" ";
2475 for (
int ik = 0; ik < N; ik++)
2476 FileGeo << C[1][ik] <<
" ";
2479 for (
int ik = 0; ik < N; ik++)
2480 FileGeo << C[2][ik] <<
" ";
2488 static int TrNumber = 0;
2489 fstream Tracks, McTracksCentr, McTracksIn, McTracksOut;
2491 Tracks.open(
"tracks.dat", fstream::out);
2492 McTracksCentr.open(
"mctrackscentr.dat", fstream::out);
2493 McTracksIn.open(
"mctracksin.dat", fstream::out);
2494 McTracksOut.open(
"mctracksout.dat", fstream::out);
2497 Tracks.open(
"tracks.dat", fstream::out | fstream::app);
2498 McTracksCentr.open(
"mctrackscentr.dat", fstream::out | fstream::app);
2499 McTracksIn.open(
"mctracksin.dat", fstream::out | fstream::app);
2500 McTracksOut.open(
"mctracksout.dat", fstream::out | fstream::app);
2503 for (vector<CbmL1Track>::iterator RecTrack =
vRTracks.begin();
2506 if (RecTrack->IsGhost())
continue;
2511 int NHits = (RecTrack->StsHits).size();
2512 float x[20],
y[20], z[20];
2515 for (
int iHit = 0; iHit < NHits; iHit++) {
2517 st[jHit] =
h.iStation;
2518 if (
h.ExtIndex < 0) {
2520 x[jHit] = MvdH->
GetX();
2521 y[jHit] = MvdH->
GetY();
2522 z[jHit] = MvdH->
GetZ();
2526 x[jHit] = StsH->
GetX();
2527 y[jHit] = StsH->
GetY();
2528 z[jHit] = StsH->
GetZ();
2533 Tracks << TrNumber <<
" " << MCTrack->
x <<
" " << MCTrack->
y <<
" "
2534 << MCTrack->
z <<
" " << MCTrack->
px <<
" " << MCTrack->
py <<
" "
2535 << MCTrack->
pz <<
" " << MCTrack->
q <<
" " << NHits << endl;
2537 float AngleXAxis = 0, AngleYAxis = 0;
2538 for (
int i = 0;
i < NHits;
i++)
2539 Tracks <<
" " << st[
i] <<
" " <<
x[
i] <<
" " <<
y[
i] <<
" " << z[
i]
2540 <<
" " << AngleXAxis <<
" " << AngleYAxis << endl;
2543 int NMCPoints = (MCTrack->
Points).size();
2545 McTracksIn << TrNumber <<
" " << MCTrack->
x <<
" " << MCTrack->
y <<
" "
2546 << MCTrack->
z <<
" " << MCTrack->
px <<
" " << MCTrack->
py <<
" "
2547 << MCTrack->
pz <<
" " << MCTrack->
q <<
" " << NMCPoints << endl;
2548 McTracksOut << TrNumber <<
" " << MCTrack->
x <<
" " << MCTrack->
y <<
" "
2549 << MCTrack->
z <<
" " << MCTrack->
px <<
" " << MCTrack->
py <<
" "
2550 << MCTrack->
pz <<
" " << MCTrack->
q <<
" " << NMCPoints << endl;
2551 McTracksCentr << TrNumber <<
" " << MCTrack->
x <<
" " << MCTrack->
y <<
" "
2552 << MCTrack->
z <<
" " << MCTrack->
px <<
" " << MCTrack->
py
2553 <<
" " << MCTrack->
pz <<
" " << MCTrack->
q <<
" " << NMCPoints
2556 for (
int iPoint = 0; iPoint < NMCPoints; iPoint++) {
2558 McTracksIn <<
" " << MCPoint.
iStation <<
" " << MCPoint.
xIn <<
" "
2559 << MCPoint.
yIn <<
" " << MCPoint.
zIn <<
" " << MCPoint.
pxIn
2560 <<
" " << MCPoint.
pyIn <<
" " << MCPoint.
pzIn << endl;
2561 McTracksOut <<
" " << MCPoint.
iStation <<
" " << MCPoint.
xOut <<
" "
2562 << MCPoint.
yOut <<
" " << MCPoint.
zOut <<
" " << MCPoint.
pxOut
2563 <<
" " << MCPoint.
pyOut <<
" " << MCPoint.
pzOut << endl;
2564 McTracksCentr <<
" " << MCPoint.
iStation <<
" " << MCPoint.
x <<
" "
2565 << MCPoint.
y <<
" " << MCPoint.
z <<
" " << MCPoint.
px <<
" "
2566 << MCPoint.
py <<
" " << MCPoint.
pz << endl;
2569 McTracksOut << endl;
2570 McTracksCentr << endl;