]>
Commit | Line | Data |
---|---|---|
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 | //////////////////////////////////////////////////////////// | |
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 | //////////////////////////////////////////////////////////// | |
21 | ||
22 | #include <TObject.h> | |
23 | #include <TString.h> | |
24 | #include <Riostream.h> | |
25 | #include "AliCTPRawData.h" | |
26 | #include "AliRunLoader.h" | |
27 | #include "AliCentralTrigger.h" | |
867ef916 | 28 | #include "AliRawDataHeader.h" |
29 | #include "AliLog.h" | |
362c9d61 | 30 | #include "AliDAQ.h" |
867ef916 | 31 | |
32 | ClassImp(AliCTPRawData) | |
33 | //////////////////////////////////////////////////////////////////////////////////////// | |
34 | ||
35 | //______________________________________________________________________________ | |
36 | AliCTPRawData::AliCTPRawData() | |
37 | { | |
38 | // Default constructor | |
39 | } | |
40 | ||
41 | //______________________________________________________________________________ | |
42 | AliCTPRawData::AliCTPRawData(const AliCTPRawData &source): | |
43 | TObject(source) | |
44 | { | |
45 | // Copy Constructor | |
46 | } | |
47 | ||
48 | //______________________________________________________________________________ | |
49 | AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source) | |
50 | { | |
51 | // Assigment operator | |
52 | if(this==&source) return *this; | |
53 | ((TObject *)this)->operator=(source); | |
54 | ||
55 | return *this; | |
56 | } | |
57 | ||
58 | //______________________________________________________________________________ | |
59 | void AliCTPRawData::RawData() | |
60 | { | |
61 | // This method writes the CTP (trigger) | |
62 | // raw data in a DDL file | |
63 | ULong64_t l2class = 0; | |
1fa33d12 | 64 | UChar_t l2cluster = 0; |
867ef916 | 65 | AliInfo("Storing the CTP DDL raw data..."); |
66 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); | |
67 | if (runloader) { | |
68 | if (!runloader->LoadTrigger()) { | |
69 | AliCentralTrigger *aCTP = runloader->GetTrigger(); | |
70 | if (AliDebugLevel() > 0) | |
71 | aCTP->Dump(); | |
72 | // First get the trigger mask | |
73 | l2class = aCTP->GetClassMask(); | |
74 | // Then get the detector cluster to be read out | |
1fa33d12 | 75 | l2cluster = aCTP->GetClusterMask(); |
867ef916 | 76 | } |
77 | else | |
78 | AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !"); | |
79 | } | |
80 | else | |
81 | AliError("No run loader is available! Putting empty trigger class into the CTP raw data !"); | |
82 | ||
83 | AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class)); | |
84 | AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster)); | |
85 | ||
86 | char fileName[15]; | |
362c9d61 | 87 | strcpy(fileName,AliDAQ::DdlFileName("TRG",0)); |
867ef916 | 88 | AliInfo(Form("Storing CTP raw data in %s",fileName)); |
89 | ofstream outfile; // logical name of the output file | |
90 | #ifndef __DECCXX | |
91 | outfile.open(fileName,ios::binary); | |
92 | #else | |
93 | outfile.open(fileName); | |
94 | #endif | |
95 | ||
96 | AliRawDataHeader header; | |
97 | // Write a dummy header | |
98 | UInt_t dataHeaderPosition=outfile.tellp(); | |
99 | outfile.write((char*)(&header),sizeof(header)); | |
100 | ||
101 | // Writing CTP raw data here | |
102 | // The format is taken as in | |
103 | // pages 134 and 135 of the | |
104 | // Trigger TDR | |
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; | |
113 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
f95e7d66 | 114 | word |= bunchCross & 0xFFF; |
867ef916 | 115 | AliDebug(1,Form("CTP word1 = 0x%x",word)); |
116 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
117 | ||
118 | word = 0; | |
119 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
f95e7d66 | 120 | word |= (orbitId >> 12) & 0xFFF; |
867ef916 | 121 | AliDebug(1,Form("CTP word2 = 0x%x",word)); |
122 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
123 | word = 0; | |
124 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
f95e7d66 | 125 | word |= orbitId & 0xFFF; |
867ef916 | 126 | AliDebug(1,Form("CTP word3 = 0x%x",word)); |
127 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
128 | ||
129 | // Now the 4th word | |
130 | word = 0; | |
131 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
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)); |
137 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
138 | ||
139 | // Then the last 4 words with the trigger classes | |
140 | word = 0; | |
141 | word |= 0 << 13; // 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)); |
144 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
145 | word = 0; | |
146 | word |= 0 << 13; // 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)); |
149 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
150 | word = 0; | |
151 | word |= 0 << 13; // 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)); |
154 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
155 | word = 0; | |
156 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
80ebf966 | 157 | word |= (UInt_t)(l2class & 0xFFF); |
867ef916 | 158 | AliDebug(1,Form("CTP word8 = 0x%x",word)); |
159 | outfile.write((char*)(&word),sizeof(UInt_t)); | |
160 | ||
161 | // Write the real data header | |
162 | UInt_t currentFilePosition=outfile.tellp(); | |
163 | outfile.seekp(dataHeaderPosition); | |
164 | header.fSize=currentFilePosition-dataHeaderPosition; | |
165 | header.SetAttribute(0); // valid data | |
166 | header.SetTriggerClass(l2class); | |
167 | outfile.write((char*)(&header),sizeof(header)); | |
168 | outfile.close(); | |
169 | ||
170 | return; | |
171 | } |