Add static functions to read magnetic field value from a file.
[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 **************************************************************************/
15
16#include "Riostream.h"
17#include "TObjArray.h"
18#include "AliTPCBuffer.h"
19#include "AliSimDigits.h"
20
21//#include "TFile.h"
22//#include "TTree.h"
23
24ClassImp(AliTPCBuffer)
25//////////////////////////////////////////////////////////////////////////////////////////////////////////////
26AliTPCBuffer::AliTPCBuffer(const char* fileName){
27 f.open("AliTPCDDL.dat",ios::binary|ios::out);
28 // fout=new TFile(fileName,"recreate");
29 // tree=new TTree("tree","Values");
30 NumberOfDigits=0;
31 fVerbose=0;
32}
33
34//////////////////////////////////////////////////////////////////////////////////////////////////////////////
35AliTPCBuffer::~AliTPCBuffer(){
36 f.close();
37 //delete tree;
38 //delete fout;
39}
40//////////////////////////////////////////////////////////////////////////////////////////////////////////////
41AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source){
42 // Copy Constructor
43 return;
44}
45//////////////////////////////////////////////////////////////////////////////////////////////////////////////
46AliTPCBuffer& AliTPCBuffer::operator=(const AliTPCBuffer &source){
47 //Assigment operator
48 return *this;
49}
50//////////////////////////////////////////////////////////////////////////////////////////////////////////////
51/*
52void 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){
53 //flag=0 the whole row is written to the root file
54 //flag=1 only value in the range [minPad,MaxPasd] are written to the root file
55 //flag=2 complementary case of 1
56 Int_t Pad;
57 Int_t Dig;
58 Int_t Time;
59 tree->Branch("sec",&sec,"sec/I");
60 tree->Branch("SubSec",&SubSec,"SubSec/I");
61 tree->Branch("row",&row,"row/I");
62 tree->Branch("Pad",&Pad,"Pad/I");
63 tree->Branch("Dig",&Dig,"Dig/I");
64 tree->Branch("Time",&Time,"Time/I");
65 digrow->First();
66 do{
67 Dig=digrow->CurrentDigit(); //adc
68 Time=digrow->CurrentRow(); //time
69 Pad =digrow->CurrentColumn(); // pad
70 // cout<<"Sec "<<sec<<" row "<<row<<" Pad "<<Pad<<" Dig "<<Dig<<" Time "<<Time<<endl;
71 if(Dig>eth){
72 switch (flag){
73 case 0:{
74 tree->Fill();
75 NumberOfDigits++;
76 break;
77 }//end case 0
78 case 1:{
79 if((Pad>=minPad)&&(Pad<=maxPad)){
80 tree->Fill();
81 NumberOfDigits++;
82 }
83 break;
84 }//end case 1
85 case 2:{
86 if((Pad<minPad)||(Pad>maxPad)){
87 tree->Fill();
88 NumberOfDigits++;
89 }
90 break;
91 }//end case 2
92 };//end switch
93 }//end if
94 }while (digrow->Next());
95 tree->Write();
96 return;
97}
98*/
99//////////////////////////////////////////////////////////////////////////////////////////////////////////////
100void 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){
101 //flag=0 the whole row is written intto the file
102 //flag=1 only value in the range [minPad,MaxPasd] are written into the file
103 //flag=2 complementary case of 1
104 struct DataPad{
105 Int_t Sec;
106 Int_t SubSec;
107 Int_t Row;
108 Int_t Pad;
109 Int_t Dig;
110 Int_t Time;
111 };
112 DataPad data;
113 data.Sec=sec;
114 data.SubSec=SubSec;
115 data.Row=row;
116 digrow->First();
117 do{
118 data.Dig=digrow->CurrentDigit(); //adc
119 data.Time=digrow->CurrentRow(); //time
120 data.Pad =digrow->CurrentColumn(); // pad
121 if(data.Dig>eth){
122 switch (flag){
123 case 0:{
124 NumberOfDigits++;
125 f.write((char*)(&data),sizeof(data));
126 break;
127 }//end case 0
128 case 1:{
129 if((data.Pad>=minPad)&&(data.Pad<=maxPad)){
130 f.write((char*)(&data),sizeof(data));
131 NumberOfDigits++;
132 }
133 break;
134 }//end case 1
135 case 2:{
136 if((data.Pad<minPad)||(data.Pad>maxPad)){
137 f.write((char*)(&data),sizeof(data));
138 NumberOfDigits++;
139 }
140 break;
141 }//end case 2
142 };//end switch
143 }//end if
144 }while (digrow->Next());
145 return;
146}
147//////////////////////////////////////////////////////////////////////////////////////////////////////////////