00001 #ifndef MpsAnalysis_HH
00002 #define MpsAnalysis_HH
00003
00004 #include <cassert>
00005
00006 #include <vector>
00007 #include <iterator>
00008 #include <map>
00009 #include <iostream>
00010 #include <fstream>
00011 #include <sstream>
00012 #include <string>
00013
00014 #include "RcdUserRO.hh"
00015 #include "SubAccessor.hh"
00016
00017 #include "TH1F.h"
00018 #include "TFile.h"
00019 #include "TH2F.h"
00020 #include "TH3F.h"
00021 #include "TH1I.h"
00022 #include "TF1.h"
00023 #include "TProfile.h"
00024 #include "TObject.h"
00025
00026 #include "MpsSensor1FullTimeStamps.hh"
00027
00028
00029 std::string IntToStr(int number) {
00030 std::ostringstream oss;
00031
00032
00033 oss<< number;
00034
00035
00036 return oss.str();
00037 }
00038
00039 class MpsAnalysis : public RcdUserRO {
00040
00041 public:
00042 enum {
00043 defaultMpsAnalysisBits=0xffff
00044 };
00045
00046 MpsAnalysis(unsigned wombat, int runNumber, int bins = 1000, int low = 0,
00047 int high = 2000, int trackingSensor = 0);
00048
00049 virtual ~MpsAnalysis();
00050
00051 bool record(const RcdRecord& r);
00052
00053 void handleBunchTrain(
00054 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* >);
00055 void handleThresholdScanRun(
00056 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* >);
00057 void handleBeamRun(
00058 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* >);
00059 void handleBeamThresholdScanRun(
00060 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* >,
00061 unsigned);
00062 void handleCosmicThresholdScanRun(
00063 std::vector<const MpsLocationData<MpsSensor1BunchTrainData>* >,
00064 unsigned);
00065
00066
00067
00068
00069 void findHitDistribution();
00070
00071
00072
00073
00074 void findNoisyPixels(int cut);
00075
00076 void makeGlobalTimeStampPlot();
00077
00078 void computeEfficiencies();
00079
00080
00081 void saveToDisk();
00082
00083 private:
00084 void populateSensorIds(SubAccessor);
00085 void makeHistograms(int[]);
00086 void writeRootFile();
00087
00088
00089
00090 bool determineRunType(std::vector<const IlcRunStart*>);
00091
00092 bool _thresholdScanRun;
00093 bool _thresholdRun;
00094 bool _mpsBeamThresholdScan;
00095 bool _mpsBeam;
00096
00097 unsigned _runNumber;
00098
00099 int _sensorIds[5];
00100
00101
00102 unsigned _pmtDaqIndex;
00103
00104 int _shaperThreshold[5];
00105 int _samplerThreshold[5];
00106
00107 unsigned _nHits;
00108 unsigned int _tHits;
00109
00110 unsigned _timeStampsBySensor[5][8192];
00111 unsigned _timeStampsByShap[5][8192];
00112 unsigned _timeStampsBySamp[5][8192];
00113
00114 unsigned _allTimeStamps[8192];
00115 TH1F* _hTimeStampsBySensor[5];
00116 TH1F* _hGlobalTimeStamps;
00117 TH1F* _hSimulTimeStamps;
00118
00119
00120 unsigned _Tracks[5][2010];
00121 unsigned _ConfirmedTracks[5][2010];
00122
00123 unsigned int _bins;
00124 int _lowEdge;
00125 int _highEdge;
00126
00127 unsigned int _nBt;
00128 unsigned int _specialSensor;
00129
00130 unsigned int _spillCycleCount;
00131
00132 TFile* _rootFile;
00133 TH2I* _hNHitsPerConfig;
00134
00135 TH2F* _hTimestampsByThreshold[5][4];
00136
00137 TH1F* _hHitsInRow;
00138 TH2F* _hHitsInBtByThreshold[5];
00139 TH2F* _hWordHits[5][4];
00140 TH2F* _hHits[5][4];
00141 TProfile* _hHitsByRegion[5][4];
00142 TH2F* _hGroupsAndRows[5][4];
00143 TH2F* _hHitPattern[5];
00144 TH1F* _hThreshEfficacy[5];
00145 TH1F* _hTimestamps;
00146 TProfile* _hEffAndThreshShap[5];
00147 TProfile* _hEffAndThreshSamp[5];
00148 TProfile* _hEffAndThreshOverall[5];
00149 TProfile* _hEffAndThreshShapDispT[5];
00150 TProfile* _hEffAndThreshSampDispT[5];
00151 TProfile* _hEffAndThreshOverallDispT[5];
00152
00153
00154 TH1F* _hEffIntegratedAllBts[5];
00155
00156
00157 TH1F* _hNHitsInBunchtrain[5];
00158
00159 TH1F* _hTracks3Vertices;
00160 TH1F* _hTracks3VerticesInT;
00161 TH1F* _hTracks4VerticesInT;
00162 TH2F* _hTracks3VerticesInXY;
00163 TH2F* _hTracks4VerticesInXY;
00164
00165 TH2F* _hSoftPhotonsSpecialSensor;
00166 typedef std::pair<int, int> uv_key;
00167 typedef std::map<uv_key, TProfile*> thresholdPfxs;
00168 thresholdPfxs _threshProfs;
00169
00170 std::vector<const MpsSensor1BunchTrainDatum*> _datums;
00171 int _configCount;
00172 typedef std::vector<TObject*> tObjs;
00173 tObjs myObjs;
00174 tObjs globals;
00175 tObjs hitsByRegion;
00176 tObjs wordsByRegion;
00177 tObjs groupsAndRows;
00178 tObjs efficiencies;
00179 tObjs efficienciesDispT;
00180 tObjs dqm;
00181 };
00182
00183
00184 #include "MpsAnalysis.cc"
00185 #endif