]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCTPRawData.cxx
Removing declaration of constructor with report identifiers as parameters
[u/mrichter/AliRoot.git] / 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). 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"
28 #include "AliRawDataHeaderSim.h"
29 #include "AliLog.h"
30 #include "AliDAQ.h"
31 #include "AliFstream.h"
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;
65   UChar_t l2cluster = 0;
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
76       l2cluster = aCTP->GetClusterMask();
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];
88   strcpy(fileName,AliDAQ::DdlFileName("TRG",0));
89   AliInfo(Form("Storing CTP raw data in %s",fileName));
90   AliFstream* outfile;         // logical name of the output file 
91   outfile = new AliFstream(fileName);
92
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
106   word |= bunchCross & 0xFFF;
107   AliDebug(1,Form("CTP word1 = 0x%x",word));
108   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
109
110   word = 0;
111   word |= 0 << 13; // BlockID = 0 in case of CTP readout
112   word |= (orbitId >> 12) & 0xFFF;
113   AliDebug(1,Form("CTP word2 = 0x%x",word));
114   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
115   word = 0;
116   word |= 0 << 13; // BlockID = 0 in case of CTP readout
117   word |= orbitId & 0xFFF;
118   AliDebug(1,Form("CTP word3 = 0x%x",word));
119   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
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
126   word |= (l2cluster & 0x3F) << 2; // L2Cluster
127   word |= (UInt_t)((l2class >> 48) & 0x3);
128   AliDebug(1,Form("CTP word4 = 0x%x",word));
129   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
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
134   word |= (UInt_t)((l2class >> 36) & 0xFFF);
135   AliDebug(1,Form("CTP word5 = 0x%x",word));
136   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
137   word = 0;
138   word |= 0 << 13; // BlockID = 0 in case of CTP readout
139   word |= (UInt_t)((l2class >> 24) & 0xFFF);
140   AliDebug(1,Form("CTP word6 = 0x%x",word));
141   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
142   word = 0;
143   word |= 0 << 13; // BlockID = 0 in case of CTP readout
144   word |= (UInt_t)((l2class >> 12) & 0xFFF);
145   AliDebug(1,Form("CTP word7 = 0x%x",word));
146   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
147   word = 0;
148   word |= 0 << 13; // BlockID = 0 in case of CTP readout
149   word |= (UInt_t)(l2class & 0xFFF);
150   AliDebug(1,Form("CTP word8 = 0x%x",word));
151   outfile->WriteBuffer((char*)(&word),sizeof(UInt_t));
152
153   delete outfile;
154
155   return;
156 }