]>
Commit | Line | Data |
---|---|---|
2e9f335b | 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 | **************************************************************************/ | |
a763ec6d | 15 | /* $Id$ */ |
2e9f335b | 16 | |
a763ec6d | 17 | // Storing digits in a binary file |
18 | // according to the DDL mapping | |
066782e8 | 19 | // To be used in Alice Data Challenges |
20 | // This class is used by AliTPCDDL.C macro | |
a763ec6d | 21 | // Author: D.Favretto |
066782e8 | 22 | |
b62e2a95 | 23 | #include <Riostream.h> |
24 | #include <TObjArray.h> | |
2e9f335b | 25 | #include "AliTPCBuffer.h" |
26 | #include "AliSimDigits.h" | |
27 | ||
28 | //#include "TFile.h" | |
29 | //#include "TTree.h" | |
30 | ||
a11596ad | 31 | using std::ios; |
32 | using std::ofstream; | |
33 | using std::endl; | |
2e9f335b | 34 | ClassImp(AliTPCBuffer) |
35 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
179c6296 | 36 | //___________________________________________________________ |
37 | AliTPCBuffer::AliTPCBuffer():TObject(), | |
38 | fVerbose(0), | |
39 | fNumberOfDigits(0), | |
40 | f() | |
41 | { | |
42 | // | |
43 | // default | |
44 | // | |
45 | } | |
46 | //____________________________________________________________ | |
47 | AliTPCBuffer::AliTPCBuffer(const char* fileName):TObject(), | |
48 | fVerbose(0), | |
49 | fNumberOfDigits(0), | |
50 | f() | |
51 | { | |
a763ec6d | 52 | // Constructor |
30c1018e | 53 | #ifndef __DECCXX |
0421c3d1 | 54 | f.open(fileName,ios::binary|ios::out); |
30c1018e | 55 | #else |
0421c3d1 | 56 | f.open(fileName,ios::out); |
30c1018e | 57 | #endif |
2e9f335b | 58 | // fout=new TFile(fileName,"recreate"); |
59 | // tree=new TTree("tree","Values"); | |
179c6296 | 60 | |
9f992f70 | 61 | remove("TPCdigits.txt"); |
2e9f335b | 62 | } |
63 | ||
64 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
65 | AliTPCBuffer::~AliTPCBuffer(){ | |
066782e8 | 66 | // The destructor closes the IO stream |
2e9f335b | 67 | f.close(); |
68 | //delete tree; | |
69 | //delete fout; | |
70 | } | |
71 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
179c6296 | 72 | AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source):TObject(source), |
73 | fVerbose(0), | |
74 | fNumberOfDigits(0), | |
75 | f() | |
76 | { | |
2e9f335b | 77 | // Copy Constructor |
a79660fb | 78 | this->fVerbose=source.fVerbose; |
2e9f335b | 79 | return; |
80 | } | |
81 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
82 | AliTPCBuffer& AliTPCBuffer::operator=(const AliTPCBuffer &source){ | |
83 | //Assigment operator | |
63a14ef0 | 84 | if(this!=&source){ |
85 | this->fVerbose=source.fVerbose; | |
86 | } | |
2e9f335b | 87 | return *this; |
88 | } | |
89 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
90 | /* | |
91 | void AliTPCBuffer::WriteRow(Int_t eth,AliSimDigits *digrow,Int_t minPad,Int_t maxPad,Int_t flag,Int_t sec,Int_t SubSec,Int_t row){ | |
92 | //flag=0 the whole row is written to the root file | |
93 | //flag=1 only value in the range [minPad,MaxPasd] are written to the root file | |
94 | //flag=2 complementary case of 1 | |
95 | Int_t Pad; | |
96 | Int_t Dig; | |
97 | Int_t Time; | |
98 | tree->Branch("sec",&sec,"sec/I"); | |
99 | tree->Branch("SubSec",&SubSec,"SubSec/I"); | |
100 | tree->Branch("row",&row,"row/I"); | |
101 | tree->Branch("Pad",&Pad,"Pad/I"); | |
102 | tree->Branch("Dig",&Dig,"Dig/I"); | |
103 | tree->Branch("Time",&Time,"Time/I"); | |
104 | digrow->First(); | |
105 | do{ | |
106 | Dig=digrow->CurrentDigit(); //adc | |
107 | Time=digrow->CurrentRow(); //time | |
108 | Pad =digrow->CurrentColumn(); // pad | |
109 | // cout<<"Sec "<<sec<<" row "<<row<<" Pad "<<Pad<<" Dig "<<Dig<<" Time "<<Time<<endl; | |
110 | if(Dig>eth){ | |
111 | switch (flag){ | |
112 | case 0:{ | |
113 | tree->Fill(); | |
a763ec6d | 114 | fNumberOfDigits++; |
2e9f335b | 115 | break; |
116 | }//end case 0 | |
117 | case 1:{ | |
118 | if((Pad>=minPad)&&(Pad<=maxPad)){ | |
119 | tree->Fill(); | |
a763ec6d | 120 | fNumberOfDigits++; |
2e9f335b | 121 | } |
122 | break; | |
123 | }//end case 1 | |
124 | case 2:{ | |
125 | if((Pad<minPad)||(Pad>maxPad)){ | |
126 | tree->Fill(); | |
a763ec6d | 127 | fNumberOfDigits++; |
2e9f335b | 128 | } |
129 | break; | |
130 | }//end case 2 | |
131 | };//end switch | |
132 | }//end if | |
133 | }while (digrow->Next()); | |
134 | tree->Write(); | |
135 | return; | |
136 | } | |
137 | */ | |
138 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
139 | void AliTPCBuffer::WriteRowBinary(Int_t eth,AliSimDigits *digrow,Int_t minPad,Int_t maxPad,Int_t flag,Int_t sec,Int_t SubSec,Int_t row){ | |
a79660fb | 140 | //It writes TPC digits as par the flag specifications. Being called by AliTPCDDL.C |
141 | //flag=0 the whole row is written into the file | |
2e9f335b | 142 | //flag=1 only value in the range [minPad,MaxPasd] are written into the file |
143 | //flag=2 complementary case of 1 | |
a79660fb | 144 | |
2e9f335b | 145 | struct DataPad{ |
146 | Int_t Sec; | |
147 | Int_t SubSec; | |
148 | Int_t Row; | |
149 | Int_t Pad; | |
150 | Int_t Dig; | |
151 | Int_t Time; | |
152 | }; | |
153 | DataPad data; | |
154 | data.Sec=sec; | |
155 | data.SubSec=SubSec; | |
156 | data.Row=row; | |
7a8519ca | 157 | if (!digrow->First()) return; |
9f992f70 | 158 | Int_t padID=-1; |
159 | Int_t ddlNumber=0; | |
160 | ofstream ftxt; | |
161 | if (fVerbose==2){ | |
162 | ftxt.open("TPCdigits.txt",ios::app); | |
163 | if(sec<36) | |
164 | ddlNumber=sec*2+SubSec; | |
165 | else | |
166 | ddlNumber=72+(sec-36)*4+SubSec; | |
167 | }//end if | |
2e9f335b | 168 | do{ |
9f992f70 | 169 | data.Dig=digrow->CurrentDigit(); //adc |
170 | data.Time=digrow->CurrentRow(); //time | |
171 | data.Pad =digrow->CurrentColumn(); // pad | |
172 | if(fVerbose==2) | |
173 | if (padID!=data.Pad){ | |
174 | ftxt<<"S:"<<data.Sec<<" DDL:"<<ddlNumber<<" R:"<<data.Row<<" P:"<<data.Pad<<endl; | |
175 | padID=data.Pad; | |
176 | }//end if | |
2e9f335b | 177 | if(data.Dig>eth){ |
178 | switch (flag){ | |
179 | case 0:{ | |
a763ec6d | 180 | fNumberOfDigits++; |
2e9f335b | 181 | f.write((char*)(&data),sizeof(data)); |
9f992f70 | 182 | if(fVerbose==2) |
183 | ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl; | |
2e9f335b | 184 | break; |
185 | }//end case 0 | |
186 | case 1:{ | |
187 | if((data.Pad>=minPad)&&(data.Pad<=maxPad)){ | |
188 | f.write((char*)(&data),sizeof(data)); | |
9f992f70 | 189 | if(fVerbose==2) |
190 | ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl; | |
a763ec6d | 191 | fNumberOfDigits++; |
2e9f335b | 192 | } |
193 | break; | |
194 | }//end case 1 | |
195 | case 2:{ | |
196 | if((data.Pad<minPad)||(data.Pad>maxPad)){ | |
197 | f.write((char*)(&data),sizeof(data)); | |
9f992f70 | 198 | if(fVerbose==2) |
199 | ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl; | |
a763ec6d | 200 | fNumberOfDigits++; |
2e9f335b | 201 | } |
202 | break; | |
203 | }//end case 2 | |
204 | };//end switch | |
205 | }//end if | |
206 | }while (digrow->Next()); | |
9f992f70 | 207 | if (fVerbose==2) |
208 | ftxt.close(); | |
2e9f335b | 209 | return; |
210 | } | |
211 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |