File indexing completed on 2023-03-17 10:39:12
0001 #include <Riostream.h>
0002 #include "TROOT.h"
0003 #include "TSystem.h"
0004 #include "HIPplots.h"
0005
0006 using namespace std;
0007
0008
0009
0010
0011
0012 void plotter(const char* base_path, const char* dir, int iov=262922, TString plotType = "cov", int param_iter=20, int det=0, bool only_plotting=false){
0013
0014 char path[512], tag[256], outpath[512];
0015
0016 TString detname[6]={ "PXB", "PXF", "TIB", "TID", "TOB", "TEC" };
0017 if (det>=1&&det<=6)
0018 sprintf(tag, "%s_%s", dir, detname[det-1].Data());
0019 else if (det==0)
0020 sprintf(tag, "%s_ALL", dir);
0021 else{
0022 cout << "sub-detector id undefined! Please choose between 1 to 6!" << endl;
0023 return;
0024 }
0025
0026 sprintf(path, "%s/%s/main", base_path, dir);
0027 sprintf(outpath, "./%s/HIP_%s_%s_IOV%i_Iter%i.root", dir, plotType.Data(), tag, iov, param_iter);
0028 cout << "Path is " << path << endl;
0029 gSystem->Exec("mkdir -p " + TString(dir));
0030
0031 HIPplots* c=new HIPplots(iov, path, outpath);
0032 int ierr=0;
0033 c->CheckFiles(ierr);
0034 if (ierr>0){
0035 cout << " ERROR !!!! Missing " << ierr << " files. Aborting." << endl;
0036 return;
0037 }
0038 else if (ierr<0){
0039 if (!only_plotting){
0040 cout << "ERROR !!!! Output file exists already. I don't want to overwrite." << endl;
0041 cout << "Please, change name of output file or delete the old one: " << outpath << endl;
0042
0043
0044 }
0045 }
0046
0047
0048 cout << "\n\nSTARTING TO Generate Root Files " << endl << endl;
0049
0050 if (!only_plotting && plotType =="cov"){
0051
0052 for (int i = 0; i < 6; i++){
0053 if (det==0) c->extractAlignParams(i, 20);
0054 else c->extractAlignParams(i, 20, det);
0055 }
0056 }
0057
0058 if (!only_plotting && (plotType =="shift"||plotType =="param")){
0059 for (int i = 0; i < 6; i++){
0060 if (det==0) c->extractAlignShifts(i, 20);
0061 else c->extractAlignShifts(i, 20, det);
0062 }
0063 }
0064
0065 if (!only_plotting && plotType =="chi2"){
0066 if (det==0) c->extractAlignableChiSquare(20);
0067 else c->extractAlignableChiSquare(20, det);
0068 }
0069
0070 cout << "\n\nSTARTING TO PLOT " << endl << endl;
0071
0072
0073 gROOT->ProcessLine(" .L tdrstyle.C");
0074 gROOT->ProcessLine("setTDRStyle()");
0075
0076 if (plotType == "hitmap"){
0077 sprintf(outpath, "./%s/HitMaps_%s_IOV%i/", dir, tag, iov);
0078 gSystem->Exec("mkdir -p " + TString(outpath));
0079 for (int i=1; i<=6; ++i){
0080 c->plotHitMap(outpath, i, 0);
0081 }
0082 }
0083 else if (plotType == "cov"){
0084 sprintf(outpath, "./%s/parsViters_%s_IOV%i.png", dir, tag, iov);
0085 c->plotAlignParams("PARAMS", outpath);
0086 }
0087 else if (plotType == "shift"){
0088 sprintf(outpath, "./%s/shiftsViters_%s_IOV%i.png", dir, tag, iov);
0089 c->plotAlignParams("SHIFTS", outpath);
0090 }
0091 else if (plotType == "param"){
0092 sprintf(outpath, "./%s/shiftsAtIter%d_%s_IOV%i.png", dir, param_iter, tag, iov);
0093 c->plotAlignParamsAtIter(param_iter, "SHIFTS", outpath);
0094 }
0095 else if (plotType == "chi2"){
0096 sprintf(outpath, "./%s/AlignableChi2n_%s_IOV%i", dir, tag, iov);
0097 c->plotAlignableChiSquare(outpath, 0.1);
0098 }
0099 else
0100 cout << "Plotting type \"" << plotType << "\" is not defined!" << endl;
0101
0102 cout << "Deleting... " << flush;
0103
0104 cout << "cleaned up HIPplots object ! We are done and good luck !" << endl;
0105
0106 }