#ifndef MpsAnalysis_HH #define MpsAnalysis_HH #include #include #include #include #include #include #include // Required for stringstreams #include #include "RcdUserRO.hh" #include "SubAccessor.hh" #include "TH1F.h" #include "TFile.h" #include "TH2F.h" #include "TH3F.h" #include "TH1I.h" #include "TF1.h" #include "TProfile.h" #include "TObject.h" #include "MapsTrack.hh" #include "MapsTrackManager.hh" #include "MapsSensor.hh" #include "MpsSensor1FullTimeStamps.hh" class MpsAnalysis : public RcdUserRO { public: enum { defaultMpsAnalysisBits=0xffff }; //First argument is ignored, bins, low and high define the histograms //in terms of the threshold ranges. MpsAnalysis(unsigned wombat, int runNumber, int bins = 1000, int low = 0, int high = 2000, int trackingSensor = 0); virtual ~MpsAnalysis(); bool record(const RcdRecord& r); void handleBunchTrain( std::vector* >, std::vector* >); void handleThresholdScanRun( std::vector* >, std::vector* >); void handleBeamRun( std::vector* >, std::vector* >); void handleBeamThresholdScanRun( std::vector* >, std::vector* >, unsigned); void handleCosmicThresholdScanRun( std::vector* >, std::vector* >, unsigned); void fillPmtTimestampPlot( std::vector* >); void populateTimeStampsAndPositions(unsigned sensor, const std::vector& hitVec, int lowestThresh); //integrates over all hits in the run to make a histogram void findHitDistribution(); //make a list of all noisy pixels who have more than 'cut' hits in the whole run void findNoisyPixels(int cut); //write Root file to disk void saveToDisk(); void makeGlobalTimeStampPlot(); //called at the end of the run void computeEfficiencies(); private: void populateSensorIds(SubAccessor); void makeHistograms(int[]); void writeRootFile(); std::map getSensorPositions(); std::map getMapsSensors(); //returns true if this was successful, otherwise false bool determineRunType(std::vector); //returns true if the sensors was rotated by 180 deg relative to the global coordinate system bool wasSensorRotated(const unsigned sensorId); bool _thresholdScanRun; bool _thresholdRun; bool _mpsBeamThresholdScan; bool _mpsBeam; bool _mpsCosmicsThresholdScan; unsigned _runNumber; int _sensorIds[5]; unsigned _pmtDaqIndex; int _shaperThreshold[5]; int _samplerThreshold[5]; unsigned _nHits; unsigned int _tHits; unsigned _ConfirmedTracks[5][2010]; unsigned _Tracks[5][2010]; unsigned _timeStampsBySensor[5][8192]; unsigned _timeStampsByShap[5][8192]; unsigned _timeStampsBySamp[5][8192]; unsigned _allTimeStamps[8192]; TH1F* _hTimeStampsBySensor[5]; TH1F* _hGlobalTimeStamps; TH1F* _hSimulTimeStamps; double _xPosBySensor[5][8192][2]; double _yPosBySensor[5][8192][2]; unsigned int _bins; int _lowEdge; int _highEdge; unsigned int _nBt; unsigned int _specialSensor; unsigned int _spillCycleCount; unsigned int _currCommonMode; TFile* _rootFile; TH2I* _hNHitsPerConfig; TH2F* _hTimestampsByThreshold[5][4]; TH1F* _hHitsInRow; TH2F* _hHitsInBtByThreshold[5]; TH2F* _hWordHits[5][4]; TH2F* _hHits[5][4]; TProfile* _hHitsByRegion[5][4]; TH2F* _hGroupsAndRows[5][4]; TH2F* _hHitPattern[5]; TH1F* _hThreshEfficacy[5]; TH1F* _hTimestamps; TProfile* _hEffAndThreshShap[5]; TProfile* _hEffAndThreshSamp[5]; TProfile* _hEffAndThreshOverall[5]; TH1F* _hTimestampsSamplers; TH1F* _hTimestampsShapers; //histograms for run quality monitoring TH1F* _hNHitsInBunchtrain[5]; TH1F* _hTracks3Vertices; TH1F* _hTracks4Vertices; TH1F* _hTracks3VerticesInT; TH1F* _hTracks4VerticesInT; TH2F* _hTracks3VerticesMeanXY; TH1F* _hTracks3VerticesXDispersion; TH1F* _hTracks3VerticesYDispersion; TH2F* _hTracksXYDispAnd4thSensor; TH2F* _hTracksXYDispAndHitsInTrack; TH1F* _hEffIntegratedAllBts[5]; TH2F* _hTracks3VerticesInXY[5]; TH2F* _hTracks4VerticesInXY[5]; TH1F* _hVetoHitCount[5]; TH2F* _hVetoHitXY[5]; TH1F* _hVetoHitXStdDev[5]; TH1F* _hVetoHitYStdDev[5]; TH1F* _hVetoT[5]; TProfile* _hEffAndThreshSampDispT[5]; TProfile* _hEffAndThreshShapDispT[5]; TProfile* _hEffAndThreshOverallDispT[5]; TH1F* _hPmtTags1; TH1F* _hPmtTags2; TH1F* _hPmtCoincidence; TH2F* _hNHitsAndDispersion; TH1F* _hNClustersInT; TH2F* _hSoftPhotonsSpecialSensor; typedef std::pair uv_key; typedef std::map thresholdPfxs; thresholdPfxs _threshProfs; std::vector _datums; int _configCount; typedef std::vector tObjs; tObjs myObjs; tObjs globals; tObjs hitsByRegion; tObjs wordsByRegion; tObjs groupsAndRows; tObjs efficiencies; tObjs efficienciesDispT; tObjs dqm; tObjs pmt; tObjs clustering; tObjs tracking; std::map _mySensors; MapsTrackManager _mtm; MapsTrackManager _mtmDispT; }; //daquser/records code structure require this... #include "MpsAnalysis.cc" #endif