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