]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITS.cxx
Clean-up of geometry classes
[u/mrichter/AliRoot.git] / ITS / AliITS.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
2ab0c725 17
4c039060 18
fe4da5cc 19///////////////////////////////////////////////////////////////////////////////
04366a57 20// //
21// An overview of the basic philosophy of the ITS code development //
22// and analysis is show in the figure below. //
23//Begin_Html //
24/*
a92b2b7d 25<img src="picts/ITS/ITS_Analysis_schema.gif">
fe4da5cc 26</pre>
27<br clear=left>
28<font size=+2 color=red>
58005f18 29<p>Roberto Barbera is in charge of the ITS Offline code (1999).
fe4da5cc 30<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
31</font>
32<pre>
33*/
34//End_Html
58005f18 35//
36// AliITS. Inner Traking System base class.
37// This class contains the base procedures for the Inner Tracking System
38//
39//Begin_Html
40/*
a92b2b7d 41<img src="picts/ITS/AliITS_Class_Diagram.gif">
58005f18 42</pre>
43<br clear=left>
44<font size=+2 color=red>
45<p>This show the class diagram of the different elements that are part of
46the AliITS class.
47</font>
48<pre>
49*/
50//End_Html
51//
52// Version: 0
53// Written by Rene Brun, Federico Carminati, and Roberto Barbera
54//
55// Version: 1
56// Modified and documented by Bjorn S. Nilsen
57// July 11 1999
58//
3bd79107 59// Version: 2
60// Modified and documented by A. Bologna
61// October 18 1999
62//
58005f18 63// AliITS is the general base class for the ITS. Also see AliDetector for
64// futher information.
65//
fe4da5cc 66///////////////////////////////////////////////////////////////////////////////
88cb7938 67
143d1056 68#include <stdlib.h>
caf37aec 69#include <TClonesArray.h>
9c74c52b 70#include <TFile.h>
7d62fb64 71#include <TParticle.h>
d5da1ecf 72#include <TString.h>
88cb7938 73#include <TTree.h>
88cb7938 74#include <TVirtualMC.h>
7d62fb64 75#include "AliDetector.h"
3bd79107 76#include "AliITS.h"
7d62fb64 77#include "AliITSDetTypeSim.h"
f77f13c8 78#include "AliITSDDLRawData.h"
88cb7938 79#include "AliITSLoader.h"
88cb7938 80#include "AliITShit.h"
81#include "AliITSmodule.h"
7d62fb64 82#include "AliITSpListItem.h"
83#include "AliITSsimulation.h"
84#include "AliITSsimulationFastPoints.h"
5d12ce38 85#include "AliMC.h"
7d62fb64 86#include "AliITSRecPoint.h"
0b5bf101 87#include "AliITSsegmentationSPD.h"
88#include "AliITSsegmentationSDD.h"
dee45d79 89#include "AliITSsimulationSDD.h"
90#include "AliITSCalibrationSDD.h"
8b3448d3 91#include "AliITSCalibrationSSD.h"
0b5bf101 92#include "AliITSsegmentationSSD.h"
93#include "AliITSRawStreamSPD.h"
94#include "AliITSRawStreamSSD.h"
95#include "AliITSRawStreamSDD.h"
0b5bf101 96#include "AliRawReader.h"
f77f13c8 97#include "AliRun.h"
7d62fb64 98#include "AliLog.h"
ef7ff1f9 99#include "AliITSInitGeometry.h"
ad7f2bfa 100#include "AliITSFOSignalsSPD.h"
828e06c7 101
3bd79107 102ClassImp(AliITS)
3bd79107 103
2aea926d 104//______________________________________________________________________
ed9289c8 105AliITS::AliITS() : AliDetector(),
106fDetTypeSim(0),
107fEuclidOut(0),
108fOpt("All"),
109fIdN(0),
110fIdSens(0),
111fIdName(0),
012f0f4c 112fITSmodules(0),
c8af5b8f 113fTiming(kFALSE),
afbc83e9 114fSimuParam(0),
115fModA(0),
116fpSDigits(0)
ed9289c8 117{
7d62fb64 118 // Default initializer for ITS
119 // The default constructor of the AliITS class. In addition to
120 // creating the AliITS class it zeros the variables fIshunt (a member
121 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
122 // fIdSens, and fIdName. The AliDetector default constructor
123 // is also called.
124
aa044888 125// SetDetectors(); // default to fOpt="All". This variable not written out.
e939a978 126//PH SetMarkerColor(kRed);
fe4da5cc 127}
2aea926d 128//______________________________________________________________________
c8af5b8f 129AliITS::AliITS(const Char_t *title):
130 AliDetector("ITS",title),
131 fDetTypeSim(0),
132 fEuclidOut(0),
133 fOpt("All"),
134 fIdN(0),
135 fIdSens(0),
136 fIdName(0),
137 fITSmodules(0),
138 fTiming(kFALSE),
afbc83e9 139 fSimuParam(0),
140 fModA(0),
141 fpSDigits(0)
012f0f4c 142{
143 // The standard Constructor for the ITS class.
144 // It also zeros the variables
145 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
146 // the pointers fIdSens and fIdName. To help in displaying hits via the
147 // ROOT macro display.C AliITS also sets the marker color to red. The
148 // variables passes with this constructor, const char *name and *title,
149 // are used by the constructor of AliDetector class. See AliDetector
150 // class for a description of these parameters and its constructor
151 // functions.
152 // Inputs:
153 // Char_t *title Simulation title for the ITS
154 // Outputs:
155 // none.
156 // Return:
157 // none.
158
159 fHits = new TClonesArray("AliITShit",1560); // from AliDetector
160 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
161 //fNhits=0; //done in AliDetector(name,title)
162 SetDetectors(); // default to fOpt="All". This variable not written out.
163 fDetTypeSim = new AliITSDetTypeSim();
164 //PH SetMarkerColor(kRed);
165 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
166 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
167}
168//______________________________________________________________________
c8af5b8f 169AliITS::AliITS(const char *name, const char *title):
170 AliDetector(name,title),
171 fDetTypeSim(0),
172 fEuclidOut(0),
173 fOpt("All"),
174 fIdN(0),
175 fIdSens(0),
176 fIdName(0),
177 fITSmodules(0),
178 fTiming(kFALSE),
afbc83e9 179 fSimuParam(0),
180 fModA(0),
181 fpSDigits(0)
ed9289c8 182{
7d62fb64 183 // The standard Constructor for the ITS class.
184 // It also zeros the variables
185 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
186 // the pointers fIdSens and fIdName. To help in displaying hits via the
187 // ROOT macro display.C AliITS also sets the marker color to red. The
188 // variables passes with this constructor, const char *name and *title,
189 // are used by the constructor of AliDetector class. See AliDetector
190 // class for a description of these parameters and its constructor
191 // functions.
192
7d62fb64 193 fHits = new TClonesArray("AliITShit",1560);
194 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
ed9289c8 195 //fNhits=0; //done in AliDetector(name,title)
7d62fb64 196
7d62fb64 197 SetDetectors(); // default to fOpt="All". This variable not written out.
ed9289c8 198
7d62fb64 199 fDetTypeSim = new AliITSDetTypeSim();
e939a978 200 //PH SetMarkerColor(kRed);
023ae34b 201 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
202 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
fe4da5cc 203
3bd79107 204}
2aea926d 205//______________________________________________________________________
58005f18 206AliITS::~AliITS(){
4a5bebc2 207 // Default destructor for ITS.
2aea926d 208 // The default destructor of the AliITS class. In addition to deleting
7d62fb64 209 // the AliITS class it deletes the memory pointed to by
210 // fIdSens, fIdName, fDetTypeSim and it's contents.
4a5bebc2 211 // Inputs:
212 // none.
213 // Outputs:
214 // none.
215 // Return:
216 // none.
023ae34b 217
88cb7938 218 if (fHits) {
219 fHits->Delete();
220 delete fHits;
221 fHits=0;
222 }
88cb7938 223 if(fITSmodules) {
224 this->ClearModules();
225 delete fITSmodules;
279a35d7 226 fITSmodules = 0;
88cb7938 227 }// end if fITSmodules!=0
228
7d62fb64 229 delete[] fIdName; // Array of TStrings
230 delete[] fIdSens;
773af0c4 231 Int_t size = AliITSgeomTGeo::GetNModules();
7d62fb64 232 if (fDetTypeSim){
233 delete fDetTypeSim;
234 fDetTypeSim = 0;
c8af5b8f 235 }
236 if(fSimuParam){
237 delete fSimuParam;
238 fSimuParam=0;
239 }
afbc83e9 240 if(fModA){
241 if(size>0){
242 for(Int_t j=0; j<size; j++){
243 fModA[j]->Delete();
244 delete fModA[j];
245 }
246 }
247 delete []fModA;
248 }
249 if(fpSDigits){
250 fpSDigits->Delete();
251 delete fpSDigits;
252 }
3bd79107 253}
3bd79107 254
2aea926d 255//______________________________________________________________________
256void AliITS::Init(){
4a5bebc2 257 // Initializer ITS after it has been built
2aea926d 258 // This routine initializes the AliITS class. It is intended to be
259 // called from the Init function in AliITSv?. Besides displaying a banner
260 // indicating that it has been called it initializes the array fIdSens
261 // and sets the default segmentation, response, digit and raw cluster
262 // classes therefore it should be called after a call to CreateGeometry.
4a5bebc2 263 // Inputs:
264 // none.
265 // Outputs:
266 // none.
267 // Return:
268 // none.
3bd79107 269 Int_t i;
2aea926d 270 // Array of TStrings
0e73d04c 271 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
7d62fb64 272
7d62fb64 273}
2aea926d 274//______________________________________________________________________
275void AliITS::SetDefaults(){
4a5bebc2 276 // sets the default segmentation, response, digit and raw cluster classes.
277 // Inputs:
278 // none.
279 // Outputs:
280 // none.
281 // Return:
282 // none.
023ae34b 283 AliInfoClass("AliITS::Setting Defaults");
7d62fb64 284 if(!fDetTypeSim) {
285 Error("SetDefaults()","fDetTypeSim is 0!");
286 return;
287 }
288
289 fDetTypeSim->SetDefaults();
c8af5b8f 290 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 291
3bd79107 292}
2aea926d 293//______________________________________________________________________
294void AliITS::SetDefaultSimulation(){
4a5bebc2 295 // sets the default simulation.
296 // Inputs:
297 // none.
298 // Outputs:
299 // none.
300 // Return:
301 // none.
7d62fb64 302 if(!fDetTypeSim) {
303 Error("SetDefaultSimulation()","fDetTypeSim is 0!");
304 return;
305 }
306
307 fDetTypeSim->SetDefaultSimulation();
c8af5b8f 308 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
04366a57 309
04366a57 310}
311
312
2aea926d 313//______________________________________________________________________
88cb7938 314void AliITS::MakeBranch(Option_t* option){
2aea926d 315 // Creates Tree branches for the ITS.
4a5bebc2 316 // Inputs:
317 // Option_t *option String of Tree types S,D, and/or R.
318 // const char *file String of the file name where these branches
319 // are to be stored. If blank then these branches
320 // are written to the same tree as the Hits were
321 // read from.
322 // Outputs:
323 // none.
324 // Return:
325 // none.
7d62fb64 326 if(!fDetTypeSim) {
327 Error("MakeBranch","fDetTypeSim is 0!");
328 return;
329 }
04366a57 330
7d62fb64 331 Bool_t cH = (strstr(option,"H")!=0);
332 Bool_t cS = (strstr(option,"S")!=0);
333 Bool_t cD = (strstr(option,"D")!=0);
334
335 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
336 AliDetector::MakeBranch(option);
337
338 if(cS) MakeBranchS(0);
339 if(cD) MakeBranchD(0);
340
341
342}
343//___________________________________________________________________
344void AliITS::MakeBranchS(const char* fl){
345
346 // Creates Tree Branch for the ITS summable digits.
347 // Inputs:
348 // cont char *fl File name where SDigits branch is to be written
349 // to. If blank it write the SDigits to the same
350 // file in which the Hits were found.
351
352
353 if(!fDetTypeSim){
354 Error("MakeBranchS","fDetTypeSim is 0!");
355 }
356 Int_t buffersize = 4000;
357 char branchname[30];
358
359 // only one branch for SDigits.
360 sprintf(branchname,"%s",GetName());
361
362 if(fLoader->TreeS()){
7d62fb64 363 TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
364 MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
365 }
366}
367//______________________________________________________________________
368void AliITS::MakeBranchD(const char* file){
369
370 //Make branch for digits
371 if(!fDetTypeSim) {
372 Warning("MakeBranchD","fDetTypeSim is 0!");
373 return;
374 }
023ae34b 375 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 376 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 377 MakeBranchInTreeD(fLoader->TreeD(),file);
378}
379
380//___________________________________________________________________
381void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
382 // Creates Tree branches for the ITS.
383
384 if(!fDetTypeSim){
385 Error("MakeBranchS","fDetTypeSim is 0!");
386 }
023ae34b 387 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 388 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 389
390 const Char_t *det[3] = {"SPD","SDD","SSD"};
a6e0ebfe 391 const Char_t* digclass;
7d62fb64 392 Int_t buffersize = 4000;
393 Char_t branchname[30];
394
395 if(!fDetTypeSim->GetDigits()){
396 fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
397 }
398 for(Int_t i=0;i<fgkNTYPES;i++){
399 digclass = fDetTypeSim->GetDigitClassName(i);
400 TString classn = digclass;
401 if(!((fDetTypeSim->GetDigits())->At(i))){
402 (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
403 }
404 else ResetDigits(i);
405 if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
406 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
407 TObjArray* dig = DigitsAddress(i);
408 if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
409 }
2aea926d 410
fe4da5cc 411}
2aea926d 412//______________________________________________________________________
413void AliITS::SetTreeAddress(){
414 // Set branch address for the Trees.
4a5bebc2 415 // Inputs:
416 // none.
417 // Outputs:
418 // none.
419 // Return:
420 // none.
023ae34b 421
7d62fb64 422 if(!fDetTypeSim) {
423 Error("SetTreeAddress","fDetTypeSim is 0!");
424 return;
425 }
426
023ae34b 427 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 428 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 429
430 TTree *treeS = fLoader->TreeS();
431 TTree *treeD = fLoader->TreeD();
432 if (fLoader->TreeH() && (fHits == 0x0)) {
433 fHits = new TClonesArray("AliITShit", 1560);
434 }
435 AliDetector::SetTreeAddress();
436
437 fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
438 fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
fe4da5cc 439}
2aea926d 440//______________________________________________________________________
2aea926d 441void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
442 // Add an ITS hit
443 // The function to add information to the AliITShit class. See the
444 // AliITShit class for a full description. This function allocates the
445 // necessary new space for the hit information and passes the variable
446 // track, and the pointers *vol and *hits to the AliITShit constructor
447 // function.
4a5bebc2 448 // Inputs:
449 // Int_t track Track number which produced this hit.
450 // Int_t *vol Array of Integer Hit information. See AliITShit.h
451 // Float_t *hits Array of Floating Hit information. see AliITShit.h
452 // Outputs:
453 // none.
454 // Return:
455 // none.
7d62fb64 456 TClonesArray &lhits = *fHits;
457 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
3bd79107 458}
9c74c52b 459
2aea926d 460//______________________________________________________________________
461void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
8e8eae84 462 Option_t *option, const char *filename){
7d62fb64 463 // fill the modules with the sorted by module hits; add hits from
464 // background if option=Add.
465
466 static TTree *trH1; //Tree with background hits
467 static Bool_t first=kTRUE;
468 static TFile *file;
469 const char *addBgr = strstr(option,"Add");
470
471 evnt = nmodules; // Dummy use of variables to remove warnings
472 if (addBgr ) {
473 if(first) {
474 file=new TFile(filename);
475 } // end if first
476 first=kFALSE;
477 file->cd();
478 file->ls();
479 // Get Hits Tree header from file
480 if(trH1) delete trH1;
481 trH1=0;
482
483 char treeName[20];
484 sprintf(treeName,"TreeH%d",bgrev);
485 trH1 = (TTree*)gDirectory->Get(treeName);
486 if (!trH1) {
487 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
488 } // end if !trH1
489 // Set branch addresses
490 } // end if addBgr
491
492 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
3bd79107 493
7d62fb64 494 if (addBgr ) {
495 FillModules(trH1,10000000); // Default mask 10M.
496 TTree *fAli=fLoader->GetRunLoader()->TreeK();
497 TFile *fileAli=0;
498 if (fAli) fileAli =fAli->GetCurrentFile();
499 fileAli->cd();
500 } // end if add
501
502
3bd79107 503}
2aea926d 504//______________________________________________________________________
b4012daf 505void AliITS::FillModules(TTree *treeH, Int_t mask) {
506 // fill the modules with the sorted by module hits;
507 // can be called many times to do a merging
508 // Inputs:
509 // TTree *treeH The tree containing the hits to be copied into
510 // the modules.
511 // Int_t mask The track number mask to indecate which file
512 // this hits came from.
513 // Outputs:
514 // none.
515 // Return:
516 // none.
517
88cb7938 518 if (treeH == 0x0)
519 {
520 Error("FillModules","Tree is NULL");
521 }
b4012daf 522 Int_t lay,lad,det,index;
523 AliITShit *itsHit=0;
524 AliITSmodule *mod=0;
525 char branchname[20];
526 sprintf(branchname,"%s",GetName());
527 TBranch *branch = treeH->GetBranch(branchname);
528 if (!branch) {
88cb7938 529 Error("FillModules","%s branch in TreeH not found",branchname);
530 return;
b4012daf 531 } // end if !branch
532 branch->SetAddress(&fHits);
533 Int_t nTracks =(Int_t) treeH->GetEntries();
534 Int_t iPrimTrack,h;
535 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
88cb7938 536 ResetHits();
537 Int_t nBytes = treeH->GetEvent(iPrimTrack);
538 if (nBytes <= 0) continue;
539 Int_t nHits = fHits->GetEntriesFast();
540 for(h=0; h<nHits; h++){
541 itsHit = (AliITShit *)fHits->UncheckedAt(h);
542 itsHit->GetDetectorID(lay,lad,det);
7d62fb64 543 if (GetITSgeom()) {
544 index = GetITSgeom()->GetModuleIndex(lay,lad,det);
88cb7938 545 } else {
546 index=det-1; // This should not be used.
547 } // end if [You must have fITSgeom for this to work!]
548 mod = GetModule(index);
549 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
550 mod->AddHit(itsHit,iPrimTrack,h);
551 } // end loop over hits
b4012daf 552 } // end loop over tracks
553}
7d62fb64 554
b4012daf 555//______________________________________________________________________
6f5308d9 556Bool_t AliITS::InitModules(Int_t size,Int_t &nmodules){
7d62fb64 557 // Initialize the modules array.
4a5bebc2 558 // Inputs:
7d62fb64 559 // Int_t size Size of array of the number of modules to be
560 // created. If size <=0 then the number of modules
561 // is gotten from AliITSgeom class kept in fITSgeom.
4a5bebc2 562 // Outputs:
7d62fb64 563 // Int_t &nmodules The number of modules existing.
4a5bebc2 564 // Return:
565 // none.
2ab0c725 566
7d62fb64 567 if(fITSmodules){
568 fITSmodules->Delete();
569 delete fITSmodules;
570 } // end fir fITSmoudles
88cb7938 571
7d62fb64 572 if(!fDetTypeSim) {
573 Error("InitModules","fDetTypeSim is null!");
6f5308d9 574 return kFALSE;
7d62fb64 575 }
c8af5b8f 576 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
828e06c7 577
7d62fb64 578 Int_t nl,indexMAX,index;
579
580 if(size<=0){ // default to using data stored in AliITSgeom
581 if(fDetTypeSim->GetITSgeom()==0) {
582 Error("InitModules","fITSgeom not defined");
6f5308d9 583 return kFALSE;
7d62fb64 584 } // end if fITSgeom==0
585 nl = fDetTypeSim->GetITSgeom()->GetNlayers();
586 indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
587 nmodules = indexMAX;
588 fITSmodules = new TObjArray(indexMAX);
589 for(index=0;index<indexMAX;index++){
590 fITSmodules->AddAt( new AliITSmodule(index),index);
591 } // end for index
592 }else{
593 fITSmodules = new TObjArray(size);
594 for(index=0;index<size;index++) {
595 fITSmodules->AddAt( new AliITSmodule(index),index);
596 } // end for index
597
598 nmodules = size;
599 } // end i size<=0
6f5308d9 600 return kTRUE;
2aea926d 601}
602//______________________________________________________________________
603void AliITS::Hits2SDigits(){
604 // Standard Hits to summable Digits function.
4a5bebc2 605 // Inputs:
606 // none.
607 // Outputs:
608 // none.
7d62fb64 609
2aea926d 610
7d62fb64 611 if(!fDetTypeSim) {
612 Error("Hits2SDigits","fDetTypeSim is null!");
ad7f2bfa 613 return;
7d62fb64 614 }
615
616 SetDefaults();
617 fLoader->LoadHits("read");
618 fLoader->LoadSDigits("recreate");
619 AliRunLoader* rl = fLoader->GetRunLoader();
023ae34b 620 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 621 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
622
7d62fb64 623 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
aacedc3e 624 // Do the Hits to Digits operation. Use Standard input values.
625 // Event number from file, no background hit merging , use size from
626 // AliITSgeom class, option="All", input from this file only.
7d62fb64 627 rl->GetEvent(iEvent);
628 if (!fLoader->TreeS()) fLoader->MakeTree("S");
629 MakeBranch("S");
630 SetTreeAddress();
631 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
632 } // end for iEvent
e0fc0305 633
7d62fb64 634 fLoader->UnloadHits();
635 fLoader->UnloadSDigits();
636
2aea926d 637}
638//______________________________________________________________________
639void AliITS::Hits2Digits(){
2aea926d 640
7d62fb64 641 //Conversion from hits to digits
642 if(!fDetTypeSim) {
643 Error("Hits2SDigits","fDetTypeSim is 0!");
644 return;
645 }
646
023ae34b 647 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 648 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 649 SetDefaults();
650
651 fLoader->LoadHits("read");
652 fLoader->LoadDigits("recreate");
653 AliRunLoader* rl = fLoader->GetRunLoader();
654 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
655 rl->GetEvent(iEvent);
656 if (!fLoader->TreeD()) fLoader->MakeTree("D");
657 MakeBranch("D");
658 SetTreeAddress();
659 HitsToDigits(iEvent,0,-1," ",fOpt," ");
660 }
661
662 fLoader->UnloadHits();
663 fLoader->UnloadDigits();
664
2aea926d 665}
7d62fb64 666
2aea926d 667//______________________________________________________________________
7d62fb64 668void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
669 Option_t *option,Option_t *opt,
670 const char *filename){
4a5bebc2 671 // Keep galice.root for signal and name differently the file for
2aea926d 672 // background when add! otherwise the track info for signal will be lost !
673 // the condition below will disappear when the geom class will be
4a5bebc2 674 // initialized for all versions - for the moment it is only for v5 !
675 // 7 is the SDD beam test version.
676 // Inputs:
677 // Int_t evnt Event to be processed.
678 // Int_t bgrev Background Hit tree number.
679 // Int_t nmodules Not used.
680 // Option_t *option String indicating if merging hits or not. To
681 // merge hits set equal to "Add". Otherwise no
682 // background hits are considered.
683 // Test_t *filename File name containing the background hits..
684 // Outputs:
685 // none.
686 // Return:
687 // none.
2aea926d 688
7d62fb64 689 if(!fDetTypeSim) {
690 Error("HitsToDigits","fDetTypeSim is null!");
691 return;
692 }
023ae34b 693 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 694 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 695 if(!GetITSgeom()) return; // need transformations to do digitization.
696 AliITSgeom *geom = GetITSgeom();
697
698 const char *all = strstr(opt,"All");
699 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
700 strstr(opt,"SSD")};
701 static Bool_t setDef=kTRUE;
702 if (setDef) SetDefaultSimulation();
703 setDef=kFALSE;
704
705 Int_t nmodules;
706 InitModules(size,nmodules);
707 FillModules(evNumber,bgrev,nmodules,option,filename);
ad7f2bfa 708
709 // Reset Fast-OR signals for this event
710 fDetTypeSim->ResetFOSignals();
7d62fb64 711
712 AliITSsimulation *sim = 0;
713 AliITSmodule *mod = 0;
714 Int_t id;
715 for(Int_t module=0;module<geom->GetIndexMax();module++){
716 id = geom->GetModuleType(module);
717 if (!all && !det[id]) continue;
718 sim = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
719 if (!sim) {
720 Error("HitsToDigits","The simulation class was not "
721 "instanciated for module %d type %s!",module,
722 geom->GetModuleTypeName(module));
723 exit(1);
724 } // end if !sim
725 mod = (AliITSmodule *)fITSmodules->At(module);
726 sim->DigitiseModule(mod,module,evNumber);
727 // fills all branches - wasted disk space
728 fLoader->TreeD()->Fill();
729 ResetDigits();
730 } // end for module
731
732 ClearModules();
a0d76912 733
ad7f2bfa 734 // Add random noise to FO signals
735 if (all || det[0]) { // SPD present
736 fDetTypeSim->ProcessNoiseForFastOr();
737 }
738
739 // Add Fast-OR signals to event (only one object per event)
740 if (all || det[0]) { // SPD present
741 fDetTypeSim->WriteFOSignals();
742 }
743
744
7d62fb64 745 fLoader->TreeD()->GetEntries();
746 fLoader->TreeD()->AutoSave();
747 // reset tree
748 fLoader->TreeD()->Reset();
2aea926d 749}
7d62fb64 750//_____________________________________________________________________
751void AliITS::Hits2PreDigits(){
752 // Turn hits into SDigits
753
754 if(!fDetTypeSim) {
755 Error("Hits2SDigits","fDetTypeSim is 0!");
756 return;
757 }
758
023ae34b 759 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 760 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 761 SetDefaults();
762
763 HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
764 0,-1," ",fOpt," ");
765}
766
2aea926d 767//______________________________________________________________________
7d62fb64 768void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
769 Option_t *option,Option_t *opt,
770 const char *filename){
4a5bebc2 771 // Keep galice.root for signal and name differently the file for
2aea926d 772 // background when add! otherwise the track info for signal will be lost !
773 // the condition below will disappear when the geom class will be
4a5bebc2 774 // initialized for all versions - for the moment it is only for v5 !
775 // 7 is the SDD beam test version.
776 // Inputs:
777 // Int_t evnt Event to be processed.
778 // Int_t bgrev Background Hit tree number.
779 // Int_t nmodules Not used.
780 // Option_t *option String indicating if merging hits or not. To
781 // merge hits set equal to "Add". Otherwise no
782 // background hits are considered.
783 // Test_t *filename File name containing the background hits..
784 // Outputs:
785 // none.
786 // Return:
787 // none.
788
7d62fb64 789
790 if(!fDetTypeSim) {
791 Error("HitsToPreDigits","fDetTypeSim is null!");
792 return;
793 }
023ae34b 794 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
c8af5b8f 795 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 796
797 if(!GetITSgeom()){
798 Error("HitsToPreDigits","fGeom is null!");
799 return; // need transformations to do digitization.
800 }
801 AliITSgeom *geom = GetITSgeom();
802
803 const char *all = strstr(opt,"All");
804 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
805 strstr(opt,"SSD")};
806 static Bool_t setDef=kTRUE;
807 if (setDef) SetDefaultSimulation();
808 setDef=kFALSE;
809
810 Int_t nmodules;
811 InitModules(size,nmodules);
812 FillModules(evNumber,bgrev,nmodules,option,filename);
813
814
815 AliITSsimulation *sim = 0;
816 AliITSmodule *mod = 0;
817 Int_t id,module;
818 for(module=0;module<geom->GetIndexMax();module++){
819 id = geom->GetModuleType(module);
820 if (!all && !det[id]) continue;
821 sim = (AliITSsimulation*)GetSimulationModel(id);
822 if (!sim) {
823 Error("HitsToPreDigits","The simulation class was not "
824 "instanciated for module %d type %s!",module,
825 geom->GetModuleTypeName(module));
826 exit(1);
827 } // end if !sim
828 mod = (AliITSmodule *)fITSmodules->At(module);
829 sim->SDigitiseModule(mod,module,evNumber);
830 // fills all branches - wasted disk space
831 fLoader->TreeS()->Fill();
832 fDetTypeSim->ResetSDigits();
833 } // end for module
04366a57 834
7d62fb64 835 ClearModules();
836
837
838 fLoader->TreeS()->GetEntries();
839 fLoader->TreeS()->AutoSave();
840 fLoader->WriteSDigits("OVERWRITE");
841 // reset tree
842 fLoader->TreeS()->Reset();
2aea926d 843}
7d62fb64 844
845//_____________________________________________________________________
846void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
847 Option_t *opt0,Option_t *opt1,
848 const char *flnm){
849 // keep galice.root for signal and name differently the file for
850 // background when add! otherwise the track info for signal will be lost !
851 // the condition below will disappear when the geom class will be
852 // initialized for all versions - for the moment it is only for v5 !
853 // Inputs:
854 // Int_t evnt Event to be processed.
855 // Int_t bgrev Background Hit tree number.
856 // Int_t size Size used by InitModules. See InitModules.
857 // Option_t *opt0 Option passed to FillModules. See FillModules.
858 // Option_t *opt1 String indicating if merging hits or not. To
859 // merge hits set equal to "Add". Otherwise no
860 // background hits are considered.
861 // Test_t *flnm File name containing the background hits..
862 // Outputs:
863 // none.
864 // Return:
865 // none.
866
867
00a7cc50 868
7d62fb64 869 if(!GetITSgeom()){
870 Error("HitsToPreDigits","fGeom is null!");
871 return; // need transformations to do digitization.
872 }
873 AliITSgeom *geom = GetITSgeom();
874
875 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
876
877 const char *all = strstr(opt1,"All");
878 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
879 strstr(opt1,"SSD")};
880 Int_t nmodules;
881 InitModules(size,nmodules);
882 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
883
884 AliITSsimulation *sim = 0;
885 AliITSmodule *mod = 0;
886 Int_t id,module;
887
888 TTree *lTR = pITSloader->TreeR();
00a7cc50 889 if(!lTR) {
890 pITSloader->MakeTree("R");
891 lTR = pITSloader->TreeR();
892 }
893
7d62fb64 894 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
00a7cc50 895 TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
896 branch->SetAddress(&ptarray);
7d62fb64 897 //m.b. : this change is nothing but a nice way to make sure
023ae34b 898 //the CPU goes up !
7d62fb64 899 for(module=0;module<geom->GetIndexMax();module++){
900 id = geom->GetModuleType(module);
901 if (!all && !det[id]) continue;
902 sim = (AliITSsimulation*)GetSimulationModel(id);
903 if (!sim) {
904 Error("HitsToFastPoints","The simulation class was not "
a5a317a9 905 "instantiated for module %d type %s!",module,
7d62fb64 906 geom->GetModuleTypeName(module));
907 exit(1);
908 } // end if !sim
909 mod = (AliITSmodule *)fITSmodules->At(module);
910 sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
911 lTR->Fill();
f1bfe73f 912 ptarray->Clear();
7d62fb64 913 } // end for module
914
915 ClearModules();
916 fLoader->WriteRecPoints("OVERWRITE");
917 delete ptarray;
918}
919//_____________________________________________________________________
920Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
921 //------------------------------------------------------------
922 // This function creates ITS clusters
923 //------------------------------------------------------------
924 if(!GetITSgeom()){
925 Error("HitsToPreDigits","fGeom is null!");
926 return 1; // need transformations to do digitization.
927 }
928 AliITSgeom *geom=GetITSgeom();
929 Int_t mmax=geom->GetIndexMax();
930
931 InitModules(-1,mmax);
932 FillModules(hTree,0);
933
7d62fb64 934 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
00a7cc50 935 TBranch *branch=cTree->GetBranch("ITSRecPoints");
936 if (!branch) cTree->Branch("ITSRecPoints",&points);
937 else branch->SetAddress(&points);
7d62fb64 938
939 AliITSsimulationFastPoints sim;
940 Int_t ncl=0;
941 for (Int_t m=0; m<mmax; m++) {
942 AliITSmodule *mod=GetModule(m);
943 sim.CreateFastRecPoints(mod,m,gRandom,points);
00a7cc50 944 ncl+=points->GetEntriesFast();
7d62fb64 945 cTree->Fill();
7d62fb64 946 points->Clear();
947 }
948
15e6a32c 949 AliDebug(1,Form("Number of found fast clusters : %d",ncl));
7d62fb64 950
951 //cTree->Write();
952
7d62fb64 953 delete points;
954 return 0;
955}
7d62fb64 956
7d62fb64 957//_____________________________________________________________________
958void AliITS::CheckLabels(Int_t lab[3]) const {
959 //------------------------------------------------------------
960 // Tries to find mother's labels
961 //------------------------------------------------------------
962
963 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
964
965 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
966 for (Int_t i=0;i<3;i++){
967 Int_t label = lab[i];
968 if (label>=0 && label<ntracks) {
969 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
970 if (part->P() < 0.005) {
971 Int_t m=part->GetFirstMother();
972 if (m<0) {
973 continue;
974 }
975 if (part->GetStatusCode()>0) {
976 continue;
977 }
978 lab[i]=m;
979 }
980 }
981 }
982
983}
984
985//______________________________________________________________________
986void AliITS::SDigitsToDigits(Option_t *opt){
ad7f2bfa 987 // Standard Summable digits to Digits function.
988 // Inputs:
989 // none.
990 // Outputs:
991 // none.
992 if (!fDetTypeSim) {
993 AliError("fDetTypeSim is 0!");
994 return;
995 }
7d62fb64 996
ad7f2bfa 997 const char *all = strstr(opt,"All");
998 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
999 strstr(opt,"SSD")};
1000
1001 // Reset Fast-OR signals for this event
1002 fDetTypeSim->ResetFOSignals();
1003
1004 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
1005 SetDefaults();
c8af5b8f 1006 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
ad7f2bfa 1007 fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
1008
1009 // Add random noise to FO signals
1010 if (all || det[0]) { // SPD present
1011 fDetTypeSim->ProcessNoiseForFastOr();
1012 }
1013 // Add Fast-OR signals to event (only one object per event)
1014 if (all || det[0]) { // SPD present
1015 fDetTypeSim->WriteFOSignals();
1016 }
7d62fb64 1017}
1018
2aea926d 1019//______________________________________________________________________
2aea926d 1020void AliITS::ResetDigits(){
4a5bebc2 1021 // Reset number of digits and the digits array for the ITS detector.
1022 // Inputs:
1023 // none.
1024 // Outputs:
1025 // none.
7d62fb64 1026 if(!fDetTypeSim) {
1027 Error("ResetDigits","fDetTypeSim is 0!");
1028 return;
1029 }
1030
1031 fDetTypeSim->ResetDigits();
3bd79107 1032
1033
2aea926d 1034}
1035//______________________________________________________________________
7d62fb64 1036void AliITS::ResetDigits(Int_t branch){
4a5bebc2 1037 // Reset number of digits and the digits array for this branch.
1038 // Inputs:
1039 // none.
1040 // Outputs:
1041 // none.
828e06c7 1042
7d62fb64 1043 if(!fDetTypeSim) {
1044 Error("ResetDigits","fDetTypeSim is 0!");
1045 return;
1046 }
1047
1048 fDetTypeSim->ResetDigits(branch);
1049
2aea926d 1050}
1051//______________________________________________________________________
1052void AliITS::AddSumDigit(AliITSpListItem &sdig){
4a5bebc2 1053 // Adds the a module full of summable digits to the summable digits tree.
1054 // Inputs:
1055 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1056 // Outputs:
1057 // none.
1058 // Return:
1059 // none.
828e06c7 1060
7d62fb64 1061 if(!fDetTypeSim) {
1062 Error("AddSumDigit","fDetTypeSim is 0!");
1063 return;
1064 }
1065 fDetTypeSim->AddSumDigit(sdig);
1066
2aea926d 1067}
1068//______________________________________________________________________
7d62fb64 1069void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
4a5bebc2 1070 // Add a simulated digit.
1071 // Inputs:
1072 // Int_t id Detector type number.
1073 // AliITSdigit *d Digit to be added to the Digits Tree. See
1074 // AliITSdigit.h
1075 // Outputs:
1076 // none.
1077 // Return:
1078 // none.
2aea926d 1079
7d62fb64 1080 if(!fDetTypeSim) {
1081 Error("AddSimDigit","fDetTypeSim is 0!");
1082 return;
1083 }
1084 fDetTypeSim->AddSimDigit(branch,d);
1085
2aea926d 1086}
1087//______________________________________________________________________
7d62fb64 1088void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
83ec5e27 1089 Int_t *hits,Float_t *charges, Int_t sigexpanded){
7f1a504b 1090 // Add a simulated digit to the list.
1091 // Inputs:
1092 // Int_t id Detector type number.
1093 // Float_t phys Physics indicator. See AliITSdigits.h
1094 // Int_t *digits Integer array containing the digits info. See
1095 // AliITSdigit.h
1096 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1097 // containing the track numbers that contributed to
1098 // this digit.
1099 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1100 // containing the hit numbers, from AliITSmodule, that
1101 // contributed to this digit.
1102 // Float_t *charge Floating point array of the signals contributed
1103 // to this digit by each track.
1104 // Outputs:
1105 // none.
1106 // Return:
1107 // none.
2aea926d 1108
7d62fb64 1109 if(!fDetTypeSim) {
1110 Error("AddSimDigit","fDetTypeSim is 0!");
1111 return;
1112 }
83ec5e27 1113 fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
7d62fb64 1114
2aea926d 1115}
0421c3d1 1116//______________________________________________________________________
aacedc3e 1117void AliITS::Digits2Raw(){
1118 // convert digits of the current event to raw data
0421c3d1 1119
7d62fb64 1120 if(!fDetTypeSim) {
1121 Error("Digits2Raw","fDetTypeSim is 0!");
1122 return;
1123 }
023ae34b 1124 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
7d62fb64 1125 SetDefaults();
c8af5b8f 1126 if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
7d62fb64 1127 fDetTypeSim->GetLoader()->LoadDigits();
1128 TTree* digits = fDetTypeSim->GetLoader()->TreeD();
0421c3d1 1129 if (!digits) {
aacedc3e 1130 Error("Digits2Raw", "no digits tree");
1131 return;
0421c3d1 1132 }
7d62fb64 1133 fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
ad7f2bfa 1134
1135 // Get the FO signals for this event
1136 AliITSFOSignalsSPD* foSignals = NULL;
1137 AliRunLoader* runLoader = AliRunLoader::Instance();
1138 AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
1139 if (!itsLoader) {
1140 AliError("ITS loader is NULL.");
1141 }
a0d76912 1142 else {
1143 if(!itsLoader->TreeD()) AliError(" !!! No TreeD available !!!");
1144 foSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD");
1145 if(!foSignals) AliError("FO signals not retrieved");
1146 }
1147
ad7f2bfa 1148 Bool_t deleteFOsignalsLater = kFALSE;
1149 if (!foSignals) {
1150 AliError("FO signals not available. No FO bits will be written.");
1151 foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
1152 deleteFOsignalsLater = kTRUE;
1153 }
1154
1155
979b5a5f 1156 AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
d9ed1779 1157 Char_t rawSDD=fDetTypeSim->GetSimuParam()->GetSDDRawDataFormat();
0421c3d1 1158 AliITSDDLRawData rawWriter;
d9ed1779 1159
1160 rawWriter.SetSDDRawFormat(rawSDD);
0421c3d1 1161 //Verbose level
1162 // 0: Silent
1163 // 1: cout messages
1164 // 2: txt files with digits
1165 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1166 //it is highly suggested to use this mode only for debugging digits files
1167 //reasonably small, because otherwise the size of the txt files can reach
1168 //quickly several MB wasting time and disk space.
1169 rawWriter.SetVerbose(0);
1170
1171 //SILICON PIXEL DETECTOR
15e6a32c 1172 AliDebug(1,"Formatting raw data for SPD");
ad7f2bfa 1173 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
1174 if(deleteFOsignalsLater) delete foSignals;
0421c3d1 1175
1176 //SILICON DRIFT DETECTOR
d9ed1779 1177 AliDebug(1,Form("Formatting raw data for SDD - Format code =%d",rawSDD));
979b5a5f 1178 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
0421c3d1 1179
1180 //SILICON STRIP DETECTOR
15e6a32c 1181 AliDebug(1,"Formatting raw data for SSD");
0421c3d1 1182 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1183
1184 fLoader->UnloadDigits();
2aea926d 1185}
2aea926d 1186//______________________________________________________________________
aacedc3e 1187AliLoader* AliITS::MakeLoader(const char* topfoldername){
1188 //builds ITSgetter (AliLoader type)
1189 //if detector wants to use castomized getter, it must overload this method
1190
64f311fe 1191 AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1192 topfoldername));
aacedc3e 1193 fLoader = new AliITSLoader(GetName(),topfoldername);
1194 return fLoader;
2aea926d 1195}
ad7f2bfa 1196//______________________________________________________________________
0b5bf101 1197Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1198{
1199 //
1200 // Converts RAW data to SDigits
1201 //
1202 // Get TreeS
1203 //
afbc83e9 1204 Int_t last = -1;
773af0c4 1205 Int_t size = AliITSgeomTGeo::GetNModules();
afbc83e9 1206 if(!fModA) {
1207 fModA = new TClonesArray*[size];
1208 for (Int_t mod = 0; mod < size; mod++) fModA[mod] = new TClonesArray("AliITSpListItem", 10000);
1209 }
1210 AliLoader* loader = (AliRunLoader::Instance())->GetLoader("ITSLoader");
1211 if (!loader){
1212 Error("Open","Can not get ITS loader from Run Loader");
1213 return kFALSE;
1214 }
0b5bf101 1215
afbc83e9 1216 TTree* tree = 0;
1217 tree = loader->TreeS();
1218 if (!tree){
1219 loader->MakeTree("S");
0b5bf101 1220 tree = loader->TreeS();
afbc83e9 1221 }
1222 //
1223 // Array for SDigits
1224 //
1225 if(!fpSDigits){
1226 fpSDigits = new TClonesArray("AliITSpListItem",10000);
1227 }
1228 TClonesArray& aSDigits = *fpSDigits;
1229 Int_t bufsize = 32000;
1230 tree->Branch("ITS", &fpSDigits, bufsize);
1231 Int_t npx = 0;
1232 //
1233 // SPD
1234 //
1235 AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1236 if(!segSPD){
1237 AliWarning("Set AliITS defaults");
1238 SetDefaults();
1239 segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1240 }
1241 npx = segSPD->Npx();
1242 Double_t thr, sigma;
0b5bf101 1243
afbc83e9 1244 AliITSRawStreamSPD inputSPD(rawReader);
1245 while(1){
1246 Bool_t next = inputSPD.Next();
1247 if (!next) break;
0b5bf101 1248
afbc83e9 1249 Int_t module = inputSPD.GetModuleID();
1250 Int_t column = inputSPD.GetColumn();
1251 Int_t row = inputSPD.GetRow();
1252 Int_t index = npx * column + row;
0b5bf101 1253
afbc83e9 1254 if (module >= size) continue;
0b5bf101 1255
afbc83e9 1256 last = (fModA[module])->GetEntries();
1257 TClonesArray& dum = *fModA[module];
1258 fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
1259 thr += 1.;
1260 new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1261 }
1262 rawReader->Reset();
1263
1264 //
1265 // SDD
1266 //
1267 AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1268 npx = segSDD->Npx();
1269 Int_t scalef=AliITSsimulationSDD::ScaleFourier(segSDD);
1270 Int_t firstSDD=AliITSgeomTGeo::GetModuleIndex(3,1,1);
1271 Int_t firstSSD=AliITSgeomTGeo::GetModuleIndex(5,1,1);
1272
1273 AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
1274 for(Int_t iMod=firstSDD; iMod<firstSSD; iMod++){
1275 AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(iMod);
1276 Bool_t isZeroSupp=cal->GetZeroSupp();
1277 if(isZeroSupp){
1278 for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,cal->GetZSLowThreshold(iSid));
1279 }else{
1280 for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,0);
dee45d79 1281 }
afbc83e9 1282 }
dee45d79 1283
afbc83e9 1284 AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
1285 inputSDD->SetDDLModuleMap(ddlmap);
1286 while(inputSDD->Next()){
1287 if(inputSDD->IsCompletedModule()==kFALSE &&
1288 inputSDD->IsCompletedDDL()==kFALSE){
1289
1290 Int_t module = inputSDD->GetModuleID();
1291 Int_t anode = inputSDD->GetCoord1()+segSDD->NpzHalf()*inputSDD->GetChannel();
1292 Int_t time = inputSDD->GetCoord2();
1293 Int_t signal10 = inputSDD->GetSignal();
1294 Int_t index = AliITSpList::GetIndex(anode,time,scalef*npx);
1295
1296 if (module >= size) continue;
1297 last = fModA[module]->GetEntries();
1298 TClonesArray& dum = *fModA[module];
1299 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1300 ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
0b5bf101 1301 }
afbc83e9 1302 }
1303 delete inputSDD;
1304 rawReader->Reset();
a4998655 1305
afbc83e9 1306 //
1307 // SSD
1308 //
1309 AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1310 npx = segSSD->Npx();
1311 AliITSRawStreamSSD inputSSD(rawReader);
1312 while(1){
1313 Bool_t next = inputSSD.Next();
1314 if (!next) break;
1315
1316 Int_t module = inputSSD.GetModuleID();
773af0c4 1317 if(module<0)AliError(Form("Invalid SSD module %d \n",module));
1318 if(module<0)continue;
afbc83e9 1319 Int_t side = inputSSD.GetSideFlag();
1320 Int_t strip = inputSSD.GetStrip();
1321 Int_t signal = inputSSD.GetSignal();
1322 Int_t index = npx * side + strip;
1323
1324 if (module >= size) continue;
0b5bf101 1325
afbc83e9 1326 last = fModA[module]->GetEntries();
1327 TClonesArray& dum = *fModA[module];
1328 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1329 }
1330 rawReader->Reset();
1331 AliITSpListItem* sdig = 0;
0b5bf101 1332
afbc83e9 1333 Int_t firstssd = GetITSgeom()->GetStartDet(kSSD);
1334 Double_t adcToEv = 1.;
1335 for (Int_t mod = 0; mod < size; mod++)
1336 {
8b3448d3 1337 if(mod>=firstssd) {
1338 AliITSCalibrationSSD* calssd = (AliITSCalibrationSSD*)fDetTypeSim->GetCalibrationModel(mod);
1339 adcToEv = 1./calssd->GetSSDDEvToADC(1.);
1340 }
afbc83e9 1341 Int_t nsdig = fModA[mod]->GetEntries();
8b3448d3 1342 for (Int_t ie = 0; ie < nsdig; ie++) {
afbc83e9 1343 sdig = (AliITSpListItem*) (fModA[mod]->At(ie));
463ae357 1344 Double_t digsig = sdig->GetSignal();
8b3448d3 1345 if(mod>=firstssd) digsig*=adcToEv; // for SSD: convert back charge from ADC to electron
1346 new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), digsig);
afbc83e9 1347 Float_t sig = sdig->GetSignalAfterElect();
1348 if(mod>=firstssd) sig*=adcToEv;
1349 if (sig > 0.) {
1350 sdig = (AliITSpListItem*)aSDigits[ie];
1351 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
0b5bf101 1352 }
afbc83e9 1353 }
0b5bf101 1354
afbc83e9 1355 tree->Fill();
1356 aSDigits.Clear();
1357 fModA[mod]->Clear();
0b5bf101 1358 }
afbc83e9 1359 loader->WriteSDigits("OVERWRITE");
1360 return kTRUE;
0b5bf101 1361}
1362
ef7ff1f9 1363//______________________________________________________________________
1364void AliITS::UpdateInternalGeometry(){
ed9289c8 1365 //reads new geometry from TGeo
012f0f4c 1366// AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1367
108bd0fe 1368 AliITSVersion_t version = (AliITSVersion_t)IsVersion();
1369 Int_t minor = 0;
012f0f4c 1370 AliITSInitGeometry initgeom;
1371 AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
ef7ff1f9 1372 SetITSgeom(geom);
ef7ff1f9 1373}
ad7f2bfa 1374//______________________________________________________________________
1375AliTriggerDetector* AliITS::CreateTriggerDetector() const {
1376 // create an AliITSTrigger object (and set trigger conditions as input)
1377 return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
1378}