struct GammaModule { Double_t tc99Count[64][1024]; Double_t tc99Center[64]; Double_t co57Count[64][1024]; Double_t co57Center[64]; Double_t ebin[64]; Double_t tc99Energy[64][1024]; }; void readModuleSpectrum(Int_t source, Int_t moduleNum, Int_t channel, GammaModule *module) { char file[256]; if (source == 0) sprintf(file,"wta%2dch%2d.txt", moduleNum, channel); else if (source == 1) sprintf(file,"wta%2dch%2d.txt", moduleNum, channel); printf("Reading %s\n", file); FILE *ifl = fopen(file, "r"); char line[256]; Float_t binNum, count; Int_t ibinNum; // Skip three lines for (Int_t i=0; i<3; i++) fgets(line,256,ifl); // Read data from file Int_t retcod; Bool_t bretcod; while ( bretcod=((retcod=fscanf(ifl, "%f", &binNum)) != EOF)) { printf("-- %d %d %d\n", bretcod, retcod, EOF); ibinNum = binNum; fscanf(ifl, "%f", &count); if (source == 0) module[moduleNum].tc99Count[channel][ibinNum] = count; else if (source == 1) module[moduleNum].co57Count[channel][ibinNum] = count; } printf("%d %d\n", retcod, EOF); fclose(ifl); } void calibrateEnergy(){ GammaModule module[16]; Int_t moduleNum = 0; const Int_t nModule = 1; Int_t moduleList[]= {0}; // for (Int_t i=0; iFindObject("c1"); if (!c1) c1 = new TCanvas("c1", "Canvas1", 0, 0, 800, 1000); TH1F *hist1 = new TH1F("hist1","Spectrum", 1024, -0.5, 1023.5); TH1F *hist2 = new TH1F("hist2","Spectrum", 1024, -0.5, 1023.5); for (Int_t i = 0; i<1024; i++) { hist1->SetBinContent(i, module[0].tc99Count[0][i]); hist2->SetBinContent(i, module[0].co57Count[0][i]); } c1->Divide(1,2); c1->cd(1); hist1->Draw(); c1->cd(2); hist2->Draw(); }