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 //Piotr.Skowronski@cern.ch :
19 //Corrections applied in order to compile (only) with new I/O and folder structure
20 //To be implemented correctly by responsible
22 // Class used to steer
23 // the digitization for ITS
28 #include <Riostream.h>
29 #include <TClonesArray.h>
34 #include <AliRunLoader.h>
35 #include <AliLoader.h>
36 #include <AliRunDigitizer.h>
37 #include "AliITSDigitizer.h"
38 #include "AliITSpList.h"
39 #include "AliITSgeom.h"
40 #include "AliITSsimulation.h"
41 #include "AliITSDetType.h"
43 ClassImp(AliITSDigitizer)
45 //______________________________________________________________________
46 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
47 // Default constructor. Assign fITS since it is never written out from
50 // Option_t * opt Not used
54 // 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.
79 //______________________________________________________________________
80 AliITSDigitizer::~AliITSDigitizer(){
81 // Default destructor.
83 // Option_t * opt Not used
89 fITS = 0; // don't delete fITS. Done else where.
90 if(fModActive) delete[] fModActive;
92 //______________________________________________________________________
93 Bool_t AliITSDigitizer::Init(){
94 // Initialization. Set up region of interest, if switched on, and
95 // loads ITS and ITSgeom.
103 fInit = kTRUE; // Assume for now init will work.
108 Warning("Init","gAlice not found");
111 fITS = (AliITS *)(gAlice->GetDetector("ITS"));
115 Warning("Init","ITS not found");
117 } else if(fITS->GetITSgeom()){
118 //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl;
119 fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
123 Warning("Init","ITS geometry not found");
126 // fModActive needs to be set to a default all kTRUE value
127 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
130 //______________________________________________________________________
131 void AliITSDigitizer::Exec(Option_t* opt){
132 // Main digitization function.
134 // Option_t * opt list of sub detector to digitize. =0 all.
140 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
142 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
144 if( !det[0] && !det[1] && !det[2] ) all = "All";
146 AliITSsimulation *sim = 0;
147 AliITSDetType *iDetType = 0;
148 static Bool_t setDef = kTRUE;
151 Error("Exec","Init not succesfull, aborting.");
155 if( setDef ) fITS->SetDefaultSimulation();
157 sprintf(name,"%s",fITS->GetName());
159 Int_t nfiles = GetManager()->GetNinputs();
160 Int_t event = GetManager()->GetOutputEventNr();
161 Int_t size = fITS->GetITSgeom()->GetIndexMax();
162 Int_t module,id,ifiles,mask;
164 Int_t *fl = new Int_t[nfiles];
167 for(id=0;id<nfiles;id++)
170 // just in case fRoiifile!=0.
174 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
176 TString loadname(name);
179 AliRunLoader *inRL = 0x0, *outRL = 0x0;
180 AliLoader *ingime = 0x0, *outgime = 0x0;
182 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
185 Error("Exec","Can not get Output Run Loader");
188 outRL->GetEvent(event);
189 outgime = outRL->GetLoader(loadname);
192 Error("Exec","Can not get Output ITS Loader");
195 outgime->LoadDigits("update");
196 if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
199 fITS->MakeBranchInTreeD(outgime->TreeD());
200 if(fRoif!=0) Info("AliITSDigitizer","Region of Interest digitization selected");
201 else Info("AliITSDigitizer","No Region of Interest selected. Digitizing everything");
202 //cout <<"fModActive="<<fModActive<<" fRoif="<<fRoif;
203 if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts.
204 //cout <<" fRoif="<<fRoif<<endl;
206 for(ifiles=0; ifiles<nfiles; ifiles++ )
208 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
209 ingime = inRL->GetLoader(loadname);
210 if (ingime->TreeS() == 0x0) ingime->LoadSDigits();
213 for(module=0; module<size; module++ )
215 if(fModActive && fRoif!=0) if(!fModActive[module]) continue;
216 id = fITS->GetITSgeom()->GetModuleType(module);
217 if(!all && !det[id]) continue;
218 iDetType = fITS->DetType( id );
220 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
222 Error( "Exec", "The simulation class was not instanciated!" );
226 // Fill the module with the sum of SDigits
227 sim->InitSimulationModule(module, event);
228 //cout << "Module=" << module;
229 for(ifiles=0; ifiles<nfiles; ifiles++ )
231 if(fRoif!=0) if(!fModActive[module]) continue;
233 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
234 ingime = inRL->GetLoader(loadname);
236 TTree *treeS = ingime->TreeS();
237 fITS->SetTreeAddress();
239 if( !(treeS && fITS->GetSDigits()) ) continue;
240 TBranch *brchSDigits = treeS->GetBranch( name );
243 brchSDigits->SetAddress( &sdig );
245 Error( "Exec", "branch ITS not found in TreeS, input file %d ",
248 } // end if brchSDigits
250 mask = GetManager()->GetMask(ifiles);
251 // add summable digits to module
252 brchSDigits->GetEvent( module );
253 lmod = sim->AddSDigitsToModule(sdig,mask);
256 fModActive[module] = lmod;
259 //cout << " end ifiles loop" << endl;
260 // Digitize current module sum(SDigits)->Digits
261 sim->FinishSDigitiseModule();
263 // fills all branches - wasted disk space
264 outgime->TreeD()->Fill();
268 outgime->TreeD()->AutoSave();
269 outgime->WriteDigits("OVERWRITE");
270 outgime->UnloadDigits();
272 for(ifiles=0; ifiles<nfiles; ifiles++ )
274 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
275 ingime = inRL->GetLoader(loadname);
276 ingime->UnloadSDigits();
282 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
285 //______________________________________________________________________
286 void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
287 // Scans through the ITS branch of the SDigits tree, ts, for modules
288 // which have SDigits in them. For these modules, a flag is set to
289 // digitize only these modules. The value of fRoif determines how many
290 // neighboring modules will also be turned on. fRoif=0 will turn on only
291 // those modules with SDigits in them. fRoif=1 will turn on, in addition,
292 // those modules that are +-1 module from the one with the SDigits. And
293 // So on. This last feature is not supported yet.
295 // TTree *ts The tree in which the existing SDigits will define the
296 // region of interest.
305 TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
306 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
307 //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
310 brchSDigits->SetAddress( &sdig );
312 Error( "SetByRegionOfInterest","branch ITS not found in TreeS");
314 } // end if brchSDigits
316 nm = fITS->GetITSgeom()->GetIndexMax();
318 //cout << " fModActive["<<m<<"]=";
319 fModActive[m] = kFALSE; // Not active by default
321 brchSDigits->GetEvent(m);
322 if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){
323 // activate the necessary modules
324 if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal.
325 fModActive[m] = kTRUE;
328 } // end if. end for i.
329 //cout << fModActive[m];
332 Info("AliITSDigitizer","Digitization by Region of Interest selected");