Newer
Older
TB_Chris / TbUT / scripts / .svn / text-base / ThresholdPlotter.cpp.svn-base
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4. #include "TH2D.h"
  5.  
  6.  
  7. using namespace std;
  8.  
  9. void ThresholdPlotter()
  10. {
  11. cout<<"start"<<endl;
  12. string fileName="noise_Mamba.dat";
  13. ifstream l_file(fileName.c_str());
  14. int channelsNumber=512;
  15. std::vector<int> thresholVector(channelsNumber,0);
  16.  
  17. for(int channel=0;channel<channelsNumber;channel++)
  18. {
  19. double l_noiseFromFile=0;
  20. l_file >> l_noiseFromFile;
  21. thresholVector[channel]=l_noiseFromFile;
  22. cout<<"NoiseRetreiver===> channel: "<< channel <<"noise: "<<l_noiseFromFile<<endl;
  23. }
  24. cout<<"create histograms" <<endl;
  25. TH2D* noiseHistogram= new TH2D("Noise Histogram","Noise (1#sigma)",100,-0.5,channelsNumber+0.5 , 100, 0, 200);
  26. TH2D* lowThresholdHistogram=new TH2D("low Thresholds Histogram","low Thresholds ",100,-0.5,channelsNumber+0.5 , 100, 0, 200);
  27. TH2D* highThresholdHistogram=new TH2D("high Thresholds Histogram","high Thresholds ",100,-0.5,channelsNumber+0.5 , 100, 0, 200);
  28.  
  29. int lawThresholdMultiplicity=2.5;
  30. int highThresholdMultiplicity=3;
  31.  
  32. cout<<"Fill histograms" <<endl;
  33.  
  34. for(int channel=0;channel<channelsNumber;channel++)
  35. {
  36. noiseHistogram->Fill(channel, thresholVector[channel]);
  37. lowThresholdHistogram->Fill(channel,lawThresholdMultiplicity* thresholVector[channel]);
  38. highThresholdHistogram->Fill(channel,highThresholdMultiplicity* thresholVector[channel]);
  39. }
  40.  
  41. TCanvas * c1 = new TCanvas("c", "c", 600, 800);
  42. noiseHistogram->GetYaxis()->SetTitle("[ADC]");
  43. noiseHistogram->GetXaxis()->SetTitle("channel");
  44. noiseHistogram->SetMarkerStyle(2);
  45. noiseHistogram->SetLineColor(kWhite);
  46.  
  47. lowThresholdHistogram->SetMarkerStyle(2);
  48. lowThresholdHistogram->SetMarkerColor(kGreen);
  49. lowThresholdHistogram->SetLineColor(kWhite);
  50.  
  51. highThresholdHistogram->SetMarkerStyle(2);
  52. highThresholdHistogram->SetMarkerColor(kRed);
  53. highThresholdHistogram->SetLineColor(kWhite);
  54.  
  55. noiseHistogram->Draw();
  56. lowThresholdHistogram->Draw("same");
  57. highThresholdHistogram->Draw("same");
  58. c1->BuildLegend(0.7296238,0.8274793,0.9004702,0.8997934);
  59. gStyle->SetOptStat(0);
  60.  
  61. }