117 double PercentDone = 0;
120 cout <<
"----------------------------------------------------------" << endl
123 cout <<
"New Cycle" << endl;
124 cout <<
"Old Folder Size = " << mFolderNames.size() << endl;
127 mNowFolderNames =
GetFName(mWorkDir);
128 cout <<
"Now NFolder = " << mNowFolderNames.size() << endl;
129 for (
size_t i = 0;
i < mNowFolderNames.size();
i++) {
130 mNowFileNames.push_back(
GetFName(mNowFolderNames[
i]));
134 std::set_difference(mNowFolderNames.begin(), mNowFolderNames.end(), mFolderNames.begin(), mFolderNames.end(), std::inserter(mDiffFolderName, mDiffFolderName.begin()));
136 cout <<
"Difference Size Between New and Initial Runs = " << mDiffFolderName.size() << endl;
139 if (mDiffFolderName.size() == 0) {
140 cout <<
"No New Run -- No Need to Reset" << endl;
146 if (mDiffFolderName.size() > 0) {
147 cout <<
"New Run Started -- Reset All Histograms" << endl;
150 for (
int i = 0;
i < sNError;
i++) {
156 std::ifstream RunFileType(sRunTypeFileName);
157 RunFileType >> mRunType;
159 LOG(
debug) <<
"NEW CONFIG: RunFileType = " << mRunType;
161 if (mRunType ==
"FakeHitRate") {
162 std::ifstream EventPush(sFakeRateDefConfig);
163 EventPush >> mEventPerPush >> mTrackError >> mWorkDir;
166 if (mRunType ==
"ThresholdScan") {
167 std::ifstream EventPush(sThresholdDefConfig);
168 EventPush >> mEventPerPush >> mTrackError >> mWorkDir;
171 LOG(
debug) <<
"NEW CONFIG: EventPerPush = " << mEventPerPush <<
" TrackError = " << mTrackError <<
" mWorkDir = " << mWorkDir;
172 LOG(
debug) <<
"DONE Reset Histogram Decision";
175 LOG(
debug) <<
"Start Creating New Now Vector";
179 for (
size_t i = 0;
i < mFolderNames.size();
i++) {
180 std::set_difference(mNowFileNames[
i].begin(), mNowFileNames[
i].
end(), mFileNames[
i].begin(), mFileNames[
i].
end(), std::inserter(mDiffFileNamePush, mDiffFileNamePush.begin()));
181 mDiffFileNames.push_back(mDiffFileNamePush);
182 cout <<
"Difference File Size Between New and Initial Runs " << mDiffFileNames[
i].size() << endl;
184 mDiffFileNamePush.clear();
187 LOG(
debug) <<
"DONE GRABING Existing";
190 for (
size_t i = mFolderNames.size();
i < mNowFolderNames.size();
i++) {
191 mDiffFileNames.push_back(mNowFileNames[
i]);
192 cout <<
"New File Size Between New and Initial Runs " << mDiffFileNames[
i].size() << endl;
195 LOG(
debug) <<
"Total New Files = " << mDiffFileNames.size();
197 LOG(
debug) <<
"DONE Creating Difference";
199 LOG(
debug) <<
"mDiffFileNames Size = " << mDiffFileNames.size();
205 for (
size_t i = 0;
i < mNowFolderNames.size();
i++) {
207 LOG(
debug) <<
"i = " <<
i <<
" mDiffFileNames[i].size() = " << mDiffFileNames[
i].size();
211 size_t pos = mNowFolderNames[
i].find_last_of(
"/");
213 if (
pos != string::npos) {
214 mRunID = mNowFolderNames[
i].substr(
pos + 1);
217 LOG(
debug) <<
"FileDone = " << mFileDone << endl;
221 if (mDiffFileNames[
i].
size() > 0 && mFileDone == 1) {
223 mFileRemain = mDiffFileNames[
i].size();
225 cout <<
"RunID = " << mRunID << endl;
226 cout <<
"File Location = " << mDiffFileNames[
i][0] << endl;
229 size_t last_index1 = mRunID.find_last_not_of(
"0123456789");
230 string RunIDS = mRunID.substr(last_index1 + 1);
234 pos = mDiffFileNames[
i][0].find_last_of(
"/");
235 if (
pos != string::npos) {
236 FileIDS = mDiffFileNames[
i][0].substr(
pos + 1);
239 cout <<
"Before FileIDS = " << FileIDS << endl;
241 size_t last_index2 = FileIDS.find_last_not_of(
"0123456789");
242 FileIDS = FileIDS.substr(last_index2 + 1);
245 mRunNumber = std::stoi(RunIDS);
246 mFileID = std::stoi(FileIDS);
248 ofstream fout(Form(
"ErrorData/ErrorLogRun%d_File%d.dat", mRunNumber, mFileID));
249 fout <<
" START OF ERROR REPORT For Run " << mRunNumber <<
" File " << mFileID << endl;
252 mInputName = mDiffFileNames[
i][0];
254 mEventRegistered = 0;
255 LOG(
debug) <<
"mInputName = " << mInputName;
260 if (mNewFileInj == 1) {
261 cout <<
"New File Injected, Now Updating the Canvas and Light" << endl;
262 mDigitsTest.emplace_back(0, 0, 0, 0);
263 mMultiDigitsTest.push_back(mDigitsTest[0]);
264 mErrorsVecTest.push_back(mErrors);
266 mFileInfo = mFileDone + mFileRemain * 10;
273 mErrorsVecTest.clear();
275 mMultiDigitsTest.clear();
276 if (mFolderNames.size() < mNowFolderNames.size()) {
277 mFileNames.push_back(NewNextFold);
279 cout <<
"Done!!! You should see the Canvas Updated " << endl;
298 auto& rawErrorReader =
reinterpret_cast<RawReader&
>(mRawReader);
301 if (NChip < NChipMax) {
307 const auto& statRU = rawErrorReader.getRUDecodingStatSW(ruInfo->idSW);
310 int pixelSize = mChipData->
getData().size();
312 NEvent = statRU->nPackets;
314 mTotalPixelSize = mTotalPixelSize + pixelSize;
316 if (NEvent > (mEventRegistered + 1) * mEventPerPush) {
318 if (mTotalPixelSize < mMaxPixelSize || mTotalPixelSize == mMaxPixelSize) {
319 cout <<
"Digit OK for 1 Push" << endl;
320 mNDigits.push_back(mTotalPixelSize);
321 mEventRegistered = mEventRegistered + 1;
322 mErrorsVec.push_back(mErrors);
323 cout <<
"TotalPixelSize = " << mTotalPixelSize <<
" Pushed" << endl;
326 if (mTotalPixelSize > mMaxPixelSize) {
327 cout <<
"Digit Spilt into 2 Pusbhes" << endl;
328 mNDigits.push_back(mTotalPixelSize / 2);
329 mNDigits.push_back(mTotalPixelSize / 2);
330 mErrorsVec.push_back(mErrors);
331 mErrorsVec.push_back(mErrors);
332 mEventRegistered = mEventRegistered + 1;
333 cout <<
"TotalPixelSize = " << mTotalPixelSize <<
" Pushed" << endl;
341 if (NEvent % 1000000 == 0 && TimePrint == 0) {
342 cout <<
"Event Number = " << NEvent << endl;
346 if (NEvent % 100000 != 0) {
351 if (mErrors[
i] < 4294967295) {
352 mErrors[
i] = mErrors[
i] + (
int)statRU->errorCounts[
i];
356 if (mTrackError == 1) {
357 if (NEventPre != NEvent) {
361 if ((
int)statRU->errorCounts[
i] > 0) {
366 if (ErrorDetcted == 1) {
367 fout <<
"Event Number = " << NEvent << endl;
368 fout <<
" ------------------------------------------------" << endl;
370 if (statRU->errorCounts[
i]) {
374 fout <<
" ------------------------------------------------" << endl;
381 for (
auto& pixel :
pixels) {
382 if (Index < IndexMax) {
385 int col = pixel.getCol();
386 int row = pixel.getRow();
387 mDigits.emplace_back(ChipID,
row,
col, 0);
394 cout <<
"Final TotalPixelSize = " << mTotalPixelSize << endl;
395 mNDigits.push_back(mTotalPixelSize);
396 mErrorsVec.push_back(mErrors);
397 LOG(
debug) <<
"Run " << mNowFolderNames[
i] <<
" File " << mInputName <<
" Integrated Raw Pixel Pushed " << mDigits.size();
398 if (mFolderNames.size() < mNowFolderNames.size()) {
399 mFileNames.push_back(NewNextFold);
401 mFileNames[
i].push_back(mInputName);
402 fout <<
" END OF ERROR REPORT " << endl;
408 LOG(
debug) <<
"mIndexPush Before = " << mIndexPush <<
" mDigits.size() = " << mDigits.size();
410 if (mDigits.size() > 0) {
411 PercentDone = double(mIndexPush) / double(mDigits.size());
413 cout <<
"Percentage Processed = " << Form(
"%.2f", 100. * PercentDone) << endl;
415 if (mIndexPush < mDigits.size()) {
416 for (
int i = 0;
i < mNDigits[
j];
i++) {
417 mMultiDigits.push_back(mDigits[mIndexPush +
i]);
419 LOG(
debug) <<
"j = " <<
j <<
" NDgits = " << mNDigits[
j] <<
" mMultiDigits Pushed = " << mMultiDigits.size();
420 LOG(
debug) <<
"i = " << 10 <<
" ErrorShould = " << mErrors[10] <<
" ErrorInjected = " << mErrorsVec[
j][10];
423 cout <<
"RunIDS = " << mRunNumber <<
" FileIDS = " << mFileID << endl;
429 mIndexPushEx = mIndexPush + mNDigits[
j];
430 LOG(
debug) <<
"IndexPushEx = " << mIndexPushEx <<
" mDigits.size() " << mDigits.size();
431 if (mIndexPushEx > mDigits.size() - 5) {
434 LOG(
debug) <<
"FileDone = " << mFileDone;
435 LOG(
debug) <<
"FileRemain = " << mFileRemain;
437 mFileInfo = mFileDone + mFileRemain * 10;
441 LOG(
debug) <<
"mIndexPush = " << mIndexPush <<
" Chip ID Pushing " << mDigits[mIndexPush].getChipIndex();
445 mMultiDigits.clear();
446 mIndexPush = mIndexPush + mNDigits[
j];
450 LOG(
debug) <<
"mIndexPush After = " << mIndexPush;
464 mFolderNames.clear();
467 mFolderNames = mNowFolderNames;
470 mNowFolderNames.clear();
471 mNowFileNames.clear();
472 mDiffFileNames.clear();
473 mDiffFolderName.clear();
475 LOG(
debug) <<
"Pushing Reset Histogram Decision";
477 cout <<
"Resetting Pushing Things" << endl;
480 if (mIndexPush > mDigits.size() - 5) {
495 cout <<
"Start Sleeping" << endl;
507 std::this_thread::sleep_for(std::chrono::milliseconds(1000));
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.