4 /**************************************************************************
5 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * Author: The ALICE Off-line Project. *
8 * Contributors are mentioned in the code where appropriate. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /* $Id: AliITSU.cxx $ */
22 ///////////////////////////////////////////////////////////////////////////////
24 // An overview of the basic philosophy of the ITS code development //
25 // and analysis is show in the figure below. //
28 <img src="picts/ITS/ITS_Analysis_schema.gif">
31 <font size=+2 color=red>
32 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
33 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
39 // AliITSU. Inner Traking System base class.
40 // This class contains the base procedures for the Inner Tracking System
44 <img src="picts/ITS/AliITS_Class_Diagram.gif">
47 <font size=+2 color=red>
48 <p>This show the class diagram of the different elements that are part of
56 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
59 // Modified and documented by Bjorn S. Nilsen
63 // Modified and documented by A. Bologna
66 // AliITSU is the general base class for the ITS. Also see AliDetector for
67 // futher information.
69 ///////////////////////////////////////////////////////////////////////////////
72 #include <TClonesArray.h>
74 #include <TParticle.h>
77 #include <TVirtualMC.h>
78 #include "AliDetector.h"
80 #include "AliITSLoader.h"
81 #include "AliITSULoader.h"
82 #include "AliITSUHit.h"
83 #include "AliITSUSDigit.h"
84 #include "AliITSUSimulation.h"
85 #include "AliITSUSimulationPix.h"
86 #include "AliITSsimulationFastPoints.h"
88 #include "AliITSUDigitizer.h"
89 #include "AliITSRecPoint.h"
90 #include "AliRawReader.h"
93 #include "AliITSdigit.h"
94 #include "AliITSUModule.h"
95 #include "AliITSUDigitPix.h"
96 #include "AliITSsegmentation.h"
97 #include "AliITSUSegmentationPix.h"
98 #include "AliITSUSimuParam.h"
99 #include "AliITSFOSignalsSPD.h"
100 #include "AliITSUParamList.h"
101 #include "AliCDBManager.h" // tmp! Later the simuparam should be loaded centrally
102 #include "AliCDBEntry.h"
106 //______________________________________________________________________
128 ,fSimInitDone(kFALSE)
130 // Default initializer for ITS
133 //______________________________________________________________________
134 AliITSU::AliITSU(const Char_t *title, Int_t nlay) :
135 AliDetector("ITS",title)
155 ,fSimInitDone(kFALSE)
157 // The standard Constructor for the ITS class.
158 AliMC* mc = gAlice->GetMCApp();
159 if( mc && mc->GetHitLists() ) {
160 fHits = new TClonesArray("AliITSUHit",100); // from AliDetector
161 mc->AddHitList(fHits);
166 //______________________________________________________________________
169 // Default destructor for ITS.
172 // delete fSimuParam; // provided by the CDBManager
175 for (int i=fNLayers;i--;) { // different layers may use the same simulation model
176 for (int j=i;j--;) if (fSimModelLr[j]==fSimModelLr[i]) fSimModelLr[j] = 0;
177 delete fSimModelLr[i];
179 delete[] fSimModelLr;
182 for (int i=fNLayers;i--;) { // different layers may use the same simulation model
183 for (int j=i;j--;) if (fSegModelLr[j]==fSegModelLr[i]) fSegModelLr[j] = 0;
184 delete fSegModelLr[i];
186 delete[] fSegModelLr;
189 delete fResponseLr; // note: the response data is owned by the CDBManager, we don't delete them
191 delete[] fLayerName; // Array of TStrings
194 int nmod = fGeomTGeo ? fGeomTGeo->GetNModules() : 0;
195 if (fModuleHits) fModuleHits->Delete();
198 for(Int_t j=0; j<nmod; j++){
204 if (fpSDigits) { fpSDigits->Delete(); delete fpSDigits; }
205 if (fSDigits) { fSDigits->Delete(); delete fSDigits; }
210 //______________________________________________________________________
211 AliDigitizer* AliITSU::CreateDigitizer(AliDigitizationInput* manager) const
213 // Creates the AliITSDigitizer in a standard way for use via AliModule.
214 // This function can not be included in the .h file because of problems
215 // with the order of inclusion (recursive).
217 // AliDigitizationInput *manager The Manger class for Digitization
221 // A new AliITSRunDigitizer (cast as a AliDigitizer).
223 return new AliITSUDigitizer(manager);
226 //______________________________________________________________________
229 // Initializer ITS after it has been built
230 // This routine initializes the AliITS class. It is intended to be
231 // called from the Init function in AliITSv?. Besides displaying a banner
232 // indicating that it has been called it initializes the array fIdSens
233 // and sets the default segmentation, response, digit and raw cluster
234 // classes therefore it should be called after a call to CreateGeometry.
236 if (!fIdSens) fIdSens = new Int_t[fNLayers];
237 for(int i=0;i<fNLayers;i++) fIdSens[i] = gMC ? gMC->VolId(fLayerName[i]) : 0;
238 fGeomTGeo = new AliITSUGeomTGeo(kTRUE);
243 //______________________________________________________________________
244 void AliITSU::MakeBranch(Option_t* option)
246 // Creates Tree branches for the ITS.
248 // Option_t *option String of Tree types S,D, and/or R.
249 // const char *file String of the file name where these branches
250 // are to be stored. If blank then these branches
251 // are written to the same tree as the Hits were
258 Bool_t cH = (strstr(option,"H")!=0);
259 Bool_t cS = (strstr(option,"S")!=0);
260 Bool_t cD = (strstr(option,"D")!=0);
262 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560);
263 AliDetector::MakeBranch(option);
265 if(cS) MakeBranchS(0);
266 if(cD) MakeBranchD(0);
270 //___________________________________________________________________
271 void AliITSU::MakeBranchS(const char* fl)
273 // Creates Tree Branch for the ITS summable digits.
275 // cont char *fl File name where SDigits branch is to be written
276 // to. If blank it write the SDigits to the same
277 // file in which the Hits were found.
279 Int_t buffersize = 4000;
282 // only one branch for SDigits.
283 snprintf(branchname,30,"%s",GetName());
284 if(fLoader->TreeS()) MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
288 //______________________________________________________________________
289 void AliITSU::MakeBranchD(const char* file)
291 //Make branch for digits
292 MakeBranchInTreeD(fLoader->TreeD(),file);
295 //___________________________________________________________________
296 void AliITSU:: MakeBranchInTreeD(TTree* treeD, const char* file)
298 // Creates Tree branches for the ITS.
300 if (!treeD) {AliFatal("No tree provided");}
301 Int_t buffersize = 4000;
302 if (!fDetDigits) InitArrays();
304 for (Int_t i=0;i<kNDetTypes;i++) {
306 TClonesArray* darr = (TClonesArray*)fDetDigits->At(i);
307 AliDetector::MakeBranchInTree(treeD,Form("%sDigits%s",GetName(),fGeomTGeo->GetDetTypeName(i)),
308 &darr,buffersize,file);
313 //______________________________________________________________________
314 void AliITSU::InitArrays()
318 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
320 fDetDigits = new TObjArray(kNDetTypes);
321 for (Int_t i=0;i<kNDetTypes;i++) fDetDigits->AddAt(new TClonesArray(GetDigitClassName(i),100),i);
323 fSDigits = new TClonesArray("AliITSUSDigit",100);
325 fDetHits = new TClonesArray("AliITSUHit",100);
327 fModuleHits = new TObjArray(fGeomTGeo->GetNModules());
328 for (int i=0;i<fGeomTGeo->GetNModules();i++) fModuleHits->AddLast( new AliITSUModule(i,fGeomTGeo) );
332 //______________________________________________________________________
333 void AliITSU::SetTreeAddress()
335 // Set branch address for the Trees.
336 TTree *treeS = fLoader->TreeS();
338 TBranch* br = treeS->GetBranch(GetName());
339 if (br) br->SetAddress(&fSDigits);
342 TTree *treeD = fLoader->TreeD();
344 if (!fDetDigits) InitArrays();
345 for (int i=0;i<kNDetTypes;i++) {
346 TString brname = Form("%sDigits%s",GetName(),GetDetTypeName(i));
347 TBranch* br = treeD->GetBranch(brname.Data());
349 TClonesArray* darr = (TClonesArray*)fDetDigits->At(i);
350 br->SetAddress(&darr);
353 if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560);
354 AliDetector::SetTreeAddress();
358 //______________________________________________________________________
359 void AliITSU::AddHit(Int_t track, Int_t *vol, Float_t *hits)
362 // The function to add information to the AliITSUHit class. See the
363 // AliITSUHit class for a full description. This function allocates the
364 // necessary new space for the hit information and passes the variable
365 // track, and the pointers *vol and *hits to the AliITSUHit constructor
368 // Int_t track Track number which produced this hit.
369 // Int_t *vol Array of Integer Hit information. See AliITSUHit.h
370 // Float_t *hits Array of Floating Hit information. see AliITSUHit.h
371 TClonesArray &lhits = *fHits;
372 new(lhits[fNhits++]) AliITSUHit(fIshunt,track,vol,hits);
376 //______________________________________________________________________
377 void AliITSU::FillModules(Int_t bgrev, Option_t *option, const char *filename)
379 // fill the modules with the sorted by module hits; add hits from
380 // background if option=Add.
382 static TTree *trH1=0; //Tree with background hits
383 static Bool_t first=kTRUE;
384 static TFile *file = 0;
385 const char *addBgr = strstr(option,"Add");
389 file = new TFile(filename);
394 // Get Hits Tree header from file
395 if (trH1) {delete trH1; trH1=0;}
398 snprintf(treeName,20,"TreeH%d",bgrev);
399 trH1 = (TTree*)gDirectory->Get(treeName);
400 if (!trH1) Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
401 // Set branch addresses
404 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
407 FillModules(trH1,10000000); // Default mask 10M.
408 TTree *fAli=fLoader->GetRunLoader()->TreeK();
411 fileAli = fAli->GetCurrentFile();
418 //______________________________________________________________________
419 void AliITSU::FillModules(TTree *treeH, Int_t /*mask*/)
421 // fill the modules with the sorted by module hits;
422 // can be called many times to do a merging
424 // TTree *treeH The tree containing the hits to be copied into
426 // Int_t mask The track number mask to indecate which file
427 // this hits came from.
429 if (treeH == 0x0) { AliError("Tree H is NULL"); return; }
431 Int_t lay,lad,det,index;
432 AliITSUHit *itsHit=0;
434 snprintf(branchname,20,"%s",GetName());
435 TBranch *branch = treeH->GetBranch(branchname);
436 if (!branch) {Error("FillModules","%s branch in TreeH not found",branchname); return;} // end if !branch
438 branch->SetAddress(&fHits);
439 Int_t nTracks =(Int_t) treeH->GetEntries();
441 for (iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++) {
443 Int_t nBytes = treeH->GetEvent(iPrimTrack);
444 if (nBytes <= 0) continue;
445 Int_t nHits = fHits->GetEntriesFast();
446 for (h=0; h<nHits; h++){
447 itsHit = (AliITSUHit *)fHits->UncheckedAt(h);
448 itsHit->GetDetectorID(lay,lad,det);
449 index = fGeomTGeo->GetModuleIndex(lay,lad,det); // !!! AliITSHit counts indices from 1!
450 itsHit = new( (*fDetHits)[fDetHits->GetEntriesFast()] ) AliITSUHit(*itsHit);
451 itsHit->SetUniqueID(h);
452 GetModule(index)->AddHit(itsHit);
453 // do we need to add a mask?
454 // itsHit->SetTrack(itsHit->GetTrack()+mask);
455 } // end loop over hits
456 } // end loop over tracks
459 //______________________________________________________________________
460 void AliITSU::ClearModules()
462 // clear accumulated hits
463 if (!fModuleHits || !fDetHits) AliFatal("Hits accumulation arrays are not defined");
464 for (int i=fGeomTGeo->GetNModules();i--;) GetModule(i)->Clear();
468 //______________________________________________________________________
469 void AliITSU::Hits2SDigits()
471 // Standard Hits to summable Digits function.
472 if (!IsSimInitDone()) InitSimulation();
473 fLoader->LoadHits("read");
474 fLoader->LoadSDigits("recreate");
475 AliRunLoader* rl = fLoader->GetRunLoader();
477 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
478 rl->GetEvent(iEvent);
479 if (!fLoader->TreeS()) fLoader->MakeTree("S");
482 Hits2SDigits(iEvent,0," "," ");
485 fLoader->UnloadHits();
486 fLoader->UnloadSDigits();
490 //______________________________________________________________________
491 void AliITSU::Hits2SDigits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename)
493 // Keep galice.root for signal and name differently the file for
494 // background when add! otherwise the track info for signal will be lost !
496 // Int_t evnt Event to be processed.
497 // Int_t bgrev Background Hit tree number.
498 // Int_t nmodules Not used.
499 // Option_t *option String indicating if merging hits or not. To
500 // merge hits set equal to "Add". Otherwise no
501 // background hits are considered.
502 // Test_t *filename File name containing the background hits..
504 if (!IsSimInitDone()) InitSimulation();
505 FillModules(bgrev,option,filename);
507 Int_t nmodules = fGeomTGeo->GetNModules();
509 for(int module=0;module<nmodules;module++) {
510 int lr = fGeomTGeo->GetLayer(module);
511 AliITSUSimulation* sim = GetSimulationModel(lr);
512 sim->InitSimulationModule(GetModule(module),evNumber/*,gAlice->GetEvNumber()*/,GetSegmentation(lr),GetResponseParam(lr));
513 sim->SDigitiseModule();
514 fLoader->TreeS()->Fill(); // fills all branches - wasted disk space
520 fLoader->TreeS()->GetEntries();
521 fLoader->TreeS()->AutoSave();
522 fLoader->WriteSDigits("OVERWRITE");
523 fLoader->TreeS()->Reset();
526 //______________________________________________________________________
527 void AliITSU::Hits2Digits()
529 // Standard Hits to Digits function.
530 if (!IsSimInitDone()) InitSimulation();
531 fLoader->LoadHits("read");
532 fLoader->LoadDigits("recreate");
533 AliRunLoader* rl = fLoader->GetRunLoader();
535 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
536 rl->GetEvent(iEvent);
537 if (!fLoader->TreeS()) fLoader->MakeTree("S");
540 Hits2Digits(iEvent,0," "," ");
543 fLoader->UnloadHits();
544 fLoader->UnloadSDigits();
548 //______________________________________________________________________
549 void AliITSU::Hits2Digits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename)
551 // Keep galice.root for signal and name differently the file for
552 // background when add! otherwise the track info for signal will be lost !
554 // Int_t evnt Event to be processed.
555 // Int_t bgrev Background Hit tree number.
556 // Option_t *option String indicating if merging hits or not. To
557 // merge hits set equal to "Add". Otherwise no
558 // background hits are considered.
559 // Test_t *filename File name containing the background hits..
562 if (!IsSimInitDone()) InitSimulation();
563 FillModules(bgrev,option,filename);
565 Int_t nmodules = fGeomTGeo->GetNModules();
566 for (Int_t module=0;module<nmodules;module++) {
567 int lr = fGeomTGeo->GetLayer(module);
568 AliITSUSimulation* sim = GetSimulationModel(lr);
569 sim->InitSimulationModule(GetModule(module),evNumber/*gAlice->GetEvNumber()*/,GetSegmentation(lr),GetResponseParam(lr));
570 sim->DigitiseModule();
571 // fills all branches - wasted disk space
572 fLoader->TreeD()->Fill();
578 // WriteFOSignals(); // Add Fast-OR signals to event (only one object per event)
579 fLoader->TreeD()->GetEntries();
580 fLoader->TreeD()->AutoSave();
581 fLoader->TreeD()->Reset();
585 //_____________________________________________________________________
586 void AliITSU::Hits2FastRecPoints(Int_t bgrev,Option_t *opt,const char *flnm)
588 // keep galice.root for signal and name differently the file for
589 // background when add! otherwise the track info for signal will be lost !
591 // Int_t evnt Event to be processed.
592 // Int_t bgrev Background Hit tree number.
593 // Option_t *opt Option passed to FillModules. See FillModules.
594 // Test_t *flnm File name containing the background hits..
599 if (!IsSimInitDone()) InitSimulation();
600 AliITSULoader *pITSloader = (AliITSULoader*)fLoader;
601 Int_t nmodules = fGeomTGeo->GetNModules();
602 FillModules(bgrev,opt,flnm);
604 TTree *lTR = pITSloader->TreeR();
606 pITSloader->MakeTree("R");
607 lTR = pITSloader->TreeR();
610 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
611 TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
612 branch->SetAddress(&ptarray);
613 for (int module=0;module<nmodules;module++){
614 int id = fGeomTGeo->GetModuleDetTypeID(module);
615 AliITSUSimulation* sim = GetSimulationModel(id);
616 if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id));
617 sim->CreateFastRecPoints( GetModule(module) ,module,gRandom,ptarray);
623 fLoader->WriteRecPoints("OVERWRITE");
627 //_____________________________________________________________________
628 Int_t AliITSU::Hits2Clusters(TTree */*hTree*/, TTree */*cTree*/)
631 // This function creates ITS clusters
632 if (!IsSimInitDone()) InitSimulation();
634 FillModules(hTree,0);
636 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
637 TBranch *branch=cTree->GetBranch("ITSRecPoints");
638 if (!branch) cTree->Branch("ITSRecPoints",&points);
639 else branch->SetAddress(&points);
641 AliITSsimulationFastPoints sim;
643 for (Int_t m=0; m<mmax; m++) {
644 sim.CreateFastRecPoints(GetModule(m),m,gRandom,points);
645 ncl+=points->GetEntriesFast();
652 AliDebug(1,Form("Number of found fast clusters : %d",ncl));
659 //_____________________________________________________________________
660 void AliITSU::CheckLabels(Int_t lab[3]) const //RSDONE
662 // Tries to find mother's labels
664 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
666 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
667 for (Int_t i=0;i<3;i++){
668 Int_t label = lab[i];
669 if (label>=0 && label<ntracks) {
670 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
671 if (part->P() < 0.005) {
672 Int_t m=part->GetFirstMother();
674 if (part->GetStatusCode()>0) continue;
682 //______________________________________________________________________
683 void AliITSU::ResetDigits() //RSDONE?
685 // Reset number of digits and the digits array for the ITS detector.
686 if (fDetDigits) for (int i=kNDetTypes;i--;) ResetDigits(i);
690 //______________________________________________________________________
691 void AliITSU::ResetDigits(Int_t branch)
693 // Reset number of digits and the digits array for this branch.
694 if (fDetDigits) ((TClonesArray*)fDetDigits->At(branch))->Clear();
698 //______________________________________________________________________
699 void AliITSU::AddSumDigit(AliITSUSDigit &sdig)
701 // Adds the module summable digits to the summable digits tree.
702 new( (*fSDigits)[fSDigits->GetEntriesFast()]) AliITSUSDigit(sdig);
706 //______________________________________________________________________
707 void AliITSU::AddSimDigit(Int_t branch, AliITSdigit *d)
709 // Add a simulated digit.
711 // Int_t id Detector type number.
712 // AliITSdigit *d Digit to be added to the Digits Tree. See
714 TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch));
715 int nd = ldigits.GetEntriesFast();
717 case AliITSUGeomTGeo::kDetTypePix:
718 new(ldigits[nd]) AliITSUDigitPix(*((AliITSUDigitPix*)d));
721 AliFatal(Form("Unknown digits branch %d",branch));
725 //______________________________________________________________________
726 void AliITSU::AddSimDigit(Int_t branch,Float_t /*phys*/,Int_t *digits,Int_t *tracks,
727 Int_t *hits,Float_t */*charges*/, Int_t /*sigexpanded*/)
729 // Add a simulated digit to the list.
731 // Int_t id Detector type number.
732 // Float_t phys Physics indicator. See AliITSdigits.h
733 // Int_t *digits Integer array containing the digits info. See
735 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
736 // containing the track numbers that contributed to
738 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
739 // containing the hit numbers, from AliITSmodule, that
740 // contributed to this digit.
741 // Float_t *charge Floating point array of the signals contributed
742 // to this digit by each track.
743 TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch));
744 int nd = ldigits.GetEntriesFast();
746 case AliITSUGeomTGeo::kDetTypePix:
747 new(ldigits[nd]) AliITSUDigitPix(digits,tracks,hits);
750 AliFatal(Form("Unknown digits branch %d",branch));
755 //______________________________________________________________________
756 void AliITSU::Digits2Raw()
758 AliError("Not ready");
761 //______________________________________________________________________
762 AliLoader* AliITSU::MakeLoader(const char* topfoldername)
764 //builds ITSgetter (AliLoader type)
765 //if detector wants to use castomized getter, it must overload this method
767 AliDebug(1,Form("Creating AliITSULoader. Top folder is %s.",topfoldername));
768 fLoader = new AliITSULoader(GetName(),topfoldername);
772 //______________________________________________________________________
773 Bool_t AliITSU::Raw2SDigits(AliRawReader* /*rawReader*/)
775 AliError("Not ready");
779 //______________________________________________________________________
781 AliTriggerDetector* AliITSU::CreateTriggerDetector() const
783 // create an AliITSTrigger object (and set trigger conditions as input)
784 return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
788 //______________________________________________________________________
789 void AliITSU::WriteFOSignals()
791 // This method write FO signals in Digits tree both in Hits2Digits
793 AliError("Not ready");
794 // fDetTypeSim->ProcessNoiseForFastOr();
797 //_______________________________________________________________________
798 void AliITSU::SDigits2Digits()
800 // Standard Summable digits to Digits function.
802 if (!IsSimInitDone()) InitSimulation();
803 TTree* trees = fLoader->TreeS();
804 if( !(trees && fSDigits) ) AliFatal("Error: No trees or SDigits.");
805 TBranch* brchSDigits = trees->GetBranch(GetName());
807 int nmodules = fGeomTGeo->GetNModules();
808 for (int module=0;module<nmodules;module++) {
809 int lr = fGeomTGeo->GetLayer(module);
810 AliITSUSimulation* sim = GetSimulationModel(lr);
811 sim->InitSimulationModule(GetModule(module),gAlice->GetEvNumber(),GetSegmentation(lr),GetResponseParam(lr));
813 brchSDigits->GetEvent(module);
814 sim->AddSDigitsToModule(fSDigits,0);
815 sim->FinishSDigitiseModule();
816 fLoader->TreeD()->Fill();
820 fLoader->TreeD()->GetEntries();
821 fLoader->TreeD()->AutoSave();
822 fLoader->TreeD()->Reset();
825 //_______________________________________________________________________
826 void AliITSU::InitSimulation()
828 // Initialize arrays, segmentations ets, needed for simulation
829 // Equivalent of old AliITSDetTypeSim construction
831 if (fSimInitDone) {AliInfo("Already done"); return;}
833 AliCDBEntry* cdbEnt = AliCDBManager::Instance()->Get("ITS/Calib/SimuParam"); // tmp: load it centrally
834 if (!cdbEnt) {AliFatal("Failed to find ITS/Calib/SimuParam on CDB"); exit(1);}
835 fSimuParam = (AliITSUSimuParam*)cdbEnt->GetObject();
837 fSensMap = new AliITSUSensMap("AliITSUSDigit",0,0);
838 fSimModelLr = new AliITSUSimulation*[fNLayers];
839 fSegModelLr = new AliITSsegmentation*[fNLayers];
840 fResponseLr = new AliITSUParamList*[fNLayers];
843 AliITSUSegmentationPix::LoadSegmentations(&arrSeg, AliITSUGeomTGeo::GetITSsegmentationFileName());
845 // add known simulation types used in the setup
846 for (int i=fNLayers;i--;) {
850 int dType = fGeomTGeo->GetLayerDetTypeID(i); // fine detector type: class + segmentation
851 int sType = dType/AliITSUGeomTGeo::kMaxSegmPerDetType; // detector simulation class
853 // check if the simulation of this sType was already created for preceeding layers
854 AliITSUSimulation* simUpg = 0;
855 for (int j=fNLayers-1;j>i;j--) {
856 simUpg = GetSimulationModel(j);
857 if (simUpg && int(simUpg->GetUniqueID())==sType) break;
861 if (!simUpg) { // need to create simulation for detector class sType
864 case AliITSUGeomTGeo::kDetTypePix :
865 simUpg = new AliITSUSimulationPix(fSimuParam,fSensMap);
867 default: AliFatal(Form("No %d detector type is defined",sType));
870 fSimModelLr[i] = simUpg;
872 // add segmentations used in the setup
873 if (!(fSegModelLr[i]=(AliITSsegmentation*)arrSeg[dType])) {AliFatal(Form("Segmentation for DetType#%d is not found",dType)); exit(1);}
875 // add response function for the detectors of this layer
876 if ( !(fResponseLr[i]=(AliITSUParamList*)fSimuParam->FindRespFunParams(dType)) ) {AliFatal(Form("Response for DetType#%d is not found in SimuParams",dType)); exit(1);}
878 // delete non needed segmentations
879 for (int i=fNLayers;i--;) arrSeg.Remove(fSegModelLr[i]);
884 fSimInitDone = kTRUE;