// Program to analyze de data decoded // //Created: 2006-08-29 by jpires #ifdef __MAKECINT__ #else using namespace std; #endif //#include "SaveROOTFile/SaveData.h" #include #include #include #include #include #include //ROOT includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* #include "TROOT.h" #include "TFile.h" #include "TTree.h" #include "TBranch.h" #include "TAxis.h" #include "TCanvas.h" #include "TPad.h" */ // Start of analysis void Analysis(); int Analyze_02() { //Reset ROOT variables gROOT->Reset(); // method to open files -> GUI char *iname=new char[50]; //ask for filenames cout << "\nIntroduza o nome do ficheiro de dados:\n"; cin >> iname; cout << endl; //cout << "\nO nome do ficheiro de dados introduzido foi: \n" << iname << endl; // raw data TFile *fin = (TFile*)gROOT->GetListOfFiles()->FindObject(iname); if (!fin) { fin = new TFile(iname); } // verifies if the file exits or if it's valid TFile f(iname); if (f.IsZombie()) { cout << "Error opening file" << endl; gROOT->Reset(); exit(-1); } Analysis(); //return 0; } void Analysis() { //Aqui assumimos que o ficheiro com os dados ja' foi aberto //Na rotina Decode(filename) pode-se abrir um ficheiro ja' existente. TFile *fin=(TFile *)gFile; if (!fin) { cout << endl << "Ficheiro .root inexistente! Saindo..." << endl; return; } TTree *t=(TTree *)fin->Get("DR"); if (!t) { cout << endl << "TTree inexistente! Saindo..." << endl; return; } //t->Print() // get the data values of the branches in the tree DR // with declaration of leaves type for raw data Int_t vsn; // version Int_t a_i; Int_t m_i; Int_t d_i; Int_t h_i; Int_t m_i; Int_t s_i; Float_t fThr1; Float_t fThr2; Float_t fThr3; Float_t fDel1; // delay trigger Float_t fDel2; // deltaT shower Int_t nevmax; // Npedidos Int_t nevents; // Nevents Int_t irun; // run number Int_t ievt; // event Int_t ientry; Int_t ntrig; Int_t a_hit; Int_t m_hit; Int_t d_hit; Int_t h_hit; Int_t m_hit; Int_t s_hit; Int_t ns_hit; Int_t tPPS; Int_t tEvento; Float_t fCh1[256]; Float_t fCh2[256]; Float_t fCh3[256]; Float_t fCh4[256]; Float_t fCh5[256]; Float_t fCh6[256]; // static variables t->SetBranchAddress("Versao",&vsn); t->SetBranchAddress("Ano_inicial",&a_i); t->SetBranchAddress("Mes_inicial",&m_i); t->SetBranchAddress("Dia_inicial",&d_i); t->SetBranchAddress("Hora_inicial",&h_i); t->SetBranchAddress("Minuto_inicial",&m_i); t->SetBranchAddress("Segundo_inicial",&s_i); t->SetBranchAddress("Limiar_canal_1",&fThr1); t->SetBranchAddress("Limiar_canal_2",&fThr2); t->SetBranchAddress("Limiar_canal_3",&fThr3); t->SetBranchAddress("Atraso_trigger",&fDel1); t->SetBranchAddress("DeltaT_shower",&fDel2); t->SetBranchAddress("Npedidos",&nevmax); t->SetBranchAddress("Neventos",&nevents); t->SetBranchAddress("RunNumber",&irun); // variables avaiable for each event t->SetBranchAddress("Evento",&ievt); t->SetBranchAddress("Entrada",&ientry); t->SetBranchAddress("NTriggers",&ntrig); t->SetBranchAddress("Ano",&a_hit); t->SetBranchAddress("Mes",&m_hit); t->SetBranchAddress("Dia",&d_hit); t->SetBranchAddress("Hora",&h_hit); t->SetBranchAddress("Minuto",&m_hit); t->SetBranchAddress("Segundo",&s_hit); t->SetBranchAddress("ns",&ns_hit);//tTrig t->SetBranchAddress("t_PPS",&tPPS); //regPPS t->SetBranchAddress("t_Evento",&tEvento);//regTrig //Sinais dos 6 canais t->SetBranchAddress("Sinal1",fCh1); t->SetBranchAddress("Sinal2",fCh2); t->SetBranchAddress("Sinal3",fCh3); t->SetBranchAddress("Sinal4",fCh4); t->SetBranchAddress("Sinal5",fCh5); t->SetBranchAddress("Sinal6",fCh6); // get entries Int_t t_nentries=t->GetEntries(); //cout << "t_nentries=" << t_nentries << endl; // get all values from branch variables -> maybe necessary to TH1F,for TTree it isn't /*for (Int_t b=0 ; b<=32 ; b++){ t->GetEntry(b); } cout << a_i << endl; */ // baselines Int_t bl1=fThr1; Int_t bl2=fThr2; Int_t bl3=fThr3; // additional variables Int_t t_nbytes=0; // drawing GUI output TCanvas *c1 = new TCanvas("c1","c1",200,10,600,400); //c1->cd(); //t->Draw("Sinal1","Sinal1>Limiar_canal_1"); TPad *pad1 = new TPad("pad1","canal 1",0.03,0.61,0.49,0.90,17); // booking histograms TH1F *t_hist1= new TH1F("Param1","Signal of the event",100,0.,5.); //t->GetEntry(27); for (Int_t i=1 ; i<10 ; i++){ for (Int_t nc=27 ; nc<=32 ; nc++){ Int_t np=(i-1)*6+nc; t_nbytes+=t->GetEntry(np);// gets the signal t_hist1->Reset(); for (Int_t j=0 ; j<256 ; j++){ if (fCh1[j]>-1){ t_hist1->Fill(j+0.5,fCh1[j]);} } //t_hist1->DrawCopy(); } pad1->cd(); t_hist1->SetFillColor(2); t_hist1->Draw(); } c1->Update(); }