Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

  1. #define tree_cxx
  2. #include "tree.h"
  3. #include <TH2.h>
  4. #include <TStyle.h>
  5. #include <TCanvas.h>
  6. #include <TMath.h>
  7. #include <iostream>
  8. void tree::Loop(int mode, TString ext)
  9. {
  10. //   In a ROOT session, you can do:
  11. //      Root > .L tree.C
  12. //      Root > tree t
  13. //      Root > t.GetEntry(12); // Fill t data members with entry number 12
  14. //      Root > t.Show();       // Show values of entry 12
  15. //      Root > t.Show(16);     // Read and show values of entry 16
  16. //      Root > t.Loop();       // Loop on all entries
  17. //
  18.  
  19. //     This is the loop skeleton where:
  20. //    jentry is the global entry number in the chain
  21. //    ientry is the entry number in the current Tree
  22. //  Note that the argument to GetEntry must be:
  23. //    jentry for TChain::GetEntry
  24. //    ientry for TTree::GetEntry and TBranch::GetEntry
  25. //
  26. //       To read only selected branches, Insert statements like:
  27. // METHOD1:
  28. //    fChain->SetBranchStatus("*",0);  // disable all branches
  29. //    fChain->SetBranchStatus("branchname",1);  // activate branchname
  30. // METHOD2: replace line
  31. //    fChain->GetEntry(jentry);       //read all branches
  32. //by  b_branchname->GetEntry(ientry); //read only this branch
  33.    if (fChain == 0) return;
  34.  
  35.    Long64_t nentries = fChain->GetEntriesFast();
  36.  
  37.    Long64_t nbytes = 0, nb = 0;
  38.    int snp=0;
  39.    TCanvas *c=0;
  40.    gStyle->SetOptStat(0) ;
  41.  
  42.    //gROOT->ForceStyle();
  43.    //gStyle->SetTitleSize(0.2);
  44.    TString pdfname("tmp.pdf");
  45.    for (Long64_t jentry=0; jentry<nentries;jentry++) {
  46.       Long64_t ientry = LoadTree(jentry);
  47.       if (ientry < 0) break;
  48.       nb = fChain->GetEntry(jentry);   nbytes += nb;
  49.       // if (Cut(ientry) < 0) continue;
  50.           TString msn=*sn;
  51.           TObjArray *ppname = msn.Tokenize("_");
  52.           int snid = (((TObjString *)(ppname->At(0)))->String()).Atoi();
  53.           cout << "Event" << voltage << " " << temp << " " << *id << " " << snid << qdc2->GetMean() <<endl;
  54.           qdc2->SetTitle( Form("T=%d V=%d sn=",temp, voltage, snid ) );
  55.           //qdc2->SetTitleSize(5.2,"t");
  56.           if (snp!=snid){
  57.                  
  58.                  
  59.                 if (c){
  60.                         c->Modified();
  61.                 c->Update();
  62.                         if (ext.Length()>2) c->Print(pdfname, ext);
  63.             }
  64.             pdfname=TString("results/")+*id + "_"+*sn+ Form("_%d.", mode) + ext;
  65.                 c= new TCanvas(*sn,*id + " "+*sn,600,900);
  66.         c->Divide(5,12,0,0.01,0.01);           
  67.           }
  68.           snp = snid;
  69.           c->cd((temp+30)/5*5+(voltage/100-1)+1);
  70.           if (mode==2 || mode==3) gPad->SetLogz(1) ;
  71.       else gPad->SetLogz(0) ;
  72.           if (mode==6) gPad->SetLogy(1) ;
  73.       else gPad->SetLogy(0) ;
  74.          
  75.           switch (mode){
  76.                  case 0: qdc2->DrawCopy(); break;
  77.                  case 1: qdc2->DrawCopy(); break;
  78.                  case 2: dpo2->DrawCopy("col"); break;
  79.                  case 3: dpo3->DrawCopy("col"); break;
  80.                  case 4: tdc2->GetXaxis()->SetRangeUser(86, 92); tdc2->DrawCopy();  break;
  81.                  case 5: tdc3->GetXaxis()->SetRangeUser(128, 132); tdc3->DrawCopy(); break;
  82.                  case 6: {
  83.                    TGraph *gr=(TGraph *)thscan->Clone();
  84.                    gr->Draw("awl");
  85.                    gr->GetXaxis()->SetRangeUser(0,TMath::Power(2,voltage/100)*33);
  86.                    break;}
  87.                  case 7: cout  << thscan->GetName()<<" " << thscan->GetN() << endl; break;
  88.           }
  89.          
  90.    }
  91.    c->Modified();
  92.    c->Update();
  93.    if (ext.Length()>2)  c->Print(pdfname,ext);
  94. }
  95.