/[PAMELA software]/calo/flight/FQLOOK/macros/FCaloQLOOK.cxx
ViewVC logotype

Diff of /calo/flight/FQLOOK/macros/FCaloQLOOK.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mocchiut, Mon Mar 20 13:40:44 2006 UTC revision 1.9 by mocchiut, Mon May 29 09:38:26 2006 UTC
# Line 1  Line 1 
1  //  //
2  //   Check for possible errors and shows raw distribution of variables coming from the DSP (no calibrations needed) - Emiliano Mocchiutti  //   Check for possible errors and shows raw distribution of variables coming from the DSP (no calibrations needed) - Emiliano Mocchiutti
3  //  //
4  //   FCaloQLOOK.c      version 1.04  (2006-03-20)  //   FCaloQLOOK.c      version 1.08  (2006-05-29)
5  //  //
6  //   The only input needed is the path to the directory created by YODA for the data file you want to analyze.  //   The only input needed is the path to the directory created by YODA for the data file you want to analyze.
7  //  //
8  //   Changelog:  //   Changelog:
9  //  //
10    //   1.07 - 1.08 (2006-05-29): Fixed bug in output filename when input is not in the form DW_YYMMDD_NNN.
11    //
12    //   1.06 - 1.07 (2006-05-23): Don't print warning in case of latchup not recognized from the status word, fixed. Added "expert" figures from 21 to 28 which appears only in the
13    //                             case of latchup alarm.
14    //
15    //   1.05 - 1.06 (2006-03-22): Add optimize flag in compiling the script!
16    //
17    //   1.04 - 1.05 (2006-03-22): Corrected wrong .C files.
18    //
19  //   1.03 - 1.04 (2006-03-20): Documentation updated.  //   1.03 - 1.04 (2006-03-20): Documentation updated.
20  //  //
21  //   1.02 - 1.03 (2006-03-20): Changed name of shared libraries (from FCaloQLOOK_cxx.so to libFCaloQLOOK.so).  //   1.02 - 1.03 (2006-03-20): Changed name of shared libraries (from FCaloQLOOK_cxx.so to libFCaloQLOOK.so).
# Line 58  void stringappend(TString& s1, const TSt Line 67  void stringappend(TString& s1, const TSt
67  }  }
68    
69  TString getFilename(const TString filename){  TString getFilename(const TString filename){
70    const string fil = (const char*)filename;    //
71    Int_t posiz = fil.find("dw_");    const string fil = gSystem->BaseName(filename.Data());
72    if ( posiz == -1 ) posiz = fil.find("DW_");    Int_t posiz = fil.find(".root");
73    if ( posiz == -1 ) return 0;    //
   Int_t posiz2 = posiz+13;  
74    TString file2;    TString file2;
75    stringcopy(file2,filename,posiz,posiz2);    if ( posiz == -1 ){
76    TString pdat(".dat");      file2 = gSystem->BaseName(filename.Data());
77    stringappend(file2,pdat);    } else {
78        Int_t posiz2 = 0;
79        stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz);
80        TString pdat(".dat");
81        stringappend(file2,pdat);  
82      };
83    return file2;    return file2;
84  }  }
85    
86  void FCaloQLOOK(TString filename, Int_t fromevent=0, Int_t toevent=0, TString outDir="", TString saveas = "ps"){  void FCaloQLOOK(TString filename, Int_t fromevent=0, Int_t toevent=0, TString outDir="", TString saveas = "ps"){
87    gStyle->SetPaperSize(19.,25.);    gStyle->SetPaperSize(19.,25.);
88    const char* startingdir = gSystem->WorkingDirectory();    const char* startingdir = gSystem->WorkingDirectory();
89      //  printf(" basename is %s \n",gSystem->BaseName(filename.Data()));
90      //  printf(" getfilename is %s \n",getFilename(filename).Data());
91    if ( !strcmp(outDir.Data(),"") ) outDir = startingdir;    if ( !strcmp(outDir.Data(),"") ) outDir = startingdir;
92    //    //
93    //    //
# Line 172  void FCaloQLOOK(TString filename, Int_t Line 187  void FCaloQLOOK(TString filename, Int_t
187    TH1F *calev01;    TH1F *calev01;
188    TH1F *calev23;    TH1F *calev23;
189    TH1F *calev03;    TH1F *calev03;
190      TH1F *lupstw[4];
191      TH1F *lup[4];
192    TH2D *calev2;    TH2D *calev2;
193    
194    h1 = new TH1F("C7","Strips hit, compress mode",100,0.,200.);    h1 = new TH1F("C7","Strips hit, compress mode",100,0.,200.);
# Line 194  void FCaloQLOOK(TString filename, Int_t Line 211  void FCaloQLOOK(TString filename, Int_t
211    calev03->SetBit(TH1F::kCanRebin);    calev03->SetBit(TH1F::kCanRebin);
212    calev2 = new TH2D("C2","calevnum(2)%iev",3000,0.,2.,100,0.,2.);    calev2 = new TH2D("C2","calevnum(2)%iev",3000,0.,2.,100,0.,2.);
213    calev2->SetBit(TH2D::kCanRebin);    calev2->SetBit(TH2D::kCanRebin);
214        
215      stringstream oss;
216      stringstream noss;
217      for ( Int_t i=0; i<4; i++){
218        oss.str("");
219        oss << "OBT stw latch up section " << i;
220        noss.str("");
221        noss << "C" << 21+i;
222        lupstw[i] = new TH1F(noss.str().c_str(),oss.str().c_str(),100,-1,1);
223        lupstw[i]->SetBit(TH1F::kCanRebin);
224        oss.str("");
225        oss << "OBT no stw latch up section " << i;
226        noss.str("");
227        noss << "C" << 25+i;
228        lup[i] = new TH1F(noss.str().c_str(),oss.str().c_str(),100,-1,1);
229        lup[i]->SetBit(TH1F::kCanRebin);
230      };
231    
232    //    //
233    // run over each event and take out some variables    // run over each event and take out some variables
234    //    //
# Line 285  void FCaloQLOOK(TString filename, Int_t Line 319  void FCaloQLOOK(TString filename, Int_t
319    Int_t outdexy = 0;    Int_t outdexy = 0;
320    Int_t indexyc = 0;    Int_t indexyc = 0;
321    Int_t outdexyc = 0;    Int_t outdexyc = 0;
322      Int_t obt = 0;
323      Int_t minobt[4];
324      Int_t maxobt[4];
325      Int_t swminobt[4];
326      Int_t swmaxobt[4];
327      Bool_t firstobt[4];
328      Bool_t swfirstobt[4];
329      for ( Int_t i = 0; i<4; i++){
330        minobt[i] = 0;
331        maxobt[i] = 0;
332        swminobt[i] = 0;
333        swmaxobt[i] = 0;
334        firstobt[i] = true;
335        swfirstobt[i] = true;
336      };
337    while ( i < maxevent+1){    while ( i < maxevent+1){
338      tshit = 0;      tshit = 0;
339      trshit = 0;      trshit = 0;
# Line 294  void FCaloQLOOK(TString filename, Int_t Line 343  void FCaloQLOOK(TString filename, Int_t
343      ph = eh->GetPscuHeader();      ph = eh->GetPscuHeader();
344      headco = headc;      headco = headc;
345      headc = ph->GetCounter();      headc = ph->GetCounter();
346        obt = ph->GetOrbitalTime();
347      calevn1 += (int)abs((int)(ce->calevnum[0]-ce->calevnum[1]));      calevn1 += (int)abs((int)(ce->calevnum[0]-ce->calevnum[1]));
348      calevn2 += (int)abs((int)(ce->calevnum[2]-ce->calevnum[3]));      calevn2 += (int)abs((int)(ce->calevnum[2]-ce->calevnum[3]));
349      calevn3 += (int)abs((int)(ce->calevnum[0]-ce->calevnum[3]));      calevn3 += (int)abs((int)(ce->calevnum[0]-ce->calevnum[3]));
# Line 397  void FCaloQLOOK(TString filename, Int_t Line 447  void FCaloQLOOK(TString filename, Int_t
447                if ( (ce->base[l][ii][bl]>32000 || ce->base[l][ii][bl] == 0 ) && ( alldexy > 512000 ||  alldexy == 0) && ce->perror[se] == 0 ) {                if ( (ce->base[l][ii][bl]>32000 || ce->base[l][ii][bl] == 0 ) && ( alldexy > 512000 ||  alldexy == 0) && ce->perror[se] == 0 ) {
448                  pdone = 1;                  pdone = 1;
449                  pshit[se][pl]++ ;                  pshit[se][pl]++ ;
450                  if ( (ce->stwerr[se] & (1 << 4)) == 0 ) lalarm[se]++;                  if ( (ce->stwerr[se] & (1 << 4)) == 0 ) {
451                  lver[se][2]++ ;                    lalarm[se]++;
452                      lup[se]->Fill(obt);
453                      if ( firstobt[se] ) minobt[se] = obt;
454                      if ( obt > maxobt[se] ) maxobt[se] = obt;
455                    };
456                    lver[se][2]++ ;        
457                };                };
458              }              }
459              //              //
# Line 460  void FCaloQLOOK(TString filename, Int_t Line 515  void FCaloQLOOK(TString filename, Int_t
515                if ( (alldexy2>512000 || alldexy2 == 0) && ce->perror[se] == 0 ) {                if ( (alldexy2>512000 || alldexy2 == 0) && ce->perror[se] == 0 ) {
516                  pdone = 1;                  pdone = 1;
517                  pshit[se][pl]++ ;                                          pshit[se][pl]++ ;                        
518                  if ( (ce->stwerr[se] & (1 << 4)) == 0 ) lalarm[se]++;                  if ( (ce->stwerr[se] & (1 << 4)) == 0 ){
519                      lalarm[se]++;
520                      lup[se]->Fill(obt);
521                      if ( firstobt[se] ) minobt[se] = obt;
522                      if ( obt > maxobt[se] ) maxobt[se] = obt;
523                    };
524                  lver[se][2]++ ;                  lver[se][2]++ ;
525                };                };
526              };              };
# Line 494  void FCaloQLOOK(TString filename, Int_t Line 554  void FCaloQLOOK(TString filename, Int_t
554          if ( cestw & (1 << 1) ) ver[k][5]++ ;          if ( cestw & (1 << 1) ) ver[k][5]++ ;
555          if ( cestw & (1 << 2) ) ver[k][4]++ ;          if ( cestw & (1 << 2) ) ver[k][4]++ ;
556          if ( cestw & (1 << 3) ) ver[k][3]++ ;          if ( cestw & (1 << 3) ) ver[k][3]++ ;
557          if ( cestw & (1 << 4) ) ver[k][2]++ ;          if ( cestw & (1 << 4) ){
558              ver[k][2]++ ;
559              lupstw[k]->Fill(obt);
560              if ( swfirstobt[k] ) swminobt[k] = obt;
561              if ( obt > swmaxobt[k] ) swmaxobt[k] = obt;
562            };
563          if ( cestw & (1 << 5) ) ver[k][1]++ ;          if ( cestw & (1 << 5) ) ver[k][1]++ ;
564          if ( cestw & (1 << 6) ) ver[k][0]++ ;                    if ( cestw & (1 << 6) ) ver[k][0]++ ;          
565        };        };
# Line 559  void FCaloQLOOK(TString filename, Int_t Line 624  void FCaloQLOOK(TString filename, Int_t
624    t->DrawLatex(2.,99.,errore.str().c_str());    t->DrawLatex(2.,99.,errore.str().c_str());
625    TPad *pd5;    TPad *pd5;
626    TPad *pd6;    TPad *pd6;
627      TPad *pd7;
628      TPad *pd8;
629    TPad *pad1;    TPad *pad1;
630    TPad *pad2;    TPad *pad2;
631    TPad *pad3;    TPad *pad3;
# Line 945  void FCaloQLOOK(TString filename, Int_t Line 1012  void FCaloQLOOK(TString filename, Int_t
1012      Dexy->Draw("SAME");      Dexy->Draw("SAME");
1013    };      };  
1014    //    //
1015      TCanvas *figura3 = 0;
1016      Bool_t printfigure3 = false;
1017      for (Int_t i = 0; i<4; i++){
1018        if ( ver[i][2] || lver[i][2] ){
1019          printfigure3 = true;
1020          break;
1021        };
1022      };
1023      if ( printfigure3 ){
1024        figura3 = new TCanvas("Calorimeter_Detector_Report_2bis/3","Calorimeter_Detector_Report_2bis/3", 1100, 900);
1025        figura3->SetFillColor(10);
1026        figura3->Range(0,0,100,100);
1027        errore.str("");
1028        errore << "EXPERT  --  File: " << file;
1029        errore << " ";
1030        t=new TLatex();
1031        t->SetTextFont(32);
1032        t->SetTextColor(1);
1033        t->SetTextAlign(12);
1034        t->SetTextSize(0.015);
1035        t->DrawLatex(2.,99.,errore.str().c_str());
1036        pd1 = new TPad("pd1","This is pad1",0.02,0.51,0.49,0.73,45);
1037        pd5 = new TPad("pd5","This is pad5",0.02,0.76,0.49,0.98,45);
1038        pd2 = new TPad("pd2","This is pad2",0.51,0.51,0.98,0.73,45);
1039        pd6 = new TPad("pd6","This is pad6",0.51,0.76,0.98,0.98,45);
1040        pd3 = new TPad("pd3","This is pad3",0.02,0.02,0.49,0.23,45);
1041        pd7 = new TPad("pd7","This is pad7",0.02,0.26,0.49,0.49,45);
1042        pd4 = new TPad("pd4","This is pad4",0.51,0.02,0.98,0.23,45);
1043        pd8 = new TPad("pd8","This is pad8",0.51,0.26,0.98,0.49,45);
1044        figura3->cd();
1045        pd1->Range(0,0,100,100);
1046        pd2->Range(0,0,100,100);
1047        pd3->Range(0,0,100,100);
1048        pd4->Range(0,0,100,100);      
1049        pd1->SetTicks();
1050        pd2->SetTicks();
1051        pd3->SetTicks();
1052        pd4->SetTicks();
1053        pd1->Draw();
1054        pd2->Draw();
1055        pd3->Draw();
1056        pd4->Draw();
1057        pd5->Range(0,0,100,100);
1058        pd6->Range(0,0,100,100);
1059        pd7->Range(0,0,100,100);
1060        pd8->Range(0,0,100,100);      
1061        pd5->SetTicks();
1062        pd6->SetTicks();
1063        pd7->SetTicks();
1064        pd8->SetTicks();
1065        pd5->Draw();
1066        pd6->Draw();
1067        pd7->Draw();
1068        pd8->Draw();
1069        pd1->cd();
1070        lup[0]->SetAxisRange((Double_t)minobt[0]*0.9,(Double_t)maxobt[0]*1.1,"X");
1071        lup[0]->Draw();
1072        pd5->cd();
1073        lupstw[0]->SetAxisRange((Double_t)swminobt[0]*0.9,(Double_t)swmaxobt[0]*1.1,"X");
1074        lupstw[0]->Draw();
1075        pd2->cd();
1076        lup[1]->SetAxisRange((Double_t)minobt[1]*0.9,(Double_t)maxobt[1]*1.1,"X");
1077        lup[1]->Draw();
1078        pd6->cd();
1079        lupstw[1]->SetAxisRange((Double_t)swminobt[1]*0.9,(Double_t)swmaxobt[1]*1.1,"X");
1080        lupstw[1]->Draw();
1081        pd3->cd();
1082        lup[2]->SetAxisRange((Double_t)minobt[2]*0.9,(Double_t)maxobt[2]*1.1,"X");
1083        lup[2]->Draw();
1084        pd7->cd();
1085        lupstw[2]->SetAxisRange((Double_t)swminobt[2]*0.9,(Double_t)swmaxobt[2]*1.1,"X");
1086        lupstw[2]->Draw();
1087        pd4->cd();
1088        lup[3]->SetAxisRange((Double_t)minobt[3]*0.9,(Double_t)maxobt[3]*1.1,"X");
1089        lup[3]->Draw();
1090        pd8->cd();
1091        lupstw[3]->SetAxisRange((Double_t)swminobt[3]*0.9,(Double_t)swmaxobt[3]*1.1,"X");
1092        lupstw[3]->Draw();
1093      };
1094      //
1095    //  output figures, report sheet:    //  output figures, report sheet:
1096    //    //
1097    TCanvas *rapporto= new TCanvas("Calorimeter_Detector_Report_3/3", "Calorimeter_Detector_Report_3/3", 1100, 900);    TCanvas *rapporto= new TCanvas("Calorimeter_Detector_Report_3/3", "Calorimeter_Detector_Report_3/3", 1100, 900);
# Line 1021  void FCaloQLOOK(TString filename, Int_t Line 1168  void FCaloQLOOK(TString filename, Int_t
1168            check = true;            check = true;
1169          }          }
1170          if (j == 2) {          if (j == 2) {
1171              //      printf("boh! lalarm[%i] = %i \n",i,lalarm[i]);
1172            if ( lalarm[i] ){            if ( lalarm[i] ){
1173              errore.str("");              errore.str("");
1174              errore << "* Latch up: " << ver[i][j];              errore << "* Latch up: " << ver[i][j];
1175              errore << " (" << lalarm[i];                      errore << " (" << lalarm[i];        
1176              errore << " NOT rec!): ";              errore << " NOT rec!): ";
1177              t->DrawLatex(0.,70.,errore.str().c_str());              t->DrawLatex(2.,70.,errore.str().c_str());
1178              check = true;              check = true;
1179            } else {            } else {
1180              errore.str("");              errore.str("");
# Line 1224  void FCaloQLOOK(TString filename, Int_t Line 1372  void FCaloQLOOK(TString filename, Int_t
1372      t->DrawLatex(60.,95.," OK! ");            t->DrawLatex(60.,95.," OK! ");      
1373    };    };
1374    //    //
1375    const string fil = (const char*)filename;    //  const string fil = (const char*)filename;
1376    Int_t posiz = fil.find("dw_");    //  Int_t posiz = fil.find("dw_");
1377    if ( posiz == -1 ) posiz = fil.find("DW_");    //  if ( posiz == -1 ) posiz = fil.find("DW_");
1378    Int_t posiz2 = posiz+13;    //  Int_t posiz2 = posiz+13;
1379    TString file2;    //  TString file2;
1380    stringcopy(file2,filename,posiz,posiz2);    //  stringcopy(file2,filename,posiz,posiz2);
1381      //
1382      const string fil = gSystem->BaseName(filename.Data());
1383      Int_t posiz = fil.find(".root");
1384    //    //
1385      TString file2;
1386      if ( posiz == -1 ){
1387        file2 = gSystem->BaseName(filename.Data());
1388      } else {
1389        Int_t posiz2 = 0;
1390        stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz);
1391      };
1392    const char *figrec = file2;    const char *figrec = file2;
1393      //
1394    const char *outdir = outDir;    const char *outdir = outDir;
1395    stringstream figsave;        stringstream figsave;    
1396    stringstream figsave1;        stringstream figsave1;    
# Line 1240  void FCaloQLOOK(TString filename, Int_t Line 1399  void FCaloQLOOK(TString filename, Int_t
1399    if ( !strcmp(format,"ps") ) {    if ( !strcmp(format,"ps") ) {
1400      figsave.str("");      figsave.str("");
1401      figsave << outdir << "/" ;      figsave << outdir << "/" ;
1402      figsave << figrec << "_qlook.";      figsave << figrec << "_CaloQLOOK.";
1403      figsave << format << "(";      figsave << format << "(";
1404      rapporto->Print(figsave.str().c_str(),"Landscape");          rapporto->Print(figsave.str().c_str(),"Landscape");    
1405      figsave1.str("");      figsave1.str("");
1406      figsave1 << outdir << "/" ;      figsave1 << outdir << "/" ;
1407      figsave1 << figrec << "_qlook.";      figsave1 << figrec << "_CaloQLOOK.";
1408      figsave1 << format;      figsave1 << format;
1409      figura->Print(figsave1.str().c_str(),"Landscape");      figura->Print(figsave1.str().c_str(),"Landscape");
1410      figsave2.str("");      figsave2.str("");
1411      figsave2 << outdir << "/" ;      figsave2 << outdir << "/" ;
1412      figsave2 << figrec << "_qlook.";      figsave2 << figrec << "_CaloQLOOK.";
1413      figsave2 << format << ")";      if ( printfigure3 ){
1414      figura2->Print(figsave2.str().c_str(),"Landscape");        figsave2 << format;
1415          figura2->Print(figsave2.str().c_str(),"Landscape");
1416          figsave2.str("");
1417          figsave2 << outdir << "/" ;
1418          figsave2 << figrec << "_CaloQLOOK.";
1419          figsave2 << format << ")";
1420          figura3->Print(figsave2.str().c_str(),"Landscape");
1421        } else {
1422          figsave2 << format << ")";;
1423          figura2->Print(figsave2.str().c_str(),"Landscape");
1424        };
1425    } else {    } else {
1426      figsave.str("");      figsave.str("");
1427      figsave << outdir << "/" ;      figsave << outdir << "/" ;
1428      figsave << figrec << "_qlook1.";      figsave << figrec << "_CaloQLOOK1.";
1429      figsave << format;      figsave << format;
1430      figura->SaveAs(figsave.str().c_str());      figura->SaveAs(figsave.str().c_str());
1431      figsave.str("");      figsave.str("");
1432      figsave << outdir << "/" ;      figsave << outdir << "/" ;
1433      figsave << figrec << "_qlook2.";      figsave << figrec << "_CaloQLOOK2.";
1434      figsave << format;      figsave << format;
1435      figura2->SaveAs(figsave.str().c_str());      figura2->SaveAs(figsave.str().c_str());
1436        if ( printfigure3 ){
1437          figsave.str("");
1438          figsave << outdir << "/" ;
1439          figsave << figrec << "_CaloQLOOK2bis.";
1440          figsave << format;
1441          figura3->SaveAs(figsave.str().c_str());
1442        };
1443      figsave.str("");      figsave.str("");
1444      figsave << outdir << "/" ;      figsave << outdir << "/" ;
1445      figsave << figrec << "_qlook3.";      figsave << figrec << "_CaloQLOOK3.";
1446      figsave << format;      figsave << format;
1447      rapporto->SaveAs(figsave.str().c_str());          rapporto->SaveAs(figsave.str().c_str());    
1448    };    };

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.23