#include #include "TH2D.h" #include "TFile.h" #include #include #include #include #include using namespace std; int cluster_size(const char * input = "out1.txt", const char * output = "pixels.root"){ ifstream fint; //input file fint.open(input); if(!fint.is_open()){ cout << "Input File " << input << " had issues while opening, closing the script\n"; return -1; } TFile * fout = new TFile(output, "RECREATE"); int pixarrX = 727, pixarrY = 727; //number of pixels in 2D vector posx; vector posy; vector thick; vector dose; string spx, spy, sth, sd; string line; stringstream ssth, ssd; double d = 0, t = 0; int c_dec = 1; int prev = 0; while (getline(fint,line)){ if(line.length() == 1 || line.empty()){ continue; } else if(isdigit(line.at(0))){ stringstream s_data(line); getline(s_data,spx,','); getline(s_data,spy,','); getline(s_data,sth,','); getline(s_data,sd,','); stringstream ssth(sth), ssd(sd); ssth >> t; //common procedure for the conversion ssd >> d; posx.push_back(stoi(spx)); //for int (not in scientific notation) the stoi function is used posy.push_back(stoi(spy)); thick.push_back(t); dose.push_back(d); } for(int i = 0; i < 4100; i++){ //looping over number of events TH1F *h_cluster_size = new TH1F("cluster_size","cluster_size",100, 0.,727.); int cluster_size = 0; cluster_size = posx.size(); h_cluster_size->Fill(cluster_size); } // h_cluster_size->Write(); } fout->Close(); return 0; }