| 1 | 
#include "TrkFunctions.cpp" | 
| 2 | 
#include <utils/yodaUtility.h> | 
| 3 | 
#include <TPaveText.h> | 
| 4 | 
#include <TLatex.h> | 
| 5 | 
#include <TCanvas.h> | 
| 6 | 
#include <TObjString.h> | 
| 7 | 
#include <TGraph.h> | 
| 8 | 
#include <PscuHeader.h> | 
| 9 | 
#include <EventHeader.h> | 
| 10 | 
#include <iostream> | 
| 11 | 
#include <fstream> | 
| 12 | 
#include <TStyle.h> | 
| 13 | 
#include <TString.h> | 
| 14 | 
#include <CalibTrk1Event.h> | 
| 15 | 
#include <CalibTrk2Event.h> | 
| 16 | 
 | 
| 17 | 
/** | 
| 18 | 
 * TrkCalibQLookExpert.cpp | 
| 19 | 
 * | 
| 20 | 
 * autor: D.Fedele | 
| 21 | 
 * version 1.0 | 
| 22 | 
 * Parameters: | 
| 23 | 
 *      base - the path to the root directory for the specific | 
| 24 | 
 *             Pamela unpack session | 
| 25 | 
 *      step - select =1 in order to analyse one event at time | 
| 26 | 
 *      fromevent - first event to analyse | 
| 27 | 
 *      toevent - last event to analyse | 
| 28 | 
 *      outdir - total path of output file  | 
| 29 | 
 *      outfile - extension of output file (pdf,ps,gif,jpg) | 
| 30 | 
 *  | 
| 31 | 
 */ | 
| 32 | 
 | 
| 33 | 
void TrkCalibQLook_EXPERT(TString file,Int_t step,Int_t fromevent, Int_t toevent,TString outdir,TString outfile) | 
| 34 | 
{   | 
| 35 | 
  //  | 
| 36 | 
  //   obtain information about the data file and select the output dir | 
| 37 | 
  const string filepath=file.Data();  | 
| 38 | 
  Int_t dwpos = filepath.find("DW_"); | 
| 39 | 
  Int_t dwpos1 = filepath.find(".root"); | 
| 40 | 
  TString fpath=(filepath.c_str()); | 
| 41 | 
  TString base,ffile; | 
| 42 | 
  stringcopy(base,fpath,0,dwpos); | 
| 43 | 
  stringcopy(ffile,fpath,dwpos,dwpos1); | 
| 44 | 
 | 
| 45 | 
  TString out; | 
| 46 | 
  if(outdir.Length()==0){ | 
| 47 | 
    out = base; | 
| 48 | 
  }else{ | 
| 49 | 
    out = outdir; | 
| 50 | 
  } | 
| 51 | 
 | 
| 52 | 
  // | 
| 53 | 
  // inizialise the variables and open the file | 
| 54 | 
  Int_t nevents=0; | 
| 55 | 
  Int_t minevent = 0; | 
| 56 | 
  Int_t maxevent = 0; | 
| 57 | 
  ULong64_t FOBT[2], HOBT=0, TOBT=0; | 
| 58 | 
   | 
| 59 | 
  FOBT[0]=0; | 
| 60 | 
  FOBT[1]=0; | 
| 61 | 
 | 
| 62 | 
  struct caltrk_def ctrk; | 
| 63 | 
  ctrk.good0[0]=0; | 
| 64 | 
  ctrk.good0[1]=0; | 
| 65 | 
  for(Int_t i=0;i<12;i++){  | 
| 66 | 
    ctrk.daqmode[i]=0; | 
| 67 | 
    ctrk.dspnum[i]=0; | 
| 68 | 
    ctrk.calibnum[i]=0; | 
| 69 | 
    ctrk.ncalev[i]=0; | 
| 70 | 
    ctrk.calfl[i]=0; | 
| 71 | 
    ctrk.ped1[i]=0; | 
| 72 | 
    ctrk.ped2[i]=0; | 
| 73 | 
    ctrk.ped3[i]=0; | 
| 74 | 
    ctrk.sig1[i]=0; | 
| 75 | 
    ctrk.sig2[i]=0; | 
| 76 | 
    ctrk.sig3[i]=0; | 
| 77 | 
    ctrk.nbad1[i]=0; | 
| 78 | 
    ctrk.nbad2[i]=0; | 
| 79 | 
    ctrk.nbad3[i]=0; | 
| 80 | 
    ctrk.crc_c[i][0]=0; | 
| 81 | 
    ctrk.crc_c[i][1]=0; | 
| 82 | 
    ctrk.crc_c[i][2]=0; | 
| 83 | 
    ctrk.crc_hc[i]=0; | 
| 84 | 
    for(Int_t iii=0;iii<3072;iii++){ | 
| 85 | 
      ctrk.dspped[i][iii]=0; | 
| 86 | 
      ctrk.dspsig[i][iii]=0; | 
| 87 | 
      ctrk.dspbad[i][iii]=0; | 
| 88 | 
    }; | 
| 89 | 
     | 
| 90 | 
  }; | 
| 91 | 
 | 
| 92 | 
  TFile *calibFile = new TFile(file); | 
| 93 | 
  if ( !calibFile ){ | 
| 94 | 
    printf("No data file, exiting...\n"); | 
| 95 | 
    return; | 
| 96 | 
  }; | 
| 97 | 
  TTree *otr1,*otr2,*hotr,*totr; | 
| 98 | 
  pamela::EventHeader *eh1=0,*eh2=0,*eh4=0,*eh3=0; | 
| 99 | 
  pamela::PscuHeader *ph=0; | 
| 100 | 
  pamela::CalibTrk1Event *trk1 = 0; | 
| 101 | 
  pamela::CalibTrk2Event *trk2 = 0;      | 
| 102 | 
   | 
| 103 | 
  hotr = (TTree*)calibFile->Get("CalibHeader"); | 
| 104 | 
  hotr->SetBranchAddress("Header", &eh4); | 
| 105 | 
   | 
| 106 | 
  totr = (TTree*)calibFile->Get("CalibTrailer"); | 
| 107 | 
  totr->SetBranchAddress("Header", &eh3); | 
| 108 | 
 | 
| 109 | 
  otr1 = (TTree*)calibFile->Get("CalibTrk1"); | 
| 110 | 
  otr1->SetBranchAddress("CalibTrk1", &trk1); | 
| 111 | 
  otr1->SetBranchAddress("Header",&eh1); | 
| 112 | 
  otr2 = (TTree*)calibFile->Get("CalibTrk2"); | 
| 113 | 
  otr2->SetBranchAddress("CalibTrk2", &trk2); | 
| 114 | 
  otr2->SetBranchAddress("Header",&eh2); | 
| 115 | 
     | 
| 116 | 
  if(otr1->GetEntries()==otr2->GetEntries()) | 
| 117 | 
    nevents = otr1->GetEntries(); | 
| 118 | 
  else{ | 
| 119 | 
    printf("WARNING: CalibTrk1 entries is different from CalibTrk2 entries"); | 
| 120 | 
    return;} | 
| 121 | 
  if (nevents<=0) { | 
| 122 | 
    calibFile->Close(); | 
| 123 | 
    printf("No calibration packets found, exiting...\n"); | 
| 124 | 
    return; | 
| 125 | 
  }; | 
| 126 | 
  //printf("Number of calibration packets: %i\n",nevents); | 
| 127 | 
 | 
| 128 | 
 | 
| 129 | 
  if ( fromevent > toevent && toevent ){ | 
| 130 | 
    printf("It must be fromevent < toevent \n"); | 
| 131 | 
    return; | 
| 132 | 
  }; | 
| 133 | 
     | 
| 134 | 
  if ( fromevent > nevents || fromevent < 0 ) { | 
| 135 | 
    printf("You can choose fromevent between 0 (all) and %i \n",nevents); | 
| 136 | 
    return; | 
| 137 | 
  }; | 
| 138 | 
     | 
| 139 | 
  if ( toevent > nevents || toevent < 0 ) { | 
| 140 | 
    printf("You can choose toevent between 0 (all) and %i \n",nevents); | 
| 141 | 
    return; | 
| 142 | 
  }; | 
| 143 | 
  if ( fromevent == 0 ) { | 
| 144 | 
    minevent = 0; | 
| 145 | 
    maxevent = nevents; | 
| 146 | 
  } else { | 
| 147 | 
    minevent = fromevent - 1; | 
| 148 | 
    if ( toevent > 0 ){ | 
| 149 | 
      maxevent = toevent; | 
| 150 | 
    } else if (toevent > nevents) {         | 
| 151 | 
      maxevent = nevents; | 
| 152 | 
    } else {        | 
| 153 | 
      maxevent = fromevent; | 
| 154 | 
    }; | 
| 155 | 
  }; | 
| 156 | 
     | 
| 157 | 
  //********************************************************************** | 
| 158 | 
  // | 
| 159 | 
  //   LOOP OVER EVENTS | 
| 160 | 
  // | 
| 161 | 
  //********************************************************************** | 
| 162 | 
     | 
| 163 | 
  //   printf("\n Scan of calibration packets from %i to %i ... \n\n",minevent+1,maxevent); | 
| 164 | 
  for (Int_t i = minevent; i < maxevent; i++){      | 
| 165 | 
      | 
| 166 | 
    otr1->GetEntry(i);  | 
| 167 | 
    otr2->GetEntry(i);  | 
| 168 | 
    totr->GetEntry(i); | 
| 169 | 
    hotr->GetEntry(i); | 
| 170 | 
    ph = eh4->GetPscuHeader(); | 
| 171 | 
    HOBT= ph->GetOrbitalTime(); | 
| 172 | 
    ph = eh3->GetPscuHeader(); | 
| 173 | 
    TOBT= ph->GetOrbitalTime(); | 
| 174 | 
       | 
| 175 | 
    ctrk.good0[0]=trk1->good0; | 
| 176 | 
    ctrk.good0[1]=trk2->good0; | 
| 177 | 
    for (Int_t m = 0; m < 6; m++){ | 
| 178 | 
      ph = eh1->GetPscuHeader(); | 
| 179 | 
      FOBT[0]= ph->GetOrbitalTime(); | 
| 180 | 
      ctrk.daqmode[trk1->DSPnumber[m]-1]=trk1->DAQmode[m]; | 
| 181 | 
      ctrk.dspnum[trk1->DSPnumber[m]-1]=trk1->DSPnumber[m]; | 
| 182 | 
      ctrk.calibnum[trk1->DSPnumber[m]-1]=trk1->calibnumber[m]; | 
| 183 | 
      ctrk.ncalev[trk1->DSPnumber[m]-1]=trk1->ncalib_event[m]; | 
| 184 | 
      ctrk.ped1[trk1->DSPnumber[m]-1]=trk1->ped_l1[m]; | 
| 185 | 
      ctrk.ped2[trk1->DSPnumber[m]-1]=trk1->ped_l2[m]; | 
| 186 | 
      ctrk.ped3[trk1->DSPnumber[m]-1]=trk1->ped_l3[m]; | 
| 187 | 
      ctrk.sig1[trk1->DSPnumber[m]-1]=trk1->sig_l1[m]; | 
| 188 | 
      ctrk.sig2[trk1->DSPnumber[m]-1]=trk1->sig_l2[m]; | 
| 189 | 
      ctrk.sig3[trk1->DSPnumber[m]-1]=trk1->sig_l3[m]; | 
| 190 | 
      ctrk.nbad1[trk1->DSPnumber[m]-1]=trk1->nbad_l1[m]; | 
| 191 | 
      ctrk.nbad2[trk1->DSPnumber[m]-1]=trk1->nbad_l2[m]; | 
| 192 | 
      ctrk.nbad3[trk1->DSPnumber[m]-1]=trk1->nbad_l3[m]; | 
| 193 | 
      ctrk.calfl[trk1->DSPnumber[m]-1]=trk1->cal_flag[m]; | 
| 194 | 
      ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk1->crc_cal[m][0]; | 
| 195 | 
      ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk1->crc_cal[m][1]; | 
| 196 | 
      ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk1->crc_cal[m][2]; | 
| 197 | 
      ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk1->crc_hcal[m]; | 
| 198 | 
      for (Int_t j = 0; j < 3072; j++){ | 
| 199 | 
        ctrk.dspped[trk1->DSPnumber[m]-1][j]=trk1->DSPped_par[m][j]; | 
| 200 | 
        ctrk.dspsig[trk1->DSPnumber[m]-1][j]=trk1->DSPsig_par[m][j]; | 
| 201 | 
        ctrk.dspbad[trk1->DSPnumber[m]-1][j]=trk1->DSPbad_par[m][j]; | 
| 202 | 
      }; | 
| 203 | 
      ph = eh2->GetPscuHeader(); | 
| 204 | 
      FOBT[1]= ph->GetOrbitalTime(); | 
| 205 | 
      ctrk.daqmode[trk2->DSPnumber[m]-1]=trk2->DAQmode[m]; | 
| 206 | 
      ctrk.dspnum[trk2->DSPnumber[m]-1]=trk2->DSPnumber[m]; | 
| 207 | 
      ctrk.calibnum[trk2->DSPnumber[m]-1]=trk2->calibnumber[m]; | 
| 208 | 
      ctrk.ncalev[trk2->DSPnumber[m]-1]=trk2->ncalib_event[m]; | 
| 209 | 
      ctrk.ped1[trk2->DSPnumber[m]-1]=trk2->ped_l1[m]; | 
| 210 | 
      ctrk.ped2[trk2->DSPnumber[m]-1]=trk2->ped_l2[m]; | 
| 211 | 
      ctrk.ped3[trk2->DSPnumber[m]-1]=trk2->ped_l3[m]; | 
| 212 | 
      ctrk.sig1[trk2->DSPnumber[m]-1]=trk2->sig_l1[m]; | 
| 213 | 
      ctrk.sig2[trk2->DSPnumber[m]-1]=trk2->sig_l2[m]; | 
| 214 | 
      ctrk.sig3[trk2->DSPnumber[m]-1]=trk2->sig_l3[m]; | 
| 215 | 
      ctrk.nbad1[trk2->DSPnumber[m]-1]=trk2->nbad_l1[m]; | 
| 216 | 
      ctrk.nbad2[trk2->DSPnumber[m]-1]=trk2->nbad_l2[m]; | 
| 217 | 
      ctrk.nbad3[trk2->DSPnumber[m]-1]=trk2->nbad_l3[m]; | 
| 218 | 
      ctrk.calfl[trk2->DSPnumber[m]-1]=trk2->cal_flag[m]; | 
| 219 | 
      ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk2->crc_cal[m][0]; | 
| 220 | 
      ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk2->crc_cal[m][1]; | 
| 221 | 
      ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk2->crc_cal[m][2]; | 
| 222 | 
      ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk2->crc_hcal[m]; | 
| 223 | 
      for (Int_t j = 0; j < 3072; j++){ | 
| 224 | 
        ctrk.dspped[trk2->DSPnumber[m]-1][j]=trk2->DSPped_par[m][j]; | 
| 225 | 
        ctrk.dspsig[trk2->DSPnumber[m]-1][j]=trk2->DSPsig_par[m][j]; | 
| 226 | 
        ctrk.dspbad[trk2->DSPnumber[m]-1][j]=trk2->DSPbad_par[m][j]; | 
| 227 | 
      }; | 
| 228 | 
    }; | 
| 229 | 
               | 
| 230 | 
 | 
| 231 | 
    // | 
| 232 | 
    // other variables definitions | 
| 233 | 
    Int_t risposta=0; | 
| 234 | 
    stringstream fromfile; | 
| 235 | 
 | 
| 236 | 
    fromfile<<"TrkCalibQLookExpert      File: "<<ffile<<"        -- CalibHeader OBT= "<<HOBT<<" -- Calib pkt OBT= "<<FOBT[0]<<" -- CalibTrailer OBT= "<<TOBT<<" --"; | 
| 237 | 
     | 
| 238 | 
    gStyle->SetLabelSize(0.08,"x"); | 
| 239 | 
    gStyle->SetLabelSize(0.08,"y"); | 
| 240 | 
    gStyle->SetTitleFillColor(10);  | 
| 241 | 
    gStyle->SetTitleFontSize(0.1); | 
| 242 | 
    gStyle->SetTitleOffset(0.8,"y"); | 
| 243 | 
    gStyle->SetTitleOffset(1.,"x"); | 
| 244 | 
    gStyle->SetTitleSize(0.06,"y"); | 
| 245 | 
    gStyle->SetTitleSize(0.06,"x"); | 
| 246 | 
    gStyle->SetOptStat(0); | 
| 247 | 
     | 
| 248 | 
    // | 
| 249 | 
    //  draw display area | 
| 250 | 
    TLatex *tzz=new TLatex(); | 
| 251 | 
    tzz->SetTextFont(32); | 
| 252 | 
    tzz->SetTextColor(1); | 
| 253 | 
    tzz->SetTextAlign(12); | 
| 254 | 
    tzz->SetTextSize(0.019); | 
| 255 | 
    Int_t canvasx=1200; | 
| 256 | 
    Int_t canvasy=900; | 
| 257 | 
    TCanvas *c1 = new TCanvas("c1","TrkCalibQLook_EXPERT_ped",canvasx,canvasy); | 
| 258 | 
    c1->SetFillColor(10); | 
| 259 | 
    tzz->DrawLatex(.01,0.98,fromfile.str().c_str()); | 
| 260 | 
    tzz->DrawLatex(.90,0.98,"PEDESTAL"); | 
| 261 | 
    TCanvas *c2 = new TCanvas("c2","TrkCalibQLook_EXPERT_sig",canvasx,canvasy); | 
| 262 | 
    c2->SetFillColor(10); | 
| 263 | 
    tzz->DrawLatex(.01,0.98,fromfile.str().c_str()); | 
| 264 | 
    tzz->DrawLatex(.90,0.98,"SIGMA"); | 
| 265 | 
 | 
| 266 | 
    //  draw pads | 
| 267 | 
    TPad *trkpad1[12],*trkpad2[12];        //pad for histos | 
| 268 | 
    TPaveText *trkpadtext[12]; //pad for header | 
| 269 | 
    TH1F *histosig[12];           //histos of sigma  | 
| 270 | 
    TH1F *histoped[12];          //histos of pedestals   | 
| 271 | 
    TH1F *histoasig[12];           //histos of sigma  | 
| 272 | 
    TH1F *histoaped[12];          //histos of pedestals | 
| 273 | 
     | 
| 274 | 
    Double_t posy = 0.95;    // up y-coord - top pads | 
| 275 | 
    Double_t hpad = 0.15;   // pad height | 
| 276 | 
    Double_t posx1=0;          // left  x-coord - pad column | 
| 277 | 
    Double_t posx2=0;          // right x-coord - pad olumn | 
| 278 | 
    Double_t posx0=0;          //       x-coord - column division | 
| 279 | 
    Double_t wrel = 0.6;     // relative x size of first sub-column | 
| 280 | 
    Double_t marg = 0.004;   // margin among pads | 
| 281 | 
    stringstream title; | 
| 282 | 
    stringstream hid; | 
| 283 | 
 | 
| 284 | 
    for(Int_t n = 0; n<12; n++){ | 
| 285 | 
      if ( (n+1)%2 ) { | 
| 286 | 
        if(n>1)posy = posy-(marg*2+hpad); | 
| 287 | 
        posx1 = marg; | 
| 288 | 
        posx2 = 0.5 - marg; | 
| 289 | 
        posx0 = 0.5*wrel; | 
| 290 | 
      } else { | 
| 291 | 
        posx1 = posx1 + 0.5; | 
| 292 | 
        posx2 = posx2 + 0.5; | 
| 293 | 
        posx0 = posx0 + 0.5; | 
| 294 | 
      }; | 
| 295 | 
      /* -----------> pad for histograms  */ | 
| 296 | 
      trkpad1[n] = new TPad("pad1"," ",posx1,posy-hpad,posx0-marg,posy,18,0,0); | 
| 297 | 
      trkpad2[n] = new TPad("pad2"," ",posx1,posy-hpad,posx0-marg,posy,18,0,0); | 
| 298 | 
      /* -----------> pad for header dump */ | 
| 299 | 
      trkpadtext[n] = new TPaveText((posx0+marg),(posy-hpad),posx2,posy); | 
| 300 | 
      /* -----------> HISTOGRAMS          */ | 
| 301 | 
      /* calibration parameters */ | 
| 302 | 
      title<<"DSP "<<n+1; | 
| 303 | 
      hid<<"h"<<n; | 
| 304 | 
      histosig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); | 
| 305 | 
      hid.str(""); | 
| 306 | 
      hid<<"hh"<<n; | 
| 307 | 
      histoped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); | 
| 308 | 
      hid.str(""); | 
| 309 | 
      hid<<"hhh"<<n; | 
| 310 | 
      title.str(""); | 
| 311 | 
      hid.str(""); | 
| 312 | 
      /* AVERAGE calibration parameters */     | 
| 313 | 
      hid<<"ah"<<n; | 
| 314 | 
      histoasig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); | 
| 315 | 
      hid.str(""); | 
| 316 | 
      hid<<"ahh"<<n; | 
| 317 | 
      histoaped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); | 
| 318 | 
      hid.str(""); | 
| 319 | 
    };                     //end loop on views | 
| 320 | 
 | 
| 321 | 
 | 
| 322 | 
    stringstream message; | 
| 323 | 
 | 
| 324 | 
    //-------------------------------- | 
| 325 | 
    //CHECK CALIBRATION procedure | 
| 326 | 
    //-------------------------------- | 
| 327 | 
    Int_t nn=0; | 
| 328 | 
    Int_t calok = 0;//BAD   | 
| 329 | 
    for(Int_t n = 0; n<12; n++){ | 
| 330 | 
      if(ctrk.ncalev[n]==0 && ctrk.calfl[n]==0)calok = 1;//GOOD | 
| 331 | 
    | 
| 332 | 
       | 
| 333 | 
      nn=ctrk.dspnum[n]-1; | 
| 334 | 
      /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* | 
| 335 | 
       * | 
| 336 | 
       * Write event LEVEL0 report | 
| 337 | 
       * | 
| 338 | 
       *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/ | 
| 339 | 
      trkpadtext[nn]->SetTextFont(40); | 
| 340 | 
      trkpadtext[nn]->SetFillColor(33); | 
| 341 | 
      if(calok==0)trkpadtext[nn]->SetFillColor(2); | 
| 342 | 
      trkpadtext[nn]->SetTextSize(0.013); | 
| 343 | 
      trkpadtext[nn]->SetTextAlign(13); | 
| 344 | 
      trkpadtext[nn]->SetTextColor(1); | 
| 345 | 
       | 
| 346 | 
      trkpadtext[nn]->AddText(" "); | 
| 347 | 
      message<<"DSP num -------->  "<<ctrk.dspnum[n]; | 
| 348 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 349 | 
      message.str(""); | 
| 350 | 
      message<<"DAQ mode -------> "<<ctrk.daqmode[n]; | 
| 351 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 352 | 
      message.str(""); | 
| 353 | 
      message<<"Calibnumber ----> "<<ctrk.calibnum[n]; | 
| 354 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 355 | 
      message.str(""); | 
| 356 | 
      message<<"ncalib_event ---> "<<ctrk.ncalev[n]; | 
| 357 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 358 | 
      message.str(""); | 
| 359 | 
      message<<"Cal_flag -------> "<<ctrk.calfl[n]; | 
| 360 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 361 | 
      message.str(""); | 
| 362 | 
      message<<"crc_hcal -------> "<<ctrk.crc_hc[n]; | 
| 363 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 364 | 
      message.str(""); | 
| 365 | 
      message<<"crc_cal: l1-  ";message.width(5);message<< ctrk.crc_c[n][0]; | 
| 366 | 
      message<<"       l2-  ";message.width(5);message<< ctrk.crc_c[n][1]; | 
| 367 | 
      message<<"       l3-  ";message.width(5);message<< ctrk.crc_c[n][2]; | 
| 368 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 369 | 
      message.str(""); | 
| 370 | 
      message<<"<PED>: l1- "; message.width(5);message<< ctrk.ped1[n]; | 
| 371 | 
      message<<"     l2-";        message.width(5);message<< ctrk.ped2[n]; | 
| 372 | 
      message<<"     l3-";        message.width(5);message<< ctrk.ped3[n]; | 
| 373 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 374 | 
      message.str(""); | 
| 375 | 
      message<<"<SIG>: l1- "; message.width(5);message<< ctrk.sig1[n]; | 
| 376 | 
      message<<"     l2-";        message.width(5);message<< ctrk.sig2[n]; | 
| 377 | 
      message<<"     l3-";        message.width(5);message<< ctrk.sig3[n]; | 
| 378 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 379 | 
      message.str(""); | 
| 380 | 
      message<<"n.BAD: l1- "; message.width(5);message<<ctrk.nbad1[n]; | 
| 381 | 
      message<<"     l2-";        message.width(5);message<< ctrk.nbad2[n]; | 
| 382 | 
      message<<"     l3-";        message.width(5);message<< ctrk.nbad3[n]; | 
| 383 | 
      //    cout << message.str()<< endl; | 
| 384 | 
      trkpadtext[nn]->AddText(message.str().c_str()); | 
| 385 | 
      message.str(""); | 
| 386 | 
       | 
| 387 | 
      if(calok==0){ | 
| 388 | 
         | 
| 389 | 
        message.str("*** FAILED ***"); | 
| 390 | 
        TText *t=trkpadtext[nn]->AddText(message.str().c_str());             | 
| 391 | 
        t->SetTextSize(0.02); | 
| 392 | 
        t->SetTextAlign(23); | 
| 393 | 
        t->SetTextColor(5); | 
| 394 | 
      }; | 
| 395 | 
       | 
| 396 | 
      /*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* | 
| 397 | 
       * | 
| 398 | 
       * Plot  histo | 
| 399 | 
       * | 
| 400 | 
       *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*/ | 
| 401 | 
 | 
| 402 | 
       | 
| 403 | 
      /******************************************************/ | 
| 404 | 
      /* fill histos */ | 
| 405 | 
      for(Int_t j = 0; j < 3072; j++){ | 
| 406 | 
        histosig[nn]->Fill((Float_t)j,ctrk.dspsig[nn][j]); | 
| 407 | 
        histoped[nn]->Fill((Float_t)j,ctrk.dspped[nn][j]); | 
| 408 | 
      }; | 
| 409 | 
      histoasig[nn]->Fill(1,ctrk.sig1[nn]); | 
| 410 | 
      histoasig[nn]->Fill(1025,ctrk.sig2[nn]); | 
| 411 | 
      histoasig[nn]->Fill(2049,ctrk.sig3[nn]); | 
| 412 | 
      histoaped[nn]->Fill(1,ctrk.ped1[nn]); | 
| 413 | 
      histoaped[nn]->Fill(1025,ctrk.ped2[nn]); | 
| 414 | 
      histoaped[nn]->Fill(2049,ctrk.ped3[nn]); | 
| 415 | 
      /******************************************************/ | 
| 416 | 
       | 
| 417 | 
      TLine li; | 
| 418 | 
      li.SetLineColor(38); | 
| 419 | 
      li.SetLineStyle(3); | 
| 420 | 
      li.SetLineWidth(2); | 
| 421 | 
       | 
| 422 | 
       | 
| 423 | 
      /* plot PEDESTAL */ | 
| 424 | 
      c1->cd(); | 
| 425 | 
      trkpadtext[nn]->Draw(); | 
| 426 | 
      trkpad1[nn]->Draw(); | 
| 427 | 
      trkpad1[nn]->cd(); | 
| 428 | 
      trkpad1[nn]->SetFillColor(10); | 
| 429 | 
      trkpad1[nn]->SetFrameFillColor(10); | 
| 430 | 
      histoped[nn]->SetLineColor(1); | 
| 431 | 
      histoped[nn]->SetFillColor(12); | 
| 432 | 
      histoped[nn]->SetLineWidth(1); | 
| 433 | 
      histoped[nn]->GetYaxis()->SetTitle("PED (ADC channels)"); | 
| 434 | 
      histoped[nn]->GetYaxis()->CenterTitle(); | 
| 435 | 
      if((nn+1)%2==1)  histoped[nn]->GetYaxis()->SetRangeUser(2500,3200); | 
| 436 | 
      if((nn+1)%2==0)  histoped[nn]->GetYaxis()->SetRangeUser(1000,1700); | 
| 437 | 
      histoaped[nn]->SetLineColor(5); | 
| 438 | 
      histoaped[nn]->SetLineWidth(1); | 
| 439 | 
      if(ctrk.good0[0]==1 && ctrk.good0[1]==1) histoped[nn]->Draw("b"); | 
| 440 | 
      else histoped[nn]->Draw("axis"); | 
| 441 | 
      histoaped[nn]->Draw("same"); | 
| 442 | 
      if((nn+1)%2==1) { | 
| 443 | 
        li.DrawLine(1024.5,2500,1024.5,3200); | 
| 444 | 
        li.DrawLine(2048.5,2500,2048.5,3200); | 
| 445 | 
      } | 
| 446 | 
      if((nn+1)%2==0) { | 
| 447 | 
        li.DrawLine(1024.5,1000,1024.5,1700); | 
| 448 | 
        li.DrawLine(2048.5,1000,2048.5,1700); | 
| 449 | 
      } | 
| 450 | 
       | 
| 451 | 
       | 
| 452 | 
      /* plot SIGMA */ | 
| 453 | 
      Double_t max=500.; | 
| 454 | 
      c2->cd(); | 
| 455 | 
      trkpadtext[nn]->Draw(); | 
| 456 | 
      trkpad2[nn]->SetLogy(); | 
| 457 | 
      trkpad2[nn]->Draw(); | 
| 458 | 
      trkpad2[nn]->cd(); | 
| 459 | 
      trkpad2[nn]->SetFillColor(10); | 
| 460 | 
      trkpad2[nn]->SetFrameFillColor(10); | 
| 461 | 
      histosig[nn]->SetLineColor(1); | 
| 462 | 
      histosig[nn]->SetFillColor(12); | 
| 463 | 
      histosig[nn]->SetLineWidth(1); | 
| 464 | 
      histosig[nn]->SetMaximum(max); | 
| 465 | 
      histosig[nn]->SetMinimum(0.5); | 
| 466 | 
      histosig[nn]->GetYaxis()->SetTitle("SIG (ADC channels)"); | 
| 467 | 
      histosig[nn]->GetYaxis()->CenterTitle(); | 
| 468 | 
      histoasig[nn]->SetLineColor(5); | 
| 469 | 
      histoasig[nn]->SetLineWidth(1); | 
| 470 | 
      if(ctrk.good0[0]==1 && ctrk.good0[1]==1) histosig[nn]->Draw("b");  | 
| 471 | 
      else histosig[nn]->Draw("axis"); | 
| 472 | 
      histoasig[nn]->Draw("same"); | 
| 473 | 
      li.DrawLine(1024.5,0,1024.5,max); | 
| 474 | 
      li.DrawLine(2048.5,0,2048.5,max); | 
| 475 | 
         | 
| 476 | 
    };//end loop on views | 
| 477 | 
     | 
| 478 | 
    c1->Update();//draw pads in canvas  | 
| 479 | 
    c2->Update();//draw pads in canvas | 
| 480 | 
 | 
| 481 | 
    stringstream nom1; | 
| 482 | 
    stringstream nom2; | 
| 483 | 
   | 
| 484 | 
    if(!strcmp(outfile.Data(),"ps")||!strcmp(outfile.Data(),"pdf")){ | 
| 485 | 
      nom1.str(""); | 
| 486 | 
      nom2.str(""); | 
| 487 | 
      nom1<<out<<ffile<<"_TrkCalibQLook_EXPERT-pkt"<<i+1<<".ps("; | 
| 488 | 
      nom2<<out<<ffile<<"_TrkCalibQLook_EXPERT-pkt"<<i+1<<".ps)"; | 
| 489 | 
      c1->Print(nom1.str().c_str(),"Landscape"); | 
| 490 | 
      c2->Print(nom2.str().c_str(),"Landscape"); | 
| 491 | 
      if(!strcmp(outfile.Data(),"pdf")){ | 
| 492 | 
        stringstream com; | 
| 493 | 
        com<<"ps2pdf13 "<<out<<ffile<<"_TrkCalibQLook_EXPERT-pkt"<<i+1<<".ps "<<out<<ffile<<"_TrkCalibQlook_EXPERT-pkt"<<i+1<<".pdf"; | 
| 494 | 
        system(com.str().c_str()); | 
| 495 | 
        com.str(""); | 
| 496 | 
        com<<"rm -f "<<out<<ffile<<"_TrkCalibQLook_EXPERT-pkt"<<i+1<<".ps"; | 
| 497 | 
        system(com.str().c_str()); | 
| 498 | 
        com.str(""); | 
| 499 | 
      } | 
| 500 | 
    } | 
| 501 | 
    else{ | 
| 502 | 
      nom1.str(""); | 
| 503 | 
      nom2.str(""); | 
| 504 | 
      nom1<<out<<ffile<<"_TrkCalibQLook_EXPERT-ped-pkt"<<i+1<<"."<<outfile.Data(); | 
| 505 | 
      nom2<<out<<ffile<<"_TrkCalibQLook_EXPERT-sig-pkt"<<i+1<<"."<<outfile.Data(); | 
| 506 | 
      c1->Print(nom1.str().c_str()); | 
| 507 | 
      c2->Print(nom2.str().c_str()); | 
| 508 | 
    }  | 
| 509 | 
   | 
| 510 | 
    delete c1; | 
| 511 | 
    delete c2; | 
| 512 | 
    for(Int_t j=0;j<12;j++){ | 
| 513 | 
      delete histosig[j];  | 
| 514 | 
      delete histoped[j]; | 
| 515 | 
      delete histoasig[j];  | 
| 516 | 
      delete histoaped[j]; | 
| 517 | 
      delete trkpadtext[j]; | 
| 518 | 
    } | 
| 519 | 
     | 
| 520 | 
    if(step==1 && i!=maxevent-1 ){   | 
| 521 | 
      printf("\n Press 1<enter> to continue, 2<enter> to quit.\n"); | 
| 522 | 
      cin>>risposta; | 
| 523 | 
      if ( i != maxevent-1 ) { | 
| 524 | 
        if ( risposta == 2 ) { | 
| 525 | 
          gROOT->Reset(); | 
| 526 | 
          //      printf("Exiting...\n"); | 
| 527 | 
          return; | 
| 528 | 
        } | 
| 529 | 
      } | 
| 530 | 
    } | 
| 531 | 
  };//end loop on events | 
| 532 | 
  calibFile->Close();    | 
| 533 | 
   | 
| 534 | 
  gROOT->Reset(); | 
| 535 | 
  //   printf("... end of packets. \n"); | 
| 536 | 
  return; | 
| 537 | 
} | 
| 538 | 
 | 
| 539 | 
 |