| 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 according
|
|---|
| 32 | // to the file type
|
|---|
| 33 | //
|
|---|
| 34 | // For more details see: MTriggerPattern
|
|---|
| 35 | //
|
|---|
| 36 | // Input:
|
|---|
| 37 | // MRawEvtData
|
|---|
| 38 | //
|
|---|
| 39 | // Output:
|
|---|
| 40 | // MTriggerPattern
|
|---|
| 41 | //
|
|---|
| 42 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 43 | #include "MTriggerPatternDecode.h"
|
|---|
| 44 |
|
|---|
| 45 | #include "MLog.h"
|
|---|
| 46 | #include "MLogManip.h"
|
|---|
| 47 |
|
|---|
| 48 | #include "MParList.h"
|
|---|
| 49 | #include "MRawEvtHeader.h"
|
|---|
| 50 | #include "MRawRunHeader.h"
|
|---|
| 51 | #include "MTriggerPattern.h"
|
|---|
| 52 |
|
|---|
| 53 | ClassImp(MTriggerPatternDecode);
|
|---|
| 54 |
|
|---|
| 55 | using namespace std;
|
|---|
| 56 |
|
|---|
| 57 | // --------------------------------------------------------------------------
|
|---|
| 58 | //
|
|---|
| 59 | // Default constructor
|
|---|
| 60 | //
|
|---|
| 61 | MTriggerPatternDecode::MTriggerPatternDecode(const char *name, const char *title)
|
|---|
| 62 | : fRunHeader(0), fEvtHeader(0), fPattern(0)
|
|---|
| 63 | {
|
|---|
| 64 | fName = name ? name : "MTriggerPatternDecode";
|
|---|
| 65 | fTitle = title ? title : "Task to decode Trigger Pattern";
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | // --------------------------------------------------------------------------
|
|---|
| 69 | //
|
|---|
| 70 | Int_t MTriggerPatternDecode::PreProcess(MParList *pList)
|
|---|
| 71 | {
|
|---|
| 72 | fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 73 | if (!fRunHeader)
|
|---|
| 74 | {
|
|---|
| 75 | *fLog << err << "MRawRunHeader not found... abort." << endl;
|
|---|
| 76 | return kFALSE;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | fEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
|
|---|
| 80 | if (!fEvtHeader)
|
|---|
| 81 | {
|
|---|
| 82 | *fLog << err << "MRawEvtHeader not found... abort." << endl;
|
|---|
| 83 | return kFALSE;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | fPattern = (MTriggerPattern*)pList->FindCreateObj("MTriggerPattern");
|
|---|
| 87 | if (!fPattern)
|
|---|
| 88 | return kFALSE;
|
|---|
| 89 |
|
|---|
| 90 | return kTRUE;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | // --------------------------------------------------------------------------
|
|---|
| 94 | //
|
|---|
| 95 | //
|
|---|
| 96 | Int_t MTriggerPatternDecode::Process()
|
|---|
| 97 | {
|
|---|
| 98 | if (fRunHeader->GetCameraVersion()==0xfac7)
|
|---|
| 99 | {
|
|---|
| 100 | UInt_t pat = 0;
|
|---|
| 101 |
|
|---|
| 102 | if (fEvtHeader->GetTriggerID()&0x4)
|
|---|
| 103 | pat |= MTriggerPattern::kTriggerLvl1;
|
|---|
| 104 |
|
|---|
| 105 | if (fEvtHeader->GetTriggerID()&0x400)
|
|---|
| 106 | pat |= MTriggerPattern::kPedestal;
|
|---|
| 107 |
|
|---|
| 108 | if (fEvtHeader->GetTriggerID()&0x100)
|
|---|
| 109 | pat |= MTriggerPattern::kCalibration;
|
|---|
| 110 |
|
|---|
| 111 | if (fEvtHeader->GetTriggerID()&0x8000)
|
|---|
| 112 | pat |= MTriggerPattern::kSumTrigger;
|
|---|
| 113 |
|
|---|
| 114 | fPattern->fPrescaled = pat;
|
|---|
| 115 | fPattern->fUnprescaled = pat;
|
|---|
| 116 |
|
|---|
| 117 | return kTRUE;
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | if (fRunHeader->GetFormatVersion()<5)
|
|---|
| 121 | {
|
|---|
| 122 | switch (fRunHeader->GetRunType()&0xff)
|
|---|
| 123 | {
|
|---|
| 124 | case MRawRunHeader::kRTData:
|
|---|
| 125 | fPattern->fPrescaled = MTriggerPattern::kTriggerLvl1;
|
|---|
| 126 | fPattern->fUnprescaled = MTriggerPattern::kTriggerLvl1;
|
|---|
| 127 | return kTRUE;
|
|---|
| 128 |
|
|---|
| 129 | case MRawRunHeader::kRTPedestal:
|
|---|
| 130 | fPattern->fPrescaled = MTriggerPattern::kPedestal;
|
|---|
| 131 | fPattern->fUnprescaled = MTriggerPattern::kPedestal;
|
|---|
| 132 | return kTRUE;
|
|---|
| 133 |
|
|---|
| 134 | case MRawRunHeader::kRTCalibration:
|
|---|
| 135 | fPattern->fPrescaled = MTriggerPattern::kCalibration;
|
|---|
| 136 | fPattern->fUnprescaled = MTriggerPattern::kCalibration;
|
|---|
| 137 | return kTRUE;
|
|---|
| 138 | }
|
|---|
| 139 | return kTRUE;
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | const UInt_t pattern = ~fEvtHeader->GetTriggerID();
|
|---|
| 143 |
|
|---|
| 144 | // The the trigger pattern is currently written with inverted bits,
|
|---|
| 145 | // but in the future this could be changed. In this case the file version
|
|---|
| 146 | // number of the raw-data format must be checked. It tells you the
|
|---|
| 147 | // file format (meaning of the bits)
|
|---|
| 148 | // If for some reason the file-format has not been correctly changed
|
|---|
| 149 | // use the run-number to decide whether the bits must be inverted or not.
|
|---|
| 150 |
|
|---|
| 151 | // Trigger Pattern is a number of 16 bits, but if the machine
|
|---|
| 152 | // is a 64 bits then the bit inversion the first 16 bits are set to 1,
|
|---|
| 153 | // possibly giving problems with the filtering with the masks.
|
|---|
| 154 | // Because UInt_t by definition is a 32 bit number on any
|
|---|
| 155 | // machine (see root manual) no check is needed.
|
|---|
| 156 | // The simplest workaround is:
|
|---|
| 157 | // pattern &= 0xffffffff;
|
|---|
| 158 |
|
|---|
| 159 | // For the moment the meaning of the bits in
|
|---|
| 160 | // MRawEvtHeader::GetTriggerID and in MTriggerPattern::fTriggerPattern
|
|---|
| 161 | // are identical - this may change in the future! In this case
|
|---|
| 162 | // the decoding HERE must be changed - NOT MTriggerPattern.
|
|---|
| 163 | // If an enhancement of the information stored in MTriggerPattern
|
|---|
| 164 | // is necessary ADD new variables! Don't change the meaning of the old
|
|---|
| 165 | // ones!
|
|---|
| 166 | fPattern->fPrescaled = pattern & 0xff;
|
|---|
| 167 | fPattern->fUnprescaled = (pattern>>8) & 0xff;
|
|---|
| 168 |
|
|---|
| 169 | // This is a workaround for the new scheme in which L1TPU (the signal
|
|---|
| 170 | // comming directly from the L1 is connected, but the L1 (routed
|
|---|
| 171 | // over L2 is disconnected)
|
|---|
| 172 | if (!fRunHeader->IsMonteCarloRun() && fRunHeader->GetTelescopeNumber()==1 &&
|
|---|
| 173 | fRunHeader->GetRunNumber()>1006246)
|
|---|
| 174 | {
|
|---|
| 175 | fPattern->fPrescaled |= (pattern>> 6)&1;
|
|---|
| 176 | fPattern->fUnprescaled |= (pattern>>14)&1;
|
|---|
| 177 |
|
|---|
| 178 | fPattern->fPrescaled &= 0xbf;
|
|---|
| 179 | fPattern->fUnprescaled &= 0xbf;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | return kTRUE;
|
|---|
| 183 | }
|
|---|