#include <map>
#include "TKey.h"
#include <TROOT.h>
#include <TRint.h>
#include <TTree.h>
#include <TFile.h>
#include <TSystem.h>
#include <iostream>
#include <TF1.h>
#include <TH2.h>
#include <TGraph.h>
#include <sstream>
#include "Log.hh"
#include <fstream>
#include "TCanvas.h"
#include "TApplication.h"
#include "TColor.h"
#include "TStyle.h"
#include "TAxis.h"
#include "TString.h"
#include "TLegend.h"
#include "MicroException.hh"
#include "root/MTRun.hh"
#include "root/MTEvent.hh"
#include "root/MTChannel.hh"
#include "root/MTMicrorocChip.hh"
Include dependency graph for test_microroc_gain.cpp:
Go to the source code of this file.
Defines | |
#define | DISPLAY |
#define | PLOT |
#define | WRITE |
Functions | |
void | usage (char *progname) |
void | set_style_myplain () |
int | main (int argc, char **argv) |
Variables | |
TStyle * | style_myplain = new TStyle("myplain","classic style") |
#define DISPLAY |
Definition at line 33 of file test_microroc_gain.cpp.
#define PLOT |
Definition at line 36 of file test_microroc_gain.cpp.
#define WRITE |
Definition at line 37 of file test_microroc_gain.cpp.
void usage | ( | char * | progname | ) |
void set_style_myplain | ( | ) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 45 of file test_microroc_gain.cpp.
00045 { 00046 00047 /*****************************************************************/ 00048 /* ARGUMENTS TO THE PROGRAM **************************************/ 00049 /* 1 - DIRECTORY OF THE ROOT FILE PRODUCED BY THE RECONSTRUCTION */ 00050 /* 2 - NAME OF THE ROOT FILE *************************************/ 00051 /* 3 - THRESHOLD THAT IS MOVED DURING THE CALIBRATION ************/ 00052 /* 0 -> DAC_0 (LOW THRESHOLD) *********************************/ 00053 /* 1 -> DAC_1 (MEDIUM THRESHOLD) ******************************/ 00054 /* 2 -> DAC_2 (HIGH THRESHOLD) ********************************/ 00055 /*****************************************************************/ 00056 if(argc != 4) 00057 { usage(argv[0]) ; 00058 return 1 ; 00059 } 00060 string root_directory = argv[1]; 00061 string pedestal_arg = argv[2]; 00062 string data_arg = argv[3]; 00063 00064 stringstream bad_channels ; 00065 00066 string pedestal_filename = root_directory + pedestal_arg ; 00067 string data_filename = root_directory + data_arg; 00068 00069 set_style_myplain() ; 00070 00071 Int_t crap ; // buffer to read data 00072 string bufferpedestal ; // buffer to read data 00073 Float_t pedestal[64] ; 00074 string bufferdata ; // buffer to read data 00075 Float_t data[64] ; 00076 Float_t gain[64] ; 00077 Float_t inputcharge = 50E-15 ; 00078 00079 ifstream dataFilePedestal ; 00080 dataFilePedestal.open(pedestal_filename.c_str(),ifstream::in) ; 00081 if (dataFilePedestal.is_open()==false) 00082 { cerr << "Could not open data file : " << pedestal_filename << endl ; 00083 exit(1) ; 00084 } 00085 ifstream dataFileData ; 00086 dataFileData.open(data_filename.c_str(),ifstream::in) ; 00087 if (dataFileData.is_open()==false) 00088 { cerr << "Could not open data file : " << data_filename << endl ; 00089 exit(1) ; 00090 } 00091 00092 int ok=0 ; // var for good chip 00093 int lg=0 ; // var for low gain chip 00094 00095 int tab_ok[64] ; 00096 for (int i=0;i<64;i++) 00097 { tab_ok[i]=0 ; 00098 } 00099 00100 Float_t lg_limit_low = 0.11 ; 00101 Float_t lg_limit_high = 0.16 ; 00102 00103 for (int ich=0;ich<64;ich++) 00104 { //getline(dataFilePedestal,bufferpedestal) ; 00105 dataFilePedestal >> crap >> pedestal[ich] ; 00106 getline(dataFilePedestal,bufferpedestal) ; 00107 //bufferpedestal >> crap >> pedestal[ich] >> crap >> crap >> crap; 00108 dataFileData >> crap >> data[ich] ; 00109 getline(dataFileData,bufferdata) ; 00110 //bufferdata >> crap >> data[ich] >> crap >> crap >> crap; 00111 gain[ich] = (inputcharge * 1E15) / (data[ich] - pedestal[ich]) ; 00112 if ((gain[ich]<= lg_limit_high) && (gain[ich]>lg_limit_low)) 00113 { ok++ ; 00114 tab_ok[ich]=1 ; 00115 } 00116 else bad_channels << ich << " " ; 00117 if ((gain[ich]>lg_limit_high) && (gain[ich]<0.30)) lg++ ; 00118 // cout << pedestal[ich] << "\t" << data[ich] << "\t" << gain[ich] << " fC/DAC" << endl ; 00119 } 00120 // from http://www.network-science.de/ascii/ style donut 00121 00122 TString flag ; 00123 Int_t min_chan_ok = 60 ; 00124 00125 if (ok==64) 00126 { cout << " OOOOOOOOO KKKKKKKKK KKKKKKK " << endl ; 00127 cout << " OO:::::::::OO K:::::::K K:::::K " << endl ; 00128 cout << " OO:::::::::::::OO K:::::::K K:::::K " << endl ; 00129 cout << "O:::::::OOO:::::::OK:::::::K K::::::K " << endl ; 00130 cout << "O::::::O O::::::OKK::::::K K:::::KKK " << endl ; 00131 cout << "O:::::O O:::::O K:::::K K:::::K " << endl ; 00132 cout << "O:::::O O:::::O K::::::K:::::K " << endl ; 00133 cout << "O:::::O O:::::O K:::::::::::K " << endl ; 00134 cout << "O:::::O O:::::O K:::::::::::K " << endl ; 00135 cout << "O:::::O O:::::O K::::::K:::::K " << endl ; 00136 cout << "O:::::O O:::::O K:::::K K:::::K " << endl ; 00137 cout << "O::::::O O::::::OKK::::::K K:::::KKK " << endl ; 00138 cout << "O:::::::OOO:::::::OK:::::::K K::::::K " << endl ; 00139 cout << " OO:::::::::::::OO K:::::::K K:::::K " << endl ; 00140 cout << " OO:::::::::OO K:::::::K K:::::K " << endl ; 00141 cout << " OOOOOOOOO KKKKKKKKK KKKKKKK " << endl ; 00142 flag = "_OK" ; 00143 //return 0; 00144 } 00145 else 00146 { if (lg==64) 00147 { 00148 cout << "*************************************" << endl ; 00149 cout << "LOW GAIN CHIP, BUT ALL CHANNELS OK ! " << endl ; 00150 cout << "Channel \t Pedestal \t Data \t Gain " << endl ; 00151 for (int i=0;i<64;i+=8) 00152 { if (tab_ok[i]== 0) 00153 { cout << i << "\t \t" << pedestal[i] << "\t \t" << data[i] << "\t \t" << gain[i] << endl ; 00154 } 00155 } 00156 cout << "*************************************" << endl ; 00157 flag = "_LG" ; 00158 } 00159 /* else if (ok>=min_chan_ok) 00160 { cout << "*************************************" << endl ; 00161 cout << 64-ok << " bad channels ! Channel(s) " << bad_channels.str() << "has/have bad gain" << endl ; 00162 cout << "*************************************" << endl ; 00163 flag = "_LG" ; 00164 00165 }*/ 00166 else 00167 { 00168 cout << "*************************************" << endl ; 00169 //cout << "Chip " << 00170 cout << "BAD CHIP: " << 64-ok << " bad channels ! Channel(s) " << bad_channels.str() << "has/have bad gain" << endl ; 00171 cout << "Channel \tPedestal \tData \t\tGain " << endl ; 00172 for (int i=0;i<64;i++) 00173 { if (tab_ok[i]== 0) 00174 { cout << i << "\t\t" << pedestal[i] << "\t\t" << data[i] << "\t\t" << gain[i] << endl ; 00175 } 00176 } 00177 cout << "*************************************" << endl ; 00178 flag = "_BAD" ; 00179 00180 /* cout << "BBBBBBBBBBBBBBBBB AAA DDDDDDDDDDDDD CCCCCCCCCCCCCHHHHHHHHH HHHHHHHHHIIIIIIIIIIPPPPPPPPPPPPPPPPP " << endl ; 00181 cout << "B::::::::::::::::B A:::A D::::::::::::DDD CCC::::::::::::CH:::::::H H:::::::HI::::::::IP::::::::::::::::P " << endl ; 00182 cout << "B::::::BBBBBB:::::B A:::::A D:::::::::::::::DD CC:::::::::::::::CH:::::::H H:::::::HI::::::::IP::::::PPPPPP:::::P " << endl ; 00183 cout << "BB:::::B B:::::B A:::::::A DDD:::::DDDDD:::::D C:::::CCCCCCCC::::CHH::::::H H::::::HHII::::::IIPP:::::P P:::::P " << endl ; 00184 cout << " B::::B B:::::B A:::::::::A D:::::D D:::::D C:::::C CCCCCC H:::::H H:::::H I::::I P::::P P:::::P " << endl ; 00185 cout << " B::::B B:::::B A:::::A:::::A D:::::D D:::::D C:::::C H:::::H H:::::H I::::I P::::P P:::::P " << endl ; 00186 cout << " B::::BBBBBB:::::B A:::::A A:::::A D:::::D D:::::D C:::::C H::::::HHHHH::::::H I::::I P::::PPPPPP:::::P " << endl ; 00187 cout << " B:::::::::::::BB A:::::A A:::::A D:::::D D:::::D C:::::C H:::::::::::::::::H I::::I P:::::::::::::PP " << endl ; 00188 cout << " B::::BBBBBB:::::B A:::::A A:::::A D:::::D D:::::D C:::::C H:::::::::::::::::H I::::I P::::PPPPPPPPP " << endl ; 00189 cout << " B::::B B:::::B A:::::AAAAAAAAA:::::A D:::::D D:::::D C:::::C H::::::HHHHH::::::H I::::I P::::P " << endl ; 00190 cout << " B::::B B:::::B A:::::::::::::::::::::A D:::::D D:::::D C:::::C H:::::H H:::::H I::::I P::::P " << endl ; 00191 cout << " B::::B B:::::B A:::::AAAAAAAAAAAAA:::::A D:::::D D:::::D C:::::C CCCCCC H:::::H H:::::H I::::I P::::P " << endl ; 00192 cout << "BB:::::BBBBBB::::::BA:::::A A:::::A DDD:::::DDDDD:::::D C:::::CCCCCCCC::::CHH::::::H H::::::HHII::::::IIPP::::::PP " << endl ; 00193 cout << "B:::::::::::::::::BA:::::A A:::::A D:::::::::::::::DD CC:::::::::::::::CH:::::::H H:::::::HI::::::::IP::::::::P " << endl ; 00194 cout << "B::::::::::::::::BA:::::A A:::::A D::::::::::::DDD CCC::::::::::::CH:::::::H H:::::::HI::::::::IP::::::::P " << endl ; 00195 cout << "BBBBBBBBBBBBBBBBBAAAAAAA AAAAAAADDDDDDDDDDDDD CCCCCCCCCCCCCHHHHHHHHH HHHHHHHHHIIIIIIIIIIPPPPPPPPPP " << endl ; 00196 */ 00197 //return -1; 00198 } 00199 } 00200 00201 TString store_file = TString(data_arg) ; 00202 // store_file.ReplaceAll("parameters_", "gain_"); 00203 store_file.ReplaceAll("_data.txt", ""); 00204 //TString (data_arg).ReplaceAll("parameters_", "gain_"); 00205 TString store_file_full ; 00206 store_file_full = root_directory + store_file + "_gain" + flag + ".txt"; 00207 //cout << store_file << endl ; 00208 ofstream out ; 00209 out.open(store_file_full) ; 00210 for (int ich=0;ich<64;ich++) 00211 { out << gain[ich] << endl ; 00212 } 00213 00214 return 0 ; 00215 }
TStyle* style_myplain = new TStyle("myplain","classic style") |
Definition at line 42 of file test_microroc_gain.cpp.