]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCAltro.C
Solving problems on Sun (D.Favretto)
[u/mrichter/AliRoot.git] / TPC / AliTPCAltro.C
CommitLineData
b62e2a95 1#if !defined(__CINT__)
2#include <Riostream.h>
3#include <TFile.h>
4#include <TTree.h>
5#include "AliTPCParamSR.h"
6#include "AliTPCDigitsArray.h"
7#include "AliSimDigits.h"
2e9f335b 8#include "AliTPCBuffer160.h"
2e9f335b 9#endif
10
11int AliTPCAltro(char* FileName,Int_t eth=0){
12 //eth is a threshold.
a79660fb 13 //Digits stored into a file have an amplitude value greater than "eth"
2e9f335b 14 Int_t offset=1; //this should be equal to the threshold
15 /*
a79660fb 16 NB the amplitude values stored in the ALTRO file are shifted by offset
2e9f335b 17 because the range for each word goes from 0 to 1023, now due to zero suppression
18 values lower that the threshold never appear.
19 */
20 TFile *cf=TFile::Open(FileName);
21 // old geometry (3.07)
22 //AliTPCParamSR *param =(AliTPCParamSR *)cf->Get("75x40_100x60");
23 // if new geometry comment out the line above and uncomment the one below
24 AliTPCParamSR *param =(AliTPCParamSR *)cf->Get("75x40_100x60_150x60");
25 AliTPCDigitsArray *digarr=new AliTPCDigitsArray;
26 digarr->Setup(param);
27
28 char cname[100];
29 //old geometry
30 //sprintf(cname,"TreeD_75x40_100x60_%d",eventn);
31 // if new geometry comment out the line above and uncomment the one below
32 Int_t eventn=0;
33 sprintf(cname,"TreeD_75x40_100x60_150x60_%d",eventn);
34 digarr->ConnectTree(cname);
35
36 Int_t PSecNumber=-1; //Previous Sector number
37 Int_t PRowNumber=-1; //Previous Row number
38 Int_t PPadNumber=-1; //Previous Pad number
39 Int_t PTimeBin=-1; //Previous Time-Bin
40 Int_t BunchLength=0;
41
42 //AliTPCBuffer160 is used in write mode to generate AltroFormat.dat file
43 AliTPCBuffer160 Buffer("AltroFormat.dat",1);
44 //number of entries in the tree
45 Int_t nrows=Int_t(digarr->GetTree()->GetEntries());
46 cout<<"Number of entries "<<nrows<<endl;
47 ULong_t Count=0;
48 Int_t nwords=0;
49 Int_t numPackets=0;
50 //ofstream ftxt("Data.txt");
51 for (Int_t n=0; n<nrows; n++) {
52 AliSimDigits *digrow=(AliSimDigits*)digarr->LoadEntry(n);
53 Int_t sec,row; // sector and row number (in the TPC)
54 param->AdjustSectorRow(digrow->GetID(),sec,row);
55 //cout<<"Sector:"<<sec<<" Row:"<<row<<endl;
56 digrow->First();
57 do{
58 Short_t dig=digrow->CurrentDigit(); //adc
59 Int_t time=digrow->CurrentRow(); //time
60 Int_t pad =digrow->CurrentColumn(); // pad
61 if(dig>eth){
62 Count++;
63 //ftxt<<"Sec: "<<sec<<" Row: "<<row<<" Pad:"<<pad<<" Time: "<<time<<" ADC:"<<dig<<endl;
64 //cout<<"Sec: "<<sec<<" Row: "<<row<<" Pad:"<<pad<<" Time: "<<time<<" ADC:"<<dig<<endl;
65 if (PPadNumber==-1){
66 PSecNumber=sec;
67 PRowNumber=row;
68 PPadNumber=pad;
69 // PAmplitude=dig;
70 PTimeBin=time;
71 BunchLength=1;
72 Buffer.FillBuffer(dig-offset);
73 nwords++;
74 }//end if
75 else{
76 if ( (time==(PTimeBin+1)) &&
77 (PPadNumber==pad) &&
78 (PRowNumber==row) &&
79 (PSecNumber==sec)){
80 BunchLength++;
81 }//end if
82 else{
83 Buffer.FillBuffer(PTimeBin);
84 Buffer.FillBuffer(BunchLength+2);
85 nwords+=2;
86 if ((PPadNumber!=pad)||(PRowNumber!=row)||(PSecNumber!=sec)){
87 //Trailer is formatted and inserted!!
88 Buffer.WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
89 numPackets++;
90 nwords=0;
91 }//end if
92
93 BunchLength=1;
94 PPadNumber=pad;
95 PRowNumber=row;
96 PSecNumber=sec;
97 }//end else
98 PTimeBin=time;
99 Buffer.FillBuffer(dig-offset);
100 nwords++;
101 }//end else
102 }//end if
103 } while (digrow->Next());
104 }//end for
105 Buffer.FillBuffer(PTimeBin);
106 Buffer.FillBuffer(BunchLength+2);
107 nwords+=2;
108 Buffer.WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
109 numPackets++;
110 cout<<"There are "<<Count<<" Digits\n";
111 cout<<"Packets "<<numPackets<<"\n";
112 //ftxt.close();
113 return 0;
114}//end macro