int cluster2(const char * input = "Chargeff.csv", 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; vector eventID; string spx, spy, sth, sd, spn; string line; stringstream ssth, ssd; double d = 0, t = 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,','); getline(s_data,spn,','); 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); eventID.push_back(stoi(spn)); } TH1F *h_cluster_size = new TH1F("cluster_size","cluster_size",100, 0.,6.); int cluster_size = 0; for(int i = 0; i < eventID; i++){ //looping over number of events cluster_size = posx.size(); } h_cluster_size->Fill(cluster_size); h_cluster_size->Write(); fout->Close(); return 0; } }