Updated macros for SDD ADC Calib with comments and printouts (Riccardo)
authorfprino <prino@to.infn.it>
Thu, 7 Aug 2014 13:06:05 +0000 (15:06 +0200)
committerfprino <prino@to.infn.it>
Thu, 7 Aug 2014 13:06:32 +0000 (15:06 +0200)
ITS/macrosSDD/MakeOCDBCorrectionFromOutputADCCalib.C [new file with mode: 0644]
ITS/macrosSDD/MakeSDDADCCalib.C

diff --git a/ITS/macrosSDD/MakeOCDBCorrectionFromOutputADCCalib.C b/ITS/macrosSDD/MakeOCDBCorrectionFromOutputADCCalib.C
new file mode 100644 (file)
index 0000000..748d3ab
--- /dev/null
@@ -0,0 +1,92 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TF1.h>
+#include <TPad.h>
+#include <TGraphErrors.h>
+#include <TROOT.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TGrid.h>
+#include <TGridResult.h>
+#include <TMath.h>
+#include <TCanvas.h>
+#include <TStyle.h>
+#include <TLatex.h>
+#include <AliCDBEntry.h>
+#include <AliITSresponseSDD.h>
+
+#endif
+
+// Inputs: Output of MakeSDDCalib.C + AliITSresponseSDD Object used to produce the cpass1 (default Run192772_192779_v0_s0.root)
+// Outputs: new ADCtoKeV and ADCvsDriftTimeHistos
+// Launch as: aliroot MakeCorrectionFromOutputCalib.C+
+
+void MakeOCDBCorrectionFromOutputADCCalib(TString fname=".",TString OCDBname="Run192772_192779_v0_s0")
+{
+  Printf("Opening file CalibResults.root in %s/",fname.Data());
+  TFile *fin = new TFile(Form("%s/SDDADCCalibResults.root",fname.Data()));
+    
+  TH1F *hmpvModpar0=(TH1F*)fin->Get("hmpvModpar0");
+  TH1F *hmpvModpar1=(TH1F*)fin->Get("hmpvModpar1");
+  Float_t s=0.0101;//Default ADC vs drift time
+  // getting ADC2keV
+  TFile* fr=TFile::Open(Form("%s.root",OCDBname.Data()));
+  AliCDBEntry* e=(AliCDBEntry*)fr->Get("AliCDBEntry");
+  AliITSresponseSDD* r=(AliITSresponseSDD*)e->GetObject();
+  TH1F* hADCtokeV=new TH1F("hADCtokeV","",260,239.5,499.5);
+  TH1F* hADCvsDriftTime=new TH1F("hADCvsDriftTime","",260,239.5,499.5);
+  r->ls();
+    
+  for(Int_t iMod=240; iMod<500; iMod++){
+    Float_t ak=r->GetADCtokeV(iMod);
+    Float_t adcdrtime=r->GetADCvsDriftTime(iMod);
+    printf("mod %d\nadc->keV=%f ",iMod,ak);
+    hADCtokeV->SetBinContent(iMod-240+1,ak);
+    hADCvsDriftTime->SetBinContent(iMod-240+1,adcdrtime);
+    //calculate new ADC2KeV
+    Double_t kprim=hmpvModpar0->GetBinContent(hmpvModpar0->FindBin(iMod));
+    if(kprim==0)kprim=84;
+    if(iMod==376)kprim=84;
+    Double_t Corr=kprim*ak/84;
+    printf("mpv=%f | Corr(adc->keV*mpv/84)=%f\n",kprim,Corr);
+    hmpvModpar0->SetBinContent(hmpvModpar0->FindBin(iMod),Corr);
+    //Calculate new ADCvsDrTime
+    Double_t sprim=hmpvModpar1->GetBinContent(hmpvModpar1->FindBin(iMod));
+    if(iMod==376){
+      sprim=0;
+    }
+    Double_t Corr2=adcdrtime-(sprim*ak/2);
+    hmpvModpar1->SetBinContent(hmpvModpar1->FindBin(iMod),Corr2);
+    printf("ADCvsDriftTime=%f | Corr(ADCvsDriftTime_old-(ADCvsDriftTime_new*adc->keV/2))=%f\n",adcdrtime,Corr2);
+  }
+    
+  hmpvModpar0->GetYaxis()->SetTitle("K^{*}=KK'/84");
+  hmpvModpar1->GetYaxis()->SetTitle("S^{*}=S-S'K/2");
+  hmpvModpar0->SetTitle("hADCtokeV - New");
+  hmpvModpar0->SetName("hADCtokeV");
+  hADCtokeV->SetTitle("hADCtokeV - Run166530_999999999_v4_s0");
+  hADCtokeV->SetLineColor(2);
+  TCanvas *c0=new TCanvas("c0","c0");
+  c0->cd(1);
+  hmpvModpar0->DrawClone("HIST");
+  hADCtokeV->DrawClone("HISTSAME");
+  gPad->BuildLegend();
+    
+    
+  hmpvModpar1->SetTitle("hADCvsDriftTime - New");
+  hmpvModpar1->SetName("hADCvsDriftTime");
+  hADCvsDriftTime->SetTitle("hADCvsDriftTime - Run166530_999999999_v4_s0");
+  hADCvsDriftTime->SetLineColor(2);
+  TCanvas *c1=new TCanvas("c1","c1");
+  hmpvModpar1->DrawClone("HIST");
+  hADCvsDriftTime->DrawClone("HISTSAME");
+  c1->BuildLegend();
+  TFile *out=new TFile(Form("%s/CorrectiondEdxSDD_%s_%s.root",fname.Data(),fname.Data(),OCDBname.Data()),"recreate");
+  hmpvModpar0->Write();
+  hmpvModpar1->Write();
+  out->Close();
+  delete out;
+    
+} //end main
+
index 5229e55..a50b0e1 100644 (file)
@@ -15,6 +15,8 @@
 #include <TLatex.h>
 #endif
 
+// For each module, finds the dEdx distribution in 8 drift time intervals. Fits each distribution with LanGaus. For each module builds the histogram of
+// Most Probable Value vs drift time and fits it with pol1. Stores the fit parameters vs module number in histograms hmpvModpar0 and hmpvModpar1.
 
 Double_t LangausFun(Double_t *x, Double_t *par);
 
@@ -48,6 +50,9 @@ void MakeSDDADCCalib(TString foldname = ".",TString filename ="QAresults_barrel.
   TH1F *hsiglModpar0 = new TH1F("hsiglModpar0","hsiglModpar0",280,229.5,509.5);
   TH1F *hsiglModpar1 = new TH1F("hsiglModpar1","hsiglModpar1",280,229.5,509.5);
 
+  TString fout="SDDADCCalibResults.root";
+  TFile *out=new TFile(Form("%s/%s",foldname.Data(),fout.Data()),"recreate");
+
   TCanvas *chdEdxproj=new TCanvas("chdEdxproj","chdEdxproj",1000,800);
   chdEdxproj->Divide(4,2);
   TCanvas* cmod=new TCanvas("cmod","module",600,900);
@@ -59,9 +64,10 @@ void MakeSDDADCCalib(TString foldname = ".",TString filename ="QAresults_barrel.
     chdEdxproj->Clear("D");
     //    chdEdxproj->Divide(4,2);
     printf("Mod. # %i \n",imod);
-    hmpv->SetTitle(Form("MPV Mod. # %i \n",imod));
-    hsig->SetTitle(Form("Gauss sigma Mod. # %i \n",imod));
-    hsigl->SetTitle(Form("Landau sigma Mod. # %i \n",imod));
+    hmpv->SetTitle(Form("MPV Mod. # %i",imod));
+    hmpv->SetName(Form("MPVModule%i",imod));
+    hsig->SetTitle(Form("Gauss sigma Mod. # %i",imod));
+    hsigl->SetTitle(Form("Landau sigma Mod. # %i",imod));
     hmpv->GetXaxis()->SetTitle("Drift time (ns)");
     hsig->GetXaxis()->SetTitle("Drift time (ns)");
     hsigl->GetXaxis()->SetTitle("Drift time (ns)");
@@ -107,6 +113,7 @@ void MakeSDDADCCalib(TString foldname = ".",TString filename ="QAresults_barrel.
       pol1mpv->SetParameter(0,84);
       pol1mpv->SetParameter(1,0);
     }
+    hmpv->Write();
     hmpvModpar1->Fill(imod,pol1mpv->GetParameter(1));
     hmpvModpar1->SetBinError(hmpvModpar1->FindBin(imod),pol1mpv->GetParError(1));
     Printf("Par0_mpv:%f Err_Par0_mpv:%f    Par1_mpv:%f Err_Par1_mpv:%f",pol1mpv->GetParameter(0),pol1mpv->GetParError(0),pol1mpv->GetParameter(1),pol1mpv->GetParError(1));
@@ -185,8 +192,6 @@ void MakeSDDADCCalib(TString foldname = ".",TString filename ="QAresults_barrel.
   chsiglModpar1->cd();
   hsiglModpar1->Draw();
   
-  TString fout="SDDADCCalibResults.root";
-  TFile *out=new TFile(Form("%s/%s",foldname.Data(),fout.Data()),"recreate");
   hmpvModpar0->Write();
   hmpvModpar1->Write();
   hsigModpar0->Write();