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 Int_t Convert4(Int_t i)
21 { //BigEndian i0i1i2i3 -> LittleEndian i3i2i1i0
25 Char_t *p=(Char_t*)&i;
33 return (*(Int_t*)temp);
37 Short_t Convert2(Short_t s)
38 { //BigEndian i0i1 -> LittleEndian i1i0
42 Char_t *p=(Char_t*)&s;
48 return (*(Short_t*)temp);
54 int main(Int_t argc, Char_t **argv)
57 //p2 -> file is in little endian
60 if((sizeof(Int_t) != 4) || (sizeof(Short_t) != 2)) {
61 cerr << "Check architecture to run the conversion on! Int_t should be 32 and Short_t should be 16 bit." << endl;
67 sprintf(fname,"%s","/home/loizides/tmp/cosmics/run0013/evt0000");
69 strcpy(fname,argv[1]);
71 strcpy(fname,argv[1]);
76 sprintf(sname,"%s.conv",fname);
78 ifstream *in = new ifstream();
79 in->open(fname,fstream::binary);
81 cerr << "Error opening input file " << fname << endl;
85 ofstream *out = new ofstream();
86 out->open(sname,fstream::in | fstream::out | fstream::binary | fstream::trunc);
88 cerr << "Error opening output file " << sname << endl;
95 in->read((Char_t*)&dummy4,sizeof(dummy4));
96 const Int_t knumofChannels = Convert4(dummy4);
98 cout << knumofChannels << endl;
100 out->write((Char_t*)&knumofChannels,sizeof(knumofChannels));
102 Int_t channelloop=knumofChannels;
103 if(islittle) channelloop=dummy4;
104 for(Int_t i = 0 ; i < channelloop ; i++){
105 in->read((Char_t*)&dummy2,sizeof(dummy2));
106 Short_t channel = Convert2(dummy2);
107 out->write((Char_t*)&channel,sizeof(channel));
109 cout << channel << " ";
116 in->read((Char_t*)&dummy4,sizeof(dummy4));
117 const Int_t numofChannelsTest = Convert4(dummy4);
119 cout << numofChannelsTest << endl;
121 out->write((Char_t*)&numofChannelsTest,sizeof(numofChannelsTest));
123 if (knumofChannels != numofChannelsTest){
124 cerr << "Error in File format: \"channels " << knumofChannels << " must be channels-test " << numofChannelsTest << "\" "<< endl;
127 in->read((Char_t*)&dummy4,sizeof(dummy4));
128 const Int_t knumofTimebins = Convert4(dummy4);
130 cout << knumofTimebins << endl;
132 out->write((Char_t*)&knumofTimebins,sizeof(knumofTimebins));
134 Int_t timeloop=knumofTimebins;
135 if(islittle) timeloop=dummy4;
137 cout << "Input: " << fname << endl;
138 cout << "Output: " << sname << endl;
139 cout << "Channels: " << knumofChannels << endl;
140 cout << "Timebins: " << knumofTimebins << endl;
142 for(int channel = 0; channel < channelloop; channel++){
143 for(int timebin = 0 ; timebin < timeloop ; timebin++){
144 in->read((Char_t*)&dummy2,sizeof(dummy2));
145 Short_t charge = Convert2(dummy2);
147 cout << charge << " ";
149 out->write((Char_t*)&charge,sizeof(charge));
163 Data format as of 28/01/2003 R. Bramm explained,
164 sorry for the German text, too lazy to translate now
166 Die Files beinhalten 512 Kanaele (Altrokanäle also 32 Altros)
167 mit je 999 Timebins. -> depends on detailed setting of the test
170 Anzahl der Kaenaele als int32
171 Liste der Kanaele je int16
172 Anzahl der Kaenaele als int32
175 und dann vollkommenformatlos
176 Anzahl der Kaenaele * Anzahl der Timebins (512*1000 values)
178 Bezogen auf das Mapping:
179 ----------------------------
180 Die Kanalnummer, die die nehmen, ist Spalte 0 oder 9 also der
181 Altrochannel. Die GSI nimmt aber einfach die "FEC Channels"
182 was einfach die Anschlusse des Kabels durchgezaehlt sind ...
183 dummerweise ist FECChannel != Altrochannel
185 FEC ist Front End Card
186 FEC Channel ist die Kanalnummer ...
187 Altro channel ist durchnummeriert vom 0 bis 511 also fuer 32 Altros.
188 (insofern ist der Name falsch ... weils mehrere altros sind.)
191 8,9,10,11,12,13,14,15,7,6,5,4,3,2,1,0 (alles + 16)
192 weiter weil der Altro auf der Unterseite liegt
194 pad und row kann man umrechnen (steht nicht die formel im .doc ?) in x,y
195 timebin ist "komplizierter" denn da brauchtm an driftgeschw. + samplingfreq
196 ja, aber in meiner tabelle mit den Altrochannels steht alles mit drin.
199 http://137.138.45.89:8080/svn/repos/TPCMapping/trunk/MappingData/mappingRowPad.data
200 dadrin steht die anzahl der pads pro row, rownummer, liste der pads
201 die pads sind in "altrochannel" codiert ... war einfacher das so einzuwurschteln
202 ... brauche ich aber nur fuer die Row view und ich hatte keinen Bock, das
203 jedes mal aus dem Ulifile zu erzeugen ...
205 wenn du in http://mactpc01.cern.ch:8080
206 /svn/repos/TPCMapping/trunk/MappingData/mapping32313029.data
207 schaust, dann ist das erste die "altrochannelnummer" und in spalte 7
209 steht der FEC channel. in den Events steht also immer 999 mal n adc value
210 fuer jeden "altrochannel" in genau der reihenfolge wie in dem obigen file.
212 Im OM.C loope ich von
213 Zeile 124 bis 175 uebers file
214 interessant ist nur das einlesen
216 dann berechne ich die baseline
220 dann rudimentaeres Clusterfindeing abe das ist unwichtig
222 dann kommt das fuellen des TPC Topviews, wo auch das "mapping " drinsteckt
238 So zur frage wer ordert:
239 Luciano und ich haben gebraeinstormed und kamen zum ergebnis, dass es
240 auch kein Problem waere die RCU pad by pad auslesen zu lassen ...
241 also "komplett korrekt" gemapped.
242 man braucht nur nen lookuptable. Da ist keine Latenz, die es problematisch
244 fee 1 channel 1 = pad 1
245 fee 1 channel 2 = pad 2
246 fee 1 channel 4 = pad 3
247 fee 1 channel 3 = pad 4
248 fee 2 channel 1 = pad 5