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 "AliDAQConfig.h"
29 #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;
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 TString detectorCluster = aCTP->GetDetectors();
76 if (detectorCluster.Contains("START")) {
77 if (detectorCluster.Contains("MUON"))
86 AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
89 AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
91 AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
92 AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
95 sprintf(fileName,"%s_%d.ddl",kDetectors[kCTPIndex],kCTPIndex*0x100);
96 AliInfo(Form("Storing CTP raw data in %s",fileName));
97 ofstream outfile; // logical name of the output file
99 outfile.open(fileName,ios::binary);
101 outfile.open(fileName);
104 AliRawDataHeader header;
105 // Write a dummy header
106 UInt_t dataHeaderPosition=outfile.tellp();
107 outfile.write((char*)(&header),sizeof(header));
109 // Writing CTP raw data here
110 // The format is taken as in
111 // pages 134 and 135 of the
114 // If not 0, from where??
115 UInt_t bunchCross = 0;
117 Bool_t esr = 0; // Enable Segmented Readout flag
119 // First 3 words here - Bunch-crossing and orbit numbers
121 word |= 0 << 13; // BlockID = 0 in case of CTP readout
122 word |= bunchCross && 0xFFF;
123 AliDebug(1,Form("CTP word1 = 0x%x",word));
124 outfile.write((char*)(&word),sizeof(UInt_t));
127 word |= 0 << 13; // BlockID = 0 in case of CTP readout
128 word |= (orbitId >> 12) && 0xFFF;
129 AliDebug(1,Form("CTP word2 = 0x%x",word));
130 outfile.write((char*)(&word),sizeof(UInt_t));
132 word |= 0 << 13; // BlockID = 0 in case of CTP readout
133 word |= orbitId && 0xFFF;
134 AliDebug(1,Form("CTP word3 = 0x%x",word));
135 outfile.write((char*)(&word),sizeof(UInt_t));
139 word |= 0 << 13; // BlockID = 0 in case of CTP readout
140 word |= ((UInt_t)esr) << 10;
141 word |= 0 << 8; // L2SwC - physics trigger
142 word |= (l2cluster && 0x3F) << 2; // L2Cluster
143 word |= (l2class >> 48) && 0x3;
144 AliDebug(1,Form("CTP word4 = 0x%x",word));
145 outfile.write((char*)(&word),sizeof(UInt_t));
147 // Then the last 4 words with the trigger classes
149 word |= 0 << 13; // BlockID = 0 in case of CTP readout
150 word |= (l2class >> 36) && 0xFFF;
151 AliDebug(1,Form("CTP word5 = 0x%x",word));
152 outfile.write((char*)(&word),sizeof(UInt_t));
154 word |= 0 << 13; // BlockID = 0 in case of CTP readout
155 word |= (l2class >> 24) && 0xFFF;
156 AliDebug(1,Form("CTP word6 = 0x%x",word));
157 outfile.write((char*)(&word),sizeof(UInt_t));
159 word |= 0 << 13; // BlockID = 0 in case of CTP readout
160 word |= (l2class >> 12) && 0xFFF;
161 AliDebug(1,Form("CTP word7 = 0x%x",word));
162 outfile.write((char*)(&word),sizeof(UInt_t));
164 word |= 0 << 13; // BlockID = 0 in case of CTP readout
165 word |= l2class && 0xFFF;
166 AliDebug(1,Form("CTP word8 = 0x%x",word));
167 outfile.write((char*)(&word),sizeof(UInt_t));
169 // Write the real data header
170 UInt_t currentFilePosition=outfile.tellp();
171 outfile.seekp(dataHeaderPosition);
172 header.fSize=currentFilePosition-dataHeaderPosition;
173 header.SetAttribute(0); // valid data
174 header.SetTriggerClass(l2class);
175 outfile.write((char*)(&header),sizeof(header));