| /drs/AnalyseWaveForms.cxx |
|---|
| 0,0 → 1,8 |
| int AnalyseWaveForms(int neve, int updatefreq, const char * fname, int trgch){ |
| // int nev=-1; |
| // int updfrq=1000; |
| // int trgch=0; |
| gROOT->Macro("C:/home/dominik/drs.C+"); |
| ana(fname); |
| return 0; |
| } |
| /drs/DrsChannel.h |
|---|
| 8,6 → 8,7 |
| float vcut[2]; |
| int edge; |
| float offset; |
| float ymin,ymax; |
| } DrsChannel; |
| #endif |
| /drs/README.txt |
|---|
| 1,3 → 1,30 |
| Analiza podatkov SiPM, zajetih z DRS4 samplerjem: |
| root |
| .L drs.C+ |
| .L process_results.cxx+ |
| // sprocesiraj vse .dat file v direktoriju datasipm (in poddirektorijih), ki se nimajo ob sebi root fileov |
| // pozene drs analizo s prednastavljenimi parametri na vsakem fileu in sporducira .root in .pdf |
| process_results("datasipm",".dat", 0); |
| // Zberi vse histograme v skupnem root fileu in jim dodaj threshold scan grafe sipm.root: |
| process_results("datasipm",".dat", 1); |
| // analiza iz root tree v sipm.root |
| // output v results (extension je drug parameter ), |
| // ena stran za vsak sipm type in sample z matriko po temperaturah in napetostih |
| .L tree.C+ |
| tree t; |
| tree.Loop(0,"pdf"); //qdc2 |
| tree.Loop(1,"png"); //qdc3 |
| tree.Loop(2,"png"); //dpo2 |
| tree.Loop(3,"png"); //dpo3 |
| tree.Loop(4,"png"); //cftdif2 |
| tree.Loop(5,"png"); //cftdif3 |
| tree.Loop(6,"png"); //thscan |
| __________________________________________________________________________ |
| Analysis of the data acquired with the readout chip |
| https://www.psi.ch/drs/drs-chip |
| /drs/drs.C |
|---|
| 3,6 → 3,7 |
| #include "TH2.h" |
| #include "TFile.h" |
| #include "TGraph.h" |
| #include "TMultiGraph.h" |
| #include "TCanvas.h" |
| #include "TStyle.h" |
| #include "TLegend.h" |
| 41,6 → 42,7 |
| TH1F *h1_qsumy; |
| TGraph *gr_wfm[NCH]; |
| TLegend *leg; |
| TMultiGraph *wfm; |
| int drs::histoinit( int nch, DrsChannel* d, int trgch, double ymin, double ymax){ |
| char histname[128]; |
| 48,15 → 50,16 |
| c_wfm->Divide(1,1); |
| c_wfm->cd(1); |
| const double maxt=1800; |
| const double maxt=200; |
| leg = new TLegend(0.8, 0.8, 1, 1); |
| wfm = new TMultiGraph(); |
| for (int i=0; i<nch; i++) { |
| sprintf(histname,"chmax_%02d",i); |
| h1_chmax[i]=new TH1F(histname,histname,1500,ymin,ymax); |
| h1_chmax[i]=new TH1F(histname,Form("%d"),1500,d[i].ymin,d[i].ymax); |
| sprintf(histname,"chmaxt_%02d",i); |
| h1_chmaxt[i]=new TH1F(histname,histname,DWIDTH,-0.1,maxt); |
| sprintf(histname,"chmin_%02d",i); |
| h1_chmin[i]=new TH1F(histname,histname,1500,ymin,ymax); |
| h1_chmin[i]=new TH1F(histname,histname,1500,d[i].ymin,d[i].ymax); |
| sprintf(histname,"chmint_%02d",i); |
| h1_chmint[i]=new TH1F(histname,histname,DWIDTH,-0.1,maxt); |
| sprintf(histname,"letime_%02d",i); |
| 66,25 → 69,45 |
| sprintf(histname,"cftdif_%02d",i); |
| h1_cftdif[i]=new TH1F(histname,histname,2000,d[i].twin[0]-d[trgch].twin[0]-40,d[i].twin[1]-d[trgch].twin[0]+20); |
| sprintf(histname,"qdc_%02d",i); |
| h1_qdc[i]=new TH1F(histname,histname,500,-4.5,4.5); |
| float dx = 7*(d[i].ymax - d[i].ymin); |
| double ymin, ymax; |
| if(d[i].edge){ |
| ymin=d[i].ymin*8; |
| ymax=d[i].ymax*8; |
| } |
| else{ |
| ymin=-d[i].ymax*8; |
| ymax=-d[i].ymin*8; |
| } |
| h1_qdc[i]=new TH1F(histname,histname,800, ymin , ymax); |
| sprintf(histname,"dpo_%02d",i); |
| h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,maxt,1500,ymin,ymax); |
| h2_dpo[i]=new TH2F(histname,histname,DWIDTH,-0.1,maxt,1500,d[i].ymin,d[i].ymax); |
| sprintf(histname,"tdcadc_%02d",i); |
| h2_tdcadc[i]=new TH2F(histname,histname,250,ymin,ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
| h2_tdcadc[i]=new TH2F(histname,histname,250,d[i].ymin,d[i].ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
| sprintf(histname,"ctdcadc_%02d",i); |
| h2_ctdcadc[i]=new TH2F(histname,histname,250,ymin,ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
| h2_ctdcadc[i]=new TH2F(histname,histname,250,d[i].ymin,d[i].ymax,400,d[i].twin[0]-d[trgch].twin[0],d[i].twin[1]-d[trgch].twin[0]); |
| gr_wfm[i]=new TGraph(DWIDTH); |
| gr_wfm[i]->SetMinimum(ymin); |
| gr_wfm[i]->SetMaximum(ymax); |
| //gr_wfm[i]->SetMinimum(d[i].ymin); |
| //gr_wfm[i]->SetMaximum(d[i].ymax); |
| gr_wfm[i]->SetLineColor(i+1); |
| gr_wfm[i]->SetMarkerColor(i+1); |
| sprintf(histname,"ch %d",i); |
| leg->AddEntry(gr_wfm[i], histname, "l"); |
| if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP"); |
| gr_wfm[i]->GetHistogram()->SetTitle("WaveForms"); |
| gr_wfm[i]->GetHistogram()->SetDirectory(0); |
| wfm->Add(gr_wfm[i]); |
| //if (i) gr_wfm[i]->Draw("LP"); else gr_wfm[i]->Draw("ALP"); |
| //gr_wfm[i]->GetHistogram()->SetTitle("WaveForms"); |
| //gr_wfm[i]->GetHistogram()->SetDirectory(0); |
| } |
| wfm->SetMinimum(ymin); |
| wfm->SetMaximum(ymax); |
| wfm->Draw("ALP"); |
| //wfm->SetTitle("WaveForms"); |
| //wfm->SetDirectory(0); |
| leg->Draw(); |
| h2_ctalk=new TH2F("ctalk","ctalk",250,0.,0.5,250,0.,0.5); |
| h2_pos=new TH2F("cpos","cpos",40,-1,1,40,-1,1); |
| 141,6 → 164,7 |
| histoinit(nch, d, trgch, ymin,ymax); |
| char rootname[0xff]; |
| sprintf(rootname, "%s_x%d_y%d.root", FileName, 0, 0); |
| froot = new TFile(rootname,"RECREATE"); |
| 236,7 → 260,6 |
| break; |
| } |
| if (iev<first) continue; |
| if (recid[0] == 'E') { |
| for ( i=0; i<nch; i++) { |
| if (!lwfm[i]) continue; |
| 264,6 → 287,7 |
| double ph1 = (d[1].edge)? chmax[1][0]: -chmin[1][0]; |
| h2_ctalk->Fill(ph0,ph1); |
| } |
| if (event<1) continue; |
| if (recid[0]!='C') continue; |
| if (ich>=nch) continue; |
| 379,25 → 403,27 |
| printf("number of events: %d\n",iev); |
| fclose(fin); |
| TString pdfname = Form("%s.pdf",FileName); |
| gStyle->SetOptStat(1111111); |
| gStyle->SetOptStat(0); |
| TCanvas* c_dpo= new TCanvas("c_dpo","DPO",750,50,700,700); |
| c_dpo->Divide(2,2); |
| for (i=0; i<nch; i++) {c_dpo->cd(i+1)->SetLogz(1); h2_dpo[i]->DrawCopy("colz");} |
| TCanvas* c_cftdif= new TCanvas("c_cftdif","DPO",750,50,700,700); |
| gStyle->SetOptStat(1111111); |
| TCanvas* c_cftdif= new TCanvas("c_cftdif","Constant fraction time difference",750,50,700,700); |
| c_cftdif->Divide(2,2); |
| for (i=0; i<nch; i++) {c_cftdif->cd(i+1); h1_cftdif[i]->DrawCopy();} |
| /* |
| TCanvas* c_cftcorr= new TCanvas("c_cftcorr","pulseheight vs timing",750,50,700,700); |
| c_cftcorr->Divide(2,2); |
| for (i=0; i<nch; i++) {c_cftcorr->cd(i+1); h2_tdcadc[i]->DrawCopy("colz");} |
| */ |
| TCanvas* c_adc= new TCanvas("c_adc","adc",750,50,700,700); |
| c_adc->Divide(2,2); |
| for (i=0; i<nch; i++) {c_adc->cd(i+1); h1_qdc[i]->DrawCopy();} |
| /* |
| TCanvas* c_qsum= new TCanvas("c_qsum","qsum",750,50,700,700); |
| c_qsum->Divide(1,2); |
| c_qsum->cd(1); h1_qsumx->DrawCopy(); |
| 408,15 → 434,18 |
| c_pos->cd(); |
| h2_pos->DrawCopy("colz"); |
| */ |
| c_pos->Print(pdfname+"(","pdf"); |
| c_wfm->Print(pdfname,"pdf"); |
| c_adc->Print(pdfname,"pdf"); |
| c_qsum->Print(pdfname,"pdf"); |
| //c_pos->Print(pdfname+"(","pdf"); |
| //c_wfm->Print(pdfname,"pdf"); |
| c_adc->Print(pdfname+"(","pdf"); |
| //c_qsum->Print(pdfname,"pdf"); |
| c_dpo->Print(pdfname,"pdf"); |
| c_cftdif->Print(pdfname + ")","pdf"); |
| c_dpo->Write(); |
| c_adc->Write(); |
| c_cftdif->Write(); |
| froot->Write(); |
| froot->Close(); |
| 472,20 → 501,53 |
| c[1].edge = edge[1]; |
| c[1].offset = offset[1]; |
| drs * d = new drs(FileName, 2, c, trgch, nev, updfrq, -0.55,0.55 ); |
| drs * d = new drs(FileName, 2, c, trgch, 0, nev, updfrq, -0.55,0.55 ); |
| } |
| void sensl(int nev=1000, int updfrq=20, char *FileName="./data/x1.dat", int trgch=0){ |
| void sensl(int nev=1000, int updfrq=20, char *FileName="./data/x1.dat", int trgch=3){ |
| // nev = -1 all events |
| double threshold[4]={-0.005,-0.005,-0.005,-0.005}; // threshold for determination of timing |
| float twin[4][2]={{980.,1150.},{980.,1150.},{980.,1150.},{980,1150.}}; // window for calculation of the timing |
| float adcgate[4][2]={{980.,1150.},{980.,1150.},{980.,1150.},{980.,1150.}}; //integration window |
| double threshold[4]={-0.005,-0.05,-0.005,-0.05}; // threshold for determination of timing |
| float twin[4][2]={{20,40.},{980.,1150.},{100.,160.},{100.,160.}}; // window for calculation of the timing |
| float adcgate[4][2]={{20.,30.}, {980.,1150.},{112.,123.},{150.,163.}}; //integration window |
| double vcut[4][2]={{-1,1},{-1,1},{-1,1},{-1,1}}; // cut on the pulseheight for filling the timing histograms |
| int edge[4]={0,0,0,0};// 1 -- rising edge, 0 -- falling edge |
| float offset[4]={0.25,0.25,0.25,0.25};// qdc offset |
| int edge[4]={1,0,1,0};// 1 -- rising edge, 0 -- falling edge |
| double offset[4]={0.25,0.25, 0.025,0.25};// qdc offset |
| double ymin[4]={-0.1,-0.5,-0.01,-0.6};// ymin offset |
| double ymax[4]={0.5,0.5,0.07,0.1};// ymin offset |
| DrsChannel c[NCH]; |
| for (int k=0;k<NCH;k++){ |
| c[k].cfrac = CFRAC; |
| c[k].threshold = threshold[k]; |
| for (int j=0;j<2;j++){ |
| c[k].twin[j] = twin[k][j]; |
| c[k].adcgate[j] = adcgate[k][j]; |
| c[k].vcut[j] = vcut[k][j]; |
| c[k].edge = edge[k]; |
| c[k].offset = offset[k]; |
| c[k].ymin = ymin[k]; |
| c[k].ymax = ymax[k]; |
| } |
| } |
| drs * d = new drs(FileName, NCH, c, trgch, 0, nev, updfrq , -1,1); |
| } |
| void ana(TString FileName="./data/x1.dat"){ |
| int nev=-1; |
| int updfrq=1000; |
| int trgch=0; |
| // nev = -1 all events |
| double threshold[4]={-0.005,-0.05,-0.005,-0.05}; // threshold for determination of timing |
| float twin[4][2]={{20,40.},{980.,1150.},{100.,160.},{100.,160.}}; // window for calculation of the timing |
| float adcgate[4][2]={{20.,30.}, {980.,1150.},{112.,123.},{150.,163.}}; //integration window |
| double vcut[4][2]={{-1,1},{-1,1},{-1,1},{-1,1}}; // cut on the pulseheight for filling the timing histograms |
| int edge[4]={1,0,1,0};// 1 -- rising edge, 0 -- falling edge |
| double offset[4]={0.25,0.25, 0.025,0.25};// qdc offset |
| double ymin[4]={-0.1,-0.5,-0.01,-0.6};// ymin offset |
| double ymax[4]={0.5,0.5,0.07,0.1};// ymin offset |
| DrsChannel c[NCH]; |
| for (int k=0;k<NCH;k++){ |
| c[k].cfrac = CFRAC; |
| 496,7 → 558,10 |
| c[k].vcut[j] = vcut[k][j]; |
| c[k].edge = edge[k]; |
| c[k].offset = offset[k]; |
| c[k].ymin = ymin[k]; |
| c[k].ymax = ymax[k]; |
| } |
| } |
| drs * d = new drs(FileName, NCH, c, trgch, nev, updfrq , -0.1,0.12); |
| cout << "DRS4 " << FileName << endl; |
| drs * d = new drs(FileName.Data(), NCH, c, trgch, 0, nev, updfrq , -0.5,0.5); |
| } |
| /drs/process_results.cxx |
|---|
| 0,0 → 1,205 |
| #include <stdlib.h> |
| #include <stdio.h> |
| #include <TSystem.h> |
| #include <TSystemFile.h> |
| #include <TString.h> |
| #include <TSystemDirectory.h> |
| #include <TList.h> |
| #include <TH1F.h> |
| #include <TH2F.h> |
| #include <TGraph.h> |
| #include <TTree.h> |
| #include <TFile.h> |
| #include <TCanvas.h> |
| #include <iostream> |
| void ana(TString fname); |
| void processRaw(TString fname){ |
| TString troot= fname + "_x0_y0.root"; |
| if(!gSystem->AccessPathName(troot)){ |
| cout << "ROOT File exists " << troot << endl; |
| } else { |
| cout << "Processing. " << troot << endl; |
| ana(fname); |
| } |
| } |
| class mytree { |
| private: |
| TH2F hdpo[4]; |
| TH1F hadc[4]; |
| TH1F htdc[4]; |
| TGraph hgr; |
| TTree *tree; |
| TFile *hfile; |
| int voltage; |
| int temperature; |
| public: |
| mytree( ); |
| ~mytree(); |
| int init(TString, TDirectory *); |
| int event(TString); |
| TString id; |
| TString sn; |
| }; |
| mytree *ptree; |
| int mytree::init(TString fname, TDirectory *dir) |
| { |
| cerr << "init " << fname << endl; |
| if(!gSystem->AccessPathName(fname)){ |
| // cout << fname <<" exists. Remove it" << endl; |
| // return -1; |
| } |
| if (hfile) return -1; |
| hfile = new TFile (fname,"RECREATE","ROOT FILE with SiPM qdc and tdf"); |
| tree = new TTree("tree","sipm data tree"); |
| tree->Branch("voltage",&voltage,"voltage/I"); |
| tree->Branch("temp",&temperature,"temperature/I"); |
| tree->Branch("id","TString",&id); |
| tree->Branch("sn","TString",&sn); |
| tree->Branch("dpo2","TH2F",&hdpo[2]); |
| tree->Branch("dpo3","TH2F",&hdpo[3]); |
| tree->Branch("qdc2","TH1F",&hadc[2]); |
| tree->Branch("qdc3","TH1F",&hadc[3]); |
| tree->Branch("tdc2","TH1F",&htdc[2]); |
| tree->Branch("tdc3","TH1F",&htdc[3]); |
| tree->Branch("thscan","TGraph",&hgr, 32000, 0); |
| return 0; |
| } |
| TObject * getHisto(TDirectory *f,TString cname, TString hname , int subpad){ |
| auto c=(TCanvas *) f->Get(cname); |
| if(!c) return NULL; |
| auto p=(TPad *) c->GetPrimitive(cname + Form("_%d",subpad+1)); |
| if(!p) return NULL; |
| //p->ls(); |
| auto o= (TObject *) p->GetPrimitive(hname + Form("_%02d",subpad)); |
| if (!o) return NULL; |
| auto o1=o->Clone(); |
| delete p; |
| delete c; |
| o1->ls(); |
| return o1; |
| } |
| int mytree::event(TString fname){ |
| TFile *f= new TFile(fname + "_x0_y0.root"); |
| TString bname=gSystem->BaseName(fname.Data()); |
| TString pname=gSystem->DirName(gSystem->DirName(fname.Data())); |
| sn =gSystem->BaseName(gSystem->DirName(fname.Data())); |
| TObjArray *ppname = pname.Tokenize("_"); |
| id = ((TObjString *)(ppname->At(1)))->String(); |
| if (!hfile || !tree) init("sipm.root",f); |
| TObjArray *t = bname.Tokenize("_."); |
| t->Print(); |
| for (Int_t i = 0; i < t->GetEntries(); i++) |
| cout << ((TObjString *)(t->At(i)))->String() << endl; |
| voltage = (((TObjString *)(t->At(2)))->String()).Atof(); |
| temperature = (((TObjString *)(t->At(1)))->String()).Atof(); |
| cout << pname << " " << voltage << " " << temperature << endl; |
| for (int i=0;i<4;i++){ |
| TH1F* h0=(TH1F *)getHisto(f,"c_adc","qdc",i); |
| TH1F* h1=(TH1F *)getHisto(f,"c_cftdif","cftdif",i); |
| TH2F* h2=(TH2F *)getHisto(f,"c_dpo","dpo",i); |
| hadc[i]=(h0)?*h0:TH1F(); |
| htdc[i]=(h1)?*h1:TH1F(); |
| hdpo[i]=(h2)?*h2:TH2F(); |
| } |
| f->Close(); |
| delete f; |
| auto gr= new TGraph(fname + ".thr"); |
| hgr = (gr)?*gr:TGraph(); |
| TString grname= id + "_" + sn + Form("_%d_%d", temperature, voltage); |
| hgr.SetName(grname); |
| hgr.ls(); |
| if (tree) tree->Fill(); |
| else cerr <<"Error No tree" << endl; |
| return 0; |
| } |
| mytree::mytree(){ |
| hfile = NULL; |
| } |
| mytree::~mytree(){ |
| // End of the loop |
| tree->Print(); |
| // Save all objects in this file |
| hfile->Write(); |
| // Close the file. Note that this is automatically done when you leave |
| // the application. |
| hfile->Close(); |
| } |
| void process_results( TString dirname=".", TString ext=".dat", int mode=0 , int level=0) { |
| TSystemDirectory dir(dirname, dirname); |
| TList *files = dir.GetListOfFiles(); |
| if (mode && level==0){ |
| ptree= new mytree(); |
| } |
| if (files) { |
| TSystemFile *file; |
| TString fname; |
| TIter next(files); |
| while ((file=(TSystemFile*)next())) { |
| fname = file->GetName(); |
| cout << "*" << fname.Data() << endl; |
| if (file->IsDirectory()){ |
| cout << "DIR:" << fname.Data() << endl; |
| if ( !fname.EqualTo(".") && !fname.EqualTo("..")){ |
| process_results(dirname + TString("/") + fname , ext, mode, level+1); |
| } |
| } else { |
| cout << "FILE:" << fname.Data() << endl; |
| if ( fname.EndsWith(ext) ){ |
| TSubString k = fname.SubString("run"); |
| TString kk(k); |
| if( kk.Length()>0 ) { |
| TString name = dirname + TString("/") + fname; |
| cout << "#######" << fname.Data() << " " << name << endl; |
| if (mode) ptree->event(name); |
| else processRaw(name); |
| } |
| } |
| } |
| } |
| } |
| if (level==0 && ptree) delete ptree; |
| } |
| /drs/runroot.bat |
|---|
| 0,0 → 1,28 |
| @echo off |
| set MPATH=%~dp0 |
| rem set MPATH=%CD% |
| cd "\" |
| FOR /D %%x in ("Program Files*") do ( |
| cd /D %%x |
| if exist "Microsoft SDKs\Windows\v7.1A\Include" set INCLUDE=%INCLUDE%;%CD%%%x\Microsoft SDKs\Windows\v7.1A\Include |
| For /D %%G in ("Microsoft Visual Studio*") do set VC=%%x\%%G |
| cd "\" |
| ) |
| echo call "%VC%\VC\vcvarsall.bat" x86 |
| call "%VC%\VC\vcvarsall.bat" x86 |
| cd "\" |
| FOR /D %%G IN ("root*") DO SET ROOTSYS=c:\%%G |
| echo ROOTSYS= "%ROOTSYS%" |
| echo INCLUDE="%INCLUDE%" |
| echo Visual C Development environment |
| echo nmake -f Makefile.win32 |
| cd /D "%MPATH%" |
| echo %1% |
| root.exe %1% |
| /drs/tree.C |
|---|
| 0,0 → 1,94 |
| #define tree_cxx |
| #include "tree.h" |
| #include <TH2.h> |
| #include <TStyle.h> |
| #include <TCanvas.h> |
| #include <TMath.h> |
| #include <iostream> |
| void tree::Loop(int mode, TString ext) |
| { |
| // In a ROOT session, you can do: |
| // Root > .L tree.C |
| // Root > tree t |
| // Root > t.GetEntry(12); // Fill t data members with entry number 12 |
| // Root > t.Show(); // Show values of entry 12 |
| // Root > t.Show(16); // Read and show values of entry 16 |
| // Root > t.Loop(); // Loop on all entries |
| // |
| // This is the loop skeleton where: |
| // jentry is the global entry number in the chain |
| // ientry is the entry number in the current Tree |
| // Note that the argument to GetEntry must be: |
| // jentry for TChain::GetEntry |
| // ientry for TTree::GetEntry and TBranch::GetEntry |
| // |
| // To read only selected branches, Insert statements like: |
| // METHOD1: |
| // fChain->SetBranchStatus("*",0); // disable all branches |
| // fChain->SetBranchStatus("branchname",1); // activate branchname |
| // METHOD2: replace line |
| // fChain->GetEntry(jentry); //read all branches |
| //by b_branchname->GetEntry(ientry); //read only this branch |
| if (fChain == 0) return; |
| Long64_t nentries = fChain->GetEntriesFast(); |
| Long64_t nbytes = 0, nb = 0; |
| int snp=0; |
| TCanvas *c=0; |
| gStyle->SetOptStat(0) ; |
| //gROOT->ForceStyle(); |
| //gStyle->SetTitleSize(0.2); |
| TString pdfname("tmp.pdf"); |
| for (Long64_t jentry=0; jentry<nentries;jentry++) { |
| Long64_t ientry = LoadTree(jentry); |
| if (ientry < 0) break; |
| nb = fChain->GetEntry(jentry); nbytes += nb; |
| // if (Cut(ientry) < 0) continue; |
| TString msn=*sn; |
| TObjArray *ppname = msn.Tokenize("_"); |
| int snid = (((TObjString *)(ppname->At(0)))->String()).Atoi(); |
| cout << "Event" << voltage << " " << temp << " " << *id << " " << snid << qdc2->GetMean() <<endl; |
| qdc2->SetTitle( Form("T=%d V=%d sn=",temp, voltage, snid ) ); |
| //qdc2->SetTitleSize(5.2,"t"); |
| if (snp!=snid){ |
| if (c){ |
| c->Modified(); |
| c->Update(); |
| if (ext.Length()>2) c->Print(pdfname, ext); |
| } |
| pdfname=TString("results/")+*id + "_"+*sn+ Form("_%d.", mode) + ext; |
| c= new TCanvas(*sn,*id + " "+*sn,600,900); |
| c->Divide(5,12,0,0.01,0.01); |
| } |
| snp = snid; |
| c->cd((temp+30)/5*5+(voltage/100-1)+1); |
| if (mode==2 || mode==3) gPad->SetLogz(1) ; |
| else gPad->SetLogz(0) ; |
| if (mode==6) gPad->SetLogy(1) ; |
| else gPad->SetLogy(0) ; |
| switch (mode){ |
| case 0: qdc2->DrawCopy(); break; |
| case 1: qdc2->DrawCopy(); break; |
| case 2: dpo2->DrawCopy("col"); break; |
| case 3: dpo3->DrawCopy("col"); break; |
| case 4: tdc2->GetXaxis()->SetRangeUser(86, 92); tdc2->DrawCopy(); break; |
| case 5: tdc3->GetXaxis()->SetRangeUser(128, 132); tdc3->DrawCopy(); break; |
| case 6: { |
| TGraph *gr=(TGraph *)thscan->Clone(); |
| gr->Draw("awl"); |
| gr->GetXaxis()->SetRangeUser(0,TMath::Power(2,voltage/100)*33); |
| break;} |
| case 7: cout << thscan->GetName()<<" " << thscan->GetN() << endl; break; |
| } |
| } |
| c->Modified(); |
| c->Update(); |
| if (ext.Length()>2) c->Print(pdfname,ext); |
| } |
| /drs/tree.h |
|---|
| 0,0 → 1,172 |
| ////////////////////////////////////////////////////////// |
| // This class has been automatically generated on |
| // Sun Oct 14 05:37:15 2018 by ROOT version 5.34/36 |
| // from TTree tree/sipm data tree |
| // found on file: sipm.root |
| ////////////////////////////////////////////////////////// |
| #ifndef tree_h |
| #define tree_h |
| #include <TROOT.h> |
| #include <TChain.h> |
| #include <TFile.h> |
| // Header file for the classes stored in the TTree if any. |
| #include <TString.h> |
| #include <TH2F.h> |
| #include <TH1F.h> |
| #include <TGraph.h> |
| // Fixed size dimensions of array or collections stored in the TTree if any. |
| class tree { |
| public : |
| TTree *fChain; //!pointer to the analyzed TTree or TChain |
| Int_t fCurrent; //!current Tree number in a TChain |
| // Declaration of leaf types |
| Int_t voltage; |
| Int_t temp; |
| TString *id; |
| TString *sn; |
| TH2F *dpo2; |
| TH2F *dpo3; |
| TH1F *qdc2; |
| TH1F *qdc3; |
| TH1F *tdc2; |
| TH1F *tdc3; |
| TGraph *thscan; |
| // List of branches |
| TBranch *b_voltage; //! |
| TBranch *b_temperature; //! |
| TBranch *b_id; //! |
| TBranch *b_sn; //! |
| TBranch *b_dpo2; //! |
| TBranch *b_dpo3; //! |
| TBranch *b_qdc2; //! |
| TBranch *b_qdc3; //! |
| TBranch *b_tdc2; //! |
| TBranch *b_tdc3; //! |
| TBranch *b_thscan; //! |
| tree(TTree *tree=0); |
| virtual ~tree(); |
| virtual Int_t Cut(Long64_t entry); |
| virtual Int_t GetEntry(Long64_t entry); |
| virtual Long64_t LoadTree(Long64_t entry); |
| virtual void Init(TTree *tree); |
| virtual void Loop(int mode =0,TString ext="png"); |
| virtual Bool_t Notify(); |
| virtual void Show(Long64_t entry = -1); |
| }; |
| #endif |
| #ifdef tree_cxx |
| tree::tree(TTree *tree) : fChain(0) |
| { |
| // if parameter tree is not specified (or zero), connect the file |
| // used to generate this class and read the Tree. |
| if (tree == 0) { |
| TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("sipm.root"); |
| if (!f || !f->IsOpen()) { |
| f = new TFile("sipm.root"); |
| } |
| f->GetObject("tree",tree); |
| } |
| Init(tree); |
| } |
| tree::~tree() |
| { |
| if (!fChain) return; |
| delete fChain->GetCurrentFile(); |
| } |
| Int_t tree::GetEntry(Long64_t entry) |
| { |
| // Read contents of entry. |
| if (!fChain) return 0; |
| return fChain->GetEntry(entry); |
| } |
| Long64_t tree::LoadTree(Long64_t entry) |
| { |
| // Set the environment to read one entry |
| if (!fChain) return -5; |
| Long64_t centry = fChain->LoadTree(entry); |
| if (centry < 0) return centry; |
| if (fChain->GetTreeNumber() != fCurrent) { |
| fCurrent = fChain->GetTreeNumber(); |
| Notify(); |
| } |
| return centry; |
| } |
| void tree::Init(TTree *tree) |
| { |
| // The Init() function is called when the selector needs to initialize |
| // a new tree or chain. Typically here the branch addresses and branch |
| // pointers of the tree will be set. |
| // It is normally not necessary to make changes to the generated |
| // code, but the routine can be extended by the user if needed. |
| // Init() will be called many times when running on PROOF |
| // (once per file to be processed). |
| // Set object pointer |
| id = 0; |
| sn = 0; |
| dpo2 = 0; |
| dpo3 = 0; |
| qdc2 = 0; |
| qdc3 = 0; |
| tdc2 = 0; |
| tdc3 = 0; |
| thscan=0; |
| // Set branch addresses and branch pointers |
| if (!tree) return; |
| fChain = tree; |
| fCurrent = -1; |
| fChain->SetMakeClass(1); |
| fChain->SetBranchAddress("voltage", &voltage, &b_voltage); |
| fChain->SetBranchAddress("temp", &temp, &b_temperature); |
| fChain->SetBranchAddress("id", &id, &b_id); |
| fChain->SetBranchAddress("sn", &sn, &b_sn); |
| fChain->SetBranchAddress("dpo2", &dpo2, &b_dpo2); |
| fChain->SetBranchAddress("dpo3", &dpo3, &b_dpo3); |
| fChain->SetBranchAddress("qdc2", &qdc2, &b_qdc2); |
| fChain->SetBranchAddress("qdc3", &qdc3, &b_qdc3); |
| fChain->SetBranchAddress("tdc2", &tdc2, &b_tdc2); |
| fChain->SetBranchAddress("tdc3", &tdc3, &b_tdc3); |
| fChain->SetBranchAddress("thscan", &thscan, &b_thscan); |
| Notify(); |
| } |
| Bool_t tree::Notify() |
| { |
| // The Notify() function is called when a new file is opened. This |
| // can be either for a new TTree in a TChain or when when a new TTree |
| // is started when using PROOF. It is normally not necessary to make changes |
| // to the generated code, but the routine can be extended by the |
| // user if needed. The return value is currently not used. |
| return kTRUE; |
| } |
| void tree::Show(Long64_t entry) |
| { |
| // Print contents of entry. |
| // If entry is not specified, print current entry |
| if (!fChain) return; |
| fChain->Show(entry); |
| } |
| Int_t tree::Cut(Long64_t entry) |
| { |
| // This function may be called from Loop. |
| // returns 1 if entry is accepted. |
| // returns -1 otherwise. |
| return 1; |
| } |
| #endif // #ifdef tree_cxx |