Line Code
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#include <iostream>
#include <vector>
#include "string"
#include "TROOT.h"
#include "TString.h"
#include "plotter.C"

using namespace std;

void splitOption(string rawoption, string& wish, string& value, char delimiter){
  size_t posEq = rawoption.find(delimiter);
  if (posEq!=string::npos){
    wish=rawoption;
    value=rawoption.substr(posEq+1);
    wish.erase(wish.begin()+posEq, wish.end());
  }
  else{
    wish="";
    value=rawoption;
  }
}
void splitOptionRecursive(string rawoption, vector<string>& splitoptions, char delimiter){
  string suboption=rawoption, result=rawoption;
  string remnant;
  while (result!=""){
    splitOption(suboption, result, remnant, delimiter);
    if (result!="") splitoptions.push_back(result);
    suboption = remnant;
  }
  if (remnant!="") splitoptions.push_back(remnant);
}

void runplot(string full_path, int iov, int iter, string plotreq="", bool only_plotting=false){
  vector<string> pathseg;
  splitOptionRecursive(full_path, pathseg, '/');
  splitOptionRecursive(pathseg.at(pathseg.size()-1), pathseg, '/');
  //for (unsigned int f=0; f<pathseg.size(); f++) cout << pathseg.at(f) << " " << f << endl;
  string obj = pathseg.at(pathseg.size()-1);
  string path = full_path; path.erase(path.find(obj.c_str()), obj.length());

  cout << "Analyzing " << obj << " in path " << path << endl;

  // choose plot type from : "cov","shift","chi2","param","hitmap"
  vector<string> plottype;
  if (plotreq==""){
    plottype.push_back("cov");
    plottype.push_back("shift");
    plottype.push_back("chi2");
    plottype.push_back("param");
    plottype.push_back("hitmap");
  }
  else{
    if (plotreq=="cov") plottype.push_back("cov");
    else if (plotreq=="shift") plottype.push_back("shift");
    else if (plotreq=="chi2") plottype.push_back("chi2");
    else if (plotreq=="param") plottype.push_back("param");
    else if (plotreq=="hitmap") plottype.push_back("hitmap");
    else return;
  }

  // plot all detectors together or individually
  bool MergeAllDet = 1;

  //*******************************************

  const unsigned int Nplots = plottype.size();

  //plotting all detectors together

  if (MergeAllDet == 1){
    for (unsigned int i = 0; i < Nplots; i++) plotter(path.c_str(), obj.c_str(), iov, plottype.at(i).c_str(), iter, 0, only_plotting);
  }

  // plotting each detector separately, don't use this for hit-map.
  else{
    // det: 0=all,1=PXB, 2=PXF, 3=TIB, 4=TID, 5=TOB, 6=TEC
    for (unsigned int i = 0; i < Nplots; i++) {
      for (unsigned int det = 0; det < 6; det++) plotter(path.c_str(), obj.c_str(), iov, plottype.at(i).c_str(), iter, det, only_plotting);
    }
  }
}