| 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): Nicola Galante  12/2004 <mailto:nicola.galante@pi.infn.it> | 
|---|
| 19 | !   Author(s): Thomas Bretz 12/2004 <mailto:tbretz@astro.uni-wuerzburg.de> | 
|---|
| 20 | ! | 
|---|
| 21 | !   Copyright: MAGIC Software Development, 2004 | 
|---|
| 22 | ! | 
|---|
| 23 | \* ======================================================================== */ | 
|---|
| 24 |  | 
|---|
| 25 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 26 | // | 
|---|
| 27 | //   MCalibrationPatternDecode | 
|---|
| 28 | // | 
|---|
| 29 | //  Decodes the trigger pattern from MRawEvtData into MCalibrationPattern. | 
|---|
| 30 | // | 
|---|
| 31 | // For files before file version 5 the trigger pattern is set to 00000000. | 
|---|
| 32 | // This can be changed using the information about the file-type. | 
|---|
| 33 | // | 
|---|
| 34 | // Input: | 
|---|
| 35 | //   MRawEvtData | 
|---|
| 36 | // | 
|---|
| 37 | // Output: | 
|---|
| 38 | //   MCalibrationPattern | 
|---|
| 39 | // | 
|---|
| 40 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 41 | #include "MCalibrationPatternDecode.h" | 
|---|
| 42 |  | 
|---|
| 43 | #include "MLog.h" | 
|---|
| 44 | #include "MLogManip.h" | 
|---|
| 45 |  | 
|---|
| 46 | #include "MParList.h" | 
|---|
| 47 | #include "MRawEvtHeader.h" | 
|---|
| 48 | #include "MRawRunHeader.h" | 
|---|
| 49 | #include "MCalibrationPattern.h" | 
|---|
| 50 |  | 
|---|
| 51 | ClassImp(MCalibrationPatternDecode); | 
|---|
| 52 |  | 
|---|
| 53 | using namespace std; | 
|---|
| 54 |  | 
|---|
| 55 | // -------------------------------------------------------------------------- | 
|---|
| 56 | // | 
|---|
| 57 | // Default constructor | 
|---|
| 58 | // | 
|---|
| 59 | MCalibrationPatternDecode::MCalibrationPatternDecode(const char *name, const char *title) | 
|---|
| 60 | : fRunHeader(0), fEvtHeader(0), fPattern(0) | 
|---|
| 61 | { | 
|---|
| 62 | fName  = name  ? name  : "MCalibrationPatternDecode"; | 
|---|
| 63 | fTitle = title ? title : "Task to decode Trigger Pattern"; | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | // -------------------------------------------------------------------------- | 
|---|
| 67 | // | 
|---|
| 68 | Int_t MCalibrationPatternDecode::PreProcess(MParList *pList) | 
|---|
| 69 | { | 
|---|
| 70 | fRunHeader = (MRawRunHeader*)pList->FindCreateObj("MRawRunHeader"); | 
|---|
| 71 | if (!fRunHeader) | 
|---|
| 72 | { | 
|---|
| 73 | *fLog << err << "MRawRunHeader not found... abort." << endl; | 
|---|
| 74 | return kFALSE; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | fEvtHeader = (MRawEvtHeader *)pList->FindObject("MRawEvtHeader"); | 
|---|
| 78 | if (!fEvtHeader) | 
|---|
| 79 | { | 
|---|
| 80 | *fLog << err << "MRawEvtHeader not found... abort." << endl; | 
|---|
| 81 | return kFALSE; | 
|---|
| 82 | } | 
|---|
| 83 |  | 
|---|
| 84 | fPattern = (MCalibrationPattern*)pList->FindCreateObj("MCalibrationPattern"); | 
|---|
| 85 | if (!fPattern) | 
|---|
| 86 | { | 
|---|
| 87 | *fLog << err << "MCalibratinPattern not found... abort." << endl; | 
|---|
| 88 | return kFALSE; | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|
| 91 | return kTRUE; | 
|---|
| 92 | } | 
|---|
| 93 |  | 
|---|
| 94 | // -------------------------------------------------------------------------- | 
|---|
| 95 | // | 
|---|
| 96 | // For files before file version 5 the trigger pattern is set to 00000000. | 
|---|
| 97 | // This can be changed using the information about the file-type. | 
|---|
| 98 | // | 
|---|
| 99 | Int_t MCalibrationPatternDecode::Process() | 
|---|
| 100 | { | 
|---|
| 101 | // No setting necessary because MCalibrationPattern::Reset() has | 
|---|
| 102 | // been called just before | 
|---|
| 103 | if (fRunHeader->GetFormatVersion()<5) | 
|---|
| 104 | return kTRUE; | 
|---|
| 105 |  | 
|---|
| 106 | UInt_t pattern = fEvtHeader->GetCalibrationPattern(); | 
|---|
| 107 |  | 
|---|
| 108 | fPattern->fCLStrength = pattern & 0xff; | 
|---|
| 109 | fPattern->fCLColor    = (MCalibrationPattern::CLColor_t)((pattern>>8)&0xf); | 
|---|
| 110 |  | 
|---|
| 111 | const UInt_t pulserpattern = (pattern >> 16) & 0xffff; | 
|---|
| 112 |  | 
|---|
| 113 | fPattern->fPulserColor =  MCalibrationCam::kNONE; | 
|---|
| 114 |  | 
|---|
| 115 | if ((pulserpattern & kGreenAndBlue) || (pulserpattern & kBlueAndUV) || (pulserpattern & kGreenAndUV)) | 
|---|
| 116 | fPattern->fPulserColor =  MCalibrationCam::kNONE; | 
|---|
| 117 | if (pulserpattern & kCT1Pulser) | 
|---|
| 118 | fPattern->fPulserColor =  MCalibrationCam::kCT1; | 
|---|
| 119 | if (pulserpattern & kAnyUV) | 
|---|
| 120 | fPattern->fPulserColor =  MCalibrationCam::kUV; | 
|---|
| 121 | if (pulserpattern & kAnyGreen) | 
|---|
| 122 | fPattern->fPulserColor =  MCalibrationCam::kGREEN; | 
|---|
| 123 | if (pulserpattern & kAnyBlue) | 
|---|
| 124 | fPattern->fPulserColor =  MCalibrationCam::kBLUE; | 
|---|
| 125 |  | 
|---|
| 126 | Float_t strength = 0.; | 
|---|
| 127 |  | 
|---|
| 128 | switch (fPattern->fPulserColor) | 
|---|
| 129 | { | 
|---|
| 130 | case MCalibrationCam::kNONE: | 
|---|
| 131 | break; | 
|---|
| 132 | case MCalibrationCam::kGREEN: | 
|---|
| 133 | if (pulserpattern & kSlot1Green) | 
|---|
| 134 | strength += 5.; | 
|---|
| 135 | if (pulserpattern & kSlot2Green) | 
|---|
| 136 | strength += 2.; | 
|---|
| 137 | if (pulserpattern & kSlot15Green) | 
|---|
| 138 | strength += 1.; | 
|---|
| 139 | if (pulserpattern & kSlot16AttGreen) | 
|---|
| 140 | strength += 0.2; | 
|---|
| 141 | break; | 
|---|
| 142 | case MCalibrationCam::kBLUE: | 
|---|
| 143 | if (pulserpattern & kSlot3Blue) | 
|---|
| 144 | strength += 5.1; | 
|---|
| 145 | if (pulserpattern & kSlot6Blue) | 
|---|
| 146 | strength += 5.2; | 
|---|
| 147 | if (pulserpattern & kSlot7Blue) | 
|---|
| 148 | strength += 5.4; | 
|---|
| 149 | if (pulserpattern & kSlot8Blue) | 
|---|
| 150 | strength += 2.; | 
|---|
| 151 | if (pulserpattern & kSlot9AttBlue) | 
|---|
| 152 | strength += 0.25; | 
|---|
| 153 | if (pulserpattern & kSlot10Blue) | 
|---|
| 154 | strength += 0.; | 
|---|
| 155 | if (pulserpattern & kSlot11Blue) | 
|---|
| 156 | strength += 1.; | 
|---|
| 157 | if (pulserpattern & kSlot14Blue) | 
|---|
| 158 | strength += 5.8; | 
|---|
| 159 | break; | 
|---|
| 160 | case MCalibrationCam::kUV: | 
|---|
| 161 | if (pulserpattern & kSlot4UV) | 
|---|
| 162 | strength += 1.; | 
|---|
| 163 | if (pulserpattern & kSlot5UV) | 
|---|
| 164 | strength += 2.; | 
|---|
| 165 | if (pulserpattern & kSlot12UV) | 
|---|
| 166 | strength += 5.1; | 
|---|
| 167 | if (pulserpattern & kSlot13UV) | 
|---|
| 168 | strength += 5.2; | 
|---|
| 169 | break; | 
|---|
| 170 | case MCalibrationCam::kCT1: | 
|---|
| 171 | strength = 20.; | 
|---|
| 172 | break; | 
|---|
| 173 | } | 
|---|
| 174 |  | 
|---|
| 175 | fPattern->fPulserStrength = strength; | 
|---|
| 176 |  | 
|---|
| 177 | return kTRUE; | 
|---|
| 178 | } | 
|---|