#include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; class TRootHandler { public: TRootHandler(void); ~TRootHandler(void); //Initializing TSTART(good data starting time), //TZERO(good caldata starting time), //TEND(good data ending time). int Initialize(float T_start, float T_cut, float T_project, char * tablepath, float m_fMaxchannel, float m_fPeakthreshold); //Reading the data file, return value: pointer to ntuple of data. TNtuple * ReadData(string infile); //Reading the calibration data file, return value: pointer to ntuple of caldata. TNtuple * ReadCalData(char * incaldatafile); float GetTMAX(); //Reading the calibration table file, return value: pointer to ntuple of caltable. TNtuple * ReadTable(string incaltablefile); //Getting a [t_zero, t_end] cut ntuple out of TNtuple * Data. TNtuple * GetTimeRangeData(TNtuple * Data, float t_start, float t_end); //Getting a [ch_min, chmax] cut ntuple out of TNtuple * Data. TNtuple * GetChannelRangeData(TNtuple * Data, float ch_min, float ch_max); //Finding peaks in an ntuple of caldata, returning a pointer to the ntuple of the found peaks. TNtuple * FindPeaks(TNtuple * CalData); TNtuple * GetUserPeaks(char * usertable); //Get the mean of a gaussian, coming from a cut data (RangeData), projected to the tproject time, return value: the found mean. float * GetProjectedMeans(TNtuple * RangeData, float t_min, float t_max, float tproject, float chmean); void TRootHandler::CloseStuff(); void SaveNtuple(TNtuple * ntup); // char * peakposname; ofstream outtable; ofstream fitresults; ofstream projdata; float TSTART; float TCUT; float TMAX; float TPROJECT; float MAXCHANNEL; float PEAKTHRESHOLD; float time; float channel; int number; float energy; float par0; float par0_err; float par1; float par1_err; float par2; float par2_err; float gpar0; float gpar0_err; float gpar1; float gpar1_err; float gpar2; float gpar2_err; float chi2; float gchi2; float chmin; //temporary chmin for calibration!!! float chmax;//temporary chmax for calibration!!! float m_fStarttime; float m_fCuttime; float m_fProject; float m_sTablepath; float m_fMaxchannel; float m_fPeakthreshold); string error1; string error2; string INCALdatafile; char name[64]; fstream outfit; char * indata; char * incaldata; char * outdata; char * incaltable; char * m_sCaldatapath; TNtuple * data; TNtuple * caldata; TNtuple * caltable; TNtuple * timetuple; TNtuple * chantuple; TNtuple * peaktuple; TNtuple * fittuple; TNtuple * usertuple; TSpectrum * spectfinder; TH1F * chanhisto; TH2F * chan2dhisto; TH1F * temphisto; TH1F * histo; TGraph * driftgraph; //TFile * rootfile; }; TRootHandler::TRootHandler(void) { // outfit.open("peakchannels.txt"); time = 0; TMAX = 0; channel = 0; energy = 0; timetuple = NULL; chantuple = NULL; spectfinder = new TSpectrum(12, 1); peaktuple = new TNtuple("peaktuple", "peaktuple", "peakpos"); data = new TNtuple("data", "data", "time:channel"); caldata = new TNtuple("caldata", "caldata", "time:channel"); caltable = new TNtuple("caltable", "caltable", "number:energy"); chanhisto = new TH1F("chanhisto", "channel histogram", 3500, 500, 7500); // chan2dhisto = new TH2F("chan2dhisto", "channel-time histogram", 1000, 0, 100000, 3500, 0, 7500); histo = new TH1F("histo", "histo", 1000, 0, 10000); fittuple = new TNtuple("fittuple", "fittuple", "fitresults"); // rootfile = new TFile("test.root", "recreate"); } TRootHandler::~TRootHandler(void) { } int TRootHandler::Initialize(float T_start, float T_cut, float T_project, char * tablepath, float m_fMaxchannel, float m_fPeakthreshold){ string path = string(tablepath); string fitresfile = path + "_fitpars.txt"; string projdatfile = path + "_projdata.txt"; fitresults.open(fitresfile.c_str()); fitresults << setw(20) << "Gaus: (a/b)*exp(-0.5*((x-c)/b)**2)" << endl; fitresults << setw(20) << "Polinom: A*x^2+B*x+C" << endl; fitresults << endl; fitresults << setw(20) << "Mean (ch)" << setw(20) << "Error" << setw(20) << "Intensity (counts)" << setw(20) << "Error" << setw(20) << "Sigma (ch)" << setw(20) << "Error" << setw(20) << "------" << setw(20) << "A" << setw(20) << "Error" << setw(20) << "B" << setw(20) << "Error" << setw(20) << "C" << setw(20) << "Error" << endl; projdata.open(projdatfile.c_str()); projdata << setw(20) << "Channel" << endl; outtable.open(path.c_str()); TSTART = T_start; TCUT = T_cut; TPROJECT = T_project; MAXCHANNEL = m_fMaxchannel; PEAKTHRESHOLD = m_fPeakthreshold; return 0; } TNtuple * TRootHandler::ReadData(string infile){ indata = infile.c_str(); ifstream input; input.open(indata); while(1){ input >> time >> channel; if(!input.good()){ break; } if(channel < MAXCHANNEL){ data->Fill(time, channel); } } input.close(); return data; } TNtuple * TRootHandler::ReadCalData(char * incaldatafile){ INCALdatafile = string(incaldatafile); ifstream input; input.open(incaldatafile); while(1){ input >> time >> channel; if(!input.good()){ break; } if(channel < MAXCHANNEL){ if(TMAX < time) TMAX = time; caldata->Fill(time, channel); chanhisto->Fill(channel); // chan2dhisto->Fill(time, channel); } } input.close(); return caldata; } float TRootHandler::GetTMAX(){ return TMAX; } TNtuple * TRootHandler::ReadTable(string incaltablefile){ incaltable = incaltablefile.c_str(); ifstream incaltab; incaltab.open(incaltable); while(1){ incaltab >> number >> energy; if(!incaltab.good()){ break; } caltable->Fill(number, energy); } incaltab.close(); return caltable; } TNtuple * TRootHandler::GetTimeRangeData(TNtuple * Data, float t_start, float t_end){ if(timetuple)delete timetuple; timetuple = new TNtuple("timerangedata", "timerangedata", "time:channel"); Data->SetBranchAddress("time",&time); Data->SetBranchAddress("channel",&channel); for(int i = 0; i < Data->GetEntries();i++){ Data->GetEntry(i); if((time >= t_start) && (time <= t_end)){ timetuple->Fill(time, channel); } } return timetuple; } TNtuple * TRootHandler::GetChannelRangeData(TNtuple * Data, float ch_min, float ch_max){ if(chantuple)delete chantuple; chantuple = new TNtuple("chanrangedata", "chanrangedata", "time:channel"); Data->SetBranchAddress("time",&time); Data->SetBranchAddress("channel",&channel); for(int i = 0; i < Data->GetEntries();i++){ Data->GetEntry(i); if((channel >= ch_min) && (channel <= ch_max)){ chantuple->Fill(time, channel); } } return chantuple; } TNtuple * TRootHandler::FindPeaks(TNtuple * CalData){ CalData->SetBranchAddress("time", &time); CalData->SetBranchAddress("channel", &channel); for(int i = 0; i < CalData->GetEntries();i++){ CalData->GetEntry(i); if(channel < 7500){ histo->Fill(channel); } } spectfinder->Search(histo,3, "", PEAKTHRESHOLD); float * pos = spectfinder->GetPositionX(); for(int i = 0; i < spectfinder->GetNPeaks();i++){ peaktuple->Fill(pos[i]); } // delete histo; return peaktuple; } TNtuple * TRootHandler::GetUserPeaks(char * usertable){ ifstream input; input.open(usertable); usertuple = (TNtuple*)gROOT->FindObject("upeaks"); if(usertuple)delete usertuple; usertuple = new TNtuple("upeaks", "upeaks", "peakpos"); float temp; while(1){ input >> temp; if(!(input.good()))break; usertuple->Fill(temp); } input.close(); return usertuple; } float * TRootHandler::GetProjectedMeans(TNtuple * RangeData, float t_min, float t_max, float tproject, float chmean){ TF1 * fitsquare = new TF1("fitsquare", "[0]+[1]*x+[2]*x*x", 0, 60000); TF1 * fitgaus = new TF1("fitgaus", "([0]/[1])*exp(-0.5*((x-[2])/[1])**2)", 0, 10000); RangeData->SetBranchAddress("time", &time); RangeData->SetBranchAddress("channel", &channel); TArrayF * temparrayt = new TArrayF(RangeData->GetEntries()); TArrayF * temparraych = new TArrayF(RangeData->GetEntries()); for(int i = 0; i < RangeData->GetEntries();i++){ RangeData->GetEntry(i); temparrayt->AddAt(time, i); temparraych->AddAt(channel, i); } TGraph * fitgraph = new TGraph(RangeData->GetEntries(), temparrayt->GetArray(), temparraych->GetArray()); fitsquare->SetRange(t_min, t_max); fitsquare->SetParameters(chmean, 0.1, 0.01); fitgraph->Fit("fitsquare","R");//!!!!!!!!!!!!!!!!!!!!! fitsquare = fitgraph->GetFunction("fitsquare"); chi2 = fitsquare->GetChisquare(); par0 = fitsquare->GetParameter(0); par0_err = fitsquare->GetParError(0); par1 = fitsquare->GetParameter(1); par1_err = fitsquare->GetParError(1); par2 = fitsquare->GetParameter(2); par2_err = fitsquare->GetParError(2); fittuple->Fill(par2); fittuple->Fill(par2_err); fittuple->Fill(chi2/(fitsquare->GetNDF())); if(((par0/par0_err)>10) && ((par1/par1_err)>10) && ((par2/par2_err)>10)){ error1 = "Good fit!"; }else{ error1 = "Wrong fit!"; } sprintf(name,"graph_%d",(int)chmean); fitgraph->SetName(name); // TFile * graphout = new TFile("outgraph.root", "update"); // fitgraph->Write(); // graphout->Close(); float chmax = chmean + 100; float chmin = chmean - 100; temphisto = new TH1F("temphisto", "temphisto", 5000, 0, 10000); temphisto->SetBins(50, chmin, chmax); float tempch = 0; float projenergy = 0; tempch = (float)(fitsquare->Eval(tproject)); for(int i = 0; i < RangeData->GetEntries();i++){ RangeData->GetEntry(i); projenergy = channel - ((fitsquare->Eval(time))-tempch); temphisto->Fill(projenergy); projdata << setw(20) << projenergy << endl; } fitgaus->SetRange(chmin, chmax); fitgaus->SetParameters(10, 25, chmean); temphisto->Fit("fitgaus","R"); fitgaus = temphisto->GetFunction("fitgaus"); gchi2 = fitgaus->GetChisquare(); gpar0 = fitgaus->GetParameter(0); gpar0_err = fitgaus->GetParError(0); gpar1 = fitgaus->GetParameter(1); gpar1_err = fitgaus->GetParError(1); gpar2 = fitgaus->GetParameter(2); gpar2_err = fitgaus->GetParError(2); if((gpar2/gpar2_err)>10){ error2 = "Good fit!"; }else{ error2 = "Wrong fit!"; } fittuple->Fill(gpar2); fittuple->Fill(gpar2_err); fittuple->Fill(gchi2/(fitgaus->GetNDF())); // delete temphisto; // delete temparrayt; // delete temparraych; // delete fitgraph; // delete fitsquare; // delete fitgaus; float * peak = new float[2]; peak[0]=gpar2; peak[1]=gpar2_err; fitresults << setw(20) << gpar2 << setw(20) << gpar2_err << setw(20) << gpar0 << setw(20) << gpar0_err << setw(20) << gpar1 << setw(20) << gpar1_err << setw(20) << " " << setw(20) << par0 << setw(20) << par0_err << setw(20) << par1 << setw(20) << par1_err << setw(20) << par2 << setw(20) << par2_err << endl; outtable << setw(20) << peak[0] << setw(20) << peak[1] << setw(20) << 1 << endl; return peak; } void TRootHandler::CloseStuff(){ outtable.close(); fitresults.close(); projdata.close(); } void TRootHandler::SaveNtuple(TNtuple * ntup){ char * name = (char*)ntup->GetName(); string rname = string(name); rname = rname + ".root"; TFile * file = new TFile(rname.c_str(), "recreate"); ntup->Write(); file->Close(); } /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //Gui starts here // // // /////////////////////////////////////////////////////////////////////////// enum ETestCommandIdentifiers { M_FILE_OPEN, M_TABLE_OPEN, M_USER_OPEN, M_FILE_SAVE, M_FILE_SAVEAS, M_FILE_PRINT, M_FILE_PRINTSETUP, M_FILE_EXIT, M_HELP_CONTENTS, M_HELP_SEARCH, M_HELP_ABOUT, }; const char *filetypes[] = { "All files", "*", "ROOT files", "*.root", "TIM files", "*.tim", 0, 0 }; class MyMainFrame { RQ_OBJECT("MyMainFrame") public: TNtuple * timecut; TNtuple * chantimecut; TNtuple * peaks; TH2F * h2f; TH1F * h1; TFile * file; TCanvas * fCanvas; TGMainFrame *fMain; TRootEmbeddedCanvas *fEcanvas; TGCheckButton * fC; TGNumberEntry *fTimeLimit[2]; TGHorizontalFrame *fF[13]; TGVerticalFrame *fF1; TGNumberEntryField *fNumericEntries[13]; TGLabel *fLabel[13]; TGMenuBar *fMenuBar; TGCompositeFrame *fMenu; TGPopupMenu *fMenuFile, *fMenuHelp, *fMenuUser; TGLayoutHints *fMenuBarLayout, *fMenuBarItemLayout, *fMenuBarHelpLayout; TGLayoutHints *fL1; TGLayoutHints *fL2; TGLayoutHints *fL3; TGLayoutHints *fL4; TNtuple * ntuple; TRootHandler * roothandler; char * filename; ofstream outfile; float MaxCh; float * thepeak; float m_fStarttime; float m_fCuttime; float m_fProject; float m_fMaxchannel; float m_fPeakthreshold; char * m_sTablePath; char * m_sCaldatapath; char * m_sUserPath; public: MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h); virtual ~MyMainFrame(); void DoDraw(); void HandleMenu(Int_t id); void HandlePopup() { } void HandlePopdown() { } void InitRoot(); void ReadFile(); void DoRun(); void SetValues(); }; MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { InitRoot(); //---------------------------------------------------------------------- //Making the main frame, being a vertical frame fMain = new TGMainFrame(p,w,h, kVerticalFrame); //---------------------------------------------------------------------- //Making the Menu fMenu = new TGCompositeFrame(fMain); fMain->AddFrame(fMenu, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0)); fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX); fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight); fMenuFile = new TGPopupMenu(gClient->GetRoot()); fMenuFile->AddEntry("&Set table path...", M_TABLE_OPEN); fMenuFile->AddEntry("&Open calib file...", M_FILE_OPEN); fMenuFile->AddSeparator(); fMenuFile->AddEntry("E&xit", M_FILE_EXIT); fMenuUser = new TGPopupMenu(gClient->GetRoot()); fMenuUser->AddEntry("&Set peakfile path...", M_USER_OPEN); fMenuHelp = new TGPopupMenu(gClient->GetRoot()); fMenuHelp->AddEntry("&About", M_HELP_ABOUT); fMenuFile->Connect("Activated(Int_t)", "MyMainFrame", this, "HandleMenu(Int_t)"); fMenuFile->Connect("PoppedUp()", "MyMainFrame", this, "HandlePopup()"); fMenuFile->Connect("PoppedDown()", "MyMainFrame", this, "HandlePopdown()"); fMenuUser->Connect("Activated(Int_t)", "MyMainFrame", this, "HandleMenu(Int_t)"); fMenuHelp->Connect("Activated(Int_t)", "MyMainFrame", this, "HandleMenu(Int_t)"); fMenuBar = new TGMenuBar(fMenu, 1, 1, kHorizontalFrame); fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout); fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout); fMenuBar->AddPopup("&User", fMenuUser, fMenuBarItemLayout); fMenu->AddFrame(fMenuBar, fMenuBarLayout); //---------------------------------------------------------------------- //Making a horizontal frame in the main frame TGHorizontalFrame * horizframe = new TGHorizontalFrame(fMain, w, h); //---------------------------------------------------------------------- //Adding a Canvas for drawing fEcanvas = new TRootEmbeddedCanvas("Ecanvas",horizframe, w, h); horizframe->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY, 10,10,10,1)); //---------------------------------------------------------------------- //Adding Numeric entries const Double_t numinit[] = { 1000, 40000, 40000, 7500, 0.01, }; const char *numlabel[] = { "Start time", "Cut time", "Project time", "Max. channel", "Threshold", }; fF1 = new TGVerticalFrame(horizframe, 50, 150); TGGC myGC = *gClient->GetResourcePool()->GetFrameGC(); TGFont *myfont = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1"); if (myfont) myGC.SetFont(myfont->GetFontHandle()); fL1 = new TGLayoutHints(kLHintsTop | kLHintsRight, 2, 2, 2, 2); horizframe->AddFrame(fF1, fL1); fL2 = new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2); fL3 = new TGLayoutHints(kLHintsNormal, 2, 2, 2, 2); fL4 = new TGLayoutHints(kLHintsExpandX | kLHintsRight, 2, 2, 2, 2); for (int i = 0; i < 5; i++){ // fF[i] = new TGVerticalFrame(horizframe, 50, 30); // horizframe->AddFrame(fFv, fL3); fLabel[i] = new TGLabel(fF1, numlabel[i], myGC(), myfont->GetFontStruct()); fF1->AddFrame(fLabel[i], fL2); fNumericEntries[i] = new TGNumberEntryField(fF1, i, numinit[i], myGC(), myfont->GetFontStruct()); fF1->AddFrame(fNumericEntries[i], fL4); } TGTextButton *set = new TGTextButton(fF1,"&Set"); set->Connect("Clicked()","MyMainFrame",this,"SetValues()"); fF1->AddFrame(set, new TGLayoutHints(kLHintsCenterX, 5, 5, 3,4)); horizframe->AddFrame(fF1, new TGLayoutHints(kLHintsExpandY, 1,1,1,1)); //---------------------------------------------------------------------- //Adding the horizontal frame to the main frame (which is vertical) fMain->AddFrame(horizframe, new TGLayoutHints(kLHintsExpandX| kLHintsExpandY, 10,10,10,1)); //---------------------------------------------------------------------- //Making a horizontal frame for buttons TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,100,40); //---------------------------------------------------------------------- //Making the buttons TGTextButton *draw = new TGTextButton(hframe,"&Draw"); draw->Connect("Clicked()","MyMainFrame",this,"DoDraw()"); hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); TGTextButton *exit = new TGTextButton(hframe,"&Exit", "gApplication->Terminate(0)"); hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); TGTextButton *run = new TGTextButton(hframe,"&Run"); run->Connect("Clicked()","MyMainFrame",this,"DoDraw()"); hframe->AddFrame(run, new TGLayoutHints(kLHintsCenterX,5,5,3,4)); //---------------------------------------------------------------------- //Adding the other horizontal frame with button to main frame fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,5,2)); // Set a name to the main frame fMain->SetWindowName("Simple Example"); // Map all subwindows of main frame fMain->MapSubwindows(); // Initialize the layout algorithm fMain->Resize(fMain->GetDefaultSize()); // fMain->HideFrame(hframe); // Map main frame fMain->MapWindow(); fCanvas = fEcanvas->GetCanvas(); gStyle->SetOptStat(0); //fCanvas->cd(); fCanvas->Divide(1,2); } void MyMainFrame::DoDraw(){ h2f->SetTitle(m_sCaldatapath); h2f->GetXaxis()->SetTitle("Time (s)"); h2f->GetXaxis()->CenterTitle(); h2f->GetYaxis()->SetTitle("Channel"); h2f->GetYaxis()->CenterTitle(); h1->GetXaxis()->SetTitle("Channel"); h1->GetXaxis()->CenterTitle(); h1->GetYaxis()->SetTitle("Counts"); h1->GetYaxis()->CenterTitle(); h1->SetTitle(m_sCaldatapath); string datapath = string(m_sCaldatapath); string outpictname = datapath + ".pdf"; char * name = outpictname.c_str(); fCanvas->cd(1); h2f->Draw("cols"); fCanvas->cd(2); h1->Draw(); fCanvas->cd(); fCanvas->Update(); fCanvas->SaveAs("anyad.pdf"); } MyMainFrame::~MyMainFrame() { fMain->Cleanup(); delete fMain; } void MyMainFrame::HandleMenu(Int_t id) { // Handle menu items. switch (id) { case M_FILE_OPEN: { static TString dir("."); TGFileInfo fi; fi.fFileTypes = filetypes; fi.fIniDir = StrDup(dir); //printf("fIniDir = %s\n", fi.fIniDir); new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fi); printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); dir = fi.fIniDir; m_sCaldatapath = fi.fFilename; ReadData(); } break; case M_TABLE_OPEN: { static TString dir("."); TGFileInfo fj; fj.fFileTypes = filetypes; fj.fIniDir = StrDup(dir); //printf("fIniDir = %s\n", fi.fIniDir); new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fj); printf("Open file: %s (dir: %s)\n", fj.fFilename, fj.fIniDir); dir = fj.fIniDir; m_sTablePath = fj.fFilename; } break; case M_USER_OPEN: { static TString dir("."); TGFileInfo fz; fz.fFileTypes = filetypes; fz.fIniDir = StrDup(dir); //printf("fIniDir = %s\n", fi.fIniDir); new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fz); printf("Open file: %s (dir: %s)\n", fz.fFilename, fz.fIniDir); dir = fz.fIniDir; m_sUserPath = fz.fFilename; } break; default: printf("Menu item %d selected\n", id); break; } } void MyMainFrame::InitRoot(){ // roothandler = new TRootHandler::TRoothandler(); m_sTablePath = "C:\\root\\bin\\output.txt"; //m_sCaldatapath = ""; thepeak = new float[2]; h2f = new TH2F("h2f", "2dhisto", 2000, 0, 20000, 3500, 0, 7500); //h1 = new TH1F("h1", "histo", 500, 0, 7500); fCanvas = NULL; file = NULL; gStyle->SetPalette(1); } void MyMainFrame::ReadData(){ cout << "Reading data..."; //delete roothandler; // TRootHandler * roothandler = new TRootHandler(); roothandler = new TRootHandler(); roothandler->Initialize(m_fStarttime, m_fCuttime,m_fProject, m_sTablePath, m_fMaxchannel, m_fPeakthreshold); data = roothandler->ReadCalData(m_sCaldatapath); float t, ch; data->SetBranchAddress("time", &t); data->SetBranchAddress("channel", &ch); cout << "Entries: " << data->GetEntries() << endl; h2f->SetBins((int)((m_fCuttime-m_fStarttime)/100), m_fStarttime, m_fCuttime, 3500, 500, 7500); for(int i = 0; i < data->GetEntries(); i++){ data->GetEntry(i); // cout << t << ", " << ch << endl; h2f->Fill(t, ch); // h1->Fill(ch); } h1 = (TH1F*)((roothandler->histo)->Clone("h1")); float tmax = roothandler->GetTMAX(); peaks = roothandler->FindPeaks(roothandler->caldata); timecut = roothandler->GetTimeRangeData(roothandler->caldata, roothandler->TCUT, roothandler->TSTART); float peak_i = 0; peaks->SetBranchAddress("peakpos", &peak_i); //TNtuple result = TNtuple("result", "result", "peaks:errors"); */ for(int i = 0; i < peaks->GetEntries();i++){ peaks->GetEntry(i);// chantimecut = roothandler->GetChannelRangeData(timecut, peak_i-100, peak_i+100); thepeak = roothandler->GetProjectedMeans(chantimecut,roothandler->TCUT,roothandler->TSTART, roothandler->TPROJECT, peak_i); // result.Fill(thepeak[0], thepeak[1]); */ } h1 = (TH1F*)((roothandler->histo)->Clone("h1")); roothandler->CloseStuff(); delete roothandler; cout << "...ready!" << endl; } void MyMainFrame::DoRun(){ roothandler = new TRootHandler(); roothandler->Initialize(m_fStarttime, m_fCuttime,m_fProject, m_sTablePath, m_fMaxchannel, m_fPeakthreshold); data = roothandler->ReadCalData(m_sCaldatapath); float t, ch; data->SetBranchAddress("time", &t); data->SetBranchAddress("channel", &ch); cout << "Entries: " << data->GetEntries() << endl; for(int i = 0; i < data->GetEntries(); i++){ data->GetEntry(i); // cout << t << ", " << ch << endl; h2f->Fill(t, ch); // h1->Fill(ch); } h1 = (TH1F*)((roothandler->histo)->Clone("h1")); float tmax = roothandler->GetTMAX(); peaks = roothandler->FindPeaks(roothandler->GetUserPeaks(m_sUPeaks)); timecut = roothandler->GetTimeRangeData(roothandler->caldata, roothandler->TCUT, roothandler->TSTART); float peak_i = 0; peaks->SetBranchAddress("peakpos", &peak_i); //TNtuple result = TNtuple("result", "result", "peaks:errors"); */ for(int i = 0; i < peaks->GetEntries();i++){ peaks->GetEntry(i);// chantimecut = roothandler->GetChannelRangeData(timecut, peak_i-100, peak_i+100); thepeak = roothandler->GetProjectedMeans(chantimecut,roothandler->TCUT,roothandler->TSTART, roothandler->TPROJECT, peak_i); // result.Fill(thepeak[0], thepeak[1]); */ } h1 = (TH1F*)((roothandler->histo)->Clone("h1")); roothandler->CloseStuff(); delete roothandler; } void MyMainFrame::SetValues(){ m_fStarttime = fNumericEntries[0]->GetNumber(); m_fCuttime = fNumericEntries[1]->GetNumber(); m_fProject = fNumericEntries[2]->GetNumber(); m_fMaxchannel = fNumericEntries[3]->GetNumber(); m_fPeakthreshold = fNumericEntries[4]->GetNumber(); cout << m_fStarttime << endl; cout << m_fCuttime << endl; cout << m_fProject << endl; cout << m_fMaxchannel << endl; cout << m_fPeakthreshold << endl; // m_sTablePath = "outtable.txt"; } void DataReducs() { new MyMainFrame(gClient->GetRoot(), 400, 400); }