| 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 | // MRawEvtHeader
|
|---|
| 32 | // MParList
|
|---|
| 33 | // MCalibrationIntensityChargeCam
|
|---|
| 34 | // MCalibrationIntensityRelTimeCam
|
|---|
| 35 | // MBadPixelsIntensityCam
|
|---|
| 36 | //
|
|---|
| 37 | // Output Containers:
|
|---|
| 38 | // MCalibrationIntensityChargeCam
|
|---|
| 39 | // MCalibrationIntensityRelTimeCam
|
|---|
| 40 | // MBadPixelsIntensityCam
|
|---|
| 41 | //
|
|---|
| 42 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 43 | #include "MCalibCalcFromPast.h"
|
|---|
| 44 |
|
|---|
| 45 | #include "MLog.h"
|
|---|
| 46 | #include "MLogManip.h"
|
|---|
| 47 |
|
|---|
| 48 | #include "MParList.h"
|
|---|
| 49 | #include "MTaskList.h"
|
|---|
| 50 |
|
|---|
| 51 | #include "MHCalibrationCam.h"
|
|---|
| 52 |
|
|---|
| 53 | #include "MCalibrationIntensityChargeCam.h"
|
|---|
| 54 | #include "MCalibrationIntensityBlindCam.h"
|
|---|
| 55 | #include "MCalibrationIntensityQECam.h"
|
|---|
| 56 | #include "MCalibrationIntensityRelTimeCam.h"
|
|---|
| 57 | #include "MCalibrationIntensityHiLoCam.h"
|
|---|
| 58 |
|
|---|
| 59 | #include "MBadPixelsIntensityCam.h"
|
|---|
| 60 |
|
|---|
| 61 | #include "MCalibrationChargeCalc.h"
|
|---|
| 62 | #include "MCalibrationRelTimeCalc.h"
|
|---|
| 63 |
|
|---|
| 64 | #include "MRawRunHeader.h"
|
|---|
| 65 | #include "MRawEvtHeader.h"
|
|---|
| 66 |
|
|---|
| 67 | #include "MGeomCam.h"
|
|---|
| 68 |
|
|---|
| 69 | ClassImp(MCalibCalcFromPast);
|
|---|
| 70 |
|
|---|
| 71 | using namespace std;
|
|---|
| 72 |
|
|---|
| 73 | // --------------------------------------------------------------------------
|
|---|
| 74 | //
|
|---|
| 75 | // Default constructor.
|
|---|
| 76 | //
|
|---|
| 77 | MCalibCalcFromPast::MCalibCalcFromPast(const char *name, const char *title)
|
|---|
| 78 | : fHeader(NULL), fGeom(NULL), fParList(NULL),
|
|---|
| 79 | fIntensCharge(NULL), fIntensRelTime(NULL), fIntensBad(NULL),
|
|---|
| 80 | fChargeCalc(NULL), fRelTimeCalc(NULL),
|
|---|
| 81 | fPattern(0)
|
|---|
| 82 | {
|
|---|
| 83 |
|
|---|
| 84 | fName = name ? name : "MCalibCalcFromPast";
|
|---|
| 85 | fTitle = title ? title : "Task to steer the processing of interlaced calibration events";
|
|---|
| 86 |
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | // -----------------------------------------------------------------------------------
|
|---|
| 90 | //
|
|---|
| 91 | // The following container are searched for and execution aborted if not in MParList:
|
|---|
| 92 | // - MRawEvtHeader
|
|---|
| 93 | // - MTaskList
|
|---|
| 94 | //
|
|---|
| 95 | Int_t MCalibCalcFromPast::PreProcess(MParList *pList)
|
|---|
| 96 | {
|
|---|
| 97 |
|
|---|
| 98 | fHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
|
|---|
| 99 | if (!fHeader)
|
|---|
| 100 | {
|
|---|
| 101 | *fLog << err << "MRawEvtHeader not found... abort." << endl;
|
|---|
| 102 | return kFALSE;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 106 | if (!fHeader)
|
|---|
| 107 | {
|
|---|
| 108 | *fLog << err << "MRawRunHeader not found... abort." << endl;
|
|---|
| 109 | return kFALSE;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
|
|---|
| 113 | if (!fGeom)
|
|---|
| 114 | {
|
|---|
| 115 | *fLog << err << "MGeomCam not found... abort." << endl;
|
|---|
| 116 | return kFALSE;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | fParList = pList;
|
|---|
| 120 | if (!fParList)
|
|---|
| 121 | {
|
|---|
| 122 | *fLog << err << "MParList not found... abort." << endl;
|
|---|
| 123 | return kFALSE;
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | MTaskList *tlist = (MTaskList*)pList->FindObject("MTaskList");
|
|---|
| 127 | if (!tlist)
|
|---|
| 128 | {
|
|---|
| 129 | *fLog << err << "MTaskList not found... abort." << endl;
|
|---|
| 130 | return kFALSE;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | //
|
|---|
| 134 | // Look for the MBadPixels Intensity Cam
|
|---|
| 135 | //
|
|---|
| 136 | fIntensBad = (MBadPixelsIntensityCam*)pList->FindCreateObj("MBadPixelsIntensityCam");
|
|---|
| 137 | if (fIntensBad)
|
|---|
| 138 | *fLog << inf << "Found MBadPixelsIntensityCam ... " << flush;
|
|---|
| 139 | else
|
|---|
| 140 | return kFALSE;
|
|---|
| 141 |
|
|---|
| 142 | //
|
|---|
| 143 | // Look for the MCalibrationIntensityBlindCam
|
|---|
| 144 | //
|
|---|
| 145 | fIntensBlind = (MCalibrationIntensityBlindCam*)pList->FindCreateObj("MCalibrationIntensityBlindCam");
|
|---|
| 146 | if (fIntensBlind)
|
|---|
| 147 | *fLog << inf << "Found MCalibrationIntensityBlindCam ... " << flush;
|
|---|
| 148 | else
|
|---|
| 149 | return kFALSE;
|
|---|
| 150 |
|
|---|
| 151 | //
|
|---|
| 152 | // Look for the MFillH name "FillChargeCam". In case yes, initialize the
|
|---|
| 153 | // corresponding IntensityCam
|
|---|
| 154 | //
|
|---|
| 155 | if (pList->FindObject(AddSerialNumber("MHCalibrationChargeCam")))
|
|---|
| 156 | {
|
|---|
| 157 |
|
|---|
| 158 | fIntensCharge = (MCalibrationIntensityChargeCam*)pList->FindCreateObj("MCalibrationIntensityChargeCam");
|
|---|
| 159 | fIntensQE = (MCalibrationIntensityQECam*) pList->FindCreateObj("MCalibrationIntensityQECam");
|
|---|
| 160 |
|
|---|
| 161 | fChargeCalc = (MCalibrationChargeCalc*)tlist->FindObject("MCalibrationChargeCalc");
|
|---|
| 162 |
|
|---|
| 163 | *fLog << inf << "Found MHCalibrationChargeCam ... " << flush;
|
|---|
| 164 |
|
|---|
| 165 | if (!fIntensCharge)
|
|---|
| 166 | {
|
|---|
| 167 | *fLog << err << "Could not find nor create MCalibrationIntensityChargeCam abort... " << endl;
|
|---|
| 168 | return kFALSE;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | if (!fIntensQE)
|
|---|
| 172 | {
|
|---|
| 173 | *fLog << err << "Could not find nor create MCalibrationIntensityQECam abort... " << endl;
|
|---|
| 174 | return kFALSE;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | if (!fChargeCalc)
|
|---|
| 178 | {
|
|---|
| 179 | *fLog << err << "Could not find MCalibrationChargeCalc abort... " << endl;
|
|---|
| 180 | return kFALSE;
|
|---|
| 181 | }
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | //
|
|---|
| 185 | // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
|
|---|
| 186 | // corresponding IntensityCam
|
|---|
| 187 | //
|
|---|
| 188 | if (pList->FindObject(AddSerialNumber("MHCalibrationRelTimeCam")))
|
|---|
| 189 | {
|
|---|
| 190 |
|
|---|
| 191 | fIntensRelTime = (MCalibrationIntensityRelTimeCam*)pList->FindCreateObj("MCalibrationIntensityRelTimeCam");
|
|---|
| 192 | fRelTimeCalc = (MCalibrationRelTimeCalc*)tlist->FindObject(AddSerialNumber("MCalibrationRelTimeCalc"));
|
|---|
| 193 |
|
|---|
| 194 | *fLog << inf << "Found MHCalibrationRelTimeCam ... " << flush;
|
|---|
| 195 |
|
|---|
| 196 | if (!fIntensRelTime)
|
|---|
| 197 | {
|
|---|
| 198 | *fLog << err << "Could not find nor create MCalibrationIntensityRelTimeCam abort... " << endl;
|
|---|
| 199 | return kFALSE;
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | if (!fRelTimeCalc)
|
|---|
| 203 | {
|
|---|
| 204 | *fLog << err << "Could not find MCalibrationRelTimeCalc abort... " << endl;
|
|---|
| 205 | return kFALSE;
|
|---|
| 206 | }
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | //
|
|---|
| 210 | // Look for the MFillH name "FillRelTimeCam". In case yes, initialize the
|
|---|
| 211 | // corresponding IntensityCam
|
|---|
| 212 | //
|
|---|
| 213 | if (pList->FindObject(AddSerialNumber("MHCalibrationHiLoCam")))
|
|---|
| 214 | {
|
|---|
| 215 |
|
|---|
| 216 | fIntensHiLo = (MCalibrationIntensityHiLoCam*)pList->FindCreateObj("MCalibrationIntensityHiLoCam");
|
|---|
| 217 |
|
|---|
| 218 | *fLog << inf << "Found MHCalibrationHiLoCam ... " << flush;
|
|---|
| 219 |
|
|---|
| 220 | if (!fIntensHiLo)
|
|---|
| 221 | {
|
|---|
| 222 | *fLog << err << "Could not find nor create MCalibrationIntensityHiLoCam abort... " << endl;
|
|---|
| 223 | return kFALSE;
|
|---|
| 224 | }
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | return kTRUE;
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | // --------------------------------------------------------------------------
|
|---|
| 231 | //
|
|---|
| 232 | // Reads the pattern from MRawEvtHeader and initializes new containers in the
|
|---|
| 233 | // Intensity Cams, if the pattern has changed. Executes CallPostProcess of the
|
|---|
| 234 | // MCalibration*Calc classes in that case.
|
|---|
| 235 | //
|
|---|
| 236 | Int_t MCalibCalcFromPast::Process()
|
|---|
| 237 | {
|
|---|
| 238 |
|
|---|
| 239 | const UInt_t pattern = fHeader->GetCalibrationPattern();
|
|---|
| 240 |
|
|---|
| 241 | if (pattern == fPattern)
|
|---|
| 242 | return kTRUE;
|
|---|
| 243 |
|
|---|
| 244 | if (fPattern == 0)
|
|---|
| 245 | {
|
|---|
| 246 | fPattern = pattern;
|
|---|
| 247 | return kTRUE;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | fPattern = pattern;
|
|---|
| 251 |
|
|---|
| 252 | //
|
|---|
| 253 | // Finalize Possible calibration histogram classes...
|
|---|
| 254 | //
|
|---|
| 255 | *fLog << inf << GetDescriptor() << " : Finalize calibration histograms..." << flush;
|
|---|
| 256 | if (Finalize("MHCalibrationChargeCam")) *fLog << "MHCalibrationChargeCam";
|
|---|
| 257 | if (Finalize("MHCalibrationChargeBlindCam")) *fLog << "MHCalibrationChargeBlindCam";
|
|---|
| 258 | if (Finalize("MHCalibrationRelTimeCam")) *fLog << "MHCalibrationRelTimeCam";
|
|---|
| 259 | if (Finalize("MHCalibrationHiLoCam")) *fLog << "MHCalibrationHiLoCam";
|
|---|
| 260 |
|
|---|
| 261 | //
|
|---|
| 262 | // Finalize possible calibration calculation tasks
|
|---|
| 263 | //
|
|---|
| 264 | *fLog << endl;
|
|---|
| 265 | *fLog << inf << GetDescriptor() << " : Finalize calibration calculations..." << flush;
|
|---|
| 266 | if (fChargeCalc)
|
|---|
| 267 | fChargeCalc->CallPostProcess();
|
|---|
| 268 | if (fRelTimeCalc)
|
|---|
| 269 | fRelTimeCalc->CallPostProcess();
|
|---|
| 270 |
|
|---|
| 271 | ReInitialize();
|
|---|
| 272 |
|
|---|
| 273 | return kTRUE;
|
|---|
| 274 | }
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 | // --------------------------------------------------------------------------
|
|---|
| 278 | //
|
|---|
| 279 | // Searches for name in the MParList and calls, if existing:
|
|---|
| 280 | // - MHCalibrationCam::Finalize()
|
|---|
| 281 | // - MHCalibrationCam::ResetHists()
|
|---|
| 282 | //
|
|---|
| 283 | Bool_t MCalibCalcFromPast::Finalize(const char* name)
|
|---|
| 284 | {
|
|---|
| 285 |
|
|---|
| 286 | MHCalibrationCam *hist = (MHCalibrationCam*)fParList->FindObject(name);
|
|---|
| 287 | if (hist)
|
|---|
| 288 | {
|
|---|
| 289 | hist->Finalize();
|
|---|
| 290 | hist->ResetHists();
|
|---|
| 291 | return kTRUE;
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | return kFALSE;
|
|---|
| 295 |
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | // --------------------------------------------------------------------------
|
|---|
| 299 | //
|
|---|
| 300 | // Re-Intitializes new containers inside the Intensity Cams.
|
|---|
| 301 | // From now on, a call to the IntensityCam functions returns pointers
|
|---|
| 302 | // to the newly created Containers.
|
|---|
| 303 | //
|
|---|
| 304 | Bool_t MCalibCalcFromPast::ReInitialize()
|
|---|
| 305 | {
|
|---|
| 306 |
|
|---|
| 307 | *fLog << endl;
|
|---|
| 308 |
|
|---|
| 309 | if (fIntensBad)
|
|---|
| 310 | {
|
|---|
| 311 | fIntensBad->AddToList(Form("MBadPixelsCam%s",GetNamePattern()),*fGeom);
|
|---|
| 312 | *fLog << inf << "New MBadPixelsCam with " << GetNamePattern() << endl;
|
|---|
| 313 | }
|
|---|
| 314 | if (fIntensCharge)
|
|---|
| 315 | {
|
|---|
| 316 | fIntensCharge->AddToList(Form("MCalibrationChargeCam%s",GetNamePattern()),*fGeom);
|
|---|
| 317 | *fLog << inf << "New MCalibrationChargeCam with " << GetNamePattern() << endl;
|
|---|
| 318 | }
|
|---|
| 319 | if (fIntensQE)
|
|---|
| 320 | {
|
|---|
| 321 | fIntensQE->AddToList(Form("MCalibrationQECam%s",GetNamePattern()),*fGeom);
|
|---|
| 322 | *fLog << inf << "New MCalibrationQECam with " << GetNamePattern() << endl;
|
|---|
| 323 | }
|
|---|
| 324 | if (fIntensBlind)
|
|---|
| 325 | {
|
|---|
| 326 | fIntensBlind->AddToList(Form("MCalibrationBlindCam%s",GetNamePattern()),*fGeom);
|
|---|
| 327 | *fLog << inf << "New MCalibrationBlindCam with " << GetNamePattern() << endl;
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | return kTRUE;
|
|---|
| 331 |
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | const char* MCalibCalcFromPast::GetNamePattern()
|
|---|
| 335 | {
|
|---|
| 336 |
|
|---|
| 337 | Float_t number[MCalibrationCam::gkNumPulserColors];
|
|---|
| 338 | memset(number,0,MCalibrationCam::gkNumPulserColors*sizeof(Float_t));
|
|---|
| 339 |
|
|---|
| 340 | enum ColorCode_t
|
|---|
| 341 | {
|
|---|
| 342 | k5LedGreen = BIT(0 ),
|
|---|
| 343 | k2LedGreen = BIT(1 ),
|
|---|
| 344 | k5LedBlue2 = BIT(2 ),
|
|---|
| 345 | k1LedUV = BIT(3 ),
|
|---|
| 346 | k2LedUV = BIT(4 ),
|
|---|
| 347 | k5LedBlue3 = BIT(5 ),
|
|---|
| 348 | k5LedBlue4 = BIT(6 ),
|
|---|
| 349 | k2LedBlue = BIT(7 ),
|
|---|
| 350 | k01LedBlue = BIT(8 ),
|
|---|
| 351 | k1LedBlue = BIT(10),
|
|---|
| 352 | k5LedUV1 = BIT(11),
|
|---|
| 353 | k5LedUV2 = BIT(12),
|
|---|
| 354 | k5LedBlue1 = BIT(13),
|
|---|
| 355 | k1LedGreen = BIT(14),
|
|---|
| 356 | k01LedGreen = BIT(15),
|
|---|
| 357 | kCT1Pulser = BIT(16)
|
|---|
| 358 | };
|
|---|
| 359 |
|
|---|
| 360 | if (fPattern & k5LedGreen)
|
|---|
| 361 | number[MCalibrationCam::kGREEN] += 5;
|
|---|
| 362 | if (fPattern & k2LedGreen)
|
|---|
| 363 | number[MCalibrationCam::kGREEN] += 2;
|
|---|
| 364 | if (fPattern & k5LedBlue2)
|
|---|
| 365 | number[MCalibrationCam::kBLUE] += 2;
|
|---|
| 366 | if (fPattern & k1LedUV)
|
|---|
| 367 | number[MCalibrationCam::kUV] += 1;
|
|---|
| 368 | if (fPattern & k2LedUV)
|
|---|
| 369 | number[MCalibrationCam::kUV] += 2;
|
|---|
| 370 | if (fPattern & k5LedBlue3)
|
|---|
| 371 | number[MCalibrationCam::kBLUE] += 5;
|
|---|
| 372 | if (fPattern & k5LedBlue4)
|
|---|
| 373 | number[MCalibrationCam::kBLUE] += 5;
|
|---|
| 374 | if (fPattern & k2LedBlue)
|
|---|
| 375 | number[MCalibrationCam::kBLUE] += 2;
|
|---|
| 376 | if (fPattern & k01LedBlue)
|
|---|
| 377 | number[MCalibrationCam::kBLUE] += 0.5;
|
|---|
| 378 | if (fPattern & k1LedBlue)
|
|---|
| 379 | number[MCalibrationCam::kBLUE] += 1;
|
|---|
| 380 | if (fPattern & k5LedUV1)
|
|---|
| 381 | number[MCalibrationCam::kUV] += 5;
|
|---|
| 382 | if (fPattern & k5LedUV2)
|
|---|
| 383 | number[MCalibrationCam::kUV] += 5;
|
|---|
| 384 | if (fPattern & k5LedBlue1)
|
|---|
| 385 | number[MCalibrationCam::kBLUE] += 5;
|
|---|
| 386 | if (fPattern & k1LedGreen)
|
|---|
| 387 | number[MCalibrationCam::kGREEN] += 1;
|
|---|
| 388 | if (fPattern & k01LedGreen)
|
|---|
| 389 | number[MCalibrationCam::kGREEN] += 0.5;
|
|---|
| 390 | if (fPattern & kCT1Pulser)
|
|---|
| 391 | number[MCalibrationCam::kCT1] += 1;
|
|---|
| 392 |
|
|---|
| 393 | TString result;
|
|---|
| 394 |
|
|---|
| 395 | for (Int_t i=0; i<MCalibrationCam::gkNumPulserColors; i++)
|
|---|
| 396 | {
|
|---|
| 397 | switch (i)
|
|---|
| 398 | {
|
|---|
| 399 | case MCalibrationCam::kGREEN:
|
|---|
| 400 | if (number[i] > 0.1)
|
|---|
| 401 | result = Form("%2.1f%s",number[i],"GREEN");
|
|---|
| 402 | break;
|
|---|
| 403 | case MCalibrationCam::kBLUE:
|
|---|
| 404 | if (number[i] > 0.1)
|
|---|
| 405 | result = Form("%2.1f%s",number[i],"BLUE");
|
|---|
| 406 | break;
|
|---|
| 407 | case MCalibrationCam::kUV:
|
|---|
| 408 | if (number[i] > 0.1)
|
|---|
| 409 | result = Form("%2.1f%s",number[i],"UV");
|
|---|
| 410 | break;
|
|---|
| 411 | case MCalibrationCam::kCT1:
|
|---|
| 412 | if (number[i] > 0.1)
|
|---|
| 413 | result = Form("%2.1f%s",number[i],"CT1");
|
|---|
| 414 | break;
|
|---|
| 415 | }
|
|---|
| 416 | }
|
|---|
| 417 | return result.Data();
|
|---|
| 418 | }
|
|---|