5 #include "AliTPCParamSR.h"
6 #include "AliTPCDigitsArray.h"
7 #include "AliSimDigits.h"
8 #include "AliTPCBuffer160.h"
11 int AliTPCAltro(Int_t eth=0){
13 //Digits stored into a file have an amplitude value greater than "eth"
14 Int_t offset=1; //this should be equal to the threshold
16 NB the amplitude values stored in the ALTRO file are shifted by offset
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.
21 Int_t PSecNumber=-1; //Previous Sector number
22 Int_t PRowNumber=-1; //Previous Row number
23 Int_t PPadNumber=-1; //Previous Pad number
24 Int_t PTimeBin=-1; //Previous Time-Bin
26 //AliTPCBuffer160 is used in write mode to generate AltroFormat.dat file
27 AliTPCBuffer160 Buffer("AltroFormat.dat",1);
32 const char * inFile_new = "galice.root";
33 AliRunLoader *rl = AliRunLoader::Open(inFile_new,"Event","read");
35 Int_t nevents=rl->GetNumberOfEvents();
36 cout<<"Number of Events:"<<nevents<<endl;
39 cout<<"Insert the event number: ";
41 }while (choice<=0 || choice>nevents);
42 rl->GetEvent(choice-1);
43 AliLoader *tpcloader=rl->GetLoader("TPCLoader");
44 tpcloader->LoadDigits();
45 TTree *digitsTree=tpcloader->TreeD();
47 AliSimDigits digrows, *dummy=&digrows;
48 digitsTree->GetBranch("Segment")->SetAddress(&dummy);
49 Stat_t nrows = digitsTree->GetEntries();
50 cout<<"Number of entries (rows):"<<nrows<<endl;
51 // get the TPC parameters
53 AliTPCParamSR* param = AliTPC::LoadTPCParam(gFile);
55 cout<<"No TPC parameter"<<endl;
56 AliTPCDigitsArray *digarr=new AliTPCDigitsArray;
58 digarr->ConnectTree(digitsTree);
59 //ofstream ftxt("Data.txt");
60 for (Int_t n=0; n<nrows; n++) {
61 Int_t sec,row; // sector and row number (in the TPC)
62 AliSimDigits *digrow=(AliSimDigits*)digarr->LoadEntry(n);
63 param->AdjustSectorRow(digrow->GetID(),sec,row);
65 //cout<<"Sector:"<<sec<<" Row:"<<row<<endl;
68 Short_t dig=digrow->CurrentDigit(); //adc
69 Int_t time=digrow->CurrentRow(); //time
70 Int_t pad =digrow->CurrentColumn(); // pad
71 //cout<<"dig:"<<dig<<" time:"<<time<<" pad:"<<pad<<endl;
74 //ftxt<<"Sec: "<<sec<<" Row: "<<row<<" Pad:"<<pad<<" Time: "<<time<<" ADC:"<<dig<<endl;
75 //cout<<"Sec: "<<sec<<" Row: "<<row<<" Pad:"<<pad<<" Time: "<<time<<" ADC:"<<dig<<endl;
83 Buffer.FillBuffer(dig-offset);
87 if ( (time==(PTimeBin+1)) &&
94 Buffer.FillBuffer(PTimeBin);
95 Buffer.FillBuffer(BunchLength+2);
97 if ((PPadNumber!=pad)||(PRowNumber!=row)||(PSecNumber!=sec)){
98 //Trailer is formatted and inserted!!
99 Buffer.WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
110 Buffer.FillBuffer(dig-offset);
114 } while (digrow->Next());
117 Buffer.FillBuffer(PTimeBin);
118 Buffer.FillBuffer(BunchLength+2);
120 Buffer.WriteTrailer(nwords,PPadNumber,PRowNumber,PSecNumber);
123 cout<<"There are "<<Count<<" Digits\n";
124 cout<<"Packets "<<numPackets<<"\n";