#include #include #include #include #include "Cell.h" #include "TGraph2DErrors.h" using namespace std; /*************************************************************************************/ Cell::Cell(double delX, double delY, double rad, double X0, double Y0) : dx(delX),dy(delY),r(rad),x0(X0),y0(Y0){ InitializeCells();//figure out n_cell and assign f = NULL; } Cell::Cell(const char* filename){//load from filename f = NULL; OpenFile(filename,"READ"); ReadData(filename); //set TDirectory(0) to keep read objects in memory after closing file CloseFile(); } Cell::~Cell(){} void Cell::ResizeVectors(int n){ xlo.ResizeTo(n); xmid.ResizeTo(n); xhi.ResizeTo(n); ylo.ResizeTo(n); ymid.ResizeTo(n); yhi.ResizeTo(n); } void Cell::InitializeCells(){ int k; double xtemp,ytemp; //determine number of cells just overtaking circle horizontally and vertically nx = 2*ceil((r-dx/2)/dx) + 1; ny = 2*ceil((r-dy/2)/dy) + 1; ResizeVectors(nx*ny); //determine resulting bounding square X_bound = (dx/2 + (nx-1)/2*dx); Y_bound = (dy/2 + (ny-1)/2*dy); k = 0; ytemp = -Y_bound; for(int i=0;iIsOpen()){ cout << "A file is already open. Close file this file before opening another." << endl; } f = new TFile(filename,opt); if (f->IsZombie()){ cout << "ERROR: Could not open file "<Close(); delete f; f = NULL; } } void Cell::ReadData(const char* filename){ if (f->IsZombie()||f==NULL){ cout << "File"<Get("dx"); dy_t = *(TVectorD*) f->Get("dy"); r_t = *(TVectorD*) f->Get("r"); x0_t = *(TVectorD*) f->Get("x0"); y0_t = *(TVectorD*) f->Get("y0"); X_bound_t = *(TVectorD*) f->Get("X_bound"); Y_bound_t = *(TVectorD*) f->Get("Y_bound"); dx = dx_t[0]; dy = dy_t[0]; r = r_t[0]; x0 = x0_t[0]; y0 = y0_t[0]; X_bound = X_bound_t[0]; Y_bound = Y_bound_t[0]; //Resize vectors before assignment TVectorD* xlo_ptr = (TVectorD*) f->Get("xlo"); n_cell = xlo_ptr->GetNoElements(); ResizeVectors(n_cell); xlo = *(TVectorD*) f->Get("xlo"); xmid = *(TVectorD*) f->Get("xmid"); xhi = *(TVectorD*) f->Get("xhi"); ylo = *(TVectorD*) f->Get("ylo"); ymid = *(TVectorD*) f->Get("ymid"); yhi = *(TVectorD*) f->Get("yhi"); nx = (int) 2*X_bound/dx; ny = (int) 2*Y_bound/dy; } void Cell::WriteData(const char* filename){ if (f->IsZombie()||f==NULL){ cout << "File"<" + convert.str(); cut1 = dumstr.c_str(); convert.str(""); convert.clear(); dumstr.clear(); convert <" + convert.str(); cut3 = dumstr.c_str(); convert.str(""); convert.clear(); dumstr.clear(); convert <Get("Q_mean"); // Q_std = *(TVectorD*) f->Get("Q_std"); Q_err = *(TVectorD*) f->Get("Q_err"); } void Q_Cell::WriteData(const char* filename){ Cell::WriteData(filename); //call parent method Q_mean.Write("Q_mean",TObject::kOverwrite); //Q_std.Write("Q_std",TObject::kOverwrite); Q_err.Write("Q_err",TObject::kOverwrite); TH2D h2D_Q("h2D_Q","MCP Mean Q",nx,-X_bound,X_bound,ny,-Y_bound,Y_bound); TGraph2DErrors graph2D_Q(n_cell); graph2D_Q.SetTitle("MCP Mean Q"); for(int i=0;iSetDirectory(0); .... } void Q_Cell::SetPoint(int i, double Qmean, double Qerr){ double x, y; GetCenter(i,x,y); SetQMean(i,Qmean); //SetQStd(i,Qstd); SetQErr(i,Qerr); //cout<<"n_cell ="<Get("T0_abs"); if (T0_abs_ptr ==NULL){ cout<<"WARNING: File "<Get("T0_abs"); T0_abs_err = *(TVectorD*) f->Get("T0_abs_err"); T0_rel = *(TVectorD*) f->Get("T0_rel"); //Define one element vectors for reading TVectorD rel_idx_t(1); rel_idx_t = *(TVectorD*) f->Get("rel_idx"); rel_idx = rel_idx_t[0]; } void T0_Cell::WriteData(const char* filename){ Cell::WriteData(filename); //call parent method T0_abs.Write("T0_abs",TObject::kOverwrite); T0_abs_err.Write("T0_abs_err",TObject::kOverwrite); T0_rel.Write("T0_rel",TObject::kOverwrite); //Define one element vectors for writing TVectorD rel_idx_t(1); rel_idx_t[0] = rel_idx; rel_idx_t.Write("rel_idx",TObject::kOverwrite); TH2D h2D_T0rel("h2D_T0rel","Relative T0 Correction",nx,-X_bound,X_bound,ny,-Y_bound,Y_bound); TGraph2DErrors graph2D_T0abs(n_cell); graph2D_T0abs.SetTitle("Absolute T0"); for(int i=0;iSetDirectory(0); .... } void T0_Cell::PrintClass(){ T0_abs.Print(); xmid.Print(); } void T0_Cell::SetPoint(int i, double Qmean, double Qerr){ double x, y; GetCenter(i,x,y); //SetT0_abs(i,Qmean); //SetT0_abs_err(i,Qerr); //cout<<"n_cell ="<