- Timestamp:
- 10/27/11 04:59:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ratescan.cc
r12291 r12294 65 65 DimStampedInfo fRates; 66 66 67 DimDescribedService fDimData; 68 67 69 int fCounter; 68 70 int fSeconds; … … 73 75 int fThresholdStep; 74 76 75 uint64_t fTriggers; 76 uint64_t fTriggersBoard[40]; 77 uint64_t fTriggersPatch[160]; 78 79 float fElapsedTime; 80 float fOnTime; 77 double fRate; 78 double fRateBoard[40]; 79 double fRatePatch[160]; 80 81 double fOnTime; 81 82 82 83 float fResolution; … … 151 152 if (fSeconds==0) 152 153 { 153 f Triggers= 0;154 155 memset(f TriggersBoard, 0, 40*sizeof(uint64_t));156 memset(f TriggersPatch, 0, 160*sizeof(uint64_t));154 fRate = 0; 155 156 memset(fRateBoard, 0, 40*sizeof(double)); 157 memset(fRatePatch, 0, 160*sizeof(double)); 157 158 158 159 fOnTime = 0; 159 fElapsedTime = 0;160 160 return; 161 161 } 162 162 163 f Triggers+= sdata.fTriggerRate;163 fRate += sdata.fTriggerRate; 164 164 for (int i=0; i<40; i++) 165 f TriggersBoard[i] += sdata.fBoardRate[i];166 for (int i=0; i< 40; i++)167 f TriggersPatch[i] += sdata.fPatchRate[i];168 169 double reference = f Triggers;165 fRateBoard[i] += sdata.fBoardRate[i]; 166 for (int i=0; i<160; i++) 167 fRatePatch[i] += sdata.fPatchRate[i]; 168 169 double reference = fRate; 170 170 if (fReference==kBoard) 171 reference = f TriggersBoard[fReferenceIdx];171 reference = fRateBoard[fReferenceIdx]; 172 172 if (fReference==kPatch) 173 reference = fTriggersPatch[fReferenceIdx]; 174 175 fOnTime += sdata.fOnTime; 176 fElapsedTime += sdata.fElapsedTime; 177 178 reference *= fElapsedTime*10; 179 180 cout << fElapsedTime << " " << fOnTime << endl; 173 reference = fRatePatch[fReferenceIdx]; 174 175 fOnTime += sdata.fOnTime; 176 177 // FIXME: 178 reference *= sdata.fElapsedTime; 181 179 182 180 if ((reference==0 || sqrt(reference)>fResolution*reference) && fSeconds<fSecondsMax) 183 181 { 184 182 ostringstream out; 185 out << "Triggers so far: " << fTriggers;183 out << "Triggers so far: " << reference; 186 184 if (reference>0) 187 185 out << " (" << sqrt(reference)/reference << ")"; … … 191 189 } 192 190 191 const double time = sdata.fElapsedTime*fSeconds; 192 const uint32_t th = fThresholdMin+fCounter*fThresholdStep; 193 194 float data[3+1+40+160]; 195 memcpy(data, &th, 4); 196 data[1] = time; // total elapsed time 197 data[2] = fOnTime/time; // relative on time 198 data[3] = fRate/fSeconds; 199 for (int i=0; i<40; i++) 200 data[i+4] = fRateBoard[i]/fSeconds; 201 for (int i=0; i<160; i++) 202 data[i+4] = fRatePatch[i]/fSeconds; 203 193 204 ostringstream sout1, sout2, sout3; 194 205 195 sout1 << fThresholdMin+fCounter*fThresholdStep<< " ";196 sout1 << float(fTriggers)/fSeconds<< " ";206 sout1 << th << " "; 207 sout1 << data[3] << " "; 197 208 for (int i=0; i<40; i++) 198 sout2 << float(fTriggersBoard[i])/fSeconds<< " ";209 sout2 << data[i+4] << " "; 199 210 for (int i=0; i<160; i++) 200 sout2 << float(fTriggersPatch[i])/fSeconds<< " ";201 sout3 << fElapsedTime << " " << fOnTime;211 sout2 << data[i+44] << " "; 212 sout3 << data[1] << " " << data[2]; 202 213 203 214 Info(sout1.str()); 204 205 215 206 216 ofstream fout("ratescan.txt", ios::app); 207 217 fout << sout1.str() << sout2.str() << sout3.str() << endl; 208 218 219 fDimData.setQuality(fCommand=="FTM_CONTROL/SET_THRESHOLD"); 220 fDimData.setData(data, 204*sizeof(float)); 221 fDimData.Update(); 209 222 210 223 fCounter++; … … 228 241 fSeconds = -2; // FIXME: In principle one missed report is enough 229 242 230 const int32_t data[2] = { -1, fThresholdMin+fCounter*fThresholdStep };231 DimClient::sendCommandNB(fCommand.c_str(), (void*) data, 8);243 const int32_t cmd[2] = { -1, fThresholdMin+fCounter*fThresholdStep }; 244 DimClient::sendCommandNB(fCommand.c_str(), (void*)cmd, 8); 232 245 } 233 246 } … … 388 401 fFTM("FTM_CONTROL/STATE", (void*)NULL, 0, this), 389 402 fRates("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this), 403 fDimData("RATE_SCAN/DATA", "I:1;F:1;F:1;F:1;F:40;F:160", ""), 390 404 fCounter(-1), fReference(kCamera), fReferenceIdx(0) 391 405 {
Note:
See TracChangeset
for help on using the changeset viewer.