| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Markus Gaug, 12/2004 <mailto:markus@ifae.es>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 25 | //
|
|---|
| 26 | // MCalibCalcFromPast
|
|---|
| 27 | //
|
|---|
| 28 | // Steers the occurrance of interlaced calibration events in one data run
|
|---|
| 29 | //
|
|---|
| 30 | // Input Containers:
|
|---|
| 31 | // MParList
|
|---|
| 32 | // MCalibrationIntensityChargeCam
|
|---|
| 33 | // MCalibrationIntensityRelTimeCam
|
|---|
| 34 | // MCalibrationIntensityConstCam
|
|---|
| 35 | // MBadPixelsIntensityCam
|
|---|
| 36 | //
|
|---|
| 37 | // Output Containers:
|
|---|
| 38 | // MCalibrationIntensityChargeCam
|
|---|
| 39 | // MCalibrationIntensityRelTimeCam
|
|---|
| 40 | // MBadPixelsIntensityCam
|
|---|
| 41 | //
|
|---|
| 42 | // Class version 2:
|
|---|
| 43 | // + UInt_t fNumPhesDump; // Number of cams after which the number of phes gets averaged
|
|---|
| 44 | // + Float_t fMeanPhes;
|
|---|
| 45 | // + Float_t fMeanPhesRelVar;
|
|---|
| 46 | // + Bool_t fUpdateNumPhes; // Update the number of photo-electrons only after fNumPhesDump number of Cams
|
|---|
| 47 | // + TArrayF fPhes;
|
|---|
| 48 | // + TArrayF fPhesVar;
|
|---|
| 49 | //
|
|---|
| 50 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 51 | #include "MCalibCalcFromPast.h"
|
|---|
| 52 |
|
|---|
| 53 | #include "MLog.h"
|
|---|
| 54 | #include "MLogManip.h"
|
|---|
| 55 |
|
|---|
| 56 | #include "MParList.h"
|
|---|
| 57 |
|
|---|
| 58 | #include "MRawRunHeader.h"
|
|---|
| 59 |
|
|---|
| 60 | #include "MHCalibrationCam.h"
|
|---|
| 61 |
|
|---|
| 62 | #include "MCalibrationIntensityChargeCam.h"
|
|---|
| 63 | #include "MCalibrationIntensityBlindCam.h"
|
|---|
| 64 | #include "MCalibrationIntensityQECam.h"
|
|---|
| 65 | #include "MCalibrationIntensityRelTimeCam.h"
|
|---|
| 66 | #include "MCalibrationIntensityConstCam.h"
|
|---|
| 67 |
|
|---|
| 68 | #include "MBadPixelsIntensityCam.h"
|
|---|
| 69 |
|
|---|
| 70 | #include "MCalibrationChargePix.h"
|
|---|
| 71 | #include "MCalibrationChargeCalc.h"
|
|---|
| 72 | #include "MCalibrationRelTimeCalc.h"
|
|---|
| 73 | #include "MCalibrateData.h"
|
|---|
| 74 |
|
|---|
| 75 | ClassImp(MCalibCalcFromPast);
|
|---|
| 76 |
|
|---|
| 77 | using namespace std;
|
|---|
| 78 |
|
|---|
| 79 | const UInt_t MCalibCalcFromPast::fgNumEventsDump = 500;
|
|---|
| 80 | const UInt_t MCalibCalcFromPast::fgNumPhesDump = 10;
|
|---|
| 81 |
|
|---|
| 82 | // --------------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Default constructor.
|
|---|
| 85 | //
|
|---|
| 86 | // Sets:
|
|---|
| 87 | // - fNumEventsDump to fgNumEventsDump
|
|---|
| 88 | // - fNumPhesDump to fgNumPhesDump
|
|---|
| 89 | //
|
|---|
| 90 | MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
|
|---|
| 91 | : fGeom(NULL), fParList(NULL), fRunHeader(NULL),
|
|---|
| 92 | fIntensCharge(NULL), fIntensBlind(NULL), fIntensRelTime(NULL), fIntensConst(NULL),
|
|---|
| 93 | fIntensBad(NULL),
|
|---|
| 94 | fChargeCalc(NULL), fRelTimeCalc(NULL), fCalibrate(NULL),
|
|---|
| 95 | fNumCam(0), fNumEvents(0), fUpdateWithFFactorMethod(kTRUE), fUpdateNumPhes(kTRUE),
|
|---|
| 96 | fNumFails(0)
|
|---|
| 97 | {
|
|---|
| 98 |
|
|---|
| 99 | fName = name ? name : "MCalibCalcFromPast";
|
|---|
| 100 | fTitle = title ? title : "Task to steer the processing of interlaced calibration events";
|
|---|
| 101 |
|
|---|
| 102 | SetNumEventsDump();
|
|---|
| 103 | SetNumPhesDump ();
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | // -----------------------------------------------------------------------------------
|
|---|
| 107 | //
|
|---|
| 108 | Int_t MCalibCalcFromPast::PreProcess(MParList *pList)
|
|---|
| 109 | {
|
|---|
| 110 |
|
|---|
| 111 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
|---|
| 112 | if (!fGeom)
|
|---|
| 113 | {
|
|---|
| 114 | *fLog << err << "MGeomCam not found... abort." << endl;
|
|---|
| 115 | return kFALSE;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | fParList = pList;
|
|---|
| 119 | if (!fParList)
|
|---|
| 120 | {
|
|---|
| 121 | *fLog << err << "MParList not found... abort." << endl;
|
|---|
| 122 | return kFALSE;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 126 | if (!fRunHeader)
|
|---|
| 127 | {
|
|---|
| 128 | *fLog << err << "MRawRunHeader not found... abort." << endl;
|
|---|
| 129 | return kFALSE;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | //
|
|---|
| 133 | // Look for the MBadPixels Intensity Cam
|
|---|
| 134 | //
|
|---|
| 135 | fIntensBad = (MBadPixelsIntensityCam*)pList->FindCreateObj("MBadPixelsIntensityCam");
|
|---|
| 136 | if (fIntensBad)
|
|---|
| 137 | *fLog << inf << "Found MBadPixelsIntensityCam ... " << flush;
|
|---|
| 138 | else
|
|---|
| 139 | return kFALSE;
|
|---|
| 140 |
|
|---|
| 141 | //
|
|---|
| 142 | // Look for the MFillH-class "MHCalibrationBlindCam". In case yes, initialize the
|
|---|
| 143 | // corresponding IntensityCam
|
|---|
| 144 | //
|
|---|
| 145 | if (pList->FindObject(AddSerialNumber("MHCalibrationBlindCam")))
|
|---|
| 146 | {
|
|---|
| 147 |
|
|---|
| 148 | *fLog << inf << "Found MHCalibrationBlindCam ... " << flush;
|
|---|
| 149 |
|
|---|
| 150 | fIntensBlind = (MCalibrationIntensityBlindCam*)pList->FindCreateObj("MCalibrationIntensityBlindCam");
|
|---|
| 151 | if (!fIntensBlind)
|
|---|
| 152 | {
|
|---|
| 153 | *fLog << err << "Could not find nor create MCalibrationIntensitBlindCam abort... " << endl;
|
|---|
| 154 | return kFALSE;
|
|---|
| 155 | }
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | //
|
|---|
| 159 | // Look for the MFillH-class "MHCalibrationChargeCam". In case yes, initialize the
|
|---|
| 160 | // corresponding IntensityCam
|
|---|
| 161 | //
|
|---|
| 162 | if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
|
|---|
| 163 | {
|
|---|
| 164 |
|
|---|
| 165 | fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
|
|---|
| 166 | fIntensQE = (MCalibrationIntensityQECam*) pList->FindCreateObj("MCalibrationIntensityQECam");
|
|---|
| 167 | fIntensConst = (MCalibrationIntensityConstCam*) pList->FindCreateObj("MCalibrationIntensityConstCam");
|
|---|
| 168 |
|
|---|
| 169 | MCalibrationChargeCam *chargeinit = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
|
|---|
| 170 | MCalibrationQECam *qeinit = (MCalibrationQECam*) pList->FindObject("MCalibrationQECam");
|
|---|
| 171 |
|
|---|
| 172 | if (chargeinit)
|
|---|
| 173 | fIntensCharge->SetCam(chargeinit,0);
|
|---|
| 174 | else
|
|---|
| 175 | *fLog << "Could not find initial MCalibrationChargeCam, cannot initialize intensity cam" << endl;
|
|---|
| 176 |
|
|---|
| 177 | if (qeinit)
|
|---|
| 178 | fIntensQE->SetCam(qeinit,0);
|
|---|
| 179 | else
|
|---|
| 180 | *fLog << "Could not find initial MCalibrationQECam, cannot initialize intensity cam" << endl;
|
|---|
| 181 |
|
|---|
| 182 | fIntensConst->GetCam()->Init(*fGeom);
|
|---|
| 183 |
|
|---|
| 184 | if (!fChargeCalc)
|
|---|
| 185 | fChargeCalc = (MCalibrationChargeCalc*)pList->FindObject("MCalibrationChargeCalc");
|
|---|
| 186 |
|
|---|
| 187 | if (!fCalibrate)
|
|---|
| 188 | fCalibrate = (MCalibrateData*)pList->FindObject("MCalibrateData");
|
|---|
| 189 |
|
|---|
| 190 | *fLog << inf << "Found MHCalibrationChargeCam ... " << flush;
|
|---|
| 191 |
|
|---|
| 192 | if (!fIntensCharge)
|
|---|
| 193 | {
|
|---|
| 194 | *fLog << err << "Could not find nor create MCalibrationIntensityChargeCam abort... " << endl;
|
|---|
| 195 | return kFALSE;
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | if (!fIntensQE)
|
|---|
| 199 | {
|
|---|
| 200 | *fLog << err << "Could not find nor create MCalibrationIntensityQECam abort... " << endl;
|
|---|
| 201 | return kFALSE;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | if (!fChargeCalc)
|
|---|
| 205 | {
|
|---|
| 206 | *fLog << err << "Could not find MCalibrationChargeCalc abort... " << endl;
|
|---|
| 207 | return kFALSE;
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | if (!fCalibrate)
|
|---|
| 211 | {
|
|---|
| 212 | *fLog << err << "Could not find MCalibrateData abort... " << endl;
|
|---|
| 213 | return kFALSE;
|
|---|
| 214 | }
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | //
|
|---|
| 218 | // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
|
|---|
| 219 | // corresponding IntensityCam
|
|---|
| 220 | //
|
|---|
| 221 | if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
|
|---|
| 222 | {
|
|---|
| 223 |
|
|---|
| 224 | fIntensRelTime = (MCalibrationIntensityRelTimeCam*)pList->FindCreateObj("MCalibrationIntensityRelTimeCam");
|
|---|
| 225 | if (!fRelTimeCalc)
|
|---|
| 226 | fRelTimeCalc = (MCalibrationRelTimeCalc*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
|
|---|
| 227 |
|
|---|
| 228 | *fLog << inf << "Found MHCalibrationRelTimeCam ... " << flush;
|
|---|
| 229 |
|
|---|
| 230 | if (!fIntensRelTime)
|
|---|
| 231 | {
|
|---|
| 232 | *fLog << err << "Could not find nor create MCalibrationIntensityRelTimeCam abort... " << endl;
|
|---|
| 233 | return kFALSE;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | if (!fRelTimeCalc)
|
|---|
| 237 | {
|
|---|
| 238 | *fLog << err << "Could not find MCalibrationRelTimeCalc abort... " << endl;
|
|---|
| 239 | return kFALSE;
|
|---|
| 240 | }
|
|---|
| 241 | }
|
|---|
| 242 |
|
|---|
| 243 | fNumCam = 0;
|
|---|
| 244 | fNumEvents = 0;
|
|---|
| 245 | fNumPhes = 0;
|
|---|
| 246 |
|
|---|
| 247 | fChargeCalc->SetUseExternalNumPhes(kFALSE);
|
|---|
| 248 |
|
|---|
| 249 | if (fUpdateNumPhes)
|
|---|
| 250 | {
|
|---|
| 251 | fPhes.Set(fNumPhesDump);
|
|---|
| 252 | fPhesVar.Set(fNumPhesDump);
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | fNumFails = 0;
|
|---|
| 256 |
|
|---|
| 257 | return kTRUE;
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | // --------------------------------------------------------------------------
|
|---|
| 261 | //
|
|---|
| 262 | // Set fNumEvents=0
|
|---|
| 263 | //
|
|---|
| 264 | // This is necessary because the calibration histograms do reset themself
|
|---|
| 265 | // if ReInit is called, so they are empty. MCalibCalcFromPast errornously
|
|---|
| 266 | // ignores how many events are in the histograms but count the number
|
|---|
| 267 | // itself.
|
|---|
| 268 | //
|
|---|
| 269 | Bool_t MCalibCalcFromPast::ReInit(MParList *pList)
|
|---|
| 270 | {
|
|---|
| 271 | if (fNumEvents>0)
|
|---|
| 272 | *fLog << inf << fNumEvents << " calibration events at the end of the last file have been skipped." << endl;
|
|---|
| 273 |
|
|---|
| 274 | fNumEvents = 0;
|
|---|
| 275 |
|
|---|
| 276 | return kTRUE;
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | // --------------------------------------------------------------------------
|
|---|
| 280 | //
|
|---|
| 281 | // - Initializes new containers in the
|
|---|
| 282 | // - Intensity Cams, if the number of calibration events has reach fNumEventsDump.
|
|---|
| 283 | // - Executes Finalize() of the MCalibration*Calc classes in that case.
|
|---|
| 284 | // - Sets the latest MCalibrationChargeCam as update class into MCalibrateData
|
|---|
| 285 | // - Initialize new MCalibration*Cams into the intensity cams.
|
|---|
| 286 | //
|
|---|
| 287 | Int_t MCalibCalcFromPast::Process()
|
|---|
| 288 | {
|
|---|
| 289 | if (fNumEvents++ < fNumEventsDump)
|
|---|
| 290 | return kTRUE;
|
|---|
| 291 |
|
|---|
| 292 | fNumEvents = 0;
|
|---|
| 293 | ReInitialize();
|
|---|
| 294 |
|
|---|
| 295 | //
|
|---|
| 296 | // Finalize Possible calibration histogram classes...
|
|---|
| 297 | //
|
|---|
| 298 | *fLog << inf << GetDescriptor() << ": Finalize calibration histograms: " << flush;
|
|---|
| 299 |
|
|---|
| 300 | if (Finalize("MHCalibrationChargeCam")) *fLog << "MHCalibrationChargeCam..." << flush;
|
|---|
| 301 | if (Finalize("MHCalibrationChargeBlindCam")) *fLog << "MHCalibrationChargeBlindCam..." << flush;
|
|---|
| 302 | if (Finalize("MHCalibrationRelTimeCam")) *fLog << "MHCalibrationRelTimeCam..." << flush;
|
|---|
| 303 |
|
|---|
| 304 | //
|
|---|
| 305 | // Finalize possible calibration calculation tasks
|
|---|
| 306 | //
|
|---|
| 307 | *fLog << endl;
|
|---|
| 308 | *fLog << inf << "Finalize calibration calculations..." << endl;
|
|---|
| 309 | if (fChargeCalc)
|
|---|
| 310 | {
|
|---|
| 311 | if (!fChargeCalc->Finalize())
|
|---|
| 312 | {
|
|---|
| 313 | fNumFails++;
|
|---|
| 314 | *fLog << warn << "WARNING - Finalization of charges failed the " << fNumFails << ". time..." << endl;
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | if (fUpdateNumPhes)
|
|---|
| 318 | {
|
|---|
| 319 | MCalibrationChargePix &avpix =(MCalibrationChargePix&)fIntensCharge->GetCam()->GetAverageArea(0);
|
|---|
| 320 | fPhes [fNumPhes] = avpix.GetPheFFactorMethod();
|
|---|
| 321 | fPhesVar[fNumPhes] = avpix.GetPheFFactorMethodVar();
|
|---|
| 322 |
|
|---|
| 323 | fNumPhes++;
|
|---|
| 324 |
|
|---|
| 325 | if (fNumPhes == fNumPhesDump)
|
|---|
| 326 | {
|
|---|
| 327 | fNumPhes = 0;
|
|---|
| 328 | if (!UpdateMeanPhes())
|
|---|
| 329 | {
|
|---|
| 330 | *fLog << warn << "Could not update mean number of photo-electrons. "
|
|---|
| 331 | << "Skip it until next update" << endl;
|
|---|
| 332 | fChargeCalc->SetUseExternalNumPhes(kFALSE);
|
|---|
| 333 | }
|
|---|
| 334 | else
|
|---|
| 335 | {
|
|---|
| 336 | *fLog << inf << "New averaged number photo-electrons: " << fMeanPhes << endl;
|
|---|
| 337 | fChargeCalc->SetExternalNumPhes ( fMeanPhes );
|
|---|
| 338 | fChargeCalc->SetExternalNumPhesRelVar( fMeanPhesRelVar );
|
|---|
| 339 | fChargeCalc->SetUseExternalNumPhes();
|
|---|
| 340 | }
|
|---|
| 341 | }
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | if (fRelTimeCalc)
|
|---|
| 346 | fRelTimeCalc->Finalize();
|
|---|
| 347 |
|
|---|
| 348 | if (fCalibrate)
|
|---|
| 349 | fCalibrate->UpdateConversionFactors(fUpdateWithFFactorMethod ? NULL
|
|---|
| 350 | : (MCalibrationChargeCam*)fIntensCharge->GetCam() );
|
|---|
| 351 |
|
|---|
| 352 | return kTRUE;
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 | // --------------------------------------------------------------------------
|
|---|
| 357 | //
|
|---|
| 358 | // Searches for name in the MParList and calls, if existing:
|
|---|
| 359 | // - MHCalibrationCam::Finalize()
|
|---|
| 360 | // - MHCalibrationCam::ResetHists()
|
|---|
| 361 | //
|
|---|
| 362 | Bool_t MCalibCalcFromPast::Finalize(const char* name, Bool_t finalize)
|
|---|
| 363 | {
|
|---|
| 364 | MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name, "MHCalibrationCam");
|
|---|
| 365 | if (!hist)
|
|---|
| 366 | return kFALSE;
|
|---|
| 367 |
|
|---|
| 368 | if (finalize)
|
|---|
| 369 | hist->Finalize();
|
|---|
| 370 |
|
|---|
| 371 | hist->ResetHists();
|
|---|
| 372 | return kTRUE;
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | // --------------------------------------------------------------------------
|
|---|
| 376 | //
|
|---|
| 377 | // Re-Intitializes new containers inside the Intensity Cams.
|
|---|
| 378 | // From now on, a call to the IntensityCam functions returns pointers
|
|---|
| 379 | // to the newly created Containers.
|
|---|
| 380 | //
|
|---|
| 381 | Bool_t MCalibCalcFromPast::ReInitialize()
|
|---|
| 382 | {
|
|---|
| 383 | fNumCam++;
|
|---|
| 384 |
|
|---|
| 385 | *fLog << inf << "MCalibCalcFromPast::ReInitialize #" << fNumCam << ": ";
|
|---|
| 386 |
|
|---|
| 387 | const Int_t runnumber = fRunHeader->GetRunNumber();
|
|---|
| 388 |
|
|---|
| 389 | if (fIntensBad)
|
|---|
| 390 | {
|
|---|
| 391 | fIntensBad->AddToList(Form("MBadPixelsCam%04d",fNumCam),*fGeom);
|
|---|
| 392 | *fLog << "MBadPixelsCam...";
|
|---|
| 393 | }
|
|---|
| 394 |
|
|---|
| 395 | if (fIntensCharge)
|
|---|
| 396 | {
|
|---|
| 397 | fIntensCharge->AddToList(Form("MCalibrationChargeCam%04d",fNumCam),*fGeom);
|
|---|
| 398 | fIntensCharge->GetCam()->SetRunNumber(runnumber);
|
|---|
| 399 | *fLog << "MCalibrationChargeCam...";
|
|---|
| 400 | }
|
|---|
| 401 | if (fIntensQE)
|
|---|
| 402 | {
|
|---|
| 403 | fIntensQE->AddToList(Form("MCalibrationQECam%04d",fNumCam),*fGeom);
|
|---|
| 404 | fIntensQE->GetCam()->SetRunNumber(runnumber);
|
|---|
| 405 | *fLog << "MCalibrationQECam...";
|
|---|
| 406 | }
|
|---|
| 407 | if (fIntensBlind)
|
|---|
| 408 | {
|
|---|
| 409 | fIntensBlind->AddToList(Form("MCalibrationBlindCam%04d",fNumCam),*fGeom);
|
|---|
| 410 | fIntensBlind->GetCam()->SetRunNumber(runnumber);
|
|---|
| 411 | *fLog << "MCalibrationBlindCam...";
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | *fLog << endl;
|
|---|
| 415 |
|
|---|
| 416 | return kTRUE;
|
|---|
| 417 |
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | Int_t MCalibCalcFromPast::PostProcess()
|
|---|
| 421 | {
|
|---|
| 422 | if (GetNumExecutions()==0)
|
|---|
| 423 | return kTRUE;
|
|---|
| 424 |
|
|---|
| 425 | // Now we reset all histograms to make sure that the PostProcess
|
|---|
| 426 | // of the following tasks doesn't try to finalize a partly empty
|
|---|
| 427 | // histogram!
|
|---|
| 428 | Finalize("MHCalibrationChargeCam", kFALSE);
|
|---|
| 429 | Finalize("MHCalibrationChargeBlindCam", kFALSE);
|
|---|
| 430 | Finalize("MHCalibrationRelTimeCam", kFALSE);
|
|---|
| 431 |
|
|---|
| 432 | if (fChargeCalc)
|
|---|
| 433 | fChargeCalc->ResetNumProcessed();
|
|---|
| 434 |
|
|---|
| 435 | if (fNumCam==0)
|
|---|
| 436 | return kTRUE;
|
|---|
| 437 |
|
|---|
| 438 | *fLog << inf << endl;
|
|---|
| 439 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
|---|
| 440 | *fLog << " " << setw(7) << fNumFails << " (" << Form("%5.1f", 100.*fNumFails/fNumCam) << "%) updates failed." << endl;
|
|---|
| 441 | *fLog << endl;
|
|---|
| 442 |
|
|---|
| 443 | return kTRUE;
|
|---|
| 444 | }
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 | Bool_t MCalibCalcFromPast::UpdateMeanPhes()
|
|---|
| 448 | {
|
|---|
| 449 | Float_t sumw = 0.;
|
|---|
| 450 | Float_t sum = 0.;
|
|---|
| 451 |
|
|---|
| 452 | for (Int_t i=0; i<fPhes.GetSize(); i++)
|
|---|
| 453 | {
|
|---|
| 454 | const Float_t weight = 1./fPhesVar[i];
|
|---|
| 455 | sum += fPhes[i]*weight;
|
|---|
| 456 | sumw += weight;
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | if (sumw < 0.000001)
|
|---|
| 460 | return kFALSE;
|
|---|
| 461 |
|
|---|
| 462 | if (sum < 0.000001)
|
|---|
| 463 | return kFALSE;
|
|---|
| 464 |
|
|---|
| 465 | fMeanPhes = sum/sumw;
|
|---|
| 466 | fMeanPhesRelVar = sumw/sum/sum;
|
|---|
| 467 |
|
|---|
| 468 | return kTRUE;
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 | // --------------------------------------------------------------------------
|
|---|
| 472 | //
|
|---|
| 473 | // Read the setup from a TEnv, eg:
|
|---|
| 474 | // MCalibCalcFromPast.UpdateWithFFactorMethod: Off, On
|
|---|
| 475 | // MCalibCalcFromPast.NumEventsDump: 500
|
|---|
| 476 | // MCalibCalcFromPast.UpdateNumPhes: yes/no
|
|---|
| 477 | // MCalibCalcFromPast.NumPhesDump: 10
|
|---|
| 478 | //
|
|---|
| 479 | Int_t MCalibCalcFromPast::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
|---|
| 480 | {
|
|---|
| 481 | Bool_t rc = kFALSE;
|
|---|
| 482 | if (IsEnvDefined(env, prefix, "UpdateWithFFactorMethod", print))
|
|---|
| 483 | {
|
|---|
| 484 | rc = kTRUE;
|
|---|
| 485 | SetUpdateWithFFactorMethod(GetEnvValue(env, prefix, "UpdateWithFFactorMethod", fUpdateWithFFactorMethod));
|
|---|
| 486 | }
|
|---|
| 487 |
|
|---|
| 488 | if (IsEnvDefined(env, prefix, "NumEventsDump", print))
|
|---|
| 489 | {
|
|---|
| 490 | SetNumEventsDump(GetEnvValue(env, prefix, "NumEventsDump", (Int_t)fNumEventsDump));
|
|---|
| 491 | rc = kTRUE;
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | if (IsEnvDefined(env, prefix, "UpdateNumPhes", print))
|
|---|
| 495 | {
|
|---|
| 496 | TString s = GetEnvValue(env, prefix, "UpdateNumPhes", "");
|
|---|
| 497 | s.ToLower();
|
|---|
| 498 | if (s.BeginsWith("no"))
|
|---|
| 499 | SetUpdateNumPhes(kFALSE);
|
|---|
| 500 | if (s.BeginsWith("yes"))
|
|---|
| 501 | SetUpdateNumPhes(kTRUE);
|
|---|
| 502 | rc = kTRUE;
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | if (IsEnvDefined(env, prefix, "NumPhesDump", print))
|
|---|
| 506 | {
|
|---|
| 507 | SetNumPhesDump(GetEnvValue(env, prefix, "NumPhesDump", (Int_t)fNumPhesDump));
|
|---|
| 508 | rc = kTRUE;
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | return rc;
|
|---|
| 512 | }
|
|---|