3 #include "AliRunDigitizer.h"
4 #include "AliTPCDigitizer.h"
12 // test of the tpc merging using AliRunDigitizer and
13 // TPC Hits2Digits, Hits2SDigits and SDigits2Digits macros
16 // 0. make 2 directorys - ev1 and ev2
18 // 1.make hits, digits,sdigits and sdigits-digits in both directories
19 // 1.a galice -b -q grun.C and produce hits
20 // 1.b. cp galice.root galice.root.hits
21 // 1.c run AliTPCHits2Digits.C
22 // 1.d cp galice.root galice.root.digits
23 // 1.e copy back cp galice.root.hits galice.root
24 // 1.f run AliTPCSDigits2Digits.C
25 // 1.g cp galice.root galice.root.sdigits
26 // 1.h run AliTPCSDigits2Digit.C
27 // 1.i cp galice.root galice.root.dig2
29 // 2. cp ev1/galice.root/galice.root.sdigit galice.root
30 // 3. load this macro and run testmerge()
32 // 4. run test function bellow to compare merged digits with original one
33 // 5. to be noticed output ftom testx() function - should be bigger than
34 // noise because in proces of digitisation we use different seed
35 // of random numbers for diffusion and gas gain
36 // -anyway in place where we have the signal should occur the signal in both casses
37 // - only the amplitude should be different - by factor of sqrt
42 // merge two example events
44 //it merge two events -one from current directory -second from directory ev2
46 AliRunDigitizer * manager = new AliRunDigitizer(2,1);
47 manager->SetInputStream(0,"galice.root");
48 manager->SetInputStream(1,"ev2/galice.root.sdigits");
49 AliTPCDigitizer dTPC(manager);
50 manager->SetNrOfEventsToWrite(1);
60 void drawmerged(Int_t sec, Int_t row, Int_t x1=-1, Int_t x2=-1, Int_t y1=-1, Int_t y2=-1)
62 //if you think that there is memory leak -
63 //you are tru but othervise graphic doesn't work
65 TFile * f = new TFile("galice.root");
66 TFile * f1= new TFile("ev1/galice.root.digits");
67 TFile * f2= new TFile("ev2/galice.root.digits");
68 TTree * tree = (TTree*)f->Get("TreeD_75x40_100x60_0");
69 TTree * tree1 = (TTree*)f1->Get("TreeD_75x40_100x60_0");
70 TTree * tree2 = (TTree*)f2->Get("TreeD_75x40_100x60_0");
76 tree->GetBranch("Segment")->SetAddress(&dig);
77 tree1->GetBranch("Segment")->SetAddress(&dig1);
78 tree2->GetBranch("Segment")->SetAddress(&dig2);
79 AliTPCParam * param =(AliTPCParam*) f->Get("75x40_100x60");
80 Int_t index = param->GetIndex(sec,row);
81 tree->GetEvent(index);
82 tree1->GetEvent(index);
83 tree2->GetEvent(index);
85 TCanvas * c = new TCanvas(" Test merged digits", "test",600,900);
89 AliH2F * his = dig->DrawDigits("cont1",x1,x2,y1,y2);
90 his->SetTitle("MergedDigits");
91 his->SetName("Merged Digits");
92 his->GetXaxis()->SetTitle("time");
93 his->GetYaxis()->SetTitle("pad");
94 his->DrawClone("cont1");
97 AliH2F * his1 =dig1->DrawDigits("cont1",x1,x2,y1,y2);
98 his1->SetTitle("background");
99 his1->SetName("background");
100 his1->GetXaxis()->SetTitle("time");
101 his1->GetYaxis()->SetTitle("pad");
102 his1->DrawClone("cont1");
105 AliH2F * his2 =dig2->DrawDigits("cont1",x1,x2,y1,y2);
106 his2->SetTitle("signal");
107 his2->SetName("signal");
108 his2->GetXaxis()->SetTitle("time");
109 his2->GetYaxis()->SetTitle("pad");
110 his2->DrawClone("cont1");
114 void drawd(TFile * f, Int_t amp1, Int_t amp2)
116 TTree * tree = (TTree*)f->Get("TreeD_75x40_100x60_0");
118 tree->GetBranch("Segment")->SetAddress(&dig);
119 TH1F * his = new TH1F("his","his",amp2-amp1,amp1,amp2);
120 for (Int_t i=0;i<60;i++){
123 Int_t nrows = dig->GetNRows();
124 Int_t ncols = dig->GetNCols();
125 for (Int_t rows=0;rows<nrows; rows++)
126 for (Int_t col=0;col<ncols; col++){
127 Int_t d = dig->GetDigitFast(rows,col);
135 //test of the merged digits
136 //compare merged digits with standard digits
137 TFile f("galice.root");
138 TFile f1("ev1/galice.root.digits");
139 TFile f2("ev2/galice.root.digits");
140 TTree * tree = (TTree*)f.Get("TreeD_75x40_100x60_0");
141 TTree * tree1 = (TTree*)f1.Get("TreeD_75x40_100x60_0");
142 TTree * tree2 = (TTree*)f2.Get("TreeD_75x40_100x60_0");
145 AliSimDigits *dig1=0;
146 AliSimDigits *dig2=0;
148 tree->GetBranch("Segment")->SetAddress(&dig);
149 tree1->GetBranch("Segment")->SetAddress(&dig1);
150 tree2->GetBranch("Segment")->SetAddress(&dig2);
152 for (Int_t i=0;i<6000;i++){
157 dig1->ExpandBuffer();
158 dig2->ExpandBuffer();
160 Int_t nrows = dig->GetNRows();
161 Int_t ncols = dig->GetNCols();
162 for (Int_t rows=0;rows<nrows; rows++)
163 for (Int_t col=0;col<ncols; col++){
164 Int_t d = dig->GetDigitFast(rows,col);
165 Int_t d1 = dig1->GetDigitFast(rows,col);
166 Int_t d2 = dig2->GetDigitFast(rows,col);
168 if (abs(d-(d1+d2))>4)
169 printf("%d\t%d\t%d\t%d\t%d\t%d\n",i,rows,col,d,d1,d2);
176 //compare merged digits with digits obtained hits2sdig->sdigtodig
177 TFile f("galice.root");
178 TFile f1("ev1/galice.root.dig2");
179 TFile f2("ev2/galice.root.dig2");
180 TTree * tree = (TTree*)f.Get("TreeD_75x40_100x60_0");
181 TTree * tree1 = (TTree*)f1.Get("TreeD_75x40_100x60_0");
182 TTree * tree2 = (TTree*)f2.Get("TreeD_75x40_100x60_0");
185 AliSimDigits *dig1=0;
186 AliSimDigits *dig2=0;
188 tree->GetBranch("Segment")->SetAddress(&dig);
189 tree1->GetBranch("Segment")->SetAddress(&dig1);
190 tree2->GetBranch("Segment")->SetAddress(&dig2);
195 for (Int_t i=0;i<6000;i++){
200 dig1->ExpandBuffer();
201 dig2->ExpandBuffer();
203 Int_t nrows = dig->GetNRows();
204 Int_t ncols = dig->GetNCols();
206 for (Int_t rows=0;rows<nrows; rows++)
207 for (Int_t col=0;col<ncols; col++){
208 Int_t d = dig->GetDigitFast(rows,col);
209 Int_t d1 = dig1->GetDigitFast(rows,col);
210 Int_t d2 = dig2->GetDigitFast(rows,col);
214 printf("%d\t%d\t%d\t%d\t%d\t%d\n",i,rows,col,d,d1,d2);
220 //test of the merged digits
221 TFile f("galice.root");
222 TFile f1("ev1/galice.root.sdigits");
223 TFile f2("ev2/galice.root.sdigits");
224 TTree * tree = (TTree*)f.Get("TreeD_75x40_100x60_0");
225 TTree * tree1 = (TTree*)f1.Get("TreeS_75x40_100x60_0");
226 TTree * tree2 = (TTree*)f2.Get("TreeS_75x40_100x60_0");
229 AliSimDigits *dig1=0;
230 AliSimDigits *dig2=0;
232 tree->GetBranch("Segment")->SetAddress(&dig);
233 tree1->GetBranch("Segment")->SetAddress(&dig1);
234 tree2->GetBranch("Segment")->SetAddress(&dig2);
236 for (Int_t i=0;i<6000;i++){
240 if ( (dig1->GetID()!=i) || (dig2->GetID()!=i) ) {
241 printf("missed segments\n");
245 dig1->ExpandBuffer();
246 dig2->ExpandBuffer();
248 Int_t nrows = dig->GetNRows();
249 Int_t ncols = dig->GetNCols();
251 for (Int_t rows=0;rows<nrows; rows++)
252 for (Int_t col=0;col<ncols; col++){
253 Int_t d = dig->GetDigitFast(rows,col);
254 Int_t d1 = dig1->GetDigitFast(rows,col)/16;
255 Int_t d2 = dig2->GetDigitFast(rows,col)/16;
258 printf("%d\t%d\t%d\t%d\t%d\t%d\n",i,rows,col,d,d1,d2);
264 void TestSDigitsDig2(){
265 //test of the digits produced by the Hits2Digits
266 //and Hits2SDigits - SDigits2Digits chain
267 TFile f1("galice.root.digits");
268 TFile f2("galice.root.dig2");
270 TTree * tree1 = (TTree*)f1.Get("TreeD_75x40_100x60_0");
271 TTree * tree2 = (TTree*)f2.Get("TreeD_75x40_100x60_0");
273 AliSimDigits *dig1=0;
274 AliSimDigits *dig2=0;
276 tree1->GetBranch("Segment")->SetAddress(&dig1);
277 tree2->GetBranch("Segment")->SetAddress(&dig2);
279 for (Int_t i=0;i<6000;i++){
283 //dig->ExpandBuffer();
284 if ( (dig1->GetID()!=i) || (dig2->GetID()!=i) ) {
285 printf("miised semgnets\n");
288 dig1->ExpandBuffer();
289 dig2->ExpandBuffer();
290 dig1->ExpandTrackBuffer();
291 dig2->ExpandTrackBuffer();
293 Int_t nrows = dig1->GetNRows();
294 Int_t ncols = dig1->GetNCols();
296 for (Int_t rows=0;rows<nrows; rows++)
297 for (Int_t col=0;col<ncols; col++){
298 Int_t d1 = dig1->GetDigitFast(rows,col);
299 Int_t d2 = dig2->GetDigitFast(rows,col);
300 Int_t t1_1 =dig1->GetTrackIDFast(rows,col,0);
301 Int_t t1_2 =dig1->GetTrackIDFast(rows,col,1);
302 Int_t t1_3 =dig1->GetTrackIDFast(rows,col,2);
304 Int_t t2_1 =dig2->GetTrackIDFast(rows,col,0);
305 Int_t t2_2 =dig2->GetTrackIDFast(rows,col,1);
306 Int_t t2_3 =dig2->GetTrackIDFast(rows,col,2);
308 if ( (d2>0) && (d1>0))
309 if ( ( ( d2>2) || (d1>2)) && (t2_1!=t1_1)) {
310 printf("%d\t%d\t%d\t\t%d\t%d\n",i,rows,col,t1_1,t2_1);
311 printf("\t\t\t\t%d\t%d\n",d1,d2);
317 void TestSDigitsDig1(){
318 //test of the digits produced by the Hits2Digits
319 //and Hits2SDigits - SDigits2Digits chain
320 TFile f1("galice.root.digits");
321 TFile f2("galice.root.dig2");
323 TTree * tree1 = (TTree*)f1.Get("TreeD_75x40_100x60_0");
324 TTree * tree2 = (TTree*)f2.Get("TreeD_75x40_100x60_0");
326 AliSimDigits *dig1=0;
327 AliSimDigits *dig2=0;
329 tree1->GetBranch("Segment")->SetAddress(&dig1);
330 tree2->GetBranch("Segment")->SetAddress(&dig2);
332 for (Int_t i=0;i<6000;i++){
336 //dig->ExpandBuffer();
337 if ( (dig1->GetID()!=i) || (dig2->GetID()!=i) ) {
338 printf("miised semgnets\n");
341 dig1->ExpandBuffer();
342 dig2->ExpandBuffer();
343 dig1->ExpandTrackBuffer();
344 dig2->ExpandTrackBuffer();
346 Int_t nrows = dig1->GetNRows();
347 Int_t ncols = dig1->GetNCols();
349 for (Int_t rows=0;rows<nrows; rows++)
350 for (Int_t col=0;col<ncols; col++){
351 // Int_t d = dig->GetDigitFast(rows,col);
352 Int_t d1 = dig1->GetDigitFast(rows,col);
353 Int_t d2 = dig2->GetDigitFast(rows,col);
356 if ( ((d2>4) || (d1>4)) && abs(d1-d2)>4)
357 printf("%d\t%d\t%d\t\t%d\t%d\n",i,rows,col,d1,d2);
366 TFile f1("galice.root.sdigits");
367 TFile f2("galice.root.digits");
368 TTree * tree1 = (TTree*)f1.Get("TreeS_75x40_100x60_0");
369 TTree * tree2 = (TTree*)f2.Get("TreeD_75x40_100x60_0");
371 AliSimDigits *dig1=0;
372 AliSimDigits *dig2=0;
374 tree1->GetBranch("Segment")->SetAddress(&dig1);
375 tree2->GetBranch("Segment")->SetAddress(&dig2);
377 for (Int_t i=0;i<6000;i++){
381 //dig->ExpandBuffer();
382 if ( (dig1->GetID()!=i) || (dig2->GetID()!=i) ) {
383 printf("miised semgnets\n");
386 dig1->ExpandBuffer();
387 dig2->ExpandBuffer();
389 Int_t nrows = dig1->GetNRows();
390 Int_t ncols = dig1->GetNCols();
392 for (Int_t rows=0;rows<nrows; rows++)
393 for (Int_t col=0;col<ncols; col++){
394 Int_t d1 = dig1->GetDigitFast(rows,col)/16.;
395 Int_t d2 = dig2->GetDigitFast(rows,col);
396 if ((d2>5) &&abs(d1-d2)>2) printf("%d\t%d\t%d\t\t%d\t%d\n",i,rows,col,d1,d2);