1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ////////////////////////////////////////////////////////////
17 //This class contains the methods to create raw data //
18 //for CTP (trigger). For Run1 the CTP data format is taken as //
19 //described in the Trigger TDR - pages 134 and 135. //
20 //The Run1 version of raw data is in: //
21 //http://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf//
22 // The Run2 version of raw data is inL
23 //http://alicetrigger.web.cern.ch/alicetrigger/ls1_upgrade/ctp_readout1_run2.pdf
24 //////////////////////////////////////////////////////////
28 #include <Riostream.h>
29 #include "AliCTPRawData.h"
30 #include "AliRunLoader.h"
31 #include "AliCentralTrigger.h"
34 #include "AliFstream.h"
36 ClassImp(AliCTPRawData)
37 ////////////////////////////////////////////////////////////////////////////////////////
39 //______________________________________________________________________________
40 AliCTPRawData::AliCTPRawData()
42 // Default constructor
45 //______________________________________________________________________________
46 AliCTPRawData::AliCTPRawData(const AliCTPRawData &source):
52 //______________________________________________________________________________
53 AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source)
56 if(this==&source) return *this;
57 ((TObject *)this)->operator=(source);
62 //______________________________________________________________________________
63 void AliCTPRawData::RawData()
65 // This method writes the CTP (trigger)
66 // raw data in a DDL file
68 ULong64_t l2class = 0;
69 UChar_t l2cluster = 0;
73 AliInfo("Storing the CTP DDL raw data...");
74 AliRunLoader *runloader = AliRunLoader::Instance();
76 if (!runloader->LoadTrigger()) {
77 AliCentralTrigger *aCTP = runloader->GetTrigger();
78 if (AliDebugLevel() > 0)
80 // First get the trigger mask
81 l2class = aCTP->GetClassMask();
82 // Then get the detector cluster to be read out
83 l2cluster = aCTP->GetClusterMask();
84 // Then get the input cluster mask
85 l0input = aCTP->GetL0TriggerInputs();
86 l1input = aCTP->GetL1TriggerInputs();
87 l2input = aCTP->GetL2TriggerInputs();
90 AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
93 AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
95 AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
96 AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
98 TString fileName = AliDAQ::DdlFileName("TRG",0);
99 AliInfo(Form("Storing CTP raw data in %s",fileName.Data()));
100 AliFstream* outfile; // logical name of the output file
101 outfile = new AliFstream(fileName.Data());
103 // Writing CTP raw data here
104 // The format is taken as in
105 // dhttp://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf
107 // If not 0, from where??
108 UInt_t bunchCross = 0;
110 Bool_t esr = 0; // Enable Segmented Readout flag
112 // First 3 words here - Bunch-crossing and orbit numbers
114 word |= 0 << 15; // BlockID = 0 in case of CTP readout
115 word |= bunchCross & 0xFFF;
116 AliDebug(1,Form("CTP word1 = 0x%x",word));
117 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
120 word |= 0 << 15; // BlockID = 0 in case of CTP readout
121 word |= (orbitId >> 12) & 0xFFF;
122 AliDebug(1,Form("CTP word2 = 0x%x",word));
123 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
125 word |= 0 << 15; // BlockID = 0 in case of CTP readout
126 word |= orbitId & 0xFFF;
127 AliDebug(1,Form("CTP word3 = 0x%x",word));
128 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
132 word |= 0 << 15; // BlockID = 0 in case of CTP readout
133 word |= ((UInt_t)esr) << 10;
134 word |= 0 << 8; // L2SwC - physics trigger
135 word |= (l2cluster & 0x3F) << 2; // L2Cluster
136 word |= (UInt_t)((l2class >> 48) & 0x3);
137 AliDebug(1,Form("CTP word4 = 0x%x",word));
138 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
140 // Then the 4 words with the trigger classes
142 word |= 0 << 15; // BlockID = 0 in case of CTP readout
143 word |= (UInt_t)((l2class >> 36) & 0xFFF);
144 AliDebug(1,Form("CTP word5 = 0x%x",word));
145 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
147 word |= 0 << 15; // BlockID = 0 in case of CTP readout
148 word |= (UInt_t)((l2class >> 24) & 0xFFF);
149 AliDebug(1,Form("CTP word6 = 0x%x",word));
150 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
152 word |= 0 << 15; // BlockID = 0 in case of CTP readout
153 word |= (UInt_t)((l2class >> 12) & 0xFFF);
154 AliDebug(1,Form("CTP word7 = 0x%x",word));
155 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
157 word |= 0 << 15; // BlockID = 0 in case of CTP readout
158 word |= (UInt_t)(l2class & 0xFFF);
159 AliDebug(1,Form("CTP word8 = 0x%x",word));
160 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
162 // The last 5 words with trigger inputs
164 word |= 0 << 15; // BlockID = 0 in case of CTP readout
165 word |= (UInt_t)((l0input >> 12) & 0xFFF);
166 AliDebug(1,Form("CTP word9 = 0x%x",word));
167 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
169 word |= 0 << 15; // BlockID = 0 in case of CTP readout
170 word |= (UInt_t)((l0input >> 0) & 0xFFF);
171 AliDebug(1,Form("CTP word10 = 0x%x",word));
172 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
174 word |= 0 << 15; // BlockID = 0 in case of CTP readout
175 word |= (UInt_t)((l1input >> 12) & 0xFFF);
176 AliDebug(1,Form("CTP word11 = 0x%x",word));
177 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
179 word |= 0 << 15; // BlockID = 0 in case of CTP readout
180 word |= (UInt_t)((l1input >> 0) & 0xFFF);
181 AliDebug(1,Form("CTP word12 = 0x%x",word));
182 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
184 word |= 0 << 15; // BlockID = 0 in case of CTP readout
185 word |= (UInt_t)((l2input >> 0) & 0xFFF);
186 AliDebug(1,Form("CTP word13 = 0x%x",word));
187 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
193 //______________________________________________________________________________
194 void AliCTPRawData::RawDataRun2()
196 // This method writes the CTP (trigger)
197 // raw data in a DDL file
198 // New payload for run2 50 more classes, 2 more clusters
199 ULong64_t l2class = 0;
200 ULong64_t l2classNext50 = 0;
201 UChar_t l2cluster = 0;
205 AliInfo("Storing the CTP DDL raw data...");
206 AliRunLoader *runloader = AliRunLoader::Instance();
208 if (!runloader->LoadTrigger()) {
209 AliCentralTrigger *aCTP = runloader->GetTrigger();
210 if (AliDebugLevel() > 0)
212 // First get the trigger mask
213 l2class = aCTP->GetClassMask();
214 l2classNext50 = aCTP->GetClassMaskNext50();
215 // Then get the detector cluster to be read out
216 l2cluster = aCTP->GetClusterMask();
217 // Then get the input cluster mask
218 l0input = aCTP->GetL0TriggerInputs();
219 l1input = aCTP->GetL1TriggerInputs();
220 l2input = aCTP->GetL2TriggerInputs();
223 AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
226 AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
228 AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
229 AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
231 TString fileName = AliDAQ::DdlFileName("TRG",0);
232 AliInfo(Form("Storing CTP raw data in %s",fileName.Data()));
233 AliFstream* outfile; // logical name of the output file
234 outfile = new AliFstream(fileName.Data());
236 // Writing CTP raw data here
237 // The format is taken as in
238 // dhttp://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf
240 // If not 0, from where??
241 UInt_t bunchCross = 0;
243 Bool_t esr = 0; // Enable Segmented Readout flag
245 // First 3 words here - Bunch-crossing and orbit numbers
247 word |= 0 << 15; // BlockID = 0 in case of CTP readout
248 word |= bunchCross & 0xFFF;
249 AliDebug(1,Form("CTP word1 = 0x%x",word));
250 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
253 word |= 0 << 15; // BlockID = 0 in case of CTP readout
254 word |= (orbitId >> 12) & 0xFFF;
255 AliDebug(1,Form("CTP word2 = 0x%x",word));
256 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
258 word |= 0 << 15; // BlockID = 0 in case of CTP readout
259 word |= orbitId & 0xFFF;
260 AliDebug(1,Form("CTP word3 = 0x%x",word));
261 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
265 word |= 0 << 15; // BlockID = 0 in case of CTP readout
266 word |= 1<<12; // version 1=run2
267 word |= ((UInt_t)esr) << 10;
268 word |= 0 << 8; // L2SwC - physics trigger
269 word |= l2cluster; // L2cluster 1-8
270 AliDebug(1,Form("CTP word4 = 0x%x",word));
271 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
273 // Then the 9 words with the trigger classes
275 word |= 0 << 15; // BlockID = 0 in case of CTP readout
276 word |= (UInt_t)((l2classNext50 >>46) & 0xF); //5 100..97
277 AliDebug(1,Form("CTP word5 = 0x%x",word));
278 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
280 word |= 0 << 15; // BlockID = 0 in case of CTP readout
281 word |= (UInt_t)((l2classNext50 >> 34) & 0xFFF); //6 96..85
282 AliDebug(1,Form("CTP word6 = 0x%x",word));
283 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
285 word |= 0 << 15; // BlockID = 0 in case of CTP readout
286 word |= (UInt_t)((l2classNext50 >> 22) & 0xFFF); //7 84..73
287 AliDebug(1,Form("CTP word7 = 0x%x",word));
288 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
290 word |= 0 << 15; // BlockID = 0 in case of CTP readout
291 word |= (UInt_t)((l2classNext50 >> 10) & 0xFFF); //8 72..61
292 AliDebug(1,Form("CTP word8 = 0x%x",word));
293 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
295 word |= 0 << 15; // BlockID = 0 in case of CTP readout
296 word |= (UInt_t)((l2classNext50 & 0x3FF)<<2); //9 60..51
297 word |= (UInt_t)((l2class >> 48) & 0x3); //9 50..49
298 AliDebug(1,Form("CTP word9 = 0x%x",word));
299 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
301 word |= 0 << 15; // BlockID = 0 in case of CTP readout
302 word |= (UInt_t)((l2class >> 36) & 0xFFF); //10 48..37
303 AliDebug(1,Form("CTP word10 = 0x%x",word));
304 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
306 word |= 0 << 15; // BlockID = 0 in case of CTP readout
307 word |= (UInt_t)((l2class >> 24) & 0xFFF); //11 36..25
308 AliDebug(1,Form("CTP word11 = 0x%x",word));
309 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
311 word |= 0 << 15; // BlockID = 0 in case of CTP readout
312 word |= (UInt_t)((l2class >> 12) & 0xFFF); //12 24-13
313 AliDebug(1,Form("CTP word12 = 0x%x",word));
314 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
316 word |= 0 << 15; // BlockID = 0 in case of CTP readout
317 word |= (UInt_t)(l2class & 0xFFF); //13 12..1
318 AliDebug(1,Form("CTP word13 = 0x%x",word));
319 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
321 // The last 5 words with trigger inputs
323 word |= 0 << 15; // BlockID = 0 in case of CTP readout
324 word |= (UInt_t)((l0input >> 12) & 0xFFF);
325 AliDebug(1,Form("CTP word14 = 0x%x",word));
326 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
328 word |= 0 << 15; // BlockID = 0 in case of CTP readout
329 word |= (UInt_t)((l0input >> 0) & 0xFFF);
330 AliDebug(1,Form("CTP word15 = 0x%x",word));
331 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
333 word |= 0 << 15; // BlockID = 0 in case of CTP readout
334 word |= (UInt_t)((l1input >> 12) & 0xFFF);
335 AliDebug(1,Form("CTP word16 = 0x%x",word));
336 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
338 word |= 0 << 15; // BlockID = 0 in case of CTP readout
339 word |= (UInt_t)((l1input >> 0) & 0xFFF);
340 AliDebug(1,Form("CTP word17 = 0x%x",word));
341 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
343 word |= 0 << 15; // BlockID = 0 in case of CTP readout
344 word |= (UInt_t)((l2input >> 0) & 0xFFF);
345 AliDebug(1,Form("CTP word18 = 0x%x",word));
346 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));