]>
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 | //////////////////////////////////////////////////////////// | |
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 | //////////////////////////////////////////////////////////// | |
21 | ||
22 | #include <TObject.h> | |
23 | #include <TString.h> | |
24 | #include <Riostream.h> | |
25 | #include "AliCTPRawData.h" | |
26 | #include "AliRunLoader.h" | |
27 | #include "AliCentralTrigger.h" | |
f7ee745b | 28 | #include "AliRawDataHeaderSim.h" |
867ef916 | 29 | #include "AliLog.h" |
362c9d61 | 30 | #include "AliDAQ.h" |
08f92f14 | 31 | #include "AliFstream.h" |
867ef916 | 32 | |
33 | ClassImp(AliCTPRawData) | |
34 | //////////////////////////////////////////////////////////////////////////////////////// | |
35 | ||
36 | //______________________________________________________________________________ | |
37 | AliCTPRawData::AliCTPRawData() | |
38 | { | |
39 | // Default constructor | |
40 | } | |
41 | ||
42 | //______________________________________________________________________________ | |
43 | AliCTPRawData::AliCTPRawData(const AliCTPRawData &source): | |
44 | TObject(source) | |
45 | { | |
46 | // Copy Constructor | |
47 | } | |
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source) | |
51 | { | |
52 | // Assigment operator | |
53 | if(this==&source) return *this; | |
54 | ((TObject *)this)->operator=(source); | |
55 | ||
56 | return *this; | |
57 | } | |
58 | ||
59 | //______________________________________________________________________________ | |
60 | void AliCTPRawData::RawData() | |
61 | { | |
62 | // This method writes the CTP (trigger) | |
63 | // raw data in a DDL file | |
64 | ULong64_t l2class = 0; | |
1fa33d12 | 65 | UChar_t l2cluster = 0; |
867ef916 | 66 | AliInfo("Storing the CTP DDL raw data..."); |
67 | AliRunLoader *runloader = AliRunLoader::GetRunLoader(); | |
68 | if (runloader) { | |
69 | if (!runloader->LoadTrigger()) { | |
70 | AliCentralTrigger *aCTP = runloader->GetTrigger(); | |
71 | if (AliDebugLevel() > 0) | |
72 | aCTP->Dump(); | |
73 | // First get the trigger mask | |
74 | l2class = aCTP->GetClassMask(); | |
75 | // Then get the detector cluster to be read out | |
1fa33d12 | 76 | l2cluster = aCTP->GetClusterMask(); |
867ef916 | 77 | } |
78 | else | |
79 | AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !"); | |
80 | } | |
81 | else | |
82 | AliError("No run loader is available! Putting empty trigger class into the CTP raw data !"); | |
83 | ||
84 | AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class)); | |
85 | AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster)); | |
86 | ||
87 | char fileName[15]; | |
362c9d61 | 88 | strcpy(fileName,AliDAQ::DdlFileName("TRG",0)); |
867ef916 | 89 | AliInfo(Form("Storing CTP raw data in %s",fileName)); |
08f92f14 | 90 | AliFstream* outfile; // logical name of the output file |
91 | outfile = new AliFstream(fileName); | |
867ef916 | 92 | |
867ef916 | 93 | // Writing CTP raw data here |
94 | // The format is taken as in | |
95 | // pages 134 and 135 of the | |
96 | // Trigger TDR | |
97 | ||
98 | // If not 0, from where?? | |
99 | UInt_t bunchCross = 0; | |
100 | UInt_t orbitId = 0; | |
101 | Bool_t esr = 0; // Enable Segmented Readout flag | |
102 | ||
103 | // First 3 words here - Bunch-crossing and orbit numbers | |
104 | UInt_t word = 0; | |
105 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
f95e7d66 | 106 | word |= bunchCross & 0xFFF; |
867ef916 | 107 | AliDebug(1,Form("CTP word1 = 0x%x",word)); |
08f92f14 | 108 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 109 | |
110 | word = 0; | |
111 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
f95e7d66 | 112 | word |= (orbitId >> 12) & 0xFFF; |
867ef916 | 113 | AliDebug(1,Form("CTP word2 = 0x%x",word)); |
08f92f14 | 114 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 115 | word = 0; |
116 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
f95e7d66 | 117 | word |= orbitId & 0xFFF; |
867ef916 | 118 | AliDebug(1,Form("CTP word3 = 0x%x",word)); |
08f92f14 | 119 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 120 | |
121 | // Now the 4th word | |
122 | word = 0; | |
123 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
124 | word |= ((UInt_t)esr) << 10; | |
125 | word |= 0 << 8; // L2SwC - physics trigger | |
f95e7d66 | 126 | word |= (l2cluster & 0x3F) << 2; // L2Cluster |
80ebf966 | 127 | word |= (UInt_t)((l2class >> 48) & 0x3); |
867ef916 | 128 | AliDebug(1,Form("CTP word4 = 0x%x",word)); |
08f92f14 | 129 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 130 | |
131 | // Then the last 4 words with the trigger classes | |
132 | word = 0; | |
133 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
80ebf966 | 134 | word |= (UInt_t)((l2class >> 36) & 0xFFF); |
867ef916 | 135 | AliDebug(1,Form("CTP word5 = 0x%x",word)); |
08f92f14 | 136 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 137 | word = 0; |
138 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
80ebf966 | 139 | word |= (UInt_t)((l2class >> 24) & 0xFFF); |
867ef916 | 140 | AliDebug(1,Form("CTP word6 = 0x%x",word)); |
08f92f14 | 141 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 142 | word = 0; |
143 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
80ebf966 | 144 | word |= (UInt_t)((l2class >> 12) & 0xFFF); |
867ef916 | 145 | AliDebug(1,Form("CTP word7 = 0x%x",word)); |
08f92f14 | 146 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 147 | word = 0; |
148 | word |= 0 << 13; // BlockID = 0 in case of CTP readout | |
80ebf966 | 149 | word |= (UInt_t)(l2class & 0xFFF); |
867ef916 | 150 | AliDebug(1,Form("CTP word8 = 0x%x",word)); |
08f92f14 | 151 | outfile->WriteBuffer((char*)(&word),sizeof(UInt_t)); |
867ef916 | 152 | |
08f92f14 | 153 | delete outfile; |
867ef916 | 154 | |
155 | return; | |
156 | } |