#include #include "TFile.h" #include "TTree.h" #include "TCanvas.h" #include "TString.h" #include "Riostream.h" void histo64(void){ // TTree *ntuple1 = new TTree("ntuple1", "data from ascii file"); // ntuple1->ReadFile(data_file, "date1/f:c0/f:c1/f:c2/f:c3/f:c4/f:c5/f:c6/f:c7/f:c8/f:c9/f:c10/f:c11/f:c12/f:c13/f:c14/f:c15/f:c16/f:c17/f:c18/f:c19/f:c20/f:c21/f:c22/f:c23/f:c24/f:c25/f:c26/f:c27/f:c28/f:c29/f:c30/f:c31/f:c32/f:c33/f:c34/f:c35/f:c36/f:c37/f:c38/f:c39/f:c40/f:c41/f:c42/f:c43/f:c44/f:c45/f:c46/f:c47/f:c48/f:c49/f:c50/f:c51/f:c52/f:c53/f:c54/f:c55/f:c56/f:c57/f:c58/f:c59/f:c60/f:c61/f:c62/f:c63/f"); // ntuple1->Write(); // ntuple->Draw(“date1:c1>histo”,””,”cont4”) ifstream in; in.open("gain1.dat"); Float_t c[64], date; Int_t nlines = 0; TFile *f = new TFile("histo.root","RECREATE"); TH1F *h[64]= new TH1F("h1","x distribution",100,-4,4); TNtuple *ntuple = new TNtuple("ntuple","data from ascii file",",date,c[0],c[1]:c[2]:c[3]:c[4]:c[5]:c[6]:c[7]:c[8]:c[9]:c[10]:c[11]:c[12]:c[13]:c[14]:c[15]:c[16]:c[17]:c[18]:c[19]:c[20]:c[21]:c[22]:c[23]:c[24]:c[25]:c[26]:c[27]:c[28]:c[29]:c[30]:c[31]:c[32]:c[33]:c[34]:c[35]:c[36]:c[37]:c[38]:c[39]:c[40]:c[41]:c[42]:c[43]:c[44]:c[45]:c[46]:c[47]:c[48]:c[49]:c[50]:c[51]:c[52]:c[53]:c[54]:c[55]:c[56]:c[57]:c[58]:c[59]:c[60]:c[61]:c[62]:c[63]"); while (1) { in >> c[0]>>c[1]>>c[2]>>c[3]>>c[4]>>c[5]>>c[6]>>c[7]>>c[8]>>c[9]>>c[10]>>c[11]>>c[12]>>c[13]>>c[14]>>c[15]>>c[16]>>c[17]>>c[18]>>c[19]>>c[20]>>c[21]>>c[22]>>c[23]>>c[24]>>c[25]>>c[26]>>c[27]>>c[28]>>c[29]>>c[30]>>c[31]>>c[32]>>c[33]>>c[34]>>c[35]>>c[36]>>c[37]>>c[38]>>c[39]>>c[40]>>c[41]>>c[42]>>c[43]>>c[44]>>c[45]>>c[46]>>c[47]>>c[48]>>c[49]>>c[50]>>c[51]>>c[52]>>c[53]>>c[54]>>c[55]>>c[56]>>c[57]>>c[58]>>c[59]>>c[60]>>c[61]>>c[62]>>c[63]>>c[64]; if (!in.good()) break; for (i=0, i<66, i++){ h[i]->Fill(c[i]);} ntuple->Fill(c[i]); nlines++; } printf(" found %d points\n",nlines); in.close(); f->Write(); TCanvas *c1 = new TCanvas("c1","plots"); c1->Divide(8,8,.001,.001); for(i=1; i<=64; i++){ c1->cd(i); // c1->cd(i)->SetLogy(); h[i]->Draw(); } c1->Modified(); c1->Update(); delete f; }