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