source: tags/Mars-V0.9.2/mtrigger/MTriggerPatternDecode.cc

Last change on this file was 5869, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.5 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// MTriggerPatternDecode
28//
29// Decodes the trigger pattern from MRawEvtData into MTriggerPattern.
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// MTriggerPattern
39//
40/////////////////////////////////////////////////////////////////////////////
41#include "MTriggerPatternDecode.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 "MTriggerPattern.h"
50
51ClassImp(MTriggerPatternDecode);
52
53using namespace std;
54
55// --------------------------------------------------------------------------
56//
57// Default constructor
58//
59MTriggerPatternDecode::MTriggerPatternDecode(const char *name, const char *title)
60 : fRunHeader(0), fEvtHeader(0), fPattern(0)
61{
62 fName = name ? name : "MTriggerPatternDecode";
63 fTitle = title ? title : "Task to decode Trigger Pattern";
64}
65
66// --------------------------------------------------------------------------
67//
68Int_t MTriggerPatternDecode::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 = (MTriggerPattern*)pList->FindCreateObj("MTriggerPattern");
85 if (!fPattern)
86 {
87 *fLog << err << "MRawEvtHeader 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//
99Int_t MTriggerPatternDecode::Process()
100{
101 // No setting necessary because MTriggerPattern::reset() has
102 // been called just before
103 if (fRunHeader->GetFormatVersion()<5)
104 return kTRUE;
105
106 UInt_t pattern = ~fEvtHeader->GetTriggerID();
107
108 // The the trigger pattern is currently written with inverted bits,
109 // but in the future this could be changed. In this case the file version
110 // number of the raw-data format must be checked. It tells you the
111 // file format (meaning of the bits)
112 // If for some reason the file-format has not been correctly changed
113 // use the run-number to decide whether the bits must be inverted or not.
114
115 // Trigger Pattern is a number of 16 bits, but if the machine
116 // is a 64 bits then the bit inversion the first 16 bits are set to 1,
117 // possibly giving problems with the filtering with the masks.
118 // Because UInt_t by definition is a 32 bit number on any
119 // machine (see root manual) no check is needed.
120 // The simplest workaround is:
121 // pattern &= 0xffffffff;
122
123 // For the moment the meaning of the bits in
124 // MRawEvtHeader::GetTriggerID and in MTriggerPattern::fTriggerPattern
125 // are identical - this may change in the future! In this case
126 // the decoding HERE must be changed - NOT MTriggerPattern.
127 // If an enhancement of the information stored in MTriggerPattern
128 // is necessary ADD new variables! Don't change the meaning of the old
129 // ones!
130 fPattern->fPrescaled = pattern & 0xff;
131 fPattern->fUnprescaled = (pattern>>8) & 0xff;
132
133 return kTRUE;
134}
Note: See TracBrowser for help on using the repository browser.