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 #include <ipc/core.h>
00007
00008 using namespace Sct;
00009 using namespace Sct::IS;
00010 using namespace SctData;
00011 using namespace std;
00012 using namespace boost;
00013
00014 class CheckRaw {
00015 public:
00016 unsigned int runNumber;
00017 unsigned int scanNumber;
00018 string moduleName;
00019 unsigned char groupID;
00020 float chip5CalFactor;
00021 unsigned char chip4Target;
00022 unsigned char chip11Threshold;
00023 unsigned char chip0Chan0Trim;
00024 unsigned int nPoints;
00025 double point0;
00026 double bin00;
00027 double bin4930;
00028 int exitCode;
00029
00030 CheckRaw() {
00031 exitCode = 0;
00032 }
00033
00034 void compare(string name) {
00035 shared_ptr<Serializable> s = IOManagerIS::instance().read(name, 0);
00036 cout << name << ": " << s->getClassName() << endl;
00037 RawScanResult& r = *dynamic_pointer_cast<RawScanResult>(s);
00038
00039 if (r.getHeader().getRunNumber() != runNumber) {
00040 cout << "RunNumber not equal. Got: " << r.getHeader().getRunNumber() << " expected: " << runNumber << endl;
00041 ++exitCode;
00042 }
00043
00044 if (r.getHeader().getScanNumber() != scanNumber) {
00045 cout << "ScanNumber not equal. Got: " << r.getHeader().getScanNumber() << " expected: " << scanNumber << endl;
00046 ++exitCode;
00047 }
00048
00049 if (r.getHeader().getModuleName() != moduleName) {
00050 cout << "ModuleName not equal. Got: " << r.getHeader().getModuleName() << " expected: " << moduleName << endl;
00051 ++exitCode;
00052 }
00053
00054 if (r.getConfiguration().getGroupId() != groupID) {
00055 cout << "GroupId not equal. Got: " << (int)r.getConfiguration().getGroupId() << " expected: " << (int)groupID << endl;
00056 ++exitCode;
00057 }
00058 if (r.getConfiguration().getChipConfiguration(5).getCalFactor() != chip5CalFactor) {
00059 cout << "chip5CalFactor not equal. Got: " << r.getConfiguration().getChipConfiguration(5).getCalFactor() << " expected: " << chip5CalFactor << endl;
00060 ++exitCode;
00061 }
00062 if (r.getConfiguration().getChipConfiguration(4).getTrimTarget() != chip4Target) {
00063 cout << "chip4Target not equal. Got: " << (int)r.getConfiguration().getChipConfiguration(4).getTrimTarget() << " expected: " << (int)chip4Target << endl;
00064 ++exitCode;
00065 }
00066 if (r.getConfiguration().getChipConfiguration(11).getThreshold() != chip11Threshold) {
00067 cout << "chip11Threshold not equal. Got: " << (int)r.getConfiguration().getChipConfiguration(11).getThreshold() << " expected: " << (int)chip11Threshold << endl;
00068 ++exitCode;
00069 }
00070 if (r.getConfiguration().getChipConfiguration(0).getTrim(0) != chip0Chan0Trim) {
00071 cout << "chip0Chan0Trim not equal. Got: " << (int)r.getConfiguration().getChipConfiguration(0).getTrim(0) << " expected: " << (int)chip0Chan0Trim << endl;
00072 ++exitCode;
00073 }
00074
00075 if (r.getPoints().getNPoints() != nPoints) {
00076 cout << "nPoints not equal. Got: " << r.getPoints().getNPoints() << " expected: " << nPoints << endl;
00077 ++exitCode;
00078 }
00079 if (r.getPoints().getPoint(0) != point0) {
00080 cout << "point0 not equal. Got: " << r.getPoints().getPoint(0) << " expected: " << point0 << endl;
00081 ++exitCode;
00082 }
00083
00084 if (fabs(r.getScanData(0).GetBinContent(1, 1) - bin00) > 0.1) {
00085 cout << "bin00 not equal. Got: " << r.getScanData(0).GetBinContent(1, 1) << " expected: " << bin00 << endl;
00086 ++exitCode;
00087 }
00088 if (fabs(r.getScanData(1).GetBinContent(50, 31) - bin4930) > 0.1) {
00089 cout << "bin4930 not equal. Got: " << r.getScanData(1).GetBinContent(50, 31) << " expected: " << bin4930 << endl;
00090 ++exitCode;
00091 }
00092 cout << endl;
00093 }
00094 };
00095
00096 int main(int argc, char** argv) {
00097 IPCCore::init(argc, argv);
00098 CheckRaw cr;
00099 try {
00100 cr.runNumber = 1047;
00101 cr.scanNumber = 6;
00102 cr.moduleName = "20220330200015";
00103 cr.groupID = 0;
00104 cr.chip5CalFactor = 1.0f;
00105 cr.chip4Target = 38;
00106 cr.chip11Threshold = 38;
00107 cr.chip0Chan0Trim = 2;
00108 cr.nPoints = 57;
00109 cr.point0 = 60;
00110 cr.bin00 = 1000;
00111 cr.bin4930 = 209;
00112 cr.compare("EventData.SctData::RawScanResult.1047.6.20220330200015");
00113
00114 cr.runNumber = 1048;
00115 cr.scanNumber = 16;
00116 cr.moduleName = "20220330200015";
00117 cr.groupID = 0;
00118 cr.chip5CalFactor = 1.0f;
00119 cr.chip4Target = 38;
00120 cr.chip11Threshold = 38;
00121 cr.chip0Chan0Trim = 2;
00122 cr.nPoints = 57;
00123 cr.point0 = 60;
00124 cr.bin00 = 1000;
00125 cr.bin4930 = 209;
00126 cr.compare("EventData.SctData::RawScanResult.1048.16.20220330200015");
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
00172
00173 } catch (Exception& e) {
00174 e.sendToMrs(MRS_ERROR);
00175 return -2;
00176 }
00177 }