-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from JeffersonLab/TrackingAlignment
Tracking alignment
- Loading branch information
Showing
14 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import os | ||
from subprocess import call | ||
|
||
################################# | ||
# Setup Parameters for iterations | ||
################################# | ||
|
||
nIterations=10 | ||
filename='/raid12/gluex/RunPeriod-2017-01/rawdata/Run030778/hd_rawdata_030778_000.evio' | ||
nThreads=4 | ||
nEvents=1000000 | ||
|
||
############################################# | ||
# You shouldn't have to edit below this lines | ||
############################################# | ||
|
||
ccdb_connection = os.environ['CCDB_CONNECTION'] | ||
|
||
if 'mysql' in ccdb_connection: | ||
print "CONNECTED TO JLAB MYSQL DATABASE === ABORTING" | ||
quit() | ||
|
||
if 'sqlite' not in ccdb_connection: | ||
print "UNKNOWN DATABASE TYPE %s == MUST USE SQLITE" % ccdb_connection | ||
quit() | ||
|
||
try: | ||
os.mkdir('FDCInternalAlignIterations'); | ||
except OSError: | ||
pass | ||
|
||
for iter in range(1,nIterations): | ||
print "Iteration %.2i of %.2i" % (iter, nIterations) | ||
call('hd_root -PPLUGINS=FDC_InternalAlignment %s -PNTHREADS=%i -PEVENTS_TO_KEEP=%i' % (filename, nThreads, nEvents), shell=True) | ||
call(r'root -l -b -q $HALLD_HOME/src/plugins/Alignment/FDC_InternalAlignment/FitScripts/FitCathodeAlignment.C\(\"hd_root.root\"\)',shell=True) | ||
call('mv Result.png FDCInternalAlignIterations/Result_Iter%.2i.png' % iter, shell=True) | ||
call('mv hd_root.root FDCInternalAlignIterations/hd_root_Planes_Iter%.2i.root' % iter, shell=True) | ||
call('ccdb add /FDC/cathode_alignment CathodeAlignment.txt', shell=True) | ||
call('hd_root -PPLUGINS=FDC_InternalAlignment %s -PNTHREADS=%i -PEVENTS_TO_KEEP=%i' % (filename, nThreads, nEvents), shell=True) | ||
call(r'root -l -b -q $HALLD_HOME/src/plugins/Alignment/FDC_InternalAlignment/FitScripts/FitCathodeProjections.C\(\"hd_root.root\"\)',shell=True) | ||
call('ccdb add /FDC/cathode_alignment CathodeAlignment.txt', shell=True) | ||
call('ccdb add /FDC/strip_pitches_v2 StripPitchesV2.txt',shell=True) | ||
call('mv hd_root.root FDCInternalAlignIterations/hd_root_Projections_Iter%.2i.root' % iter, shell=True) | ||
call('mv ResultU.png FDCInternalAlignIterations/ResultU_Iter%.2i.png' % iter, shell=True) | ||
call('mv ResultV.png FDCInternalAlignIterations/ResultV_Iter%.2i.png' % iter, shell=True) | ||
|
||
print "======= FINAL ITERATION =======" | ||
call('hd_root -PPLUGINS=FDC_InternalAlignment %s -PNTHREADS=%i -PEVENTS_TO_KEEP=%i' % (filename, nThreads, nEvents), shell=True) | ||
call('mv hd_root.root FDCInternalAlignIterations/hd_root_Planes_Iter%.2i.root' % nIterations, shell=True) | ||
call(r'root -l -b -q $HALLD_HOME/src/plugins/Alignment/FDC_InternalAlignment/FitScripts/FitCathodeAlignment.C\(\"hd_root.root\"\)',shell=True) | ||
call('ccdb add /FDC/cathode_alignment CathodeAlignment.txt', shell=True) | ||
call('mv Result.png FDCInternalAlignIterations/Result_Iter%.2i.png' % nIterations, shell=True) | ||
call(r'root -l -b -q $HALLD_HOME/src/plugins/Alignment/FDC_InternalAlignment/FitScripts/FitCathodeProjections.C\(\"hd_root.root\"\)',shell=True) | ||
call('mv ResultU.png FDCInternalAlignIterations/ResultU_Iter%.2i.png' % nIterations, shell=True) | ||
call('mv ResultV.png FDCInternalAlignIterations/ResultV_Iter%.2i.png' % nIterations, shell=True) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Script to get current values of the offsets from the alignment root file, and shift them according to the MILLEPEDE result. | ||
#include <map> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <string> | ||
#include "TProfile.h" | ||
#include "TFile.h" | ||
|
||
using namespace std; | ||
|
||
void DumpCDCOffsets(TString rootFile = "hd_root.root"){ | ||
|
||
TFile *file = TFile::Open(rootFile); | ||
TProfile *hCDCConstants; | ||
file->GetObject("AlignmentConstants/CDCAlignmentConstants",hCDCConstants); | ||
|
||
// Global CDC offsets | ||
ofstream outFile; | ||
outFile.open("cdc_global.txt"); | ||
for (unsigned int i = 1; i<=6; i++){ | ||
int histIndex = i; | ||
outFile << hCDCConstants->GetBinContent(histIndex) << " " ; | ||
} | ||
outFile.close(); | ||
|
||
// Wire alignment | ||
outFile.open("cdc_wire_alignment.txt"); | ||
for (unsigned int i = 1001; i<=15088; i++){ | ||
int histIndex = i; | ||
outFile << hCDCConstants->GetBinContent(histIndex) << " " ; | ||
if (i%4 == 0) outFile << endl; | ||
} | ||
outFile.close(); | ||
|
||
// t0 alignment | ||
outFile.open("cdc_t0_alignment.txt"); | ||
for (unsigned int i = 16001; i<=19522; i++){ | ||
int histIndex = i; | ||
outFile << hCDCConstants->GetBinContent(histIndex) << endl; | ||
} | ||
outFile.close(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Script to get current values of the offsets from the alignment root file and dump them to text files | ||
#include <map> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <string> | ||
#include "TProfile.h" | ||
#include "TFile.h" | ||
|
||
using namespace std; | ||
|
||
void DumpFDCOffsets(TString rootFile = "hd_root.root"){ | ||
|
||
TFile *file = TFile::Open(rootFile); | ||
TProfile *hFDCConstants; | ||
file->GetObject("AlignmentConstants/FDCAlignmentConstants",hFDCConstants); | ||
|
||
// Cell offsets | ||
// Indices are 101001, 101100 etc... | ||
ofstream outFile; | ||
outFile.open("cell_offsets.txt"); | ||
for (unsigned int i = 1; i<=24; i++){ | ||
int histIndex = i*1000; | ||
outFile << hFDCConstants->GetBinContent(histIndex+1) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+100) << endl ; | ||
} | ||
outFile.close(); | ||
|
||
// Cathode Offsets | ||
// Indices are 101, 102, 103, 104 | ||
outFile.open("cathode_alignment.txt"); | ||
for (unsigned int i = 1; i<=24; i++){ | ||
int histIndex = i*1000; | ||
outFile << hFDCConstants->GetBinContent(histIndex+103) << " " ;//dPhiU | ||
outFile << hFDCConstants->GetBinContent(histIndex+101) << " " ;//dU | ||
outFile << hFDCConstants->GetBinContent(histIndex+104) << " " ;//dPhiV | ||
outFile << hFDCConstants->GetBinContent(histIndex+102) << endl ;//dV | ||
} | ||
outFile.close(); | ||
|
||
// Strip Pitches | ||
// Indices are 200...209 | ||
outFile.open("strip_pitches.txt"); | ||
for (unsigned int i = 1; i<=24; i++){ | ||
int histIndex = i*1000; | ||
outFile << hFDCConstants->GetBinContent(histIndex+200) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+201) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+202) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+203) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+204) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+205) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+206) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+207) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+208) << " " ; | ||
outFile << hFDCConstants->GetBinContent(histIndex+209) << endl; | ||
} | ||
outFile.close(); | ||
|
||
// Wire Alignment | ||
// Indices are 2 | ||
outFile.open("wire_alignment.txt"); | ||
for (unsigned int i = 1; i<=24; i++){ | ||
int histIndex = i*1000; | ||
outFile << hFDCConstants->GetBinContent(histIndex+2) << " 0.0 0.0" << endl; | ||
} | ||
outFile.close(); | ||
|
||
for (unsigned int i = 1; i<=4; i++){ | ||
outFile.open(Form("t0_package%i.txt",i)); | ||
for (unsigned int j=1; j<=6;j++){ | ||
for (unsigned int k = 1; k<= 96; k++){ | ||
int histIndex = ((i-1)*4+j)*1000 + 900; | ||
outFile << hFDCConstants->GetBinContent(histIndex+k)<< " " ; | ||
} | ||
outFile << endl; | ||
} | ||
outFile.close(); | ||
} | ||
//gains | ||
for (unsigned int i = 1; i<=4; i++){ | ||
outFile.open(Form("gains_package%i.txt",i)); | ||
for (unsigned int j=1; j<=6;j++){ | ||
for (unsigned int k = 1; k<= 216; k++){ | ||
int histIndex = ((i-1)*4+j)*1000 + 300; | ||
outFile << hFDCConstants->GetBinContent(histIndex+k) << " " ; | ||
} | ||
outFile << endl; | ||
for (unsigned int k = 1; k<= 216; k++){ | ||
int histIndex = ((i-1)*4+j)*1000 + 600; | ||
outFile << hFDCConstants->GetBinContent(histIndex+k) << " " ; | ||
} | ||
outFile << endl; | ||
} | ||
outFile.close(); | ||
} | ||
} |