3 // Author: Constantin Loizides <loizides@ikf.uni-frankfurt.de>
4 //*-- Copyright © ALICE HLT Group
7 Program to convert big <-> little endian cosmics data of 02/2003.
10 #include "AliL3StandardIncludes.h"
11 #include "AliL3RootTypes.h"
20 //this flag is for the cosmics/pubsub test
25 struct stat stat_results;
28 Int_t Convert4(Int_t i)
29 { //BigEndian i0i1i2i3 -> LittleEndian i3i2i1i0
33 Char_t *p=(Char_t*)&i;
41 return (*(Int_t*)temp);
45 Short_t Convert2(Short_t s)
46 { //BigEndian i0i1 -> LittleEndian i1i0
50 Char_t *p=(Char_t*)&s;
56 return (*(Short_t*)temp);
60 int main(Int_t argc, Char_t **argv)
63 //p2 -> file is in little endian
66 if((sizeof(Int_t) != 4) || (sizeof(Short_t) != 2)) {
67 cerr << "Check architecture to run the conversion on! Int_t should be 32 and Short_t should be 16 bit." << endl;
73 sprintf(fname,"%s","/home/loizides/tmp/cosmics/run0013/evt0000");
75 strcpy(fname,argv[1]);
77 strcpy(fname,argv[1]);
81 ifstream *in = new ifstream();
82 in->open(fname,fstream::binary);
84 cerr << "Error opening input file " << fname << endl;
90 sprintf(sname,"%s.added",fname);
92 sprintf(sname,"%s.conv",fname);
94 ofstream *out = new ofstream();
95 out->open(sname,fstream::in | fstream::out | fstream::binary | fstream::trunc);
97 cerr << "Error opening output file " << sname << endl;
105 if (stat(fname, &stat_results) == 0){
106 dummy4=stat_results.st_size/4;
107 cout << "Add file size: " << dummy4 << endl;
109 cerr << "Error stating input file " << fname << endl;
112 out->write((Char_t*)&dummy4,sizeof(dummy4));
115 in->read((Char_t*)&dummy4,sizeof(dummy4));
116 const Int_t knumofChannels = Convert4(dummy4);
118 cout << knumofChannels << endl;
120 out->write((Char_t*)&knumofChannels,sizeof(knumofChannels));
122 Int_t channelloop=knumofChannels;
123 if(islittle) channelloop=dummy4;
124 for(Int_t i = 0 ; i < channelloop ; i++){
125 in->read((Char_t*)&dummy2,sizeof(dummy2));
126 Short_t channel = Convert2(dummy2);
127 out->write((Char_t*)&channel,sizeof(channel));
129 cout << channel << " ";
136 in->read((Char_t*)&dummy4,sizeof(dummy4));
137 const Int_t numofChannelsTest = Convert4(dummy4);
139 cout << numofChannelsTest << endl;
141 out->write((Char_t*)&numofChannelsTest,sizeof(numofChannelsTest));
143 if (knumofChannels != numofChannelsTest){
144 cerr << "Error in File format: \"channels " << knumofChannels << " must be channels-test " << numofChannelsTest << "\" "<< endl;
147 in->read((Char_t*)&dummy4,sizeof(dummy4));
148 const Int_t knumofTimebins = Convert4(dummy4);
150 cout << knumofTimebins << endl;
152 out->write((Char_t*)&knumofTimebins,sizeof(knumofTimebins));
154 Int_t timeloop=knumofTimebins;
155 if(islittle) timeloop=dummy4;
157 cout << "Input: " << fname << endl;
158 cout << "Output: " << sname << endl;
159 cout << "Channels: " << knumofChannels << endl;
160 cout << "Timebins: " << knumofTimebins << endl;
162 for(int channel = 0; channel < channelloop; channel++){
163 for(int timebin = 0 ; timebin < timeloop ; timebin++){
164 in->read((Char_t*)&dummy2,sizeof(dummy2));
165 Short_t charge = Convert2(dummy2);
167 cout << charge << " ";
169 out->write((Char_t*)&charge,sizeof(charge));
183 Data format as of 28/01/2003 R. Bramm explained,
184 sorry for the German text, too lazy to translate now
186 Die Files beinhalten 512 Kanaele (Altrokanäle also 32 Altros)
187 mit je 999 Timebins. -> depends on detailed setting of the test
190 Anzahl der Kaenaele als int32
191 Liste der Kanaele je int16
192 Anzahl der Kaenaele als int32
195 und dann vollkommenformatlos
196 Anzahl der Kaenaele * Anzahl der Timebins (512*1000 values)
198 Bezogen auf das Mapping:
199 ----------------------------
200 Die Kanalnummer, die die nehmen, ist Spalte 0 oder 9 also der
201 Altrochannel. Die GSI nimmt aber einfach die "FEC Channels"
202 was einfach die Anschlusse des Kabels durchgezaehlt sind ...
203 dummerweise ist FECChannel != Altrochannel
205 FEC ist Front End Card
206 FEC Channel ist die Kanalnummer ...
207 Altro channel ist durchnummeriert vom 0 bis 511 also fuer 32 Altros.
208 (insofern ist der Name falsch ... weils mehrere altros sind.)
211 8,9,10,11,12,13,14,15,7,6,5,4,3,2,1,0 (alles + 16)
212 weiter weil der Altro auf der Unterseite liegt
214 pad und row kann man umrechnen (steht nicht die formel im .doc ?) in x,y
215 timebin ist "komplizierter" denn da brauchtm an driftgeschw. + samplingfreq
216 ja, aber in meiner tabelle mit den Altrochannels steht alles mit drin.
219 http://137.138.45.89:8080/svn/repos/TPCMapping/trunk/MappingData/mappingRowPad.data
220 dadrin steht die anzahl der pads pro row, rownummer, liste der pads
221 die pads sind in "altrochannel" codiert ... war einfacher das so einzuwurschteln
222 ... brauche ich aber nur fuer die Row view und ich hatte keinen Bock, das
223 jedes mal aus dem Ulifile zu erzeugen ...
225 wenn du in http://mactpc01.cern.ch:8080
226 /svn/repos/TPCMapping/trunk/MappingData/mapping32313029.data
227 schaust, dann ist das erste die "altrochannelnummer" und in spalte 7
229 steht der FEC channel. in den Events steht also immer 999 mal n adc value
230 fuer jeden "altrochannel" in genau der reihenfolge wie in dem obigen file.
232 Im OM.C loope ich von
233 Zeile 124 bis 175 uebers file
234 interessant ist nur das einlesen
236 dann berechne ich die baseline
240 dann rudimentaeres Clusterfindeing abe das ist unwichtig
242 dann kommt das fuellen des TPC Topviews, wo auch das "mapping " drinsteckt
258 So zur frage wer ordert:
259 Luciano und ich haben gebraeinstormed und kamen zum ergebnis, dass es
260 auch kein Problem waere die RCU pad by pad auslesen zu lassen ...
261 also "komplett korrekt" gemapped.
262 man braucht nur nen lookuptable. Da ist keine Latenz, die es problematisch
264 fee 1 channel 1 = pad 1
265 fee 1 channel 2 = pad 2
266 fee 1 channel 4 = pad 3
267 fee 1 channel 3 = pad 4
268 fee 2 channel 1 = pad 5