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"
32 ClassImp(AliCTPRawData)
33 ////////////////////////////////////////////////////////////////////////////////////////
35 //______________________________________________________________________________
36 AliCTPRawData::AliCTPRawData()
38 // Default constructor
41 //______________________________________________________________________________
42 AliCTPRawData::AliCTPRawData(const AliCTPRawData &source):
48 //______________________________________________________________________________
49 AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source)
52 if(this==&source) return *this;
53 ((TObject *)this)->operator=(source);
58 //______________________________________________________________________________
59 void AliCTPRawData::RawData()
61 // This method writes the CTP (trigger)
62 // raw data in a DDL file
63 ULong64_t l2class = 0;
64 UChar_t l2cluster = 0;
65 AliInfo("Storing the CTP DDL raw data...");
66 AliRunLoader *runloader = AliRunLoader::GetRunLoader();
68 if (!runloader->LoadTrigger()) {
69 AliCentralTrigger *aCTP = runloader->GetTrigger();
70 if (AliDebugLevel() > 0)
72 // First get the trigger mask
73 l2class = aCTP->GetClassMask();
74 // Then get the detector cluster to be read out
75 l2cluster = aCTP->GetClusterMask();
78 AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
81 AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
83 AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
84 AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
87 strcpy(fileName,AliDAQ::DdlFileName("TRG",0));
88 AliInfo(Form("Storing CTP raw data in %s",fileName));
89 ofstream outfile; // logical name of the output file
91 outfile.open(fileName,ios::binary);
93 outfile.open(fileName);
96 AliRawDataHeader header;
97 // Write a dummy header
98 UInt_t dataHeaderPosition=outfile.tellp();
99 outfile.write((char*)(&header),sizeof(header));
101 // Writing CTP raw data here
102 // The format is taken as in
103 // pages 134 and 135 of the
106 // If not 0, from where??
107 UInt_t bunchCross = 0;
109 Bool_t esr = 0; // Enable Segmented Readout flag
111 // First 3 words here - Bunch-crossing and orbit numbers
113 word |= 0 << 13; // BlockID = 0 in case of CTP readout
114 word |= bunchCross & 0xFFF;
115 AliDebug(1,Form("CTP word1 = 0x%x",word));
116 outfile.write((char*)(&word),sizeof(UInt_t));
119 word |= 0 << 13; // BlockID = 0 in case of CTP readout
120 word |= (orbitId >> 12) & 0xFFF;
121 AliDebug(1,Form("CTP word2 = 0x%x",word));
122 outfile.write((char*)(&word),sizeof(UInt_t));
124 word |= 0 << 13; // BlockID = 0 in case of CTP readout
125 word |= orbitId & 0xFFF;
126 AliDebug(1,Form("CTP word3 = 0x%x",word));
127 outfile.write((char*)(&word),sizeof(UInt_t));
131 word |= 0 << 13; // BlockID = 0 in case of CTP readout
132 word |= ((UInt_t)esr) << 10;
133 word |= 0 << 8; // L2SwC - physics trigger
134 word |= (l2cluster & 0x3F) << 2; // L2Cluster
135 word |= (UInt_t)((l2class >> 48) & 0x3);
136 AliDebug(1,Form("CTP word4 = 0x%x",word));
137 outfile.write((char*)(&word),sizeof(UInt_t));
139 // Then the last 4 words with the trigger classes
141 word |= 0 << 13; // BlockID = 0 in case of CTP readout
142 word |= (UInt_t)((l2class >> 36) & 0xFFF);
143 AliDebug(1,Form("CTP word5 = 0x%x",word));
144 outfile.write((char*)(&word),sizeof(UInt_t));
146 word |= 0 << 13; // BlockID = 0 in case of CTP readout
147 word |= (UInt_t)((l2class >> 24) & 0xFFF);
148 AliDebug(1,Form("CTP word6 = 0x%x",word));
149 outfile.write((char*)(&word),sizeof(UInt_t));
151 word |= 0 << 13; // BlockID = 0 in case of CTP readout
152 word |= (UInt_t)((l2class >> 12) & 0xFFF);
153 AliDebug(1,Form("CTP word7 = 0x%x",word));
154 outfile.write((char*)(&word),sizeof(UInt_t));
156 word |= 0 << 13; // BlockID = 0 in case of CTP readout
157 word |= (UInt_t)(l2class & 0xFFF);
158 AliDebug(1,Form("CTP word8 = 0x%x",word));
159 outfile.write((char*)(&word),sizeof(UInt_t));
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));