]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliCTPRawData.cxx
Correction.
[u/mrichter/AliRoot.git] / STEER / AliCTPRawData.cxx
CommitLineData
867ef916 1/**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16////////////////////////////////////////////////////////////
23549dab 17//This class contains the methods to create raw data //
18//for CTP (trigger). The CTP data format is taken as //
19//described in the Trigger TDR - pages 134 and 135. //
20//The updated version of raw data is in: //
21//http://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf//
22//////////////////////////////////////////////////////////
867ef916 23
24#include <TObject.h>
25#include <TString.h>
26#include <Riostream.h>
27#include "AliCTPRawData.h"
28#include "AliRunLoader.h"
29#include "AliCentralTrigger.h"
f7ee745b 30#include "AliRawDataHeaderSim.h"
867ef916 31#include "AliLog.h"
362c9d61 32#include "AliDAQ.h"
08f92f14 33#include "AliFstream.h"
867ef916 34
35ClassImp(AliCTPRawData)
36////////////////////////////////////////////////////////////////////////////////////////
37
38//______________________________________________________________________________
39AliCTPRawData::AliCTPRawData()
40{
41 // Default constructor
42}
43
44//______________________________________________________________________________
45AliCTPRawData::AliCTPRawData(const AliCTPRawData &source):
46 TObject(source)
47{
48 // Copy Constructor
49}
50
51//______________________________________________________________________________
52AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source)
53{
54 // Assigment operator
55 if(this==&source) return *this;
56 ((TObject *)this)->operator=(source);
57
58 return *this;
59}
60
61//______________________________________________________________________________
62void AliCTPRawData::RawData()
63{
64 // This method writes the CTP (trigger)
65 // raw data in a DDL file
66 ULong64_t l2class = 0;
1fa33d12 67 UChar_t l2cluster = 0;
23549dab 68 UInt_t l0input = 0;
69 UInt_t l1input = 0;
70 UShort_t l2input=0;
867ef916 71 AliInfo("Storing the CTP DDL raw data...");
33c3c91a 72 AliRunLoader *runloader = AliRunLoader::Instance();
867ef916 73 if (runloader) {
74 if (!runloader->LoadTrigger()) {
75 AliCentralTrigger *aCTP = runloader->GetTrigger();
76 if (AliDebugLevel() > 0)
77 aCTP->Dump();
78 // First get the trigger mask
79 l2class = aCTP->GetClassMask();
80 // Then get the detector cluster to be read out
1fa33d12 81 l2cluster = aCTP->GetClusterMask();
23549dab 82 // Then get the input cluster mask
83 l0input = aCTP->GetL0TriggerInputs();
84 l1input = aCTP->GetL1TriggerInputs();
85 l2input = aCTP->GetL2TriggerInputs();
867ef916 86 }
87 else
88 AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
89 }
90 else
91 AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
92
93 AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
94 AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
95
96 char fileName[15];
362c9d61 97 strcpy(fileName,AliDAQ::DdlFileName("TRG",0));
867ef916 98 AliInfo(Form("Storing CTP raw data in %s",fileName));
08f92f14 99 AliFstream* outfile; // logical name of the output file
100 outfile = new AliFstream(fileName);
867ef916 101
867ef916 102 // Writing CTP raw data here
103 // The format is taken as in
23549dab 104 // dhttp://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf
867ef916 105
106 // If not 0, from where??
107 UInt_t bunchCross = 0;
108 UInt_t orbitId = 0;
109 Bool_t esr = 0; // Enable Segmented Readout flag
110
111 // First 3 words here - Bunch-crossing and orbit numbers
112 UInt_t word = 0;
23549dab 113 word |= 0 << 15; // BlockID = 0 in case of CTP readout
f95e7d66 114 word |= bunchCross & 0xFFF;
867ef916 115 AliDebug(1,Form("CTP word1 = 0x%x",word));
08f92f14 116 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 117
118 word = 0;
23549dab 119 word |= 0 << 15; // BlockID = 0 in case of CTP readout
f95e7d66 120 word |= (orbitId >> 12) & 0xFFF;
867ef916 121 AliDebug(1,Form("CTP word2 = 0x%x",word));
08f92f14 122 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 123 word = 0;
23549dab 124 word |= 0 << 15; // BlockID = 0 in case of CTP readout
f95e7d66 125 word |= orbitId & 0xFFF;
867ef916 126 AliDebug(1,Form("CTP word3 = 0x%x",word));
08f92f14 127 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 128
129 // Now the 4th word
130 word = 0;
23549dab 131 word |= 0 << 15; // BlockID = 0 in case of CTP readout
867ef916 132 word |= ((UInt_t)esr) << 10;
133 word |= 0 << 8; // L2SwC - physics trigger
f95e7d66 134 word |= (l2cluster & 0x3F) << 2; // L2Cluster
80ebf966 135 word |= (UInt_t)((l2class >> 48) & 0x3);
867ef916 136 AliDebug(1,Form("CTP word4 = 0x%x",word));
08f92f14 137 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 138
23549dab 139 // Then the 4 words with the trigger classes
867ef916 140 word = 0;
23549dab 141 word |= 0 << 15; // BlockID = 0 in case of CTP readout
80ebf966 142 word |= (UInt_t)((l2class >> 36) & 0xFFF);
867ef916 143 AliDebug(1,Form("CTP word5 = 0x%x",word));
08f92f14 144 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 145 word = 0;
23549dab 146 word |= 0 << 15; // BlockID = 0 in case of CTP readout
80ebf966 147 word |= (UInt_t)((l2class >> 24) & 0xFFF);
867ef916 148 AliDebug(1,Form("CTP word6 = 0x%x",word));
08f92f14 149 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 150 word = 0;
23549dab 151 word |= 0 << 15; // BlockID = 0 in case of CTP readout
80ebf966 152 word |= (UInt_t)((l2class >> 12) & 0xFFF);
867ef916 153 AliDebug(1,Form("CTP word7 = 0x%x",word));
08f92f14 154 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 155 word = 0;
23549dab 156 word |= 0 << 15; // BlockID = 0 in case of CTP readout
80ebf966 157 word |= (UInt_t)(l2class & 0xFFF);
867ef916 158 AliDebug(1,Form("CTP word8 = 0x%x",word));
08f92f14 159 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
867ef916 160
23549dab 161 // The last 5 words with trigger inputs
162 word = 0;
163 word |= 0 << 15; // BlockID = 0 in case of CTP readout
164 word |= (UInt_t)((l0input >> 12) & 0xFFF);
165 AliDebug(1,Form("CTP word9 = 0x%x",word));
166 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
167 word = 0;
168 word |= 0 << 15; // BlockID = 0 in case of CTP readout
169 word |= (UInt_t)((l0input >> 0) & 0xFFF);
170 AliDebug(1,Form("CTP word10 = 0x%x",word));
171 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
172 word = 0;
173 word |= 0 << 15; // BlockID = 0 in case of CTP readout
174 word |= (UInt_t)((l1input >> 12) & 0xFFF);
175 AliDebug(1,Form("CTP word11 = 0x%x",word));
176 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
177 word = 0;
178 word |= 0 << 15; // BlockID = 0 in case of CTP readout
179 word |= (UInt_t)((l1input >> 0) & 0xFFF);
180 AliDebug(1,Form("CTP word12 = 0x%x",word));
181 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
182 word = 0;
183 word |= 0 << 15; // BlockID = 0 in case of CTP readout
184 word |= (UInt_t)((l2input >> 0) & 0xFFF);
185 AliDebug(1,Form("CTP word13 = 0x%x",word));
186 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
187
08f92f14 188 delete outfile;
867ef916 189
190 return;
191}