trimdac_scan.cpp 1.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
void trimdac_scan(){
  std::vector<TH1D*>histo;
  std::vector<std::string>filenames={
    std::string("dacs0x0_bl_thr.dat"),
    std::string("dacs0x1_bl_thr.dat"),
    std::string("dacs0x2_bl_thr.dat"),
    std::string("dacs0x3_bl_thr.dat"),
    std::string("dacs0x4_bl_thr.dat"),
    std::string("dacs0x5_bl_thr.dat"),
    std::string("dacs0x6_bl_thr.dat"),
    std::string("dacs0x7_bl_thr.dat"),
    std::string("dacs0x8_bl_thr.dat"),
    std::string("dacs0x9_bl_thr.dat"),
    std::string("dacs0xA_bl_thr.dat"),
    std::string("dacs0xB_bl_thr.dat"),
    std::string("dacs0xC_bl_thr.dat"),
    std::string("dacs0xD_bl_thr.dat"),
    std::string("dacs0xE_bl_thr.dat"),
    std::string("dacs0xF_bl_thr.dat")
  };
  std::vector<int>colors={kTeal+3,kPink-3,kOrange+8,kRed+4 ,kCyan+2,kMagenta+1,kGreen-3,kPink-6,kBlue+3,kYellow+3,kPink+2,kBlue-6,kRed-1,kYellow-5,kRed-8,kAzure};
  double data;
  TCanvas*c1 = new TCanvas();
  THStack*hs = new THStack("hs", "Trim dac scan");
  
  for(int ctr=0;ctr<17;ctr++){
    std::ifstream datafile(filenames.at(ctr).c_str());
    std::string histo_name = "h"+ filenames.at(ctr);
    TH1D* h1= new TH1D(histo_name.c_str(),"Trim dac scan", 175,950,1300);
    
    if(datafile.is_open()){
      cout<<" The data file "<<filenames.at(ctr) << " is opened ..."<<std::endl;
      
      while(!datafile.eof()){
	
	datafile>>data;
	//	cout<<data<<std::endl;
	h1->Fill(data);
      }
      h1->SetLineColor(colors.at(ctr));
      histo.push_back(h1);
      cout<<filenames.at(ctr)<<"histogram is filled..."<<std::endl;
    }
    //datafile.close();
  }
  
  cout<<"size of the histo vector is "<<histo.size()<<std::endl; 
  
 
  for(int i=0;i<histo.size();i++){
    cout<<"stacking"<< histo.at(i)<<std::endl;
    hs->Add(histo.at(i),"sames");
  }
  hs->Draw("hist nostack");
  hs->GetXaxis()->SetTitle("Threshold [LSB]");
  hs->GetYaxis()->SetTitle(" #pixels");

  cout<<"Done.."<<std::endl;
}