1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include <Riostream.h>
20 #include <TObjArray.h>
25 #include <AliRunDigitizer.h>
27 #include "AliITSDigitizer.h"
28 #include "AliITShit.h"
29 #include "AliITSmodule.h"
30 #include "AliITSsimulation.h"
31 #include "AliITSDetType.h"
32 #include "AliITSgeom.h"
34 ClassImp(AliITSDigitizer)
36 //______________________________________________________________________
37 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
38 // Default constructor. Assign fITS since it is never written out from
41 // Option_t * opt Not used
45 // A blank AliITSDigitizer class.
49 //______________________________________________________________________
50 AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
51 // Standard constructor. Assign fITS since it is never written out from
54 // Option_t * opt Not used
58 // An AliItSDigitizer class.
62 //______________________________________________________________________
63 AliITSDigitizer::~AliITSDigitizer(){
64 // Default destructor.
66 // Option_t * opt Not used
72 fITS = 0; // don't delete fITS. Done else where.
75 //______________________________________________________________________
76 Bool_t AliITSDigitizer::Init(){
85 // if(GetHits()) fITS->fHits = new TClonesArray("AliITSHit",1000);
88 //______________________________________________________________________
89 void AliITSDigitizer::Exec(Option_t* opt){
90 // Main digitizing function.
92 // Option_t * opt list of subdetector to digitize. =0 all.
97 Int_t size=0,ifls=0,trk=0,ntracks=0,h=0,nhit=0;
101 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
103 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
105 if(!det[0] && !det[1] && !det[2]) all = "All";
107 AliITSsimulation *sim = 0;
108 AliITSDetType *iDetType = 0;
109 AliITSmodule *mod = 0;
110 Int_t id=0,module=0,nfls=0,mask=0;
111 static Bool_t setDef=kTRUE;
113 if(!fITS) fITS = (AliITS*)(gAlice->GetDetector("ITS"));
114 if(!(fITS->GetITSgeom())){
115 Warning("Exec","Need ITS geometry to be properly defined first.");
116 return; // need transformations to do digitization.
117 } // end if !GetITSgeom()
118 if (setDef) fITS->SetDefaultSimulation();
120 sprintf(name,"%s",fITS->GetName());
122 fITS->InitModules(0,size);
125 nfls = GetManager()->GetNinputs();
126 for(ifls=0;ifls<nfls;ifls++){
127 treeH = GetManager()->GetInputTreeH(ifls);
128 if(!(treeH && GetHits())) continue;
129 brchHits = treeH->GetBranch(name);
132 fITS->SetHitsAddressBranch(brchHits);
134 Error("Exec","branch ITS not found");
137 ntracks = (Int_t) treeH->GetEntries();
138 for(trk=0;trk<ntracks;trk++){
140 brchHits->GetEntry(trk);
141 nhit = GetHits()->GetEntries();
142 mask = GetManager()->GetMask(ifls);
145 mod = GetModule(itsHit->GetModule());
146 id = fITS->GetITSgeom()->GetModuleType(module);
147 if (!all && !det[id]) continue;
148 mod->AddHit(itsHit,trk+mask,h);
154 fITS->MakeBranchInTreeD(GetManager()->GetTreeD());
155 for(module=0;module<size;module++){
156 id = fITS->GetITSgeom()->GetModuleType(module);
157 if (!all && !det[id]) continue;
158 iDetType = fITS->DetType(id);
159 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
161 Error("Exec","The simulation class was not instanciated!");
164 mod = GetModule(module);
165 sim->DigitiseModule(mod,module,0);
166 // fills all branches - wasted disk space
167 GetManager()->GetTreeD()->Fill();
171 fITS->ClearModules();
173 GetManager()->GetTreeD()->GetEntries();
174 GetManager()->GetTreeD()->Write(0,TObject::kOverwrite);
176 GetManager()->GetTreeD()->Reset();