]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSBeamTestDigSDD.cxx
Fixed message format and debug level
[u/mrichter/AliRoot.git] / ITS / AliITSBeamTestDigSDD.cxx
1 ////////////////////////////////////////////////////
2 //  Class to define                               //
3 //  SDD beam test raw 2 dig conv.                 //
4 //  Origin: E. Crescio crescio@to.infn.it         //
5 //                                                // 
6 //                                                //
7 ////////////////////////////////////////////////////
8 #include "AliITS.h"
9 #include "AliITSdigitSDD.h"
10 #include "AliRawReader.h"
11 #include "AliVMERawStream.h"
12 #include "AliITSRawStreamSDDv2.h"
13 #include "AliITSRawStreamSDDv3.h"
14 #include "AliITSRawStreamSDD.h"
15 #include "AliITSBeamTestDigSDD.h"
16 #include "AliITSEventHeader.h"
17 #include "AliITSgeom.h"
18 #include <TBranch.h>
19 #include <TTree.h>
20
21 ClassImp(AliITSBeamTestDigSDD)
22
23 //_____________________________________________________________
24   AliITSBeamTestDigSDD::AliITSBeamTestDigSDD(): AliITSBeamTestDig()
25 {
26   //
27   // Constructor
28   //
29   SetBtPeriod();
30   fSubEventAttributes=0;
31   fThreshold=0;
32   fStreamer=0;
33 }
34
35 //_____________________________________________________________
36 AliITSBeamTestDigSDD::AliITSBeamTestDigSDD(const Text_t* name, const Text_t* title): AliITSBeamTestDig(name,title)
37 {
38   //
39   // Constructor
40   //
41   SetBtPeriod();
42   fSubEventAttributes=0;
43   fThreshold=0;
44   fStreamer=0;
45 }
46
47 //__________________________________________________________________
48 AliITSBeamTestDigSDD::~AliITSBeamTestDigSDD()
49 {
50   //
51   // Destructor
52   //
53   if(fSubEventAttributes) delete fSubEventAttributes;
54   if(fStreamer) delete fStreamer;
55  }
56
57
58 //_______________________________________________________________________
59 void AliITSBeamTestDigSDD::Exec(Option_t* /*opt*/)
60 {
61
62   // Reads raw data and fills the tree of digits
63
64   TBranch* branch = fTreeD->GetBranch("ITSDigitsSDD");
65   Int_t maxn=0;
66   AliITSgeom* geom = fBt->GetITSgeom();
67   Int_t nsdd=0;
68   Int_t nspd=0;
69   Int_t nssd=0;
70   for(Int_t nlay=1;nlay<=geom->GetNlayers();nlay++){
71     for(Int_t nlad=1;nlad<=geom->GetNladders(nlay);nlad++){
72       for(Int_t ndet=1;ndet<=geom->GetNdetectors(nlay);ndet++){
73         Int_t index=geom->GetModuleIndex(nlay,nlad,ndet);
74         if(geom->GetModuleTypeName(index)=="kSPD") nspd++;
75         if(geom->GetModuleTypeName(index)=="kSDD") nsdd++;
76         if(geom->GetModuleTypeName(index)=="kSSD") nssd++;
77       }
78     }
79   }
80   if(GetBtPeriod()==kAug04) maxn=nsdd;
81   if(GetBtPeriod()==kNov04) maxn=nspd+nsdd+nssd;
82   TClonesArray** digits = new TClonesArray*[maxn];
83   Int_t* idig = new Int_t[maxn];
84   for(Int_t idet=0;idet<maxn;idet++){
85     digits[idet]=new TClonesArray("AliITSdigitSDD");
86     idig[idet]=0;
87   }
88
89   switch(fBtPer){
90   case kNov04:
91     fStreamer = new AliITSRawStreamSDDv3(fReader);
92     break;
93   case kAug04:
94     AliVMERawStream vmeStreamer(fReader);
95     fReader->RequireHeader(kFALSE);
96     while(fReader->ReadHeader()){
97       fSubEventAttributes = fReader->GetSubEventAttributes();
98     }
99     
100     fSDDEvType=GetEventType();
101     if(fSDDEvType==1) fITSHeader->SetEventTypeSDD(kReal);
102     if(fSDDEvType==2) fITSHeader->SetEventTypeSDD(kCalibration1);
103     if(fSDDEvType==3) fITSHeader->SetEventTypeSDD(kCalibration2);
104     fReader->Reset();
105     fStreamer = new AliITSRawStreamSDDv2(fReader);
106     break;
107   }
108
109  
110   fStreamer->SetLowCarlosThreshold(fThreshold,0);
111   fStreamer->SetLowCarlosThreshold(fThreshold,1);
112
113   //from raw data the signal is already decompressed..
114   //set compressed fSignal of AliITSdigitSDD to -1000
115   //set expanded fSignalExpanded of AliITSdigitSDD equal to fStreamer.GetSignal() 
116   while(fStreamer->Next()){   
117     Int_t ndet =0;
118     if(GetBtPeriod()==kNov04) ndet=fStreamer->GetChannel()+nspd;
119     if(GetBtPeriod()==kAug04) ndet=fStreamer->GetChannel();
120     Int_t anode = fStreamer->GetCoord1();
121
122     /* if we are reading only one det, two wings
123        if(fStreamer.GetChannel()==1) anode+=256; //wing 1 0-255, wing 2 256-511
124     */
125
126     /* bt august 2004 and november 2004: with only 1 carlos 
127        channel 0 for one wing of one
128        det, channel 1 for the wing of the second det*/
129
130     const Int_t kdgt[3]={anode,fStreamer->GetCoord2(),-1000};
131     const Int_t ktracks[10]={0,0,0,0,0,0,0,0,0,0};
132     const Int_t khits[10]={0,0,0,0,0,0,0,0,0,0};
133     const Float_t kcharges[10]={0,0,0,0,0,0,0,0,0,0};
134  
135
136     new ((*digits[ndet])[idig[ndet]]) AliITSdigitSDD(0,kdgt,ktracks,khits,kcharges,fStreamer->GetSignal());
137     idig[ndet]++;
138   }
139
140   if(GetBtPeriod()==kNov04){
141     Int_t jitter=fStreamer->ReadJitter();
142     fITSHeader->SetJitterSDD(jitter);
143   }
144   for(Int_t n = 0;n<maxn;n++){
145     branch->SetAddress(&digits[n]);
146     branch->Fill();
147   
148   }
149       
150   fTreeD->SetEntries(maxn);
151   fReader->Reset();
152   fTreeD->AutoSave();
153
154   for(Int_t n=0;n<maxn;n++){
155     delete digits[n];
156   }
157
158   
159   delete[] digits;
160   delete[] idig;
161   delete fStreamer;
162 }
163
164   
165 //______________________________________
166 Int_t AliITSBeamTestDigSDD::GetEventType(){
167
168   // defines the SDD event type:
169   // 1: physics event (kReal)
170   // 2: calibration 1 (kCalibration1, injector pulse)
171   // 3: calibration 2 (kCalibration2, test pulse)
172  
173   fSDDEvType=0;
174   if(fSubEventAttributes[0]==0 && fSubEventAttributes[1]==0 && fSubEventAttributes[2]==0) fSDDEvType = 1;
175   if(fSubEventAttributes[0]==1 && fSubEventAttributes[1]==0 && fSubEventAttributes[2]==0) fSDDEvType = 2;
176
177   if(fSubEventAttributes[0]==2 && fSubEventAttributes[1]==0 && fSubEventAttributes[2]==0) fSDDEvType = 3;
178
179   return fSDDEvType;
180 }
181
182 //______________________________________________________________________
183 AliITSBeamTestDigSDD::AliITSBeamTestDigSDD(const AliITSBeamTestDigSDD &bt):AliITSBeamTestDig(bt){
184     // Copy constructor. 
185
186   fSDDEvType = bt.fSDDEvType;
187   fSubEventAttributes = bt.fSubEventAttributes;
188   fBtPer = bt.fBtPer;
189   fThreshold = bt.fThreshold;
190   fStreamer = bt.fStreamer;
191 }
192 //______________________________________________________________________
193 AliITSBeamTestDigSDD& AliITSBeamTestDigSDD::operator=(const AliITSBeamTestDigSDD &source){
194     // Assignment operator. This is a function which is not allowed to be
195     // done to the ITS beam test dig. It exits with an error.
196     // Inputs:
197     if(this==&source) return *this;
198     Error("operator=","You are not allowed to make a copy of the AliITSBeamTestDig");
199     exit(1);
200     return *this; //fake return
201 }
202
203
204
205