]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliCTPRawData.cxx
Fix for coverity - mainly unused variables
[u/mrichter/AliRoot.git] / STEER / STEER / AliCTPRawData.cxx
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). For Run1 the CTP data format is taken as                //
19 //described in the Trigger TDR - pages 134  and 135.                //
20 //The Run1 version of raw data is in:                            //
21 //http://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf//
22 // The Run2 version of raw data is inL
23 //http://alicetrigger.web.cern.ch/alicetrigger/ls1_upgrade/ctp_readout1_run2.pdf
24 //////////////////////////////////////////////////////////
25
26 #include <TObject.h>
27 #include <TString.h>
28 #include <Riostream.h>
29 #include "AliCTPRawData.h"
30 #include "AliRunLoader.h"
31 #include "AliCentralTrigger.h"
32 #include "AliLog.h"
33 #include "AliDAQ.h"
34 #include "AliFstream.h"
35
36 ClassImp(AliCTPRawData)
37 ////////////////////////////////////////////////////////////////////////////////////////
38
39 //______________________________________________________________________________
40 AliCTPRawData::AliCTPRawData()
41 {
42   // Default constructor
43 }
44
45 //______________________________________________________________________________
46 AliCTPRawData::AliCTPRawData(const AliCTPRawData &source):
47   TObject(source)
48 {
49   // Copy Constructor
50 }
51
52 //______________________________________________________________________________
53 AliCTPRawData& AliCTPRawData::operator=(const AliCTPRawData &source)
54 {
55   // Assigment operator
56   if(this==&source) return *this;
57   ((TObject *)this)->operator=(source);
58  
59  return *this;
60 }
61
62 //______________________________________________________________________________
63 void AliCTPRawData::RawData()
64 {
65   // This method writes the CTP (trigger)
66   // raw data in a DDL file
67   // run1 payload
68   ULong64_t l2class = 0;
69   UChar_t l2cluster = 0;
70   UInt_t l0input = 0;
71   UInt_t l1input = 0;
72   UShort_t l2input=0;
73   AliInfo("Storing the CTP DDL raw data...");
74   AliRunLoader *runloader = AliRunLoader::Instance();
75   if (runloader) {
76     if (!runloader->LoadTrigger()) {
77       AliCentralTrigger *aCTP = runloader->GetTrigger();
78       if (AliDebugLevel() > 0)
79         aCTP->Dump();
80       // First get the trigger mask
81       l2class = aCTP->GetClassMask();
82       // Then get the detector cluster to be read out
83       l2cluster = aCTP->GetClusterMask();
84       // Then get the input cluster mask
85       l0input = aCTP->GetL0TriggerInputs();
86       l1input = aCTP->GetL1TriggerInputs();
87       l2input = aCTP->GetL2TriggerInputs();
88     }
89     else
90       AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
91   }
92   else
93     AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
94
95   AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
96   AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
97
98   TString fileName = AliDAQ::DdlFileName("TRG",0);
99   AliInfo(Form("Storing CTP raw data in %s",fileName.Data()));
100   AliFstream* outfile;         // logical name of the output file 
101   outfile = new AliFstream(fileName.Data());
102
103   // Writing CTP raw data here
104   // The format is taken as in
105   // dhttp://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf
106
107   // If not 0, from where??
108   UInt_t bunchCross = 0;
109   UInt_t orbitId = 0;
110   Bool_t esr = 0; // Enable Segmented Readout flag
111
112   // First 3 words here - Bunch-crossing and orbit numbers
113   UInt_t word = 0;
114   word |= 0 << 15; // BlockID = 0 in case of CTP readout
115   word |= bunchCross & 0xFFF;
116   AliDebug(1,Form("CTP word1 = 0x%x",word));
117   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
118
119   word = 0;
120   word |= 0 << 15; // BlockID = 0 in case of CTP readout
121   word |= (orbitId >> 12) & 0xFFF;
122   AliDebug(1,Form("CTP word2 = 0x%x",word));
123   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
124   word = 0;
125   word |= 0 << 15; // BlockID = 0 in case of CTP readout
126   word |= orbitId & 0xFFF;
127   AliDebug(1,Form("CTP word3 = 0x%x",word));
128   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
129
130   // Now the 4th word
131   word = 0;
132   word |= 0 << 15; // BlockID = 0 in case of CTP readout
133   word |= ((UInt_t)esr) << 10;
134   word |= 0 << 8; // L2SwC - physics trigger
135   word |= (l2cluster & 0x3F) << 2; // L2Cluster
136   word |= (UInt_t)((l2class >> 48) & 0x3);
137   AliDebug(1,Form("CTP word4 = 0x%x",word));
138   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
139
140   // Then the  4 words with the trigger classes
141   word = 0;
142   word |= 0 << 15; // BlockID = 0 in case of CTP readout
143   word |= (UInt_t)((l2class >> 36) & 0xFFF);
144   AliDebug(1,Form("CTP word5 = 0x%x",word));
145   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
146   word = 0;
147   word |= 0 << 15; // BlockID = 0 in case of CTP readout
148   word |= (UInt_t)((l2class >> 24) & 0xFFF);
149   AliDebug(1,Form("CTP word6 = 0x%x",word));
150   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
151   word = 0;
152   word |= 0 << 15; // BlockID = 0 in case of CTP readout
153   word |= (UInt_t)((l2class >> 12) & 0xFFF);
154   AliDebug(1,Form("CTP word7 = 0x%x",word));
155   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
156   word = 0;
157   word |= 0 << 15; // BlockID = 0 in case of CTP readout
158   word |= (UInt_t)(l2class & 0xFFF);
159   AliDebug(1,Form("CTP word8 = 0x%x",word));
160   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
161
162   // The last 5 words with trigger inputs
163   word = 0;
164   word |= 0 << 15; // BlockID = 0 in case of CTP readout
165   word |= (UInt_t)((l0input >> 12) & 0xFFF);
166   AliDebug(1,Form("CTP word9 = 0x%x",word));
167   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
168   word = 0;
169   word |= 0 << 15; // BlockID = 0 in case of CTP readout
170   word |= (UInt_t)((l0input >> 0) & 0xFFF);
171   AliDebug(1,Form("CTP word10 = 0x%x",word));
172   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
173   word = 0;
174   word |= 0 << 15; // BlockID = 0 in case of CTP readout
175   word |= (UInt_t)((l1input >> 12) & 0xFFF);
176   AliDebug(1,Form("CTP word11 = 0x%x",word));
177   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
178   word = 0;
179   word |= 0 << 15; // BlockID = 0 in case of CTP readout
180   word |= (UInt_t)((l1input >> 0) & 0xFFF);
181   AliDebug(1,Form("CTP word12 = 0x%x",word));
182   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
183   word = 0;
184   word |= 0 << 15; // BlockID = 0 in case of CTP readout
185   word |= (UInt_t)((l2input >> 0) & 0xFFF);
186   AliDebug(1,Form("CTP word13 = 0x%x",word));
187   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
188   
189   delete outfile;
190
191   return;
192 }
193 //______________________________________________________________________________
194 void AliCTPRawData::RawDataRun2()
195 {
196   // This method writes the CTP (trigger)
197   // raw data in a DDL file
198   // New payload for run2 50 more classes, 2 more clusters 
199   ULong64_t l2class = 0;
200   ULong64_t l2classNext50 = 0;
201   UChar_t l2cluster = 0;
202   UInt_t l0input = 0;
203   UInt_t l1input = 0;
204   UShort_t l2input=0;
205   AliInfo("Storing the CTP DDL raw data...");
206   AliRunLoader *runloader = AliRunLoader::Instance();
207   if (runloader) {
208     if (!runloader->LoadTrigger()) {
209       AliCentralTrigger *aCTP = runloader->GetTrigger();
210       if (AliDebugLevel() > 0)
211         aCTP->Dump();
212       // First get the trigger mask
213       l2class = aCTP->GetClassMask();
214       l2classNext50 = aCTP->GetClassMaskNext50();
215       // Then get the detector cluster to be read out
216       l2cluster = aCTP->GetClusterMask();
217       // Then get the input cluster mask
218       l0input = aCTP->GetL0TriggerInputs();
219       l1input = aCTP->GetL1TriggerInputs();
220       l2input = aCTP->GetL2TriggerInputs();
221     }
222     else
223       AliWarning("No trigger can be loaded! Putting empty trigger class into the CTP raw data !");
224   }
225   else
226     AliError("No run loader is available! Putting empty trigger class into the CTP raw data !");
227
228   AliDebug(1,Form("CTP trigger mask = 0x%llx",l2class));
229   AliDebug(1,Form("CTP detector cluster = 0x%x",l2cluster));
230
231   TString fileName = AliDAQ::DdlFileName("TRG",0);
232   AliInfo(Form("Storing CTP raw data in %s",fileName.Data()));
233   AliFstream* outfile;         // logical name of the output file 
234   outfile = new AliFstream(fileName.Data());
235
236   // Writing CTP raw data here
237   // The format is taken as in
238   // dhttp://epweb2.ph.bham.ac.uk/user/krivda/alice/ctp/ctp_readout1.pdf
239
240   // If not 0, from where??
241   UInt_t bunchCross = 0;
242   UInt_t orbitId = 0;
243   Bool_t esr = 0; // Enable Segmented Readout flag
244
245   // First 3 words here - Bunch-crossing and orbit numbers
246   UInt_t word = 0;
247   word |= 0 << 15; // BlockID = 0 in case of CTP readout
248   word |= bunchCross & 0xFFF;
249   AliDebug(1,Form("CTP word1 = 0x%x",word));
250   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
251
252   word = 0;
253   word |= 0 << 15; // BlockID = 0 in case of CTP readout
254   word |= (orbitId >> 12) & 0xFFF;
255   AliDebug(1,Form("CTP word2 = 0x%x",word));
256   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
257   word = 0;
258   word |= 0 << 15; // BlockID = 0 in case of CTP readout
259   word |= orbitId & 0xFFF;
260   AliDebug(1,Form("CTP word3 = 0x%x",word));
261   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
262
263   // Now the 4th word
264   word = 0;
265   word |= 0 << 15; // BlockID = 0 in case of CTP readout
266   word |= 1<<12;   // version 1=run2
267   word |= ((UInt_t)esr) << 10;
268   word |= 0 << 8; // L2SwC - physics trigger
269   word |= l2cluster;  // L2cluster 1-8
270   AliDebug(1,Form("CTP word4 = 0x%x",word));
271   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
272
273   // Then the 9 words with the trigger classes
274   word = 0;
275   word |= 0 << 15; // BlockID = 0 in case of CTP readout
276   word |= (UInt_t)((l2classNext50 >>46) & 0xF);  //5 100..97
277   AliDebug(1,Form("CTP word5 = 0x%x",word));
278   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
279   word = 0;
280   word |= 0 << 15; // BlockID = 0 in case of CTP readout
281   word |= (UInt_t)((l2classNext50 >> 34) & 0xFFF);  //6 96..85
282   AliDebug(1,Form("CTP word6 = 0x%x",word));
283   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
284   word = 0;
285   word |= 0 << 15; // BlockID = 0 in case of CTP readout
286   word |= (UInt_t)((l2classNext50 >> 22) & 0xFFF);  //7 84..73
287   AliDebug(1,Form("CTP word7 = 0x%x",word));
288   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
289   word = 0;
290   word |= 0 << 15; // BlockID = 0 in case of CTP readout
291   word |= (UInt_t)((l2classNext50 >> 10) & 0xFFF);   //8 72..61
292   AliDebug(1,Form("CTP word8 = 0x%x",word));
293   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
294   word = 0;
295   word |= 0 << 15; // BlockID = 0 in case of CTP readout
296   word |= (UInt_t)((l2classNext50 & 0x3FF)<<2);   //9 60..51
297   word |= (UInt_t)((l2class >> 48) & 0x3);   //9 50..49
298   AliDebug(1,Form("CTP word9 = 0x%x",word));
299   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
300   word = 0;
301   word |= 0 << 15; // BlockID = 0 in case of CTP readout
302   word |= (UInt_t)((l2class >> 36) & 0xFFF);   //10 48..37
303   AliDebug(1,Form("CTP word10 = 0x%x",word));
304   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
305   word = 0;
306   word |= 0 << 15; // BlockID = 0 in case of CTP readout
307   word |= (UInt_t)((l2class >> 24) & 0xFFF);   //11 36..25 
308   AliDebug(1,Form("CTP word11 = 0x%x",word));
309   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
310   word = 0;
311   word |= 0 << 15; // BlockID = 0 in case of CTP readout
312   word |= (UInt_t)((l2class >> 12) & 0xFFF);   //12 24-13 
313   AliDebug(1,Form("CTP word12 = 0x%x",word));
314   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
315   word = 0;
316   word |= 0 << 15; // BlockID = 0 in case of CTP readout
317   word |= (UInt_t)(l2class & 0xFFF);   //13 12..1 
318   AliDebug(1,Form("CTP word13 = 0x%x",word));
319   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
320
321   // The last 5 words with trigger inputs
322   word = 0;
323   word |= 0 << 15; // BlockID = 0 in case of CTP readout
324   word |= (UInt_t)((l0input >> 12) & 0xFFF);
325   AliDebug(1,Form("CTP word14 = 0x%x",word));
326   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
327   word = 0;
328   word |= 0 << 15; // BlockID = 0 in case of CTP readout
329   word |= (UInt_t)((l0input >> 0) & 0xFFF);
330   AliDebug(1,Form("CTP word15 = 0x%x",word));
331   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
332   word = 0;
333   word |= 0 << 15; // BlockID = 0 in case of CTP readout
334   word |= (UInt_t)((l1input >> 12) & 0xFFF);
335   AliDebug(1,Form("CTP word16 = 0x%x",word));
336   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
337   word = 0;
338   word |= 0 << 15; // BlockID = 0 in case of CTP readout
339   word |= (UInt_t)((l1input >> 0) & 0xFFF);
340   AliDebug(1,Form("CTP word17 = 0x%x",word));
341   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
342   word = 0;
343   word |= 0 << 15; // BlockID = 0 in case of CTP readout
344   word |= (UInt_t)((l2input >> 0) & 0xFFF);
345   AliDebug(1,Form("CTP word18 = 0x%x",word));
346   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
347   
348   delete outfile;
349
350   return;
351 }