Fork me on GitHub

Changeset 31f3bca in git for external


Ignore:
Timestamp:
Feb 25, 2020, 8:57:59 PM (5 years ago)
Author:
Pavel Demin <pavel.demin@…>
Branches:
ImprovedOutputFile, master
Children:
3e5f05c
Parents:
7d790c1
Message:

read detector geometry from card

File:
1 edited

Legend:

Unmodified
Added
Removed
  • external/TrackCovariance/SolGeom.cc

    r7d790c1 r31f3bca  
    11#include <iostream>
     2#include <sstream>
    23
    34#include <TString.h>
     
    4142void SolGeom::Read(const char *data)
    4243{
    43   char strng[200];
    44   int nbytes = 200;
    45   FILE *fdata = fopen(data, "r");
    46   if (!fdata)
    47   {
    48     cout << "SolGeom::GeoRead - can't open input file" << endl;
    49     return;
    50   }
    5144  Int_t tyLay;
    52   char LyLabl[20];
    53   float xMin;
    54   float xMax;
    55   float rPos;
    56   float thLay;
    57   float rlLay;
     45  string LyLabl;
     46  Double_t xMin;
     47  Double_t xMax;
     48  Double_t rPos;
     49  Double_t thLay;
     50  Double_t rlLay;
    5851  Int_t nmLay;
    59   float stLayU;
    60   float stLayL;
    61   float sgLayU;
    62   float sgLayL;
     52  Double_t stLayU;
     53  Double_t stLayL;
     54  Double_t sgLayU;
     55  Double_t sgLayL;
    6356  Int_t flLay;
    6457
     58  stringstream data_stream(data);
     59  string line;
     60
    6561  fNlay = 0;
    66   while (fgets(strng, nbytes, fdata) != NULL)
     62  while(getline(data_stream, line))
    6763  {
    68     cout << strng;
    69     int status = sscanf(strng, "%d %s %g %g %g %g %g %d %g %g %g %g %d",
    70       &tyLay, LyLabl, &xMin, &xMax, &rPos, &thLay,
    71       &rlLay, &nmLay, &stLayU, &stLayL, &sgLayU, &sgLayL, &flLay);
     64    stringstream line_stream(line);
     65
     66    line_stream >> tyLay >> LyLabl >> xMin >> xMax >> rPos >> thLay >> rlLay >> nmLay >> stLayU >> stLayL >> sgLayU >> sgLayL >> flLay;
     67
     68    if(line_stream.fail()) continue;
     69
    7270    ftyLay[fNlay] = tyLay;
    7371    fLyLabl[fNlay] = LyLabl;
     
    8886    if (tyLay == 2) fFlay++;
    8987    if (flLay == 1) fNm++;
    90 
    9188  }
    92 
    93   cout << "SolGeom::GeoRead completed with " << fNlay << " layers input" << endl;
    9489}
    9590
Note: See TracChangeset for help on using the changeset viewer.