warning fix
[u/mrichter/AliRoot.git] / TOF / CreatePulserRunHisto.C
CommitLineData
df1f2cc4 1void CreatePulserRunHisto(Int_t iLDC=0){
2
3 // macro to create histogram as if from pulser data
4
5 AliTOFGeometry * geom = new AliTOFGeometry();
6 AliTOFDecoder * decoder = new AliTOFDecoder();
7 Int_t array0[2160];
8 Int_t array1[2208];
9 Int_t array2[2160];
10 Int_t array3[2208];
11 Int_t array4[2160];
12 Int_t array5[2208];
13 // simulating data from LDC reading DDL # iLDC*6+{0,1,2,3,4,5}
14 Int_t iDDL[6];
15 for (Int_t j=0;j<6;j++){
16 iDDL[j]=j+iLDC*6;
17 }
18 decoder->GetArrayDDL(array0,iDDL[0]);
19 cout << " DDL " << iDDL[0] << " done " << endl;
20 decoder->GetArrayDDL(array1,iDDL[1]);
21 cout << " DDL " << iDDL[1] << " done " << endl;
22 decoder->GetArrayDDL(array2,iDDL[2]);
23 cout << " DDL " << iDDL[2] << " done " << endl;
24 decoder->GetArrayDDL(array3,iDDL[3]);
25 cout << " DDL " << iDDL[3] << " done " << endl;
26 decoder->GetArrayDDL(array4,iDDL[4]);
27 cout << " DDL " << iDDL[4] << " done " << endl;
28 decoder->GetArrayDDL(array5,iDDL[5]);
29 cout << " DDL " << iDDL[5] << " done " << endl;
30
31 // debugging printings
32 for (Int_t i=0;i<2160;i++){
33 cout << " array0[" << i << "] = " << array0[i] << endl;
34 cout << " array2[" << i << "] = " << array2[i] << endl;
35 cout << " array4[" << i << "] = " << array4[i] << endl;
36 }
37 for (Int_t i=0;i<2208;i++){
38 cout << " array1[" << i << "] = " << array1[i] << endl;
39 cout << " array3[" << i << "] = " << array3[i] << endl;
40 cout << " array5[" << i << "] = " << array5[i] << endl;
41 }
42
43 static const Int_t size = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
44 cout << " size = " << size << endl;
45 TH1F::AddDirectory(0);
46 TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", size,-0.5,size-0.5);
47 for (Int_t ibin=1;ibin<=size;ibin++){
48 htofPulser->SetBinContent(ibin,-1);
49 }
50
51 for (Int_t i=0;i<2160;i++){
52 if (htofPulser->GetBinContent(array0[i]+1)<0) htofPulser->SetBinContent(array0[i]+1,10000);
53 if (htofPulser->GetBinContent(array2[i]+1)<0) htofPulser->SetBinContent(array2[i]+1,10000);
54 if (htofPulser->GetBinContent(array4[i]+1)<0) htofPulser->SetBinContent(array4[i]+1,10000);
55 }
56
57 for (Int_t i=0;i<2208;i++){
58 if (htofPulser->GetBinContent(array1[i]+1)<0) htofPulser->SetBinContent(array1[i]+1,10000);
59 if (htofPulser->GetBinContent(array3[i]+1)<0) htofPulser->SetBinContent(array3[i]+1,10000);
60 if (htofPulser->GetBinContent(array5[i]+1)<0) htofPulser->SetBinContent(array5[i]+1,10000);
61 }
62
63 const Int_t ndead =3;
64 Int_t idead[18]; // indexes of dead channels
65 Float_t ifloatdead[ndead]; // indexes of dead channels
66 TRandom *rnd = new TRandom(4357);
67 TDatime ciccio;
68 //cout << " time = " << ciccio.Get() << endl;
69 rnd->SetSeed(ciccio.Get());
70 rnd->RndmArray(ndead,ifloatdead);
71
72 for (Int_t i=0;i<ndead;i++){
73 Int_t index = Int_t(ifloatdead[i]*2160);
74 idead[i*3] = array0[index];
75 idead[i*3+1] = array2[index];
76 idead[i*3+2] = array4[index];
77 cout << " channels " << idead[i*3] << ", " << idead[i*3+1] << ", " << idead[i*3+2] << ", " << " will be skipped " << endl;
78 }
79
80 for (Int_t i=0;i<ndead;i++){
81 Int_t index = Int_t(ifloatdead[i]*2208);
82 idead[i*3+9] = array1[index];
83 idead[i*3+9+1] = array3[index];
84 idead[i*3+9+2] = array5[index];
85 cout << " channels " << idead[i*3+9] << ", " << idead[i*3+9+1] << ", " << idead[i*3+9+2] << ", " << " will be skipped " << endl;
86 }
87
88 for (Int_t i=0;i<ndead*6;i++){
89 cout << " idead[" << i << "] = " << idead[i] << endl;
90 }
91
92 Bool_t tobeskipped=kFALSE;
93 for (Int_t i=0;i<size;i++){
94 tobeskipped = kFALSE;
95 for (Int_t j=0;j<ndead*6;j++){
96 if (i==idead[j]) {
97 tobeskipped=kTRUE;
98 cout << " skipping channel " << i << " with idead = " << idead[j] << endl;
99 break;
100 }
101 }
102 if (tobeskipped && (htofPulser->GetBinContent(i+1)!=-1)) htofPulser->SetBinContent(i+1,0);
103 else {
104 // cout << " filling channel " << i << endl;
105 // htofPulser->Fill(i,10000);
106 }
107 }
108 TCanvas *c = new TCanvas("c","c",-2,30,500,500);
109 htofPulser->Draw();
110 char filename[100];
111 sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC);
112 TFile *fileout = new TFile(filename,"RECREATE");
113 htofPulser->Write("hTOFpulser");
114 fileout->Close();
115}