]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCBuffer.cxx
090ddbed36c5eb8dcab6e39bbc0bf1b186092bd4
[u/mrichter/AliRoot.git] / TPC / AliTPCBuffer.cxx
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 /* $Id$ */
16
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
21 // Author: D.Favretto
22
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
31 ClassImp(AliTPCBuffer)
32 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
33 AliTPCBuffer::AliTPCBuffer(const char* fileName){
34   //
35   // Constructor
36   //
37   f.open("AliTPCDDL.dat",ios::binary|ios::out);
38   // fout=new TFile(fileName,"recreate");
39   // tree=new TTree("tree","Values");
40   fNumberOfDigits=0;
41   fVerbose=0;
42 }
43
44 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
45 AliTPCBuffer::~AliTPCBuffer(){
46   // The destructor closes the IO stream
47   f.close();
48   //delete tree;
49   //delete fout;
50 }
51 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
52 AliTPCBuffer::AliTPCBuffer(const AliTPCBuffer &source){
53   // Copy Constructor
54   return;
55 }
56 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
57 AliTPCBuffer& AliTPCBuffer::operator=(const AliTPCBuffer &source){
58   //Assigment operator
59   return *this;
60 }
61 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
62 /*
63 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){
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();
86         fNumberOfDigits++;
87         break;
88       }//end case 0
89       case 1:{
90           if((Pad>=minPad)&&(Pad<=maxPad)){
91             tree->Fill();
92             fNumberOfDigits++;
93           }
94         break;
95       }//end case 1
96       case 2:{
97         if((Pad<minPad)||(Pad>maxPad)){
98           tree->Fill();
99           fNumberOfDigits++;
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 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
111 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){
112   //flag=0 the whole row is written intto the file
113   //flag=1 only value in the range [minPad,MaxPasd] are written into the file
114   //flag=2 complementary case of 1
115   struct DataPad{
116     Int_t Sec;
117     Int_t SubSec;
118     Int_t Row;
119     Int_t Pad;
120     Int_t Dig;
121     Int_t Time;
122   };
123   DataPad data;
124   data.Sec=sec;
125   data.SubSec=SubSec;
126   data.Row=row;
127   digrow->First();
128   do{
129     data.Dig=digrow->CurrentDigit(); //adc
130     data.Time=digrow->CurrentRow(); //time
131     data.Pad =digrow->CurrentColumn(); // pad 
132     if(data.Dig>eth){
133       switch (flag){
134       case 0:{
135         fNumberOfDigits++;
136         f.write((char*)(&data),sizeof(data));
137         break;
138       }//end case 0
139       case 1:{
140         if((data.Pad>=minPad)&&(data.Pad<=maxPad)){
141           f.write((char*)(&data),sizeof(data));
142           fNumberOfDigits++;
143         }
144         break;
145       }//end case 1
146       case 2:{
147         if((data.Pad<minPad)||(data.Pad>maxPad)){
148           f.write((char*)(&data),sizeof(data));
149           fNumberOfDigits++;
150         }
151         break;
152       }//end case 2
153       };//end switch
154     }//end if
155   }while (digrow->Next());
156   return;
157 }
158 //////////////////////////////////////////////////////////////////////////////////////////////////////////////