| 1 | mocchiut | 1.1 | // | 
| 2 |  |  | //   Look for calibrations in the file - Emiliano Mocchiutti | 
| 3 |  |  | // | 
| 4 |  |  | //   FCaloFINDCALIBS.cxx      version 1.01  (2006-03-08) | 
| 5 |  |  | // | 
| 6 |  |  | //   The only input needed is the path to the directory created by YODA for the data file you want to analyze. | 
| 7 |  |  | // | 
| 8 |  |  | //   Changelog: | 
| 9 |  |  | // | 
| 10 |  |  | //   1.00 - 1.01 (2006-03-08): Flight version, read unique YODA file. | 
| 11 |  |  | // | 
| 12 |  |  | //   0.00 - 1.00 (2006-03-08): Clone of CaloFINDCALIBS v2r06. | 
| 13 |  |  | // | 
| 14 |  |  | #include <fstream> | 
| 15 |  |  | #include <sstream> | 
| 16 |  |  | #include <TTree.h> | 
| 17 |  |  | #include <TClassEdit.h> | 
| 18 |  |  | #include <TObject.h> | 
| 19 |  |  | #include <TList.h> | 
| 20 |  |  | #include <TSystem.h> | 
| 21 |  |  | #include <TSystemDirectory.h> | 
| 22 |  |  | #include <TString.h> | 
| 23 |  |  | #include <TFile.h> | 
| 24 |  |  | #include <TClass.h> | 
| 25 |  |  | #include <TCanvas.h> | 
| 26 |  |  | #include <TH1.h> | 
| 27 |  |  | #include <TH1F.h> | 
| 28 |  |  | #include <TH2D.h> | 
| 29 |  |  | #include <TLatex.h> | 
| 30 |  |  | #include <TPad.h> | 
| 31 |  |  | #include <TPaveLabel.h> | 
| 32 |  |  | #include <TChain.h> | 
| 33 |  |  | #include <fcalostructs.h> | 
| 34 |  |  | extern TString whatnamewith(TString, Int_t); | 
| 35 |  |  | extern int CaloFindCalibs(TString &, TString &, Int_t &, Calib &); | 
| 36 |  |  | extern int OLDCaloFindCalibs(TString &, Calib &); | 
| 37 |  |  | extern void stringcopy(TString&, const TString&, Int_t, Int_t); | 
| 38 |  |  | // | 
| 39 |  |  | using namespace std; | 
| 40 |  |  |  | 
| 41 |  |  | void FCaloFINDCALIBS(TString filename){ | 
| 42 |  |  | struct Calib calib; | 
| 43 |  |  | // | 
| 44 |  |  | for (Int_t s=0; s<4;s++){ | 
| 45 |  |  | for (Int_t d = 0; d<51; d++){ | 
| 46 |  |  | calib.ttime[s][d] = 0 ; | 
| 47 |  |  | calib.time[s][d] = 0 ; | 
| 48 |  |  | }; | 
| 49 |  |  | }; | 
| 50 |  |  | // | 
| 51 |  |  | // first of all find the calibrations in the file | 
| 52 |  |  | // | 
| 53 |  |  | Int_t wused = 0; | 
| 54 |  |  | Int_t err = CaloFindCalibs(filename, filename, wused, calib); | 
| 55 |  |  | if ( err ){ | 
| 56 |  |  | printf("\n %s: no such file or directory \n\n",filename.Data()); | 
| 57 |  |  | return; | 
| 58 |  |  | }; | 
| 59 |  |  | // | 
| 60 |  |  | // print on the screen the results: | 
| 61 |  |  | // | 
| 62 |  |  | const char *ffile = filename; | 
| 63 |  |  | printf(" ------ %s ------- \n \n",ffile); | 
| 64 |  |  | Int_t calibex = 0; | 
| 65 |  |  | TString pfile; | 
| 66 |  |  | for (Int_t s=0; s<4;s++){ | 
| 67 |  |  | printf(" ** SECTION %i **\n",s); | 
| 68 |  |  | for (Int_t d = 0; d<51; d++){ | 
| 69 |  |  | if ( calib.ttime[s][d] != 0 ) { | 
| 70 |  |  | calibex++; | 
| 71 |  |  | if ( calib.fcode[s][d] != 10 ){ | 
| 72 |  |  | TString file2 = ""; | 
| 73 |  |  | stringcopy(file2,filename,0,0); | 
| 74 |  |  | pfile = (TString)whatnamewith(file2,calib.fcode[s][d]); | 
| 75 |  |  | } else { | 
| 76 |  |  | pfile = (TString)filename; | 
| 77 |  |  | }; | 
| 78 |  |  | const char *ffile = pfile; | 
| 79 |  |  | printf(" - from time %i to time %i use calibration at\n time %i, file: %s \n",calib.time[s][d],calib.time[s][d+1],calib.ttime[s][d],ffile); | 
| 80 |  |  | }; | 
| 81 |  |  | }; | 
| 82 |  |  | printf("\n"); | 
| 83 |  |  | }; | 
| 84 |  |  | printf(" ----------------------------------------------------------------------- \n \n"); | 
| 85 |  |  | if ( calibex < 4 ) { | 
| 86 |  |  | printf("No full calibration data in this file!\n"); | 
| 87 |  |  | }; | 
| 88 |  |  | // | 
| 89 |  |  | return; | 
| 90 |  |  | } | 
| 91 |  |  |  | 
| 92 |  |  | void FCaloOLDFINDCALIBS(TString filename){ | 
| 93 |  |  | struct Calib calib; | 
| 94 |  |  | // | 
| 95 |  |  | for (Int_t s=0; s<4;s++){ | 
| 96 |  |  | for (Int_t d = 0; d<50; d++){ | 
| 97 |  |  | calib.ttime[s][d] = 0 ; | 
| 98 |  |  | if ( d < 49 ) calib.time[s][d] = 0 ; | 
| 99 |  |  | }; | 
| 100 |  |  | }; | 
| 101 |  |  | // | 
| 102 |  |  | // first of all find the calibrations in the file | 
| 103 |  |  | // | 
| 104 |  |  | Int_t err = OLDCaloFindCalibs(filename, calib); | 
| 105 |  |  | if ( err ){ | 
| 106 |  |  | printf("\n %s: no such file or directory \n\n",filename.Data()); | 
| 107 |  |  | return; | 
| 108 |  |  | }; | 
| 109 |  |  | // | 
| 110 |  |  | // print on the screen the results: | 
| 111 |  |  | // | 
| 112 |  |  | printf(" ---------------------------------------------------------- \n \n"); | 
| 113 |  |  | Int_t calibex = 0; | 
| 114 |  |  | for (Int_t s=0; s<4;s++){ | 
| 115 |  |  | Int_t stop = 0; | 
| 116 |  |  | for (Int_t d = 0; d<48; d++){ | 
| 117 |  |  | if ( calib.ttime[s][d] != 0 ) calibex++; | 
| 118 |  |  | if ( calib.time[s][0] != 0 ){ | 
| 119 |  |  | if ( d == 0 )  printf(" Section %i from time 0 to time %i use calibration at time %i \n",s,calib.time[s][d],calib.ttime[s][d]); | 
| 120 |  |  | if ( calib.time[s][d+1] != 0 ) { | 
| 121 |  |  | printf(" Section %i from time %i to time %i use calibration at time %i \n",s,calib.time[s][d],calib.time[s][d+1],calib.ttime[s][d+1]); | 
| 122 |  |  | } else { | 
| 123 |  |  | if ( !stop ){ | 
| 124 |  |  | printf(" Section %i from time %i use calibration at time %i \n",s,calib.time[s][d],calib.ttime[s][d+1]); | 
| 125 |  |  | stop = 1; | 
| 126 |  |  | }; | 
| 127 |  |  | }; | 
| 128 |  |  | } else { | 
| 129 |  |  | if ( calib.ttime[s][d] != 0 ) printf(" Section %i from time 0 use calibration at time %i \n",s,calib.ttime[s][d]); | 
| 130 |  |  | }; | 
| 131 |  |  | }; | 
| 132 |  |  | printf("\n"); | 
| 133 |  |  | }; | 
| 134 |  |  | printf(" ---------------------------------------------------------- \n"); | 
| 135 |  |  | const char *ffile = filename; | 
| 136 |  |  | printf(" %s  \n",ffile); | 
| 137 |  |  | if ( calibex < 4 ) { | 
| 138 |  |  | printf("No full calibration data in this file!\n"); | 
| 139 |  |  | }; | 
| 140 |  |  | // | 
| 141 |  |  | return; | 
| 142 |  |  | } | 
| 143 |  |  |  |