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 **************************************************************************/
18 Revision 1.1 2002/03/15 17:25:54 nilsen
19 Renaming of old hit based Digitizer to make room for new SDigit version.
21 Revision 1.1 2001/11/27 16:27:28 nilsen
22 Adding AliITSDigitizer class to do merging and digitization . Based on the
23 TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
24 file. The following files required minor changes. AliITS, added functions
25 SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
26 AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
27 the original Root Directory in function Compress1D. Now it uses gDirectory.
32 #include <Riostream.h>
33 #include <TObjArray.h>
38 #include <AliRunDigitizer.h>
40 #include "AliITSDigitizer.h"
41 #include "AliITShit.h"
42 #include "AliITSmodule.h"
43 #include "AliITSsimulation.h"
44 #include "AliITSDetType.h"
45 #include "AliITSgeom.h"
47 ClassImp(AliITSDigitizer)
49 //______________________________________________________________________
50 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
51 // Default constructor. Assign fITS since it is never written out from
54 // Option_t * opt Not used
58 // A blank AliITSDigitizer class.
62 //______________________________________________________________________
63 AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
64 // Standard constructor. Assign fITS since it is never written out from
67 // Option_t * opt Not used
71 // An AliItSDigitizer class.
75 //______________________________________________________________________
76 AliITSDigitizer::~AliITSDigitizer(){
77 // Default destructor.
79 // Option_t * opt Not used
85 fITS = 0; // don't delete fITS. Done else where.
88 //______________________________________________________________________
89 Bool_t AliITSDigitizer::Init(){
98 // if(GetHits()) fITS->fHits = new TClonesArray("AliITSHit",1000);
101 //______________________________________________________________________
102 void AliITSDigitizer::Exec(Option_t* opt){
103 // Main digitizing function.
105 // Option_t * opt list of subdetector to digitize. =0 all.
110 Int_t size=0,ifls=0,trk=0,ntracks=0,h=0,nhit=0;
114 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
116 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
118 if(!det[0] && !det[1] && !det[2]) all = "All";
120 AliITSsimulation *sim = 0;
121 AliITSDetType *iDetType = 0;
122 AliITSmodule *mod = 0;
123 Int_t id=0,module=0,nfls=0,mask=0;
124 static Bool_t setDef=kTRUE;
126 if(!fITS) fITS = (AliITS*)(gAlice->GetDetector("ITS"));
127 if(!(fITS->GetITSgeom())){
128 Warning("Exec","Need ITS geometry to be properly defined first.");
129 return; // need transformations to do digitization.
130 } // end if !GetITSgeom()
131 if (setDef) fITS->SetDefaultSimulation();
133 sprintf(name,"%s",fITS->GetName());
135 fITS->InitModules(0,size);
138 nfls = GetManager()->GetNinputs();
139 for(ifls=0;ifls<nfls;ifls++){
140 treeH = GetManager()->GetInputTreeH(ifls);
141 if(!(treeH && GetHits())) continue;
142 brchHits = treeH->GetBranch(name);
145 fITS->SetHitsAddressBranch(brchHits);
147 Error("Exec","branch ITS not found");
150 ntracks = (Int_t) treeH->GetEntries();
151 for(trk=0;trk<ntracks;trk++){
153 brchHits->GetEntry(trk);
154 nhit = GetHits()->GetEntries();
155 mask = GetManager()->GetMask(ifls);
158 mod = GetModule(itsHit->GetModule());
159 id = fITS->GetITSgeom()->GetModuleType(module);
160 if (!all && !det[id]) continue;
161 mod->AddHit(itsHit,trk+mask,h);
167 fITS->MakeBranchInTreeD(GetManager()->GetTreeD());
168 for(module=0;module<size;module++){
169 id = fITS->GetITSgeom()->GetModuleType(module);
170 if (!all && !det[id]) continue;
171 iDetType = fITS->DetType(id);
172 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
174 Error("Exec","The simulation class was not instanciated!");
177 mod = GetModule(module);
178 sim->DigitiseModule(mod,module,0);
179 // fills all branches - wasted disk space
180 GetManager()->GetTreeD()->Fill();
184 fITS->ClearModules();
186 GetManager()->GetTreeD()->GetEntries();
187 GetManager()->GetTreeD()->Write(0,TObject::kOverwrite);
189 GetManager()->GetTreeD()->Reset();