1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
23 #include <Riostream.h>
24 #include <TObjArray.h>
25 #include "AliTPCBuffer.h"
26 #include "AliSimDigits.h"
34 ClassImp(AliTPCBuffer)
35 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
36 //___________________________________________________________
37 AliTPCBuffer::AliTPCBuffer():TObject(),
46 //____________________________________________________________
47 AliTPCBuffer::AliTPCBuffer(const char* fileName):TObject(),
54 f.open(fileName,ios::binary|ios::out);
56 f.open(fileName,ios::out);
58 // fout=new TFile(fileName,"recreate");
59 // tree=new TTree("tree","Values");
61 remove("TPCdigits.txt");
64 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
65 AliTPCBuffer::~AliTPCBuffer(){
66 // The destructor closes the IO stream
71 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
72 AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source):TObject(source),
78 this->fVerbose=source.fVerbose;
81 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
82 AliTPCBuffer& AliTPCBuffer::operator=(const AliTPCBuffer &source){
85 this->fVerbose=source.fVerbose;
89 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
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
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");
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;
118 if((Pad>=minPad)&&(Pad<=maxPad)){
125 if((Pad<minPad)||(Pad>maxPad)){
133 }while (digrow->Next());
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){
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
142 //flag=1 only value in the range [minPad,MaxPasd] are written into the file
143 //flag=2 complementary case of 1
157 if (!digrow->First()) return;
162 ftxt.open("TPCdigits.txt",ios::app);
164 ddlNumber=sec*2+SubSec;
166 ddlNumber=72+(sec-36)*4+SubSec;
169 data.Dig=digrow->CurrentDigit(); //adc
170 data.Time=digrow->CurrentRow(); //time
171 data.Pad =digrow->CurrentColumn(); // pad
173 if (padID!=data.Pad){
174 ftxt<<"S:"<<data.Sec<<" DDL:"<<ddlNumber<<" R:"<<data.Row<<" P:"<<data.Pad<<endl;
181 f.write((char*)(&data),sizeof(data));
183 ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl;
187 if((data.Pad>=minPad)&&(data.Pad<=maxPad)){
188 f.write((char*)(&data),sizeof(data));
190 ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl;
196 if((data.Pad<minPad)||(data.Pad>maxPad)){
197 f.write((char*)(&data),sizeof(data));
199 ftxt<<"A:"<<data.Dig<<" T:"<<data.Time<<endl;
206 }while (digrow->Next());
211 //////////////////////////////////////////////////////////////////////////////////////////////////////////////