Updated macros
authorcoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Nov 2011 17:53:48 +0000 (17:53 +0000)
committercoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Nov 2011 17:53:48 +0000 (17:53 +0000)
ZDC/PlotPedestalsvsTime.C
ZDC/PlotTDCcalibvsTime.C [new file with mode: 0644]
ZDC/ZDCQAtrending.C

index 919e5aa..d19a27c 100644 (file)
@@ -81,7 +81,7 @@ void PlotPedestalsvsTime(Int_t year=2011, Int_t firstRun=141820,
     f->Close();
  }
 
- TFile *outfile=new TFile(Form("Calib%dVsTime.root",year),"recreate");
+ TFile *outfile=new TFile(Form("PedCalib%dVsTime.root",year),"recreate");
  outfile->cd();
  for(int i=0; i<kNchannels; i++) graph[i]->Write();
  outfile->Close();
diff --git a/ZDC/PlotTDCcalibvsTime.C b/ZDC/PlotTDCcalibvsTime.C
new file mode 100644 (file)
index 0000000..a1947c7
--- /dev/null
@@ -0,0 +1,124 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <Riostream.h>
+#include <TSystem.h>
+#include <TRandom.h>
+#include <TROOT.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TGraphErrors.h>
+#include <TGrid.h>
+#include <TFile.h>
+#include <TH1F.h>
+#include "AliCDBEntry.h"
+#include "AliCDBGrid.h"
+#include "AliCDBId.h"
+#include "AliCDBLocal.h"
+#include "AliCDBManager.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBPath.h"
+#include "AliCDBRunRange.h"
+#include "AliCDBStorage.h"
+#include "AliDCSValue.h"
+#include "AliZDC.h"
+#include "AliZDCv3.h"
+#include "AliZDCTDCCalib.h"
+
+#endif
+
+
+void PlotTDCcalibvsTime(Int_t year=2011, Int_t firstRun=166000, 
+                  Int_t lastRun=167000)
+{
+
+
+  TGrid::Connect("alien:",0,0,"t");
+  gSystem->Exec(Form("gbbox find \"/alice/data/%d/OCDB/ZDC/Calib/TDCCalib/\" \"Run*.root\" > calibAlienFiles.txt",year));
+  FILE* listruns=fopen("calibAlienFiles.txt","r");
+  
+  const int kNchannels=6;
+  TGraphErrors* graph[6];
+  for(Int_t i=0; i<kNchannels; i++){
+     graph[i] = new TGraphErrors(0);
+     char name[50], title[50];
+     sprintf(name,"graph%d",i); sprintf(title,"TDC calib. coeff. %d vs. run#",i);
+     graph[i]->SetName("graph");  graph[i]->SetTitle("title");
+  }
+
+  Char_t filnam[200], filnamalien[200];
+  Int_t iPoint=0;
+  Int_t nrun, nrun2, nv, ns;
+
+  while(!feof(listruns)){
+    int st = fscanf(listruns,"%s\n",filnam);    
+    Char_t directory[100];
+    sprintf(directory,"/alice/data/%d",year);
+    if(!strstr(filnam,directory)) continue;
+    sscanf(filnam,"/alice/data/%d/OCDB/ZDC/Calib/TDCCalib/Run%d_%d_v%d_s%d.root",&year,&nrun,&nrun2,&nv,&ns);
+    if(nrun<firstRun) continue;
+    if(nrun>lastRun) continue;
+    sprintf(filnamalien,"alien://%s",filnam);
+    printf("Opening file: %s\n",filnam);
+    TFile *f = TFile::Open(filnamalien);  
+    AliCDBEntry *entry = (AliCDBEntry*)f->Get("AliCDBEntry");
+    AliZDCTDCCalib *calibdata = dynamic_cast<AliZDCTDCCalib*>  (entry->GetObject());
+    
+    for(int i=0; i<kNchannels; i++){
+         graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanTDC(i));
+        graph[i]->SetPointError(iPoint, 0., calibdata->GetWidthTDC(i));
+    }
+    iPoint++;
+    f->Close();
+ }
+
+ TFile *outfile=new TFile(Form("TDCCalib%dVsTime.root",year),"recreate");
+ outfile->cd();
+ for(int i=0; i<kNchannels; i++) graph[i]->Write();
+ outfile->Close();
+
+ //***********************************************************
+ // #### ROOT initialization
+ gROOT->Reset();
+ gStyle->SetCanvasColor(10);
+ gStyle->SetFrameFillColor(10);
+ gStyle->SetOptTitle(0);
+ gStyle->SetOptStat(1111);
+ gStyle->SetOptFit(0);
+ gStyle->SetTitleTextColor(4);
+ gStyle->SetStatTextColor(4);
+ gStyle->SetStatX(0.92);
+ gStyle->SetStatY(0.92);
+ gStyle->SetLineColor(1);
+ gStyle->SetPalette(1);
+ gStyle->SetPadTopMargin(0.05);
+ gStyle->SetPadRightMargin(0.05);
+ gStyle->SetPadBottomMargin(0.09);
+ gStyle->SetPadLeftMargin(0.09); 
+ gStyle->SetTitleOffset(1.1,"Y");  
+ // *************************************************************
+
+ TCanvas *cHadPeds = new TCanvas("cHadPeds","Hadronic ZDC pedestals",0,0,1200,800);
+ cHadPeds->Divide(3,2);
+ for(int ic=0; ic<6; ic++){
+   // *** ZNC pedestals
+   cHadPeds->cd(ic+1);
+   //
+   TH1F *haxis1 = gPad->DrawFrame(firstRun-100, -100, lastRun+100, 0);
+   haxis1->GetXaxis()->SetNoExponent();
+   haxis1->SetXTitle("RUN no.");
+   if(ic==0) haxis1->SetYTitle("ZNC TDC calib");
+   else if(ic==1)  haxis1->SetYTitle("ZNA TDC calib");
+   else if(ic==2)  haxis1->SetYTitle("ZPC TDC calib");
+   else if(ic==3)  haxis1->SetYTitle("ZPA TDC calib");
+   else if(ic==4)  haxis1->SetYTitle("ZEM1 TDC calib");
+   else if(ic==5)  haxis1->SetYTitle("ZEM2 TDC calib");
+   //
+   graph[ic]->SetMarkerStyle(20);
+   graph[ic]->SetMarkerColor(kAzure+ic);
+   graph[ic]->Draw("P, SAME");
+   // 
+ }
+ cHadPeds->SaveAs("ZDCTDCvsTime1.gif");
+ cHadPeds->SaveAs("ZDCTDCvsTime1.C");
+
+}
index 626beea..581b6e1 100644 (file)
@@ -47,7 +47,7 @@ void ZDCQAtrending(TString period,
   
   Bool_t useExternalList = kFALSE;
   Int_t runList[10000];
-  Int_t totRuns  =  0;
+  Int_t totRuns = 0;
   if(runListFile.Length()>0){
     if(!gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",runListFile.Data()))){
       printf("Use Run List from %s  --- runs to be analyzed:\n",runListFile.Data());
@@ -55,14 +55,15 @@ void ZDCQAtrending(TString period,
       FILE* rfil = fopen(runListFile.Data(),"r");
       Int_t nrun;
       while(!feof(rfil)){
-       fscanf(rfil,"%d, ",&nrun);
+       int stat = fscanf(rfil,"%d, ",&nrun);
        if(feof(rfil)) break;
        runList[totRuns++] = nrun;
       }
       for(Int_t ir = 0; ir<totRuns; ir++){
        printf("%d\n",runList[ir]);
       }
-    }else{
+    }
+    else{
       printf("File with run list does not exist\n");
     }
   }
@@ -120,21 +121,23 @@ void ZDCQAtrending(TString period,
   TString  path = Form("/alice/data/%d/%s/",year,period.Data());
   TGridResult *gr  =  gGrid->Query(path,fileName);
   Int_t nFiles  =  gr->GetEntries();
-  printf(" --->%d files found\n", nFiles);
-  if (nFiles < 1) return;
+  printf(" --->%d merged QAresults.root files found in %s\n", nFiles,path.Data());
+  if(nFiles < 1) return;
 
   Int_t nAnalyzedFiles = 0;
   if(nFiles > 1){
     for(Int_t iFil  =  0; iFil <nFiles ; iFil++) { 
       TString fileNameLong = Form("%s",gr->GetKey(iFil,"turl"));
       if(!fileNameLong.Contains(recoPass.Data())) continue;
-      if(!fileNameLong.Contains(qaTrain.Data())) continue;
-      if(fileNameLong.Contains("TRD") || fileNameLong.Contains("EMCAL")) continue;
+// Commented Sep. 2011
+//      if(!fileNameLong.Contains(qaTrain.Data())) continue;
+//      if(fileNameLong.Contains("TRD") || fileNameLong.Contains("EMCAL")) continue;
       TString runNumber = fileNameLong;
       runNumber.ReplaceAll(Form("alien:///alice/data/%d/%s/",year,period.Data()),"");
       runNumber.Remove(9,runNumber.Sizeof());
    
       Int_t iRun = atoi(runNumber.Data());
+      //printf("  runNumber: %s -> iRun %d\n",runNumber.Data(), iRun);
       if(useExternalList){
        Bool_t keepRun = kFALSE;
        for(Int_t ir = 0; ir<totRuns; ir++){
@@ -152,13 +155,20 @@ void ZDCQAtrending(TString period,
       if(iRun<firstRun) continue;
       if(iRun>lastRun) continue;    
 
+printf("  fileNameLog: %s\n",fileNameLong.Data());
       if(useOnlyMerged){
        TString isMerged = fileNameLong;
-       isMerged.Remove(isMerged.Sizeof()-16); 
-       isMerged.Remove(0,isMerged.Sizeof()-5);
-       if(!isMerged.Contains("QA")) continue;
+       //
+       if(!isMerged.Contains(recoPass.Data())) continue;
+       if(isMerged.Contains("Stage")) continue;
+printf("  ->  isMerged: %s\n",isMerged.Data());
+       isMerged.Remove(0,isMerged.Sizeof()-20); 
+printf("  ->  isMerged: %s\n",isMerged.Data());
+       if(!isMerged.Contains(qaTrain) || !isMerged.Contains("QAresults.root")) continue;
+printf("isMerged %s\n",isMerged.Data());
+       
       }
-      printf("Open File %s  Run %d\n",fileNameLong.Data(),iRun);
+      printf("Open File %s  \n",fileNameLong.Data());
       
 
       TFile* f = TFile::Open(fileNameLong.Data());  
@@ -387,6 +397,7 @@ void MakePlots(TString ntupleFileName){
     htdcdiff->GetYaxis()->SetTitle("TDC Diff (ns)");
   }
 
+  
   TCanvas *c1 = new TCanvas("c1", "Mean value ZNs", 0, 0, 1200, 1000);
   c1->Divide(1,2);
   //