]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCBuffer.cxx
Setting the branch address to permit correct reading
[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
2e9f335b 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
31ClassImp(AliTPCBuffer)
32//////////////////////////////////////////////////////////////////////////////////////////////////////////////
33AliTPCBuffer::AliTPCBuffer(const char* fileName){
a763ec6d 34 // Constructor
30c1018e 35#ifndef __DECCXX
2e9f335b 36 f.open("AliTPCDDL.dat",ios::binary|ios::out);
30c1018e 37#else
38 f.open("AliTPCDDL.dat",ios::out);
39#endif
2e9f335b 40 // fout=new TFile(fileName,"recreate");
41 // tree=new TTree("tree","Values");
a763ec6d 42 fNumberOfDigits=0;
2e9f335b 43 fVerbose=0;
44}
45
46//////////////////////////////////////////////////////////////////////////////////////////////////////////////
47AliTPCBuffer::~AliTPCBuffer(){
066782e8 48 // The destructor closes the IO stream
2e9f335b 49 f.close();
50 //delete tree;
51 //delete fout;
52}
53//////////////////////////////////////////////////////////////////////////////////////////////////////////////
54AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source){
55 // Copy Constructor
a79660fb 56 this->fVerbose=source.fVerbose;
2e9f335b 57 return;
58}
59//////////////////////////////////////////////////////////////////////////////////////////////////////////////
60AliTPCBuffer& AliTPCBuffer::operator=(const AliTPCBuffer &source){
61 //Assigment operator
a79660fb 62 this->fVerbose=source.fVerbose;
2e9f335b 63 return *this;
64}
65//////////////////////////////////////////////////////////////////////////////////////////////////////////////
66/*
67void 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){
68 //flag=0 the whole row is written to the root file
69 //flag=1 only value in the range [minPad,MaxPasd] are written to the root file
70 //flag=2 complementary case of 1
71 Int_t Pad;
72 Int_t Dig;
73 Int_t Time;
74 tree->Branch("sec",&sec,"sec/I");
75 tree->Branch("SubSec",&SubSec,"SubSec/I");
76 tree->Branch("row",&row,"row/I");
77 tree->Branch("Pad",&Pad,"Pad/I");
78 tree->Branch("Dig",&Dig,"Dig/I");
79 tree->Branch("Time",&Time,"Time/I");
80 digrow->First();
81 do{
82 Dig=digrow->CurrentDigit(); //adc
83 Time=digrow->CurrentRow(); //time
84 Pad =digrow->CurrentColumn(); // pad
85 // cout<<"Sec "<<sec<<" row "<<row<<" Pad "<<Pad<<" Dig "<<Dig<<" Time "<<Time<<endl;
86 if(Dig>eth){
87 switch (flag){
88 case 0:{
89 tree->Fill();
a763ec6d 90 fNumberOfDigits++;
2e9f335b 91 break;
92 }//end case 0
93 case 1:{
94 if((Pad>=minPad)&&(Pad<=maxPad)){
95 tree->Fill();
a763ec6d 96 fNumberOfDigits++;
2e9f335b 97 }
98 break;
99 }//end case 1
100 case 2:{
101 if((Pad<minPad)||(Pad>maxPad)){
102 tree->Fill();
a763ec6d 103 fNumberOfDigits++;
2e9f335b 104 }
105 break;
106 }//end case 2
107 };//end switch
108 }//end if
109 }while (digrow->Next());
110 tree->Write();
111 return;
112}
113*/
114//////////////////////////////////////////////////////////////////////////////////////////////////////////////
115void 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 116 //It writes TPC digits as par the flag specifications. Being called by AliTPCDDL.C
117 //flag=0 the whole row is written into the file
2e9f335b 118 //flag=1 only value in the range [minPad,MaxPasd] are written into the file
119 //flag=2 complementary case of 1
a79660fb 120
2e9f335b 121 struct DataPad{
122 Int_t Sec;
123 Int_t SubSec;
124 Int_t Row;
125 Int_t Pad;
126 Int_t Dig;
127 Int_t Time;
128 };
129 DataPad data;
130 data.Sec=sec;
131 data.SubSec=SubSec;
132 data.Row=row;
133 digrow->First();
134 do{
135 data.Dig=digrow->CurrentDigit(); //adc
136 data.Time=digrow->CurrentRow(); //time
137 data.Pad =digrow->CurrentColumn(); // pad
138 if(data.Dig>eth){
139 switch (flag){
140 case 0:{
a763ec6d 141 fNumberOfDigits++;
2e9f335b 142 f.write((char*)(&data),sizeof(data));
143 break;
144 }//end case 0
145 case 1:{
146 if((data.Pad>=minPad)&&(data.Pad<=maxPad)){
147 f.write((char*)(&data),sizeof(data));
a763ec6d 148 fNumberOfDigits++;
2e9f335b 149 }
150 break;
151 }//end case 1
152 case 2:{
153 if((data.Pad<minPad)||(data.Pad>maxPad)){
154 f.write((char*)(&data),sizeof(data));
a763ec6d 155 fNumberOfDigits++;
2e9f335b 156 }
157 break;
158 }//end case 2
159 };//end switch
160 }//end if
161 }while (digrow->Next());
162 return;
163}
164//////////////////////////////////////////////////////////////////////////////////////////////////////////////