]>
Commit | Line | Data |
---|---|---|
867ef916 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | //////////////////////////////////////////////////////////// | |
23549dab | 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 | ////////////////////////////////////////////////////////// | |
867ef916 | 23 | |
24 | #include <TObject.h> | |
25 | #include <TString.h> | |
26 | #include <Riostream.h> | |
27 | #include "AliCTPRawData.h" | |
28 | #include "AliRunLoader.h" | |
29 | #include "AliCentralTrigger.h" | |
867ef916 | 30 | #include "AliLog.h" |
362c9d61 | 31 | #include "AliDAQ.h" |
08f92f14 | 32 | #include "AliFstream.h" |
867ef916 | 33 | |
34 | ClassImp(AliCTPRawData) | |
35 | //////////////////////////////////////////////////////////////////////////////////////// | |
36 | ||
37 | //______________________________________________________________________________ | |
38 | AliCTPRawData::AliCTPRawData() | |
39 | { | |
40 | // Default constructor | |
41 | } | |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliCTPRawData::AliCTPRawData(const AliCTPRawData &source): | |
45 | TObject(source) | |
46 | { | |
47 | // Copy Constructor | |
48 | } | |
49 | ||
50 | //______________________________________________________________________________ | |
51 | AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source) | |
52 | { | |
53 | // Assigment operator | |
54 | if(this==&source) return *this; | |
55 | ((TObject *)this)->operator=(source); | |
56 | ||
57 | return *this; | |
58 | } | |
59 | ||
60 | //______________________________________________________________________________ | |
61 | void AliCTPRawData::RawData() | |
62 | { | |
63 | // This method writes the CTP (trigger) | |
64 | // raw data in a DDL file | |
65 | ULong64_t l2class = 0; | |
1fa33d12 | 66 | UChar_t l2cluster = 0; |
23549dab | 67 | UInt_t l0input = 0; |
68 | UInt_t l1input = 0; | |
69 | UShort_t l2input=0; | |
867ef916 | 70 | AliInfo("Storing the CTP DDL raw data..."); |
33c3c91a | 71 | AliRunLoader *runloader = AliRunLoader::Instance(); |
867ef916 | 72 | if (runloader) { |
73 | if (!runloader->LoadTrigger()) { | |
74 | AliCentralTrigger *aCTP = runloader->GetTrigger(); | |
75 | if (AliDebugLevel() > 0) | |
76 | aCTP->Dump(); | |
77 | // First get the trigger mask | |
78 | l2class = aCTP->GetClassMask(); | |
79 | // Then get the detector cluster to be read out | |
1fa33d12 | 80 | l2cluster = aCTP->GetClusterMask(); |
23549dab | 81 | // Then get the input cluster mask |
82 | l0input = aCTP->GetL0TriggerInputs(); | |
83 | l1input = aCTP->GetL1TriggerInputs(); | |
84 | l2input = aCTP->GetL2TriggerInputs(); | |
867ef916 | 85 | } |
86 | else | |
87 | AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !"); | |
88 | } | |
89 | else | |
90 | AliError("No run loader is available! Putting empty trigger class into the CTP raw data !"); | |
91 | ||
92 | AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class)); | |
93 | AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster)); | |
94 | ||
a4124171 | 95 | TString fileName = AliDAQ::DdlFileName("TRG",0); |
96 | AliInfo(Form("Storing CTP raw data in %s",fileName.Data())); | |
08f92f14 | 97 | AliFstream* outfile; // logical name of the output file |
a4124171 | 98 | outfile = new AliFstream(fileName.Data()); |
867ef916 | 99 | |
867ef916 | 100 | // Writing CTP raw data here |
101 | // The format is taken as in | |
23549dab | 102 | // dhttp://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf |
867ef916 | 103 | |
104 | // If not 0, from where?? | |
105 | UInt_t bunchCross = 0; | |
106 | UInt_t orbitId = 0; | |
107 | Bool_t esr = 0; // Enable Segmented Readout flag | |
108 | ||
109 | // First 3 words here - Bunch-crossing and orbit numbers | |
110 | UInt_t word = 0; | |
23549dab | 111 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
f95e7d66 | 112 | word |= bunchCross & 0xFFF; |
867ef916 | 113 | AliDebug(1,Form("CTP word1 = 0x%x",word)); |
08f92f14 | 114 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 115 | |
116 | word = 0; | |
23549dab | 117 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
f95e7d66 | 118 | word |= (orbitId >> 12) & 0xFFF; |
867ef916 | 119 | AliDebug(1,Form("CTP word2 = 0x%x",word)); |
08f92f14 | 120 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 121 | word = 0; |
23549dab | 122 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
f95e7d66 | 123 | word |= orbitId & 0xFFF; |
867ef916 | 124 | AliDebug(1,Form("CTP word3 = 0x%x",word)); |
08f92f14 | 125 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 126 | |
127 | // Now the 4th word | |
128 | word = 0; | |
23549dab | 129 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
867ef916 | 130 | word |= ((UInt_t)esr) << 10; |
131 | word |= 0 << 8; // L2SwC - physics trigger | |
f95e7d66 | 132 | word |= (l2cluster & 0x3F) << 2; // L2Cluster |
80ebf966 | 133 | word |= (UInt_t)((l2class >> 48) & 0x3); |
867ef916 | 134 | AliDebug(1,Form("CTP word4 = 0x%x",word)); |
08f92f14 | 135 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 136 | |
23549dab | 137 | // Then the 4 words with the trigger classes |
867ef916 | 138 | word = 0; |
23549dab | 139 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
80ebf966 | 140 | word |= (UInt_t)((l2class >> 36) & 0xFFF); |
867ef916 | 141 | AliDebug(1,Form("CTP word5 = 0x%x",word)); |
08f92f14 | 142 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 143 | word = 0; |
23549dab | 144 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
80ebf966 | 145 | word |= (UInt_t)((l2class >> 24) & 0xFFF); |
867ef916 | 146 | AliDebug(1,Form("CTP word6 = 0x%x",word)); |
08f92f14 | 147 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 148 | word = 0; |
23549dab | 149 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
80ebf966 | 150 | word |= (UInt_t)((l2class >> 12) & 0xFFF); |
867ef916 | 151 | AliDebug(1,Form("CTP word7 = 0x%x",word)); |
08f92f14 | 152 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 153 | word = 0; |
23549dab | 154 | word |= 0 << 15; // BlockID = 0 in case of CTP readout |
80ebf966 | 155 | word |= (UInt_t)(l2class & 0xFFF); |
867ef916 | 156 | AliDebug(1,Form("CTP word8 = 0x%x",word)); |
08f92f14 | 157 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 158 | |
23549dab | 159 | // The last 5 words with trigger inputs |
160 | word = 0; | |
161 | word |= 0 << 15; // BlockID = 0 in case of CTP readout | |
162 | word |= (UInt_t)((l0input >> 12) & 0xFFF); | |
163 | AliDebug(1,Form("CTP word9 = 0x%x",word)); | |
164 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); | |
165 | word = 0; | |
166 | word |= 0 << 15; // BlockID = 0 in case of CTP readout | |
167 | word |= (UInt_t)((l0input >> 0) & 0xFFF); | |
168 | AliDebug(1,Form("CTP word10 = 0x%x",word)); | |
169 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); | |
170 | word = 0; | |
171 | word |= 0 << 15; // BlockID = 0 in case of CTP readout | |
172 | word |= (UInt_t)((l1input >> 12) & 0xFFF); | |
173 | AliDebug(1,Form("CTP word11 = 0x%x",word)); | |
174 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); | |
175 | word = 0; | |
176 | word |= 0 << 15; // BlockID = 0 in case of CTP readout | |
177 | word |= (UInt_t)((l1input >> 0) & 0xFFF); | |
178 | AliDebug(1,Form("CTP word12 = 0x%x",word)); | |
179 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); | |
180 | word = 0; | |
181 | word |= 0 << 15; // BlockID = 0 in case of CTP readout | |
182 | word |= (UInt_t)((l2input >> 0) & 0xFFF); | |
183 | AliDebug(1,Form("CTP word13 = 0x%x",word)); | |
184 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); | |
185 | ||
08f92f14 | 186 | delete outfile; |
867ef916 | 187 | |
188 | return; | |
189 | } |