source: trunk/Mars/mcalib/MCalibrationPatternDecode.cc@ 9918

Last change on this file since 9918 was 9329, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 6.1 KB
Line 
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// MRawRunHeader
37//
38// Output:
39// MCalibrationPattern
40//
41/////////////////////////////////////////////////////////////////////////////
42#include "MCalibrationPatternDecode.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47#include "MParList.h"
48#include "MRawEvtHeader.h"
49#include "MRawRunHeader.h"
50#include "MCalibrationPattern.h"
51
52ClassImp(MCalibrationPatternDecode);
53
54using namespace std;
55
56// --------------------------------------------------------------------------
57//
58// Default constructor
59//
60MCalibrationPatternDecode::MCalibrationPatternDecode(const char *name, const char *title)
61 : fRunHeader(0), fEvtHeader(0), fPattern(0)
62{
63 fName = name ? name : "MCalibrationPatternDecode";
64 fTitle = title ? title : "Task to decode Trigger Pattern";
65}
66
67// --------------------------------------------------------------------------
68//
69Int_t MCalibrationPatternDecode::PreProcess(MParList *pList)
70{
71 fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
72 if (!fRunHeader)
73 {
74 *fLog << err << "MRawRunHeader not found... abort." << endl;
75 return kFALSE;
76 }
77
78 fEvtHeader = (MRawEvtHeader *)pList->FindObject("MRawEvtHeader");
79 if (!fEvtHeader)
80 {
81 *fLog << err << "MRawEvtHeader not found... abort." << endl;
82 return kFALSE;
83 }
84
85 fPattern = (MCalibrationPattern*)pList->FindCreateObj("MCalibrationPattern");
86 if (!fPattern)
87 return kFALSE;
88
89 return kTRUE;
90}
91
92// --------------------------------------------------------------------------
93//
94// For files before file version 5 the trigger pattern is set to 00000000.
95// This can be changed using the information about the file-type.
96//
97Int_t MCalibrationPatternDecode::Process()
98{
99 // No setting necessary because MCalibrationPattern::Reset() has
100 // been called just before
101 if (fRunHeader->GetFormatVersion()<5)
102 return kTRUE;
103
104 // Get calibration pattern from event header
105 const UInt_t pattern = fEvtHeader->GetCalibrationPattern();
106
107 const UInt_t str = (pattern ) & 0x00ff;
108 const UInt_t col = (pattern>> 8) & 0x000f;
109 const UInt_t pat = (pattern>>16) & 0xffff;
110
111 fPattern->fCLStrength = str;
112 fPattern->fCLColor = (MCalibrationPattern::CLColor_t)col;
113
114 // Set a default pattern
115 fPattern->fPulserColor = MCalibrationCam::kNONE;
116
117 // This is a MC workaround because the CT1 bit cannot be set
118 // It would be bit 33 in the pattern which simple
119 // doesn't exist in a 32 bit integer.
120 if (fRunHeader->IsMonteCarloRun() && pat==0)
121 fPattern->fPulserColor = MCalibrationCam::kCT1;
122
123 // Check the pattern
124 if ((pat & kGreenAndBlue) || (pat & kBlueAndUV) || (pat & kGreenAndUV))
125 fPattern->fPulserColor = MCalibrationCam::kNONE;
126
127 // FIXME: This condition can never be true!
128 //if (pat & kCT1Pulser)
129 // fPattern->fPulserColor = MCalibrationCam::kCT1;
130
131 if (pat & kAnyUV)
132 fPattern->fPulserColor = MCalibrationCam::kUV;
133
134 if (pat & kAnyGreen)
135 fPattern->fPulserColor = MCalibrationCam::kGREEN;
136
137 if (pat & kAnyBlue)
138 fPattern->fPulserColor = MCalibrationCam::kBLUE;
139
140 // Now decode the strength
141 fPattern->fPulserStrength = 0.;
142
143 switch (fPattern->fPulserColor)
144 {
145 case MCalibrationCam::kNONE:
146 break;
147
148 case MCalibrationCam::kGREEN:
149 if (pat & kSlot1Green)
150 fPattern->fPulserStrength += 5.0;
151 if (pat & kSlot2Green)
152 fPattern->fPulserStrength += 2.0;
153 if (pat & kSlot15Green)
154 fPattern->fPulserStrength += 1.0;
155 if (pat & kSlot16AttGreen)
156 fPattern->fPulserStrength += 0.2;
157 break;
158
159 case MCalibrationCam::kBLUE:
160 if (pat & kSlot3Blue)
161 fPattern->fPulserStrength += 5.1;
162 if (pat & kSlot6Blue)
163 fPattern->fPulserStrength += 5.2;
164 if (pat & kSlot7Blue)
165 fPattern->fPulserStrength += 5.4;
166 if (pat & kSlot8Blue)
167 fPattern->fPulserStrength += 2.0;
168 if (pat & kSlot9AttBlue)
169 fPattern->fPulserStrength += 0.25;
170 if (pat & kSlot10Blue)
171 fPattern->fPulserStrength += 0.0;
172 if (pat & kSlot11Blue)
173 fPattern->fPulserStrength += 1.0;
174 if (pat & kSlot14Blue)
175 fPattern->fPulserStrength += 5.8;
176 break;
177
178 case MCalibrationCam::kUV:
179 if (pat & kSlot4UV)
180 fPattern->fPulserStrength += 1.0;
181 if (pat & kSlot5UV)
182 fPattern->fPulserStrength += 2.0;
183 if (pat & kSlot12UV)
184 fPattern->fPulserStrength += 5.1;
185 if (pat & kSlot13UV)
186 fPattern->fPulserStrength += 5.2;
187 break;
188
189 case MCalibrationCam::kCT1:
190 fPattern->fPulserStrength = 20.;
191 break;
192 }
193
194 return kTRUE;
195}
Note: See TracBrowser for help on using the repository browser.