source: trunk/MagicSoft/Mars/mtrigger/MTriggerPatternDecode.cc@ 5803

Last change on this file since 5803 was 5803, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 4.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// MTriggerPatternDecode
28//
29// Decodes the trigger pattern from MRawEvtData into MTriggerPattern.
30//
31// Input:
32// MRawEvtData
33//
34// Output:
35// MTriggerPattern
36//
37/////////////////////////////////////////////////////////////////////////////
38#include "MTriggerPatternDecode.h"
39
40#include "MLog.h"
41#include "MLogManip.h"
42
43#include "MParList.h"
44#include "MRawEvtHeader.h"
45#include "MRawRunHeader.h"
46#include "MTriggerPattern.h"
47
48ClassImp(MTriggerPatternDecode);
49
50using namespace std;
51
52// --------------------------------------------------------------------------
53//
54// Default constructor
55//
56MTriggerPatternDecode::MTriggerPatternDecode(const char *name, const char *title)
57 : fRunHeader(0), fEvtHeader(0), fPattern(0)
58{
59 fName = name ? name : "MTriggerPatternDecode";
60 fTitle = title ? title : "Task to decode Trigger Pattern";
61}
62
63// --------------------------------------------------------------------------
64//
65Int_t MTriggerPatternDecode::PreProcess(MParList *pList)
66{
67 fRunHeader = (MRawRunHeader*)pList->FindCreateObj("MRawRunHeader");
68 if (!fRunHeader)
69 {
70 *fLog << err << "MRawRunHeader not found... abort." << endl;
71 return kFALSE;
72 }
73
74 fEvtHeader = (MRawEvtHeader *)pList->FindObject("MRawEvtHeader");
75 if (!fEvtHeader)
76 {
77 *fLog << err << "MRawEvtHeader not found... abort." << endl;
78 return kFALSE;
79 }
80
81 fPattern = (MTriggerPattern*)pList->FindCreateObj("MTriggerPattern");
82 if (!fPattern)
83 {
84 *fLog << err << "MRawEvtHeader not found... abort." << endl;
85 return kFALSE;
86 }
87
88 return kTRUE;
89}
90
91// --------------------------------------------------------------------------
92//
93Int_t MTriggerPatternDecode::Process()
94{
95 if (fRunHeader->GetFormatVersion()<5)
96 return kTRUE;
97
98 UInt_t pattern = ~fEvtHeader->GetTriggerID();
99
100 // The the trigger pattern is currently written with inverted bits,
101 // but in the future this could be changed. In this case the file version
102 // number of the raw-data format must be checked. It tells you the
103 // file format (meaning of the bits)
104 // If for some reason the file-format has not been correctly changed
105 // use the run-number to decide whether the bits must be inverted or not.
106
107 // Trigger Pattern is a number of 16 bits, but if the machine
108 // is a 64 bits then the bit inversion the first 16 bits are set to 1,
109 // possibly giving problems with the filtering with the masks.
110 // Because UInt_t by definition is a 32 bit number on any
111 // machine (see root manual) no check is needed.
112 // The simplest workaround is:
113 // pattern &= 0xffffffff;
114
115 // For the moment the meaning of the bits in
116 // MRawEvtHeader::GetTriggerID and in MTriggerPattern::fTriggerPattern
117 // are identical - this may change in the future! In this case
118 // the decoding HERE must be changed - NOT MTriggerPattern.
119 // If an enhancement of the information stored in MTriggerPattern
120 // is necessary ADD new variables! Don't change the meaning of the old
121 // ones!
122 fPattern->fPrescaled = pattern & 0xff;
123 fPattern->fUnprescaled = (pattern>>8) & 0xff;
124
125 return kTRUE;
126}
Note: See TracBrowser for help on using the repository browser.