-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmakecartesianmap.C
More file actions
41 lines (32 loc) · 1.07 KB
/
makecartesianmap.C
File metadata and controls
41 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <fstream>
#include <sstream>
#include "TVector3.h"
#include "TFile.h"
#include "TNtuple.h"
Int_t makecartesianmap( std::string filename = "TPC_fld_map_f_shiftby2p85cm.table" )
{
std::ifstream ifs( filename );
std::string line;
double x,y,z;
double bx,by,bz;
double gauss2tesla = 1.0/10000.0;
std::string rootfile = "sphenix3dmapxyz.root";
TFile *f = new TFile(rootfile.c_str(),"recreate");
TNtuple fieldmap("fieldmap","sPHENIX 3D Field Map TPC_fld_map_f_shiftby2p85cm.table 2020.01.16 (Tesla)","x:y:z:bx:by:bz");
int linenum = 0;
while (getline (ifs, line)) {
// std::cout << line << std::endl;
std::istringstream iss(line);
iss >> x >> y >> z >> bx >> by >> bz;
if ( iss.rdstate() & std::ios::failbit ) {
std::cout << "ignore line: " << line << std::endl;
continue;
}
std::cout << x << "," << y << "," << z << "," << bx << "," << by << "," << bz << std::endl;
fieldmap.Fill(x,y,z,bx*gauss2tesla,by*gauss2tesla,bz*gauss2tesla);
linenum++;
}
f->Write();
return linenum;
}