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). The CTP data format is taken as //
19 //described in the Trigger TDR - pages 134 and 135. //
20 ////////////////////////////////////////////////////////////
24 #include <Riostream.h>
25 #include "AliCTPRawData.h"
26 #include "AliRunLoader.h"
27 #include "AliCentralTrigger.h"
28 #include "AliRawDataHeader.h"
31 #include "AliFstream.h"
33 ClassImp(AliCTPRawData)
34 ////////////////////////////////////////////////////////////////////////////////////////
36 //______________________________________________________________________________
37 AliCTPRawData::AliCTPRawData()
39 // Default constructor
42 //______________________________________________________________________________
43 AliCTPRawData::AliCTPRawData(const AliCTPRawData &source):
49 //______________________________________________________________________________
50 AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source)
53 if(this==&source) return *this;
54 ((TObject *)this)->operator=(source);
59 //______________________________________________________________________________
60 void AliCTPRawData::RawData()
62 // This method writes the CTP (trigger)
63 // raw data in a DDL file
64 ULong64_t l2class = 0;
65 UChar_t l2cluster = 0;
66 AliInfo("Storing the CTP DDL raw data...");
67 AliRunLoader *runloader = AliRunLoader::GetRunLoader();
69 if (!runloader->LoadTrigger()) {
70 AliCentralTrigger *aCTP = runloader->GetTrigger();
71 if (AliDebugLevel() > 0)
73 // First get the trigger mask
74 l2class = aCTP->GetClassMask();
75 // Then get the detector cluster to be read out
76 l2cluster = aCTP->GetClusterMask();
79 AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
82 AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
84 AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
85 AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
88 strcpy(fileName,AliDAQ::DdlFileName("TRG",0));
89 AliInfo(Form("Storing CTP raw data in %s",fileName));
90 AliFstream* outfile; // logical name of the output file
91 outfile = new AliFstream(fileName);
93 AliRawDataHeader header;
94 // Write a dummy header
95 UInt_t dataHeaderPosition=outfile->Tellp();
96 outfile->WriteBuffer((char*)(&header),sizeof(header));
98 // Writing CTP raw data here
99 // The format is taken as in
100 // pages 134 and 135 of the
103 // If not 0, from where??
104 UInt_t bunchCross = 0;
106 Bool_t esr = 0; // Enable Segmented Readout flag
108 // First 3 words here - Bunch-crossing and orbit numbers
110 word |= 0 << 13; // BlockID = 0 in case of CTP readout
111 word |= bunchCross & 0xFFF;
112 AliDebug(1,Form("CTP word1 = 0x%x",word));
113 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
116 word |= 0 << 13; // BlockID = 0 in case of CTP readout
117 word |= (orbitId >> 12) & 0xFFF;
118 AliDebug(1,Form("CTP word2 = 0x%x",word));
119 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
121 word |= 0 << 13; // BlockID = 0 in case of CTP readout
122 word |= orbitId & 0xFFF;
123 AliDebug(1,Form("CTP word3 = 0x%x",word));
124 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
128 word |= 0 << 13; // BlockID = 0 in case of CTP readout
129 word |= ((UInt_t)esr) << 10;
130 word |= 0 << 8; // L2SwC - physics trigger
131 word |= (l2cluster & 0x3F) << 2; // L2Cluster
132 word |= (UInt_t)((l2class >> 48) & 0x3);
133 AliDebug(1,Form("CTP word4 = 0x%x",word));
134 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
136 // Then the last 4 words with the trigger classes
138 word |= 0 << 13; // BlockID = 0 in case of CTP readout
139 word |= (UInt_t)((l2class >> 36) & 0xFFF);
140 AliDebug(1,Form("CTP word5 = 0x%x",word));
141 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
143 word |= 0 << 13; // BlockID = 0 in case of CTP readout
144 word |= (UInt_t)((l2class >> 24) & 0xFFF);
145 AliDebug(1,Form("CTP word6 = 0x%x",word));
146 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
148 word |= 0 << 13; // BlockID = 0 in case of CTP readout
149 word |= (UInt_t)((l2class >> 12) & 0xFFF);
150 AliDebug(1,Form("CTP word7 = 0x%x",word));
151 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
153 word |= 0 << 13; // BlockID = 0 in case of CTP readout
154 word |= (UInt_t)(l2class & 0xFFF);
155 AliDebug(1,Form("CTP word8 = 0x%x",word));
156 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
158 // Write the real data header
159 UInt_t currentFilePosition=outfile->Tellp();
160 outfile->Seekp(dataHeaderPosition);
161 header.fSize=currentFilePosition-dataHeaderPosition;
162 header.SetAttribute(0); // valid data
163 header.SetTriggerClass(l2class);
164 outfile->WriteBuffer((char*)(&header),sizeof(header));