Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ApplyCDCOffsets.C
Go to the documentation of this file.
1 // Script to get current values of the offsets from the alignment root file, and shift them according to the MILLEPEDE result.
2 #include <map>
3 #include <fstream>
4 #include <iostream>
5 #include <string>
6 #include "TProfile.h"
7 #include "TFile.h"
8 
9 using namespace std;
10 
11 void ApplyCDCOffsets(TString rootFile = "hd_root.root", TString pedeOutFile = "millepede.res"){
12 
13  TFile *file = TFile::Open(rootFile);
14  TProfile *hCDCConstants;
15  file->GetObject("AlignmentConstants/CDCAlignmentConstants",hCDCConstants);
16 
17  ifstream pedeResult;
18  pedeResult.open(pedeOutFile.Data());
19 
20  map < int, double> resultMap;
21 
22  bool firstLine = true;
23  string line;
24  while (getline(pedeResult,line)){
25  if (firstLine){
26  firstLine = false;
27  continue;
28  }
29  int index; double value;
30  istringstream iss(line);
31  iss >> index >> value;
32 
33  resultMap[index]=value;
34  }
35 
36  // Global CDC offsets
37  ofstream outFile;
38  outFile.open("cdc_global.txt");
39  for (unsigned int i = 1; i<=6; i++){
40  int histIndex = i;
41  int pedeIndex = i;
42  outFile << resultMap[pedeIndex] + hCDCConstants->GetBinContent(histIndex) << " " ;
43  }
44  outFile.close();
45 
46  // Wire alignment
47  outFile.open("cdc_wire_alignment.txt");
48  for (unsigned int i = 1001; i<=15088; i++){
49  int histIndex = i;
50  int pedeIndex = i;
51  outFile << resultMap[pedeIndex] + hCDCConstants->GetBinContent(histIndex) << " " ;
52  if (i%4 == 0) outFile << endl;
53  }
54  outFile.close();
55 
56  // t0 alignment
57  outFile.open("cdc_t0_alignment.txt");
58  for (unsigned int i = 16001; i<=19522; i++){
59  int histIndex = i;
60  int pedeIndex = i;
61  outFile << hCDCConstants->GetBinContent(histIndex) - resultMap[pedeIndex]<< endl;
62  }
63  outFile.close();
64 
65 }
TFile * outFile
Definition: FitGains.C:15
static char index(char c)
Definition: base64.cpp:115
void ApplyCDCOffsets(TString rootFile="hd_root.root", TString pedeOutFile="millepede.res")