#include "TH1.h" #include "TH2.h" #include "TCanvas.h" #include "TGraph.h" #include "TGraph2D.h" #include "TStyle.h" #include #include // reads a data file fname with nch channels and return an 1D histogram TH1F *readDataFile(char* fname, int nch) { int itmp, ch; float fc; TH1F *h = new TH1F("h1","",nch,-0.5,nch-0.5); h->Sumw2(); FILE* fp=fopen(fname,"r"); if (fp==NULL) { printf("Could not open file %s\n",fname); return h; } for (int j=0; jSetBinContent(j+1,fc); } fclose(fp); return h; } // Creates a 2D histogram from a set of files (fn is the format of the file name) TH2F* createScan(char* fn, int mi, int ma, int step, int nch) { char fname[1000]; TH1F *hdum; TH2F *h2 = new TH2F("h2","",nch,-0.5,nch-0.5,((ma-mi)/step)+1,mi-(Double_t)step/2.,ma+(Double_t)step/2.); h2->SetStats(kFALSE); for (int i=mi; iFill(j,i,hdum->GetBinContent(j+1)); delete hdum; } return h2; } float pixelAveCount(TH2F *h2, int ichan) { float pixAveCount; int nsteps = h2->GetYaxis()->GetNbins(); float pixCount=0.; for (int istep=1; istepGetBinContent (ichan+1, istep); } pixAveCount = pixCount/nsteps; return pixAveCount; } //scans through bad channels bool item_exists(int item, int *array, int arrSize) { for(int k=0; k < arrSize; k++) { if(array[k] == item) { return true; } } return false; } void storeToVector(char *fpath0, int chMin, int chMax, int sensor) { gStyle->SetCanvasDefH(500); gStyle->SetCanvasDefW(560); gStyle->SetPalette(1); char fname[256]; char fn[6] = "/run_"; char ext[5] = ".raw"; int begin = 0; int end = 59; char specifier[3] = "%d"; float pixelAveCnts; int filter = 20; vector avCnt[filter]; int size_goodChan; Double_t avPixCount; vector ioc; const char *fbadname ="/home/results/layer_2_2011May/badChan_AllMods.raw"; char line_bad[80]; int badChan; vector vec_bad; int size; FILE *fbad = fopen(fbadname,"r"); if(fbad==NULL) { printf("Could not open file %s\n", fbadname); return; } while (fgets(line_bad, 256, fbad) != NULL) { sscanf(line_bad, "%d",&badChan); vec_bad.push_back(badChan); } size=vec_bad.size(); int *bad=new int[size*sizeof(int)]; for (int ibad =0; ibad iocData() ; int igoodChan = 0; char channel[]= "Good Channel"; char chanNum[100]; vector iocVector = iocData() ; float iocData_elem; // Double_t mypar[2], emypar[2]; vector fitElements; const char *fitFile0 = "/home/res1/filElements.sensor0"; char fitFile[256]; sprintf(fitFile,"%s%d",fitFile0, sensor); FILE *ftfile = fopen(fitFile, "w"); if(ftfile==NULL) { printf("Could not open file %s\n", fitFile); return; } size_goodChan = avCnt[0].size(); const char *hist = " Sensor"; char histName[256]; sprintf(histName,"%s%d", hist, sensor); TCanvas *c1 = new TCanvas("c1"); //c1=c1; TCanvas *c2 = new TCanvas("c2"); TGraph2D *g2Deff = new TGraph2D(filter); M1: if(igoodChan>=0 && igoodChan< size_goodChan){ sprintf(chanNum, "%s %d", channel,igoodChan ); TGraph *geff = new TGraph(); geff ->SetLineColor(2); geff ->SetMarkerStyle(20); geff ->SetMarkerSize(2); geff ->SetMarkerColor(2); geff ->SetLineWidth(8); geff ->SetTitle(chanNum); for (int ifilter =0; ifilterSetPoint(ifilter, iocData_elem, avPixCount); g2Deff->SetPoint(ifilter,igoodChan, iocData_elem, avPixCount); } printf("g2Deff Xmin %f Ymin %f Zmin %f\n", g2Deff->GetXmin(), g2Deff->GetYmin(), g2Deff->GetZmin()); printf("g2Deff Xmax %f Ymax %f Zmax %f\n", g2Deff->GetXmax(), g2Deff->GetYmax(), g2Deff->GetZmax()); c1->cd(); geff->Draw("ALP"); c1->Modified(); usleep(500000); c1->Update(); delete geff; igoodChan++; if (igoodChan<=size_goodChan) goto M1; } c2->cd(); g2Deff->Draw("surf4"); fclose(ftfile); return; } //read ioc data vector iocData() { vector ioc; int itmp, nreadings =20; float iocReading; const char *f_ioc = "/home/l_common/Frances/results/efficiencyMay2011/iocReadings.log"; FILE * fioc = fopen(f_ioc, "r"); if(fioc==NULL) { printf("Could not open file %s'\n", f_ioc); return ioc; } for(int iioc=0; iioc