//************************************************
// Author: Federica Lionetto
// Created on: 20/11/2014
//************************************************

/*
PulseShapevsV reads two text files (containing the bias voltage and the current values) and creates a ROOT file with the following information:
- laser delay at the peak of the Beetle pulse shape (float laserDelayAtPeak) as a function of the bias voltage;
- average ADC signal at the peak of the Beetle pulse shape (float float averageADCSignalAtPeak) as a function of the bias voltage.

Compile with:

make

Run with:

./PulseShapevsV [input text file 1] [input text file 2] [additional folder]

where

- [input text file 1] is the complete path, including the folder and the filename, of the text file one wants to process (increasing bias voltage);
- [input text file 2] is the complete path, including the folder and the filename, of the text file one wants to process (decreasing bias voltage);
- [additional folder] is the optional additional folder where the output will be saved.

A folder named AnalysisResults will be created in a fixed location and a ROOT file will be saved in there. A folder named Figures will be created inside the folder named AnalysisResults, with some monitoring plots.

If needed, an additional folder can be specified, that will be created inside the folder named AnalysisResults.
*/

#include "../Tools/Lib.C"
#include "../Tools/lhcbStyle.C"
#include "../Tools/Style.C"
#include "../Tools/Useful.C"

#include "../Tools/Par.C"

void PulseShapevsV(char *filename1, char *filename2, char *externalPath=0);

int main(int argc, char *argv[])
{
  getLHCbStyle();
  PersonalStyle();

  if ((argc ==2) && (string(argv[1]) == "--info"))
  {
    cout << "**************************************************" << endl;

    cout << "Some comments." << endl;
    
    cout << "**************************************************" << endl;

    return 0;
  }
  else if (argc < 3)
  {
    cout << "**************************************************" << endl;
    
    cout << "Error! Input files missing..." << endl;
    cout << "Please use the following format:" << endl;
    cout << "./PulseShapevsV [1] [2] [3]" << endl;
    cout << "with:" << endl;
    cout << "[1] = Input text file 1, complete path (increasing bias voltage);" << endl;
    cout << "[2] = Input text file 2, complete path (decreasing bias voltage);" << endl;
    cout << "[3] = Additional folder, optional." << endl;
    cout << "Type ./PulseShapevsV --info for more information." << endl;

    cout << "**************************************************" << endl;

    return 0;  
  }
  else
  {
    cout << "File 1 to process: " << argv[1] << endl;
    cout << "File 2 to process: " << argv[2] << endl;
    if (argc == 3)
      PulseShapevsV(argv[1],argv[2]);
    else if (argc == 4)
      PulseShapevsV(argv[1],argv[2],argv[3]);
    else
    {
      cout << "Error! Too many arguments given..." << endl;
      
      return 0;
    }
    
    return 0;  
  }  
}

void IVScan(char *filename1, char *filename2, char *externalPath)
{
  cout << "**************************************************" << endl;
  cout << "Showing the pulse shape changes as a function of the bias voltage..." << endl;
  cout << "**************************************************" << endl;

  // Do not comment this line.
  gROOT->ProcessLine("#include <vector>");






return;
}
