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>
36 #include <AliRunDigitizer.h>
37 #include "AliITSDigitizer.h"
38 #include "AliITSgeom.h"
39 #include "AliITSsimulation.h"
41 ClassImp(AliITSDigitizer)
43 //______________________________________________________________________
44 AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
45 // Default constructor. Assign fITS since it is never written out from
48 // Option_t * opt Not used
52 // A blank AliITSDigitizer class.
61 //______________________________________________________________________
62 AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
63 // Standard constructor. Assign fITS since it is never written out from
66 // Option_t * opt Not used
70 // An AliItSDigitizer class.
80 //______________________________________________________________________
81 AliITSDigitizer::AliITSDigitizer(const AliITSDigitizer &/*rec*/):AliDigitizer(/*rec*/){
84 Error("Copy constructor","Copy constructor not allowed");
87 //______________________________________________________________________
88 AliITSDigitizer& AliITSDigitizer::operator=(const AliITSDigitizer& /*source*/){
89 // Assignment operator. This is a function which is not allowed to be
91 Error("operator=","Assignment operator not allowed\n");
95 //______________________________________________________________________
96 AliITSDigitizer::~AliITSDigitizer(){
97 // Default destructor.
99 // Option_t * opt Not used
104 fITS = 0; // don't delete fITS. Done else where.
105 if(fModActive) delete[] fModActive;
107 //______________________________________________________________________
108 Bool_t AliITSDigitizer::Init(){
109 // Initialization. Set up region of interest, if switched on, and
110 // loads ITS and ITSgeom.
118 fInit = kTRUE; // Assume for now init will work.
123 Warning("Init","gAlice not found");
126 fITS = (AliITS *)(gAlice->GetDetector("ITS"));
130 Warning("Init","ITS not found");
132 } else if(fITS->GetITSgeom()){
133 //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl;
134 fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()];
138 Warning("Init","ITS geometry not found");
141 // fModActive needs to be set to a default all kTRUE value
142 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
145 //______________________________________________________________________
146 void AliITSDigitizer::Exec(Option_t* opt){
147 // Main digitization function.
149 // Option_t * opt list of sub detector to digitize. =0 all.
155 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
157 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
159 if( !det[0] && !det[1] && !det[2] ) all = "All";
161 Int_t nfiles = GetManager()->GetNinputs();
162 Int_t event = GetManager()->GetOutputEventNr();
163 AliITSsimulation *sim = 0;
166 fITS->SetDefaultSimulation();
170 Error("Exec","Init not successful, aborting.");
174 sprintf(name,"%s",fITS->GetName());
176 Int_t size = fITS->GetITSgeom()->GetIndexMax();
177 Int_t module,id,ifiles,mask;
179 Int_t *fl = new Int_t[nfiles];
182 for(id=0;id<nfiles;id++)
185 // just in case fRoiifile!=0.
189 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
191 TString loadname(name);
194 AliRunLoader *inRL = 0x0, *outRL = 0x0;
195 AliLoader *ingime = 0x0, *outgime = 0x0;
197 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
200 Error("Exec","Can not get Output Run Loader");
203 outRL->GetEvent(event);
204 outgime = outRL->GetLoader(loadname);
207 Error("Exec","Can not get Output ITS Loader");
211 outgime->LoadDigits("update");
212 if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
215 fITS->MakeBranchInTreeD(outgime->TreeD());
216 if(fRoif!=0) Info("AliITSDigitizer","Region of Interest digitization selected");
217 else Info("AliITSDigitizer","No Region of Interest selected. Digitizing everything");
218 //cout <<"fModActive="<<fModActive<<" fRoif="<<fRoif;
219 if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts.
220 //cout <<" fRoif="<<fRoif<<endl;
222 for(ifiles=0; ifiles<nfiles; ifiles++ )
224 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
225 ingime = inRL->GetLoader(loadname);
226 if (ingime->TreeS() == 0x0) ingime->LoadSDigits();
229 for(module=0; module<size; module++ )
231 if(fModActive && fRoif!=0) if(!fModActive[module]) continue;
232 id = fITS->GetITSgeom()->GetModuleType(module);
233 if(!all && !det[id]) continue;
234 sim = (AliITSsimulation*)fITS->GetSimulationModel(id);
236 Error( "Exec", "The simulation class was not instanciated!" );
239 // Fill the module with the sum of SDigits
240 sim->InitSimulationModule(module, event);
241 //cout << "Module=" << module;
242 for(ifiles=0; ifiles<nfiles; ifiles++ )
244 if(fRoif!=0) if(!fModActive[module]) continue;
246 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
247 ingime = inRL->GetLoader(loadname);
249 TTree *treeS = ingime->TreeS();
250 fITS->SetTreeAddress();
252 if( !(treeS && fITS->GetSDigits()) ) continue;
253 TBranch *brchSDigits = treeS->GetBranch( name );
256 brchSDigits->SetAddress( &sdig );
258 Error( "Exec", "branch ITS not found in TreeS, input file %d ",
261 } // end if brchSDigits
263 mask = GetManager()->GetMask(ifiles);
264 // add summable digits to module
265 brchSDigits->GetEvent( module );
266 lmod = sim->AddSDigitsToModule(sdig,mask);
267 if(fRegionOfInterest && (ifiles==0))
269 fModActive[module] = lmod;
272 //cout << " end ifiles loop" << endl;
273 // Digitize current module sum(SDigits)->Digits
274 sim->FinishSDigitiseModule();
276 // fills all branches - wasted disk space
277 outgime->TreeD()->Fill();
281 outgime->TreeD()->AutoSave();
282 outgime->WriteDigits("OVERWRITE");
283 outgime->UnloadDigits();
284 for(ifiles=0; ifiles<nfiles; ifiles++ )
286 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles]));
287 ingime = inRL->GetLoader(loadname);
288 ingime->UnloadSDigits();
294 for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE;
299 //______________________________________________________________________
300 void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){
301 // Scans through the ITS branch of the SDigits tree, ts, for modules
302 // which have SDigits in them. For these modules, a flag is set to
303 // digitize only these modules. The value of fRoif determines how many
304 // neighboring modules will also be turned on. fRoif=0 will turn on only
305 // those modules with SDigits in them. fRoif=1 will turn on, in addition,
306 // those modules that are +-1 module from the one with the SDigits. And
307 // So on. This last feature is not supported yet.
309 // TTree *ts The tree in which the existing SDigits will define the
310 // region of interest.
319 TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
320 TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
321 //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl;
324 brchSDigits->SetAddress( &sdig );
326 Error( "SetByRegionOfInterest","branch ITS not found in TreeS");
328 } // end if brchSDigits
330 nm = fITS->GetITSgeom()->GetIndexMax();
332 //cout << " fModActive["<<m<<"]=";
333 fModActive[m] = kFALSE; // Not active by default
335 brchSDigits->GetEvent(m);
336 if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){
337 // activate the necessary modules
338 if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal.
339 fModActive[m] = kTRUE;
342 } // end if. end for i.
343 //cout << fModActive[m];
346 Info("AliITSDigitizer","Digitization by Region of Interest selected");