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 //The updated version of raw data is in: //
21 //http://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf//
22 //////////////////////////////////////////////////////////
26 #include <Riostream.h>
27 #include "AliCTPRawData.h"
28 #include "AliRunLoader.h"
29 #include "AliCentralTrigger.h"
30 #include "AliRawDataHeaderSim.h"
33 #include "AliFstream.h"
35 ClassImp(AliCTPRawData)
36 ////////////////////////////////////////////////////////////////////////////////////////
38 //______________________________________________________________________________
39 AliCTPRawData::AliCTPRawData()
41 // Default constructor
44 //______________________________________________________________________________
45 AliCTPRawData::AliCTPRawData(const AliCTPRawData &source):
51 //______________________________________________________________________________
52 AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source)
55 if(this==&source) return *this;
56 ((TObject *)this)->operator=(source);
61 //______________________________________________________________________________
62 void AliCTPRawData::RawData()
64 // This method writes the CTP (trigger)
65 // raw data in a DDL file
66 ULong64_t l2class = 0;
67 UChar_t l2cluster = 0;
71 AliInfo("Storing the CTP DDL raw data...");
72 AliRunLoader *runloader = AliRunLoader::Instance();
74 if (!runloader->LoadTrigger()) {
75 AliCentralTrigger *aCTP = runloader->GetTrigger();
76 if (AliDebugLevel() > 0)
78 // First get the trigger mask
79 l2class = aCTP->GetClassMask();
80 // Then get the detector cluster to be read out
81 l2cluster = aCTP->GetClusterMask();
82 // Then get the input cluster mask
83 l0input = aCTP->GetL0TriggerInputs();
84 l1input = aCTP->GetL1TriggerInputs();
85 l2input = aCTP->GetL2TriggerInputs();
88 AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
91 AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
93 AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
94 AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
96 TString fileName = AliDAQ::DdlFileName("TRG",0);
97 AliInfo(Form("Storing CTP raw data in %s",fileName.Data()));
98 AliFstream* outfile; // logical name of the output file
99 outfile = new AliFstream(fileName.Data());
101 // Writing CTP raw data here
102 // The format is taken as in
103 // dhttp://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf
105 // If not 0, from where??
106 UInt_t bunchCross = 0;
108 Bool_t esr = 0; // Enable Segmented Readout flag
110 // First 3 words here - Bunch-crossing and orbit numbers
112 word |= 0 << 15; // BlockID = 0 in case of CTP readout
113 word |= bunchCross & 0xFFF;
114 AliDebug(1,Form("CTP word1 = 0x%x",word));
115 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
118 word |= 0 << 15; // BlockID = 0 in case of CTP readout
119 word |= (orbitId >> 12) & 0xFFF;
120 AliDebug(1,Form("CTP word2 = 0x%x",word));
121 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
123 word |= 0 << 15; // BlockID = 0 in case of CTP readout
124 word |= orbitId & 0xFFF;
125 AliDebug(1,Form("CTP word3 = 0x%x",word));
126 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
130 word |= 0 << 15; // BlockID = 0 in case of CTP readout
131 word |= ((UInt_t)esr) << 10;
132 word |= 0 << 8; // L2SwC - physics trigger
133 word |= (l2cluster & 0x3F) << 2; // L2Cluster
134 word |= (UInt_t)((l2class >> 48) & 0x3);
135 AliDebug(1,Form("CTP word4 = 0x%x",word));
136 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
138 // Then the 4 words with the trigger classes
140 word |= 0 << 15; // BlockID = 0 in case of CTP readout
141 word |= (UInt_t)((l2class >> 36) & 0xFFF);
142 AliDebug(1,Form("CTP word5 = 0x%x",word));
143 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
145 word |= 0 << 15; // BlockID = 0 in case of CTP readout
146 word |= (UInt_t)((l2class >> 24) & 0xFFF);
147 AliDebug(1,Form("CTP word6 = 0x%x",word));
148 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
150 word |= 0 << 15; // BlockID = 0 in case of CTP readout
151 word |= (UInt_t)((l2class >> 12) & 0xFFF);
152 AliDebug(1,Form("CTP word7 = 0x%x",word));
153 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
155 word |= 0 << 15; // BlockID = 0 in case of CTP readout
156 word |= (UInt_t)(l2class & 0xFFF);
157 AliDebug(1,Form("CTP word8 = 0x%x",word));
158 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
160 // The last 5 words with trigger inputs
162 word |= 0 << 15; // BlockID = 0 in case of CTP readout
163 word |= (UInt_t)((l0input >> 12) & 0xFFF);
164 AliDebug(1,Form("CTP word9 = 0x%x",word));
165 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
167 word |= 0 << 15; // BlockID = 0 in case of CTP readout
168 word |= (UInt_t)((l0input >> 0) & 0xFFF);
169 AliDebug(1,Form("CTP word10 = 0x%x",word));
170 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
172 word |= 0 << 15; // BlockID = 0 in case of CTP readout
173 word |= (UInt_t)((l1input >> 12) & 0xFFF);
174 AliDebug(1,Form("CTP word11 = 0x%x",word));
175 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
177 word |= 0 << 15; // BlockID = 0 in case of CTP readout
178 word |= (UInt_t)((l1input >> 0) & 0xFFF);
179 AliDebug(1,Form("CTP word12 = 0x%x",word));
180 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
182 word |= 0 << 15; // BlockID = 0 in case of CTP readout
183 word |= (UInt_t)((l2input >> 0) & 0xFFF);
184 AliDebug(1,Form("CTP word13 = 0x%x",word));
185 outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));