#include "TComplex.h" #include "TCanvas.h" #include "TPad.h" #include "TH1.h" #include "TF1.h" #include "TGraph.h" #include "TStyle.h" #include "TVirtualFitter.h" #include "TDatime.h" #include "TTree.h" #include "TFile.h" #include "Riostream.h" #include "TPaveLabel.h" TCanvas *c1, *c2; TPad *selold = 0; void Drawdat(){ //datatree TFile *file = new TFile("Envrconv_05112006.root"); TTree *Envronetree = (TTree*)file->Get("Envronetree"); //Decleration of leaves types Double_t tELMB; Double_t tchannel; Double_t ttsec; Double_t tval; Int_t tlines; //Set branch addresses Envronetree->SetBranchAddress("tlines",&tlines); Envronetree->SetBranchAddress("tELMB",&tELMB); Envronetree->SetBranchAddress("tchannel",&tchannel); Envronetree->SetBranchAddress("ttsec",&ttsec); Envronetree->SetBranchAddress("tval",&tval); //tree for separating channels TFile *ffile = new TFile("treefg.root"); TTree *tfg = (TTree*)ffile->Get("tfg"); //Declaration of leaves types Int_t tstop; Int_t nstops; //Set branch addresses tfg->SetBranchAddress("tstop",&tstop); tfg->SetBranchAddress("nstops",&nstops); //Decleare tfg friendtree of Datatree Envronetree->AddFriend(tfg); //identifiertree TFile *ifile = new TFile("identi.root"); TTree *Treeidenti = (TTree*)ifile->Get("Treeidenti"); //Declaration of leaves types vector *tidentivec = new vector; //Set branch address Treeidenti->SetBranchAddress("tidentivec",&tidentivec); Int_t id = Treeidenti->GetEntries(); //create canvas and histogram with time on xaxis c1 = new TCanvas("c1","Time on Axis",10,10,600,800); int i=0; int c=0; Int_t p = tfg->GetEntries(); c = ceil(sqrt(4)); c1->Divide(c,c); TDatime da(2006,05,11,00,00,00); gStyle->SetTimeOffset(da.Convert()); gStyle->SetOptStat(11); // cout<< "id " << id << " p " << p << endl; TH2F *hist = new TH2F("hist", "Temperature vs. time",900,40000,86400,100,-30,30); TArrayD *tstoparr = new TArrayD(p); for(Int_t i=0;iGetEntry(i); tstoparr -> AddAt(tstop,i); } //read all entries and fill histogram Int_t nentries = Envronetree->GetEntries(); for (Int_t z=1;z<=4;z++) { c1->cd(z); for(Int_t i=tstoparr->At(z-1); iAt(z); i++){ Envronetree->GetEntry(i); hist->Fill(ttsec,tval); } Treeidenti->GetEntry(i); hist -> SetTitle("Temperature vs.time"); hist -> GetYaxis() -> SetTitle("temperature [#circC]"); hist -> GetXaxis() -> SetTitle("time [sec]"); hist -> GetXaxis() -> SetLabelSize(0.03); hist -> GetXaxis() -> SetTimeDisplay(1); hist -> GetXaxis() -> SetTimeFormat("%H\:%M"); TPaveLabel pl; hist -> DrawCopy(); Float_t x1=0.67, y1=0.875, x2=0.85, y2=0.95; // pl.DrawPaveLabel(x1,y1,x2,y2,"test","brNDC"); hist -> Reset(); } c1->AddExec("tnail","tnail()"); c2 = new TCanvas("c2","c2",650,10,800,600); } void tnail() { TPad *sel = (TPad*)gPad->GetSelectedPad(); int px = gPad->GetEventX(); int py = gPad->GetEventY(); if (sel && sel != c1 && sel != c2) { if (selold) delete selold; c2->cd(); TPad *newpad = (TPad*)sel->Clone(); c2->GetListOfPrimitives()->Add(newpad); newpad->SetPad(0,0,1,1); selold = newpad; c2->Update(); } }