]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSFDigitizer.cxx
New Class AliITSTrackleterSPDEff:
[u/mrichter/AliRoot.git] / ITS / AliITSFDigitizer.cxx
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  
16 /* $Id$ */
17
18 //////////////////////////////////////////////////////////////////
19 // Class for fast reconstruction of recpoints                   //
20 //                                                              //
21 //                                                              //
22 //////////////////////////////////////////////////////////////////
23
24 #include <stdlib.h>
25 #include <TTree.h>
26
27 #include <AliRun.h>
28 #include <AliRunLoader.h>
29 #include <AliLoader.h>
30 #include <AliRunDigitizer.h>
31
32 #include "AliITSFDigitizer.h"
33 #include "AliITSgeom.h"
34 #include "AliITSsimulationFastPoints.h"
35
36 ClassImp(AliITSFDigitizer)
37
38 //______________________________________________________________________
39 AliITSFDigitizer::AliITSFDigitizer() : AliDigitizer(),
40 fITS(0),
41 fInit(kFALSE){
42 //
43 // Default constructor.
44 //
45 }
46 //______________________________________________________________________
47 AliITSFDigitizer::AliITSFDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr),
48 fITS(0),
49 fInit(kFALSE){
50 //
51 // Standard constructor.
52 //
53 }
54 //______________________________________________________________________
55 AliITSFDigitizer::AliITSFDigitizer(const AliITSFDigitizer &rec):AliDigitizer(rec),
56 fITS(rec.fITS),
57 fInit(rec.fInit){
58     // Copy constructor. 
59   
60 }
61 //______________________________________________________________________
62 AliITSFDigitizer& AliITSFDigitizer::operator=(const AliITSFDigitizer& /*source*/){
63
64     // Assignment operator. This is a function which is not allowed to be
65     // done.
66     Error("operator=","Assignment operator not allowed\n");
67     return *this; 
68 }
69
70 //______________________________________________________________________
71 AliITSFDigitizer::~AliITSFDigitizer(){
72 //
73 // Default destructor. 
74 //
75     fITS = 0; // don't delete fITS. Done else where.
76 }
77 //______________________________________________________________________
78 Bool_t AliITSFDigitizer::Init(){
79 //
80 // Initialization. 
81 // loads ITS and ITSgeom.
82 // Inputs:
83 //      none.
84 // Outputs:
85 //      none.
86
87   
88   fInit = kFALSE;
89   if(!gAlice) {
90     fITS      = 0;
91     Warning("Init","gAlice not found");
92     return fInit;
93   }
94   fITS = (AliITS *)(gAlice->GetDetector("ITS"));
95   if(!fITS){
96     Warning("Init","ITS not found");
97     return fInit;
98   } 
99   if(!fITS->GetITSgeom()){
100     Warning("Init","ITS geometry not found");
101     return fInit;
102   }
103   return fInit = kTRUE;
104 }
105 ////////////////////////////////////////////////////////////////////////
106 void AliITSFDigitizer::Exec(Option_t* opt){
107 //
108 // Main digitization function. 
109 // Inputs:
110 //      Option_t * opt  "deb" ... more verbose output 
111 //
112
113     AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints();
114     AliRunLoader* outrl = AliRunLoader::GetRunLoader(
115                                         fManager->GetOutputFolderName());
116     if (outrl == 0x0){
117         Error("Exec","Can not find Run Loader in output folder.");
118         return;
119     }
120     AliLoader* outgime = outrl->GetLoader("ITSLoader");
121     if (outgime == 0x0){
122         Error("Exec","Can not get TOF Loader from Output Run Loader.");
123         return;
124     }
125     if(strstr(opt,"deb")){
126         Info("Exec","sim=%p, outrl=%p, outgime=%p",sim,outrl,outgime);
127     }
128     TTree* outputTreeR = outgime->TreeR();
129     if (outputTreeR == 0x0){
130         outgime->MakeTree("R");
131         outputTreeR = outgime->TreeR();
132     }
133     
134     TClonesArray* recPoints = new TClonesArray("AliITSRecPoint",1000);
135     TBranch* branch = outputTreeR->GetBranch("ITSRecPointsF");
136     if(branch) branch->SetAddress(recPoints);
137     else outputTreeR->Branch("ITSRecPointsF",&recPoints);
138     Int_t nModules;
139     fITS->InitModules(-1,nModules);
140
141 // load hits into modules
142     for (Int_t iFile = 0; iFile < fManager->GetNinputs(); iFile++){
143         AliRunLoader* rl = AliRunLoader::GetRunLoader(
144                                        fManager->GetInputFolderName(iFile));
145         if (rl == 0x0){
146             Error("Exec","Can not find Run Loader in input %d folder.",iFile);
147             return;
148         }
149
150         AliLoader* gime = rl->GetLoader("ITSLoader");
151         if (gime == 0x0){
152             Error("Exec","Can not get TOF Loader from Input %d Run Loader.",
153                   iFile);
154             return;
155         }
156
157         gime->LoadHits();
158         fITS->FillModules(gime->TreeH(),fManager->GetMask(iFile));
159         gime->UnloadHits();
160     }
161   
162 // transform hits to fast rec points
163
164     AliITSgeom *geom = fITS->GetITSgeom();
165     for(Int_t moduleIndex = 0; moduleIndex<geom->GetIndexMax(); moduleIndex++){
166         sim->CreateFastRecPoints(moduleIndex,recPoints);
167         outputTreeR->Fill();
168         recPoints->Clear();
169     }
170     outrl->WriteRecPoints("OVERWRITE");
171 //  outputTreeR->AutoSave();
172 }
173 ////////////////////////////////////////////////////////////////////////