1 ////////////////////////////////////////////////////
2 // Class to manage the //
3 // ITS beam test conversion from rawdata //
4 // to digits. It executes the digitization for //
5 // SPD, SDD and SSD. //
8 // Origin: E. Crescio crescio@to.infn.it //
9 // J. Conrad Jan.Conrad@cern.ch //
10 ////////////////////////////////////////////////////
11 #include "AliHeader.h"
13 #include "AliRunLoader.h"
14 #include "AliITSEventHeader.h"
15 #include "AliITSLoader.h"
16 #include "AliITSBeamTestDigSDD.h"
17 #include "AliITSBeamTestDigSPD.h"
18 #include "AliITSBeamTestDigSSD.h"
19 #include "AliITSBeamTestDigitizer.h"
20 #include "AliRawReaderDate.h"
21 #include "AliRawReaderRoot.h"
23 const TString AliITSBeamTestDigitizer::fgkDefaultDigitsFileName="ITS.Digits.root";
25 ClassImp(AliITSBeamTestDigitizer)
28 //_____________________________________________________________
29 AliITSBeamTestDigitizer::AliITSBeamTestDigitizer():TTask()
32 // Default constructor
46 //_____________________________________________________________
47 AliITSBeamTestDigitizer::AliITSBeamTestDigitizer(const Text_t* name, const Text_t* title, Char_t* opt,const char* filename):TTask(name,title)
50 // Standard constructor
62 Bool_t aug04 = choice.Contains("Aug04");
63 Bool_t nov04 = choice.Contains("Nov04");
64 if(aug04) fPeriod=kAug04;
65 if(nov04) fPeriod=kNov04;
69 //_____________________________________________________________
70 AliITSBeamTestDigitizer::AliITSBeamTestDigitizer(const Text_t* name, const Text_t* title, Int_t run, Char_t* opt,const char* filename):TTask(name,title)
85 Bool_t aug04 = choice.Contains("Aug04");
86 Bool_t nov04 = choice.Contains("Nov04");
87 if(aug04) fPeriod=kAug04;
88 if(nov04) fPeriod=kNov04;
93 //___________________________________________________________
94 void AliITSBeamTestDigitizer::Init(const char* filename){
97 //Initialization of run loader and its loader
98 //creation of galice.root
102 fRunLoader = AliRunLoader::Open(filename,AliConfig::GetDefaultEventFolderName(),"update");
103 if (fRunLoader == 0x0)
105 Error("AliITSBeamTestDigitizer","Can not load the session",filename);
108 fRunLoader->LoadgAlice();
109 gAlice = fRunLoader->GetAliRun();
112 Error("AliITSBeamTestDigitizer","gAlice not found on file. Aborting.");
115 fRunLoader->MakeTree("E");
116 fLoader = (AliITSLoader*)fRunLoader->GetLoader("ITSLoader");
118 fDigitsFileName=fgkDefaultDigitsFileName;
119 this->Add(new AliITSBeamTestDigSPD("DigSPD","SPD Digitization"));
120 this->Add(new AliITSBeamTestDigSDD("DigSDD","SDD Digitization"));
121 this->Add(new AliITSBeamTestDigSSD("DigSSD","SSD Digitization"));
127 //______________________________________________________________________
128 AliITSBeamTestDigitizer::AliITSBeamTestDigitizer(const AliITSBeamTestDigitizer &bt):TTask(bt){
131 if(this==&bt) return;
132 Error("Copy constructor",
133 "You are not allowed to make a copy of the AliITSBeamTestDigitizer");
137 //______________________________________________________________________
138 AliITSBeamTestDigitizer& AliITSBeamTestDigitizer::operator=(const AliITSBeamTestDigitizer &source){
139 // Assignment operator. This is a function which is not allowed to be
140 // done to the ITS beam test digitizer. It exits with an error.
142 if(this==&source) return *this;
143 Error("operator=","You are not allowed to make a copy of the AliITSBeamTestDigitizer");
145 return *this; //fake return
149 //______________________________________________________________
150 AliITSBeamTestDigitizer::~AliITSBeamTestDigitizer(){
153 // if(fBt) delete fBt;
154 if(fLoader) delete fLoader;
155 if(fHeader) delete fHeader;
159 //_____________________________________________________________
160 void AliITSBeamTestDigitizer::SetNumberOfEventsPerFile(Int_t nev)
162 //Sets number of events per file
164 if(fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nev);
165 else Warning("SetNumberOfEventsPerFile","fRunLoader is 0");
169 //____________________________________________________
170 void AliITSBeamTestDigitizer::ExecDigitization(){
172 // Execution of digitisation for SPD,SDD and SSD
175 Warning("ExecDigitization()","Run Init() please..");
178 fLoader->SetDigitsFileName(fDigitsFileName);
179 fLoader->LoadDigits("recreate");
183 if(GetOptDate()) rd = new AliRawReaderDate(fRawdataFileName,fEvIn);
184 else rd = new AliRawReaderRoot(fRawdataFileName,fEvIn);
186 AliHeader* header = fRunLoader->GetHeader();
190 AliITSBeamTestDigSDD* digSDD = (AliITSBeamTestDigSDD*)fTasks->FindObject("DigSDD");
191 AliITSBeamTestDigSPD* digSPD = (AliITSBeamTestDigSPD*)fTasks->FindObject("DigSPD");
192 AliITSBeamTestDigSSD* digSSD = (AliITSBeamTestDigSSD*)fTasks->FindObject("DigSSD");
198 if(iev>fEvFin) break;
200 AliITSEventHeader* itsh = new AliITSEventHeader("ITSHeader");
201 fRunLoader->SetEventNumber(iev);
203 rd->RequireHeader(fFlagHeader);
204 rd->SelectEvents(fDATEEvType);
206 digSDD->SetRawReader(rd);
207 digSPD->SetRawReader(rd);
208 digSSD->SetRawReader(rd);
210 if(fLoader->TreeD() == 0x0) fLoader->MakeTree("D");
212 TTree* treeD = (TTree*)fLoader->TreeD();
214 // Make branches outside the dig-classes
216 TClonesArray* digitsSPD = new TClonesArray("AliITSdigitSPD",1000);
217 treeD->Branch("ITSDigitsSPD",&digitsSPD);
219 TClonesArray* digitsSDD = new TClonesArray("AliITSdigitSDD",1000);
220 treeD->Branch("ITSDigitsSDD",&digitsSDD);
222 TClonesArray* digitsSSD = new TClonesArray("AliITSdigitSSD",1000);
223 treeD->Branch("ITSDigitsSSD",&digitsSSD);
226 digSSD->SetTree(treeD);
227 digSDD->SetTree(treeD);
228 digSPD->SetTree(treeD);
230 AliITSgeom* geom = fLoader->GetITSgeom();
232 digSSD->SetITSgeom(geom);
233 digSDD->SetITSgeom(geom);
234 digSPD->SetITSgeom(geom);
236 digSSD->SetITSEventHeader(itsh);
237 digSDD->SetITSEventHeader(itsh);
238 digSPD->SetITSEventHeader(itsh);
240 digSDD->SetBtPeriod(GetBeamTestPeriod());
241 if(GetBeamTestPeriod()==1)digSDD->SetThreshold(16);
242 else digSDD->SetThreshold(0);
245 header->SetEventNrInRun(iev);
246 header->SetEvent(iev);
247 header->SetRun(fRunNumber);
248 fRunLoader->GetHeader()->AddDetectorEventHeader(itsh);
249 fRunLoader->TreeE()->Fill();
250 header->Reset(fRunNumber,iev);
256 }while(rd->NextEvent());
259 fRunLoader->WriteHeader("OVERWRITE");
260 fRunLoader->WriteRunLoader("OVERWRITE");
263 fLoader->UnloadDigits();
264 fLoader->UnloadRawClusters();
265 fRunLoader->UnloadHeader();
272 //_______________________________________________
273 void AliITSBeamTestDigitizer:: SetActive(const TString& subdet,Bool_t value){
275 //Sets active sub-tasks (detectors)
277 Bool_t sdd = subdet.Contains("SDD");
278 Bool_t spd = subdet.Contains("SPD");
279 Bool_t ssd = subdet.Contains("SSD");
282 AliITSBeamTestDigSDD* digSDD = (AliITSBeamTestDigSDD*)fTasks->FindObject("DigSDD");
283 digSDD->SetActive(value);
287 AliITSBeamTestDigSPD* digSPD = (AliITSBeamTestDigSPD*)fTasks->FindObject("DigSPD");
288 digSPD->SetActive(value);
293 AliITSBeamTestDigSSD* digSSD = (AliITSBeamTestDigSSD*)fTasks->FindObject("DigSSD");
294 digSSD->SetActive(value);