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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////
18 //Piotr.Skowronski@cern.ch : //
19 //Corrections applied in order to compile (only) //
20 // with new I/O and folder structure //
21 //To be implemented correctly by responsible //
23 // Class used to steer //
24 // the digitization for ITS //
26 ///////////////////////////////////////////////////////////////////////////
29 #include <TClonesArray.h>
34 #include "AliRunLoader.h"
35 #include "AliLoader.h"
37 #include "AliRunDigitizer.h"
38 #include "AliITSDigitizer.h"
39 #include "AliITSgeom.h"
40 #include "AliITSsimulation.h"
42 ClassImp(AliITSDigitizer)
44 //______________________________________________________________________
45 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
46 // Default constructor. Assign fITS since it is never written out from
49 // Option_t * opt Not used
53 // 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.
81 //______________________________________________________________________
82 AliITSDigitizer::AliITSDigitizer(const AliITSDigitizer &/*rec*/):AliDigitizer(/*rec*/){
85 Error("Copy constructor","Copy constructor not allowed");
88 //______________________________________________________________________
89 AliITSDigitizer& AliITSDigitizer::operator=(const AliITSDigitizer& /*source*/){
90 // Assignment operator. This is a function which is not allowed to be
92 Error("operator=","Assignment operator not allowed\n");
96 //______________________________________________________________________
97 AliITSDigitizer::~AliITSDigitizer(){
98 // Default destructor.
100 // Option_t * opt Not used
105 fITS = 0; // don't delete fITS. Done else where.
106 if(fModActive) delete[] fModActive;
108 //______________________________________________________________________
109 Bool_t AliITSDigitizer::Init(){
110 // Initialization. Set up region of interest, if switched on, and
111 // loads ITS and ITSgeom.
119 fInit = kTRUE; // Assume for now init will work.
124 Warning("Init","gAlice not found");
127 fITS = (AliITS *)(gAlice->GetDetector("ITS"));
131 Warning("Init","ITS not found");
133 } else if(fITS->GetITSgeom()){
134 //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl;
135 fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
139 Warning("Init","ITS geometry not found");
142 // fModActive needs to be set to a default all kTRUE value
143 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
146 //______________________________________________________________________
147 void AliITSDigitizer::Exec(Option_t* opt){
148 // Main digitization function.
150 // Option_t * opt list of sub detector to digitize. =0 all.
156 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
158 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
160 if( !det[0] && !det[1] && !det[2] ) all = "All";
162 Int_t nfiles = GetManager()->GetNinputs();
163 Int_t event = GetManager()->GetOutputEventNr();
164 AliITSsimulation *sim = 0;
167 fITS->SetDefaultSimulation();
171 Error("Exec","Init not successful, aborting.");
175 sprintf(name,"%s",fITS->GetName());
177 Int_t size = fITS->GetITSgeom()->GetIndexMax();
178 Int_t module,id,ifiles,mask;
180 Int_t *fl = new Int_t[nfiles];
183 for(id=0;id<nfiles;id++)
186 // just in case fRoiifile!=0.
190 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
192 TString loadname(name);
195 AliRunLoader *inRL = 0x0, *outRL = 0x0;
196 AliLoader *ingime = 0x0, *outgime = 0x0;
198 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
201 Error("Exec","Can not get Output Run Loader");
204 outRL->GetEvent(event);
205 outgime = outRL->GetLoader(loadname);
208 Error("Exec","Can not get Output ITS Loader");
212 outgime->LoadDigits("update");
213 if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
216 fITS->MakeBranchInTreeD(outgime->TreeD());
218 AliDebug(1,"Region of Interest digitization selected");
221 AliDebug(1,"No Region of Interest selected. Digitizing everything");
223 if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts.
225 for(ifiles=0; ifiles<nfiles; ifiles++ )
227 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
228 ingime = inRL->GetLoader(loadname);
229 if (ingime->TreeS() == 0x0) ingime->LoadSDigits();
232 for(module=0; module<size; module++ )
234 if(fModActive && fRoif!=0) if(!fModActive[module]) continue;
235 id = fITS->GetITSgeom()->GetModuleType(module);
236 if(!all && !det[id]) continue;
237 sim = (AliITSsimulation*)fITS->GetSimulationModel(id);
239 Error( "Exec", "The simulation class was not instanciated!" );
242 // Fill the module with the sum of SDigits
243 sim->InitSimulationModule(module, event);
244 //cout << "Module=" << module;
245 for(ifiles=0; ifiles<nfiles; ifiles++ )
247 if(fRoif!=0) if(!fModActive[module]) continue;
249 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
250 ingime = inRL->GetLoader(loadname);
252 TTree *treeS = ingime->TreeS();
253 fITS->SetTreeAddress();
255 if( !(treeS && fITS->GetSDigits()) ) continue;
256 TBranch *brchSDigits = treeS->GetBranch( name );
259 brchSDigits->SetAddress( &sdig );
261 Error( "Exec", "branch ITS not found in TreeS, input file %d ",
264 } // end if brchSDigits
266 mask = GetManager()->GetMask(ifiles);
267 // add summable digits to module
268 brchSDigits->GetEvent( module );
269 lmod = sim->AddSDigitsToModule(sdig,mask);
270 if(fRegionOfInterest && (ifiles==0))
272 fModActive[module] = lmod;
275 //cout << " end ifiles loop" << endl;
276 // Digitize current module sum(SDigits)->Digits
277 sim->FinishSDigitiseModule();
279 // fills all branches - wasted disk space
280 outgime->TreeD()->Fill();
284 outgime->TreeD()->AutoSave();
285 outgime->WriteDigits("OVERWRITE");
286 outgime->UnloadDigits();
287 for(ifiles=0; ifiles<nfiles; ifiles++ )
289 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
290 ingime = inRL->GetLoader(loadname);
291 ingime->UnloadSDigits();
297 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
302 //______________________________________________________________________
303 void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
304 // Scans through the ITS branch of the SDigits tree, ts, for modules
305 // which have SDigits in them. For these modules, a flag is set to
306 // digitize only these modules. The value of fRoif determines how many
307 // neighboring modules will also be turned on. fRoif=0 will turn on only
308 // those modules with SDigits in them. fRoif=1 will turn on, in addition,
309 // those modules that are +-1 module from the one with the SDigits. And
310 // So on. This last feature is not supported yet.
312 // TTree *ts The tree in which the existing SDigits will define the
313 // region of interest.
322 TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
323 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
324 //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
327 brchSDigits->SetAddress( &sdig );
329 Error( "SetByRegionOfInterest","branch ITS not found in TreeS");
331 } // end if brchSDigits
333 nm = fITS->GetITSgeom()->GetIndexMax();
335 //cout << " fModActive["<<m<<"]=";
336 fModActive[m] = kFALSE; // Not active by default
338 brchSDigits->GetEvent(m);
339 if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){
340 // activate the necessary modules
341 if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal.
342 fModActive[m] = kTRUE;
345 } // end if. end for i.
346 //cout << fModActive[m];
349 AliDebug(1,"Digitization by Region of Interest selected");