]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/src/Clustering/RawDataReconstruction/rawddl5.C
This commit was generated by cvs2svn to compensate for changes in r11742,
[u/mrichter/AliRoot.git] / HLT / MUON / src / Clustering / RawDataReconstruction / rawddl5.C
1 // ROOT includes
2 // #include "TBranch.h"
3 #include "TClonesArray.h"
4 #include "TFile.h"
5 #include "TH1.h"
6 #include "TParticle.h"
7 #include "TTree.h"
8 // //
9 // // // STEER includes
10 #include "AliRun.h"
11 #include "AliRunLoader.h"
12 #include "AliHeader.h"
13 #include "AliLoader.h"
14 #include "AliStack.h"
15 // //
16 // // // MUON includes
17 #include "AliMUON.h"
18 #include "AliMUONData.h"
19 #include "AliMUONHit.h"
20 #include "AliMUONConstants.h"
21 #include "AliMUONDigit.h"
22 // // //
23 // //
24 // 
25 void rawddl5(Int_t evNumber1=0,Int_t evNumber2=0) 
26 {
27   long int mappheader2,mapp2[123456];
28   FILE *fb = fopen("lutraw51.dat","r");
29   for(Int_t n=0;n<59136;n++)
30     {
31      fscanf(fb,"%ld",&mappheader2);
32      fscanf(fb,"%ld",&mapp2[mappheader2]);
33     }
34   fclose(fb);
35   long int mappheader4,mapp4[123456];
36   FILE *fc = fopen("lutraw52.dat","r");
37   for(Int_t n=0;n<59136;n++)
38     {
39      fscanf(fc,"%ld",&mappheader4);
40      fscanf(fc,"%ld",&mapp4[mappheader4]);
41     }
42   fclose(fc);
43         FILE *fp = fopen("ddl17.dat","w+");              
44         FILE *fq = fopen("ddl18.dat","w+");              
45         FILE *fr = fopen("ddl19.dat","w+");              
46         FILE *fs = fopen("ddl20.dat","w+");
47    AliRunLoader * RunLoader = AliRunLoader::Open("galice.root","MUONFolder","REA
48            D");
49   if (RunLoader ==0x0) {
50                 printf(">>> Error : Error Opening %s file \n","galice.root");
51         return;
52                       }
53   // Loading MUON subsystem
54      AliLoader * MUONLoader = RunLoader->GetLoader("MUONLoader");
55         MUONLoader->LoadDigits("READ");
56
57   // Creating MUON data container
58      AliMUONData muondata(MUONLoader,"MUON","MUON");
59
60      Int_t ievent, nevents;
61      nevents = RunLoader->GetNumberOfEvents();
62        printf(">>> No. of Event %d \n",nevents);
63        AliMUONDigit * mDigit;
64        
65         Int_t dspheader[1000][4];
66         Int_t dsphead[1000][100];
67 //   Start loop over events
68   for (int ievent=evNumber1; ievent<= evNumber2; ievent++) // event start 
69       {
70               printf("Event:%d\n",ievent+1);
71           for(Int_t ii=0;ii<1000;ii++)
72             {
73           for(Int_t ij=0;ij<100;ij++)
74              {
75               dsphead[ii][ij]=0;
76              }
77             }
78         for(Int_t ik=0;ik<1000;ik++)
79             {
80           for(Int_t il=0;il<4;il++)
81              {
82               dspheader[ik][il]=0;
83              }
84             }
85        RunLoader->GetEvent(ievent);
86
87        muondata.SetTreeAddress("D");
88
89        Int_t ncathodes=2;
90        for(Int_t icathode=0; icathode<ncathodes; icathode++) {
91        muondata.GetCathode(icathode);
92
93        Int_t ichamber;
94        for( ichamber=8; ichamber<10; ichamber++) {
95        Int_t idigit, ndigits;
96        ndigits = (Int_t) muondata.Digits(ichamber)->GetEntriesFast(); //9 or 10
97        for(idigit=0; idigit<ndigits; idigit++) {
98        mDigit = static_cast<AliMUONDigit*>(muondata.Digits(ichamber)->At(idigit)
99 );
100                    {                                              // pads start
101                Int_t dsp = 0, xydata=0, manu=0, adc=0;
102                Int_t index=0, counter=0;
103                     Int_t iqpad = mDigit->Signal();              // charge per pad
104                          if(iqpad>=4096)
105                                    iqpad = 4095;
106                     Int_t iPx = mDigit->PadX();               // pad number on X
107                     Int_t iPy = mDigit->PadY();               // pad number on Y
108                                                                               
109         Int_t modx = abs(iPx);
110         if(icathode==0)
111          {
112  xydata = 2048*modx+iPy;
113  manu=((mapp2[xydata]>>6)&1023);
114  adc=(((mapp2[xydata]<<11)>>11)&63);
115         dsp=iPy/80;
116          }
117               if(icathode == 1)
118                 {
119  xydata = 256*modx+iPy;
120  manu=((mapp4[xydata]>>6)&1023);
121 if(manu>0){
122  adc=(((mapp4[xydata]<<11)>>11)&63);
123 if(manu<=625)
124   dsp=0;
125 if(manu>625&&manu<=637)
126   dsp=1;
127 if(manu>637&&manu<=656)
128   dsp=2;
129 if(manu>656&&manu<=680)
130   dsp=3;
131 if(manu>680&&manu<=716)
132   dsp=4;
133 if(manu>716&&manu<=752)
134   dsp=5;
135 if(manu>752&&manu<=788)
136   dsp=6;
137 if(manu>788&&manu<=824)
138   dsp=7;
139 if(manu>824&&manu<=860)
140   dsp=8;
141 if(manu>860&&manu<=884)
142   dsp=9;
143 if(manu>884&&manu<=903)
144   dsp=10;
145 if(manu>903&&manu<=915)
146   dsp=11;
147 if(manu>915&&manu<=924)
148   dsp=12;
149           }
150                 }
151 if(iPx<0)
152   {
153    if(ichamber==8)
154      {
155        dsp+=601;
156        index=0;
157      }
158    if(ichamber==9)
159      {
160        dsp+=641;
161        index=2;
162      }
163    dspheader[dsp][index]+=1;
164    counter = dspheader[dsp][index];
165    dsphead[dsp][counter]=4096*(64*(manu)+adc)+iqpad; 
166   }
167 else
168   {
169    if(ichamber==8)
170      {
171        dsp+=621;
172        index=1;
173      }
174    if(ichamber==9)
175      {
176        dsp+=661;
177        index=3;
178      }
179     dspheader[dsp][index]+=1;
180     counter = dspheader[dsp][index];
181     dsphead[dsp][counter]=4096*(64*(manu)+adc)+iqpad; 
182   }
183                } //pad
184               }   //digit
185              }  // chamber
186             } //cathode
187  for(Int_t dsp=601;dsp<680;dsp++)
188     {
189    for(Int_t aa=0;aa<4;aa++)
190      {
191      Int_t dspcount=dspheader[dsp][aa];
192 if(aa==0)
193   {
194      fwrite(&dsp,2,1,fp);
195      fwrite(&dspcount,2,1,fp);
196      for(Int_t ax=1;ax<=dspcount;ax++)
197        fwrite(&dsphead[dsp][ax],4,1,fp);
198   }
199 if(aa==1)
200   {
201      fwrite(&dsp,2,1,fq);
202      fwrite(&dspcount,2,1,fq);
203      for(Int_t ax=1;ax<=dspcount;ax++)
204        fwrite(&dsphead[dsp][ax],4,1,fq);
205   }
206 if(aa==2)
207   {
208      fwrite(&dsp,2,1,fr);
209      fwrite(&dspcount,2,1,fr);
210      for(Int_t ax=1;ax<=dspcount;ax++)
211        fwrite(&dsphead[dsp][ax],4,1,fr);
212   }
213 if(aa==3)
214   {
215      fwrite(&dsp,2,1,fs);
216      fwrite(&dspcount,2,1,fs);
217      for(Int_t ax=1;ax<=dspcount;ax++)
218        fwrite(&dsphead[dsp][ax],4,1,fs);
219   }
220       }
221      }
222      } //event
223 fclose(fp);
224 fclose(fq);
225 fclose(fr);
226 fclose(fs);
227 }  // end of funtion