00001 #include "Sct/IS/IOManagerIS.h"
00002 #include "SctData/RawScanResult.h"
00003 #include "SctData/ScanPoints.h"
00004 #include "SctData/ModuleConfiguration.h"
00005 #include <TH2.h>
00006
00007 using namespace Sct;
00008 using namespace Sct::IS;
00009 using namespace SctData;
00010 using namespace std;
00011 using namespace boost;
00012
00013 class CheckRaw {
00014 public:
00015 unsigned int runNumber;
00016 unsigned int scanNumber;
00017 string moduleName;
00018 unsigned char groupID;
00019 float chip5CalFactor;
00020 unsigned char chip4Target;
00021 unsigned char chip11Threshold;
00022 unsigned char chip0Chan0Trim;
00023 unsigned int nPoints;
00024 double point0;
00025 double bin00;
00026 double bin4930;
00027 int exitCode;
00028
00029 CheckRaw() {
00030 exitCode = 0;
00031 }
00032
00033 void compare(string name) {
00034 shared_ptr<Serializable> s = IOManagerIS::instance().read(name, 0);
00035 cout << name << ": " << s->getClassName() << endl;
00036 RawScanResult& r = *dynamic_pointer_cast<RawScanResult>(s);
00037
00038 if (r.getHeader().getRunNumber() != runNumber) {
00039 cout << "RunNumber not equal. Got: " << r.getHeader().getRunNumber() << " expected: " << runNumber << endl;
00040 ++exitCode;
00041 }
00042
00043 if (r.getHeader().getScanNumber() != scanNumber) {
00044 cout << "ScanNumber not equal. Got: " << r.getHeader().getScanNumber() << " expected: " << scanNumber << endl;
00045 ++exitCode;
00046 }
00047
00048 if (r.getHeader().getModuleName() != moduleName) {
00049 cout << "ModuleName not equal. Got: " << r.getHeader().getModuleName() << " expected: " << moduleName << endl;
00050 ++exitCode;
00051 }
00052
00053 if (r.getConfiguration().getGroupId() != groupID) {
00054 cout << "GroupId not equal. Got: " << (int)r.getConfiguration().getGroupId() << " expected: " << (int)groupID << endl;
00055 ++exitCode;
00056 }
00057 if (r.getConfiguration().getChipConfiguration(5).getCalFactor() != chip5CalFactor) {
00058 cout << "chip5CalFactor not equal. Got: " << r.getConfiguration().getChipConfiguration(5).getCalFactor() << " expected: " << chip5CalFactor << endl;
00059 ++exitCode;
00060 }
00061 if (r.getConfiguration().getChipConfiguration(4).getTrimTarget() != chip4Target) {
00062 cout << "chip4Target not equal. Got: " << (int)r.getConfiguration().getChipConfiguration(4).getTrimTarget() << " expected: " << (int)chip4Target << endl;
00063 ++exitCode;
00064 }
00065 if (r.getConfiguration().getChipConfiguration(11).getThreshold() != chip11Threshold) {
00066 cout << "chip11Threshold not equal. Got: " << (int)r.getConfiguration().getChipConfiguration(11).getThreshold() << " expected: " << (int)chip11Threshold << endl;
00067 ++exitCode;
00068 }
00069 if (r.getConfiguration().getChipConfiguration(0).getTrim(0) != chip0Chan0Trim) {
00070 cout << "chip0Chan0Trim not equal. Got: " << (int)r.getConfiguration().getChipConfiguration(0).getTrim(0) << " expected: " << (int)chip0Chan0Trim << endl;
00071 ++exitCode;
00072 }
00073
00074 if (r.getPoints().getNPoints() != nPoints) {
00075 cout << "nPoints not equal. Got: " << r.getPoints().getNPoints() << " expected: " << nPoints << endl;
00076 ++exitCode;
00077 }
00078 if (r.getPoints().getPoint(0) != point0) {
00079 cout << "point0 not equal. Got: " << r.getPoints().getPoint(0) << " expected: " << point0 << endl;
00080 ++exitCode;
00081 }
00082
00083 if (fabs(r.getScanData(0).GetBinContent(1, 1) - bin00) > 0.1) {
00084 cout << "bin00 not equal. Got: " << r.getScanData(0).GetBinContent(1, 1) << " expected: " << bin00 << endl;
00085 ++exitCode;
00086 }
00087 if (fabs(r.getScanData(1).GetBinContent(50, 31) - bin4930) > 0.1) {
00088 cout << "bin4930 not equal. Got: " << r.getScanData(1).GetBinContent(50, 31) << " expected: " << bin4930 << endl;
00089 ++exitCode;
00090 }
00091 cout << endl;
00092 }
00093 };
00094
00095 int main(int argc, char** argv) {
00096 CheckRaw cr;
00097 try {
00098 cr.runNumber = 1047;
00099 cr.scanNumber = 6;
00100 cr.moduleName = "20220330200015";
00101 cr.groupID = 0;
00102 cr.chip5CalFactor = 1.0f;
00103 cr.chip4Target = 38;
00104 cr.chip11Threshold = 38;
00105 cr.chip0Chan0Trim = 2;
00106 cr.nPoints = 57;
00107 cr.point0 = 60;
00108 cr.bin00 = 1000;
00109 cr.bin4930 = 209;
00110 cr.compare("EventData.SctData::RawScanResult.1047.6.20220330200015");
00111
00112 cr.runNumber = 1048;
00113 cr.scanNumber = 16;
00114 cr.moduleName = "20220330200015";
00115 cr.groupID = 0;
00116 cr.chip5CalFactor = 1.0f;
00117 cr.chip4Target = 38;
00118 cr.chip11Threshold = 38;
00119 cr.chip0Chan0Trim = 2;
00120 cr.nPoints = 57;
00121 cr.point0 = 60;
00122 cr.bin00 = 1000;
00123 cr.bin4930 = 209;
00124 cr.compare("EventData.SctData::RawScanResult.1048.16.20220330200015");
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 } catch (Exception& e) {
00172 e.sendToMrs(MRS_ERROR);
00173 return -2;
00174 }
00175 }