BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CheckMap.C
Go to the documentation of this file.
1using namespace TMath;
2
3void CheckMap()
4{
5
6 TString name1900 = "FieldMap_1900_extrap.root";
7 TFile* file1900 = TFile::Open(name1900);
8 TTreeReader reader("Field_map", file1900);
9 TTreeReaderArray<Double_t> x(reader, "field_points.X");
10 TTreeReaderArray<Double_t> y(reader, "field_points.Y");
11 TTreeReaderArray<Double_t> z(reader, "field_points.Z");
12 TTreeReaderArray<Double_t> bx(reader, "field_points.Bx");
13 TTreeReaderArray<Double_t> by(reader, "field_points.By");
14 TTreeReaderArray<Double_t> bz(reader, "field_points.Bz");
15
16 Int_t fNx = 206;
17 Int_t fNy = 87;
18 Int_t fNz = 341;
19
20 TGraph* gBy_vs_z[fNy][fNx];
21
22 Int_t pntNumber = 0;
23 while (reader.Next()) {
24 if (pntNumber % 10000 == 0)
25 printf("pntNumber = %d\n", pntNumber);
26
27 Int_t iz = pntNumber % fNz;
28 Int_t ix = (pntNumber / fNz) % fNx;
29 Int_t iy = ((pntNumber / fNz) / fNx) % fNy;
30
31 if (iz == 0) {
32 gBy_vs_z[iy][ix] = new TGraph(fNz);
33 gBy_vs_z[iy][ix]->SetTitle(Form("%3.2f_%3.2f", y[0], x[0]));
34 gBy_vs_z[iy][ix]->SetName(Form("%3.2f_%3.2f", y[0], x[0]));
35 }
36
37 gBy_vs_z[iy][ix]->SetPoint(iz, z[0], by[0]);
38
39 pntNumber++;
40 }
41
42 TFile* f = new TFile("MagFieldGraphs.root", "RECREATE");
43 for (Int_t iy = 0; iy < fNy; ++iy) {
44 for (Int_t ix = 0; ix < fNx; ++ix) {
45 Bool_t badGraph = kFALSE;
46 for (Int_t iz = 1; iz < fNz; ++iz) {
47 if (Abs(gBy_vs_z[iy][ix]->GetPointY(iz) - gBy_vs_z[iy][ix]->GetPointY(iz - 1)) > 1.0) {
48 badGraph = kTRUE;
49 break;
50 }
51 }
52 if (badGraph) {
53 cout << iy << " " << ix << endl;
54 gBy_vs_z[iy][ix]->Write();
55 }
56 }
57 }
58 f->Write();
59}
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
char * Form(const char *fmt,...)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
void SetName(const char *name="") override
void SetTitle(const char *title="") override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
void CheckMap()
Definition CheckMap.C:3
Double_t Abs(Double_t d)