Newer
Older
TB_Chris / Kepler / Scripts / .svn / text-base / PixelMapAnalysis_Kepler.h.svn-base
  1. #include "TFile.h"
  2. #include "TH2D.h"
  3. #include <iostream>
  4. #include <fstream>
  5. #include <iomanip>
  6. #include <vector>
  7. #include <algorithm>
  8. #include "TROOT.h"
  9. #include "TKey.h"
  10. #include "TIterator.h"
  11. #include <string>
  12.  
  13. /*
  14. ......................................................................
  15. Author: Hella Snoek (hella.snoek@cern.ch)
  16. Date: 22.07.2014
  17.  
  18. Simple ROOT analysis code to analyse the pixel hit maps for
  19. - DEAD: no hits
  20. - HOT: too many hits
  21. - LOW: too few hits
  22. pixel hits.
  23.  
  24. A pixel cell is compared to its 8 neighbouring (exception for pixel on
  25. the edge below) pixel cells. The 2 highest and 2 lowest hit counts
  26. are removed before making an average of the surrounding pixel cells.
  27. The minimum required count in a cell for the analysis is 20.
  28. A HOT cell is 40 times higher than the average.
  29. A LOW cell is 4 std deviations (sqrt) lower.
  30.  
  31. For the cells on the edge of the sensor the highest and lowest hits
  32. are not removed for the average.
  33.  
  34. ......................................................................
  35. */
  36.  
  37. using namespace std;
  38. void PixelMapAnalysis(TH2D* hist, unsigned int plane, ostream& os = std::cout ){
  39. for (int col=0;col<256;col++){
  40. for (int row=0;row<256;row++)
  41. {
  42. double count = hist->GetBinContent(col+1,row+1);
  43.  
  44. vector<double> neighbours;
  45. for( int i = 0 ; i < 3; i++)
  46. {
  47. for(int j=0; j < 3; j++)
  48. {
  49. if( i == 1 && j == 1) continue;
  50. neighbours.push_back( hist->GetBinContent( col +i, row +j ));
  51. }
  52. }
  53. double total(0.);
  54. if (col>0&&col<255&&row>0&&row<255) {
  55. for (uint i=2;i<neighbours.size()-2;i++) total=total+neighbours[i];
  56.  
  57. if (count >10*total)
  58. os << plane << " "<< col << " "<< row << endl;
  59. }
  60. else {
  61. for (uint i=0;i<neighbours.size();i++)
  62. total=total+neighbours[i];
  63.  
  64. if (count >10*total)
  65. os << plane << " "<< col << " "<< row << endl;
  66. }
  67. }
  68. }
  69. }