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