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