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>
79 #include "AliDetector.h"
81 #include "AliITSLoader.h"
82 #include "AliITSULoader.h"
83 #include "AliITSUHit.h"
84 #include "AliITSUSDigit.h"
85 #include "AliITSUSimulation.h"
86 #include "AliITSUSimulationPix.h"
87 #include "AliITSsimulationFastPoints.h"
89 #include "AliITSUDigitizer.h"
90 #include "AliITSRecPoint.h"
91 #include "AliRawReader.h"
94 #include "AliITSdigit.h"
95 #include "AliITSUModule.h"
96 #include "AliITSUDigitPix.h"
97 #include "AliITSsegmentation.h"
98 #include "AliITSUSegmentationPix.h"
99 #include "AliITSUSimuParam.h"
100 #include "AliITSFOSignalsSPD.h"
101 #include "AliITSUParamList.h"
102 #include "AliCDBManager.h" // tmp! Later the simuparam should be loaded centrally
103 #include "AliCDBEntry.h"
105 using namespace TMath;
109 //______________________________________________________________________
131 ,fSimInitDone(kFALSE)
133 // Default initializer for ITS
136 //______________________________________________________________________
137 AliITSU::AliITSU(const Char_t *title, Int_t nlay) :
138 AliDetector("ITS",title)
158 ,fSimInitDone(kFALSE)
160 // The standard Constructor for the ITS class.
161 AliMC* mc = gAlice->GetMCApp();
162 if( mc && mc->GetHitLists() ) {
163 fHits = new TClonesArray("AliITSUHit",100); // from AliDetector
164 mc->AddHitList(fHits);
169 //______________________________________________________________________
172 // Default destructor for ITS.
175 // delete fSimuParam; // provided by the CDBManager
178 for (int i=fNLayers;i--;) { // different layers may use the same simulation model
179 for (int j=i;j--;) if (fSimModelLr[j]==fSimModelLr[i]) fSimModelLr[j] = 0;
180 delete fSimModelLr[i];
182 delete[] fSimModelLr;
185 for (int i=fNLayers;i--;) { // different layers may use the same simulation model
186 for (int j=i;j--;) if (fSegModelLr[j]==fSegModelLr[i]) fSegModelLr[j] = 0;
187 delete fSegModelLr[i];
189 delete[] fSegModelLr;
192 delete[] fResponseLr; // note: the response data is owned by the CDBManager, we don't delete them
194 delete[] fLayerName; // Array of TStrings
197 int nmod = fGeomTGeo ? fGeomTGeo->GetNModules() : 0;
198 if (fModuleHits) fModuleHits->Delete();
201 for(Int_t j=0; j<nmod; j++){
207 if (fpSDigits) { fpSDigits->Delete(); delete fpSDigits; }
208 if (fSDigits) { fSDigits->Delete(); delete fSDigits; }
213 //______________________________________________________________________
214 AliDigitizer* AliITSU::CreateDigitizer(AliDigitizationInput* manager) const
216 // Creates the AliITSDigitizer in a standard way for use via AliModule.
217 // This function can not be included in the .h file because of problems
218 // with the order of inclusion (recursive).
220 // AliDigitizationInput *manager The Manger class for Digitization
224 // A new AliITSRunDigitizer (cast as a AliDigitizer).
226 return new AliITSUDigitizer(manager);
229 //______________________________________________________________________
232 // Initializer ITS after it has been built
233 // This routine initializes the AliITS class. It is intended to be
234 // called from the Init function in AliITSv?. Besides displaying a banner
235 // indicating that it has been called it initializes the array fIdSens
236 // and sets the default segmentation, response, digit and raw cluster
237 // classes therefore it should be called after a call to CreateGeometry.
239 if (!fIdSens) fIdSens = new Int_t[fNLayers];
240 for(int i=0;i<fNLayers;i++) fIdSens[i] = gMC ? gMC->VolId(fLayerName[i]) : 0;
241 fGeomTGeo = new AliITSUGeomTGeo(kTRUE);
246 //______________________________________________________________________
247 void AliITSU::MakeBranch(Option_t* option)
249 // Creates Tree branches for the ITS.
251 // Option_t *option String of Tree types S,D, and/or R.
252 // const char *file String of the file name where these branches
253 // are to be stored. If blank then these branches
254 // are written to the same tree as the Hits were
261 Bool_t cH = (strstr(option,"H")!=0);
262 Bool_t cS = (strstr(option,"S")!=0);
263 Bool_t cD = (strstr(option,"D")!=0);
265 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560);
266 AliDetector::MakeBranch(option);
268 if(cS) MakeBranchS(0);
269 if(cD) MakeBranchD(0);
273 //___________________________________________________________________
274 void AliITSU::MakeBranchS(const char* fl)
276 // Creates Tree Branch for the ITS summable digits.
278 // cont char *fl File name where SDigits branch is to be written
279 // to. If blank it write the SDigits to the same
280 // file in which the Hits were found.
282 Int_t buffersize = 4000;
285 // only one branch for SDigits.
286 snprintf(branchname,30,"%s",GetName());
287 if(fLoader->TreeS()) MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
291 //______________________________________________________________________
292 void AliITSU::MakeBranchD(const char* file)
294 //Make branch for digits
295 MakeBranchInTreeD(fLoader->TreeD(),file);
298 //___________________________________________________________________
299 void AliITSU:: MakeBranchInTreeD(TTree* treeD, const char* file)
301 // Creates Tree branches for the ITS.
303 if (!treeD) {AliFatal("No tree provided");}
304 Int_t buffersize = 4000;
305 if (!fDetDigits) InitArrays();
307 for (Int_t i=0;i<kNDetTypes;i++) {
309 TClonesArray* darr = (TClonesArray*)fDetDigits->At(i);
310 AliDetector::MakeBranchInTree(treeD,Form("%sDigits%s",GetName(),fGeomTGeo->GetDetTypeName(i)),
311 &darr,buffersize,file);
316 //______________________________________________________________________
317 void AliITSU::InitArrays()
321 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
323 fDetDigits = new TObjArray(kNDetTypes);
324 for (Int_t i=0;i<kNDetTypes;i++) fDetDigits->AddAt(new TClonesArray(GetDigitClassName(i),100),i);
326 fSDigits = new TClonesArray("AliITSUSDigit",100);
328 fDetHits = new TClonesArray("AliITSUHit",100);
330 fModuleHits = new TObjArray(fGeomTGeo->GetNModules());
331 for (int i=0;i<fGeomTGeo->GetNModules();i++) fModuleHits->AddLast( new AliITSUModule(i,fGeomTGeo) );
335 //______________________________________________________________________
336 void AliITSU::SetTreeAddress()
338 // Set branch address for the Trees.
339 TTree *treeS = fLoader->TreeS();
341 TBranch* br = treeS->GetBranch(GetName());
342 if (br) br->SetAddress(&fSDigits);
345 TTree *treeD = fLoader->TreeD();
347 if (!fDetDigits) InitArrays();
348 for (int i=0;i<kNDetTypes;i++) {
349 TString brname = Form("%sDigits%s",GetName(),GetDetTypeName(i));
350 TBranch* br = treeD->GetBranch(brname.Data());
352 TClonesArray* darr = (TClonesArray*)fDetDigits->At(i);
353 br->SetAddress(&darr);
356 if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560);
357 AliDetector::SetTreeAddress();
361 //______________________________________________________________________
362 void AliITSU::AddHit(Int_t track, Int_t *vol, Float_t *hits)
365 // The function to add information to the AliITSUHit class. See the
366 // AliITSUHit class for a full description. This function allocates the
367 // necessary new space for the hit information and passes the variable
368 // track, and the pointers *vol and *hits to the AliITSUHit constructor
371 // Int_t track Track number which produced this hit.
372 // Int_t *vol Array of Integer Hit information. See AliITSUHit.h
373 // Float_t *hits Array of Floating Hit information. see AliITSUHit.h
374 TClonesArray &lhits = *fHits;
375 new(lhits[fNhits++]) AliITSUHit(fIshunt,track,vol,hits);
379 //______________________________________________________________________
380 void AliITSU::FillModules(Int_t bgrev, Option_t *option, const char *filename)
382 // fill the modules with the sorted by module hits; add hits from
383 // background if option=Add.
385 static TTree *trH1=0; //Tree with background hits
386 static Bool_t first=kTRUE;
387 static TFile *file = 0;
388 const char *addBgr = strstr(option,"Add");
392 file = new TFile(filename);
397 // Get Hits Tree header from file
398 if (trH1) {delete trH1; trH1=0;}
401 snprintf(treeName,20,"TreeH%d",bgrev);
402 trH1 = (TTree*)gDirectory->Get(treeName);
403 if (!trH1) Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
404 // Set branch addresses
407 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
410 FillModules(trH1,10000000); // Default mask 10M.
411 TTree *fAli=fLoader->GetRunLoader()->TreeK();
414 fileAli = fAli->GetCurrentFile();
421 //______________________________________________________________________
422 void AliITSU::FillModules(TTree *treeH, Int_t /*mask*/)
424 // fill the modules with the sorted by module hits;
425 // can be called many times to do a merging
427 // TTree *treeH The tree containing the hits to be copied into
429 // Int_t mask The track number mask to indecate which file
430 // this hits came from.
432 if (treeH == 0x0) { AliError("Tree H is NULL"); return; }
434 Int_t lay,lad,det,index;
435 AliITSUHit *itsHit=0;
437 snprintf(branchname,20,"%s",GetName());
438 TBranch *branch = treeH->GetBranch(branchname);
439 if (!branch) {Error("FillModules","%s branch in TreeH not found",branchname); return;} // end if !branch
441 branch->SetAddress(&fHits);
442 Int_t nTracks =(Int_t) treeH->GetEntries();
444 for (iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++) {
446 Int_t nBytes = treeH->GetEvent(iPrimTrack);
447 if (nBytes <= 0) continue;
448 Int_t nHits = fHits->GetEntriesFast();
449 for (h=0; h<nHits; h++){
450 itsHit = (AliITSUHit *)fHits->UncheckedAt(h);
451 itsHit->GetDetectorID(lay,lad,det);
452 index = fGeomTGeo->GetModuleIndex(lay,lad,det); // !!! AliITSHit counts indices from 1!
453 itsHit = new( (*fDetHits)[fDetHits->GetEntriesFast()] ) AliITSUHit(*itsHit);
454 itsHit->SetUniqueID(h);
455 GetModule(index)->AddHit(itsHit);
456 // do we need to add a mask?
457 // itsHit->SetTrack(itsHit->GetTrack()+mask);
458 } // end loop over hits
459 } // end loop over tracks
462 //______________________________________________________________________
463 void AliITSU::ClearModules()
465 // clear accumulated hits
466 if (!fModuleHits || !fDetHits) AliFatal("Hits accumulation arrays are not defined");
467 for (int i=fGeomTGeo->GetNModules();i--;) GetModule(i)->Clear();
471 //______________________________________________________________________
472 void AliITSU::Hits2SDigits()
474 // Standard Hits to summable Digits function.
475 if (!IsSimInitDone()) InitSimulation();
476 fLoader->LoadHits("read");
477 fLoader->LoadSDigits("recreate");
478 AliRunLoader* rl = fLoader->GetRunLoader();
480 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
481 rl->GetEvent(iEvent);
482 if (!fLoader->TreeS()) fLoader->MakeTree("S");
485 Hits2SDigits(iEvent,0," "," ");
488 fLoader->UnloadHits();
489 fLoader->UnloadSDigits();
493 //______________________________________________________________________
494 void AliITSU::Hits2SDigits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename)
496 // Keep galice.root for signal and name differently the file for
497 // background when add! otherwise the track info for signal will be lost !
499 // Int_t evnt Event to be processed.
500 // Int_t bgrev Background Hit tree number.
501 // Int_t nmodules Not used.
502 // Option_t *option String indicating if merging hits or not. To
503 // merge hits set equal to "Add". Otherwise no
504 // background hits are considered.
505 // Test_t *filename File name containing the background hits..
507 if (!IsSimInitDone()) InitSimulation();
508 FillModules(bgrev,option,filename);
510 Int_t nmodules = fGeomTGeo->GetNModules();
512 float roPhase=0; // synchronysation type between layers/modules
513 Bool_t randomyzeModules = kFALSE; // do we need to randomize layers
515 for(int module=0;module<nmodules;module++) {
516 int lr = fGeomTGeo->GetLayer(module);
517 AliITSUSimulation* sim = GetSimulationModel(lr);
518 sim->InitSimulationModule(GetModule(module),evNumber/*,gAlice->GetEvNumber()*/,GetSegmentation(lr),GetResponseParam(lr));
520 if (prevLr!=lr) { // new layer started)
521 roPhase = fSimuParam->GetLrROCycleShift(lr);
522 if (Abs(roPhase)<1.) roPhase = roPhase*sim->GetReadOutCycleLength(); // modules synchronized within layer with this offset
523 else randomyzeModules = kTRUE; // modules have random offset
525 if (randomyzeModules) sim->GenerateReadOutCycleOffset();
526 else sim->SetReadOutCycleOffset(roPhase);
528 sim->SDigitiseModule();
529 fLoader->TreeS()->Fill(); // fills all branches - wasted disk space
536 fLoader->TreeS()->GetEntries();
537 fLoader->TreeS()->AutoSave();
538 fLoader->WriteSDigits("OVERWRITE");
539 fLoader->TreeS()->Reset();
542 //______________________________________________________________________
543 void AliITSU::Hits2Digits()
545 // Standard Hits to Digits function.
546 if (!IsSimInitDone()) InitSimulation();
547 fLoader->LoadHits("read");
548 fLoader->LoadDigits("recreate");
549 AliRunLoader* rl = fLoader->GetRunLoader();
551 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
552 rl->GetEvent(iEvent);
553 if (!fLoader->TreeS()) fLoader->MakeTree("S");
556 Hits2Digits(iEvent,0," "," ");
559 fLoader->UnloadHits();
560 fLoader->UnloadSDigits();
564 //______________________________________________________________________
565 void AliITSU::Hits2Digits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename)
567 // Keep galice.root for signal and name differently the file for
568 // background when add! otherwise the track info for signal will be lost !
570 // Int_t evnt Event to be processed.
571 // Int_t bgrev Background Hit tree number.
572 // Option_t *option String indicating if merging hits or not. To
573 // merge hits set equal to "Add". Otherwise no
574 // background hits are considered.
575 // Test_t *filename File name containing the background hits..
578 if (!IsSimInitDone()) InitSimulation();
579 FillModules(bgrev,option,filename);
581 Int_t nmodules = fGeomTGeo->GetNModules();
583 float roPhase=0; // synchronysation type between layers/modules
584 Bool_t randomyzeModules = kFALSE; // do we need to randomize layers
586 for (Int_t module=0;module<nmodules;module++) {
587 int lr = fGeomTGeo->GetLayer(module);
588 AliITSUSimulation* sim = GetSimulationModel(lr);
590 sim->InitSimulationModule(GetModule(module),evNumber/*gAlice->GetEvNumber()*/,GetSegmentation(lr),GetResponseParam(lr));
591 if (prevLr!=lr) { // new layer started)
592 roPhase = fSimuParam->GetLrROCycleShift(lr);
593 if (Abs(roPhase)<1.) roPhase = roPhase*sim->GenerateReadOutCycleOffset(); // modules synchronized within layer with this offset
594 else randomyzeModules = kTRUE; // modules have random offset
596 if (randomyzeModules) sim->GenerateReadOutCycleOffset();
597 else sim->SetReadOutCycleOffset(roPhase);
598 sim->DigitiseModule();
599 // fills all branches - wasted disk space
600 fLoader->TreeD()->Fill();
607 // WriteFOSignals(); // Add Fast-OR signals to event (only one object per event)
608 fLoader->TreeD()->GetEntries();
609 fLoader->TreeD()->AutoSave();
610 fLoader->TreeD()->Reset();
614 //_____________________________________________________________________
615 void AliITSU::Hits2FastRecPoints(Int_t bgrev,Option_t *opt,const char *flnm)
617 // keep galice.root for signal and name differently the file for
618 // background when add! otherwise the track info for signal will be lost !
620 // Int_t evnt Event to be processed.
621 // Int_t bgrev Background Hit tree number.
622 // Option_t *opt Option passed to FillModules. See FillModules.
623 // Test_t *flnm File name containing the background hits..
628 if (!IsSimInitDone()) InitSimulation();
629 AliITSULoader *pITSloader = (AliITSULoader*)fLoader;
630 Int_t nmodules = fGeomTGeo->GetNModules();
631 FillModules(bgrev,opt,flnm);
633 TTree *lTR = pITSloader->TreeR();
635 pITSloader->MakeTree("R");
636 lTR = pITSloader->TreeR();
639 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
640 TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
641 branch->SetAddress(&ptarray);
642 for (int module=0;module<nmodules;module++){
643 int id = fGeomTGeo->GetModuleDetTypeID(module);
644 AliITSUSimulation* sim = GetSimulationModel(id);
645 if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id));
646 sim->CreateFastRecPoints( GetModule(module) ,module,gRandom,ptarray);
652 fLoader->WriteRecPoints("OVERWRITE");
656 //_____________________________________________________________________
657 Int_t AliITSU::Hits2Clusters(TTree */*hTree*/, TTree */*cTree*/)
660 // This function creates ITS clusters
661 if (!IsSimInitDone()) InitSimulation();
663 FillModules(hTree,0);
665 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
666 TBranch *branch=cTree->GetBranch("ITSRecPoints");
667 if (!branch) cTree->Branch("ITSRecPoints",&points);
668 else branch->SetAddress(&points);
670 AliITSsimulationFastPoints sim;
672 for (Int_t m=0; m<mmax; m++) {
673 sim.CreateFastRecPoints(GetModule(m),m,gRandom,points);
674 ncl+=points->GetEntriesFast();
681 AliDebug(1,Form("Number of found fast clusters : %d",ncl));
688 //_____________________________________________________________________
689 void AliITSU::CheckLabels(Int_t lab[3]) const //RSDONE
691 // Tries to find mother's labels
693 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
695 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
696 for (Int_t i=0;i<3;i++){
697 Int_t label = lab[i];
698 if (label>=0 && label<ntracks) {
699 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
700 if (part->P() < 0.005) {
701 Int_t m=part->GetFirstMother();
703 if (part->GetStatusCode()>0) continue;
711 //______________________________________________________________________
712 void AliITSU::ResetDigits() //RSDONE?
714 // Reset number of digits and the digits array for the ITS detector.
715 if (fDetDigits) for (int i=kNDetTypes;i--;) ResetDigits(i);
719 //______________________________________________________________________
720 void AliITSU::ResetDigits(Int_t branch)
722 // Reset number of digits and the digits array for this branch.
723 if (fDetDigits) ((TClonesArray*)fDetDigits->At(branch))->Clear();
727 //______________________________________________________________________
728 void AliITSU::AddSumDigit(AliITSUSDigit &sdig)
730 // Adds the module summable digits to the summable digits tree.
731 new( (*fSDigits)[fSDigits->GetEntriesFast()]) AliITSUSDigit(sdig);
735 //______________________________________________________________________
736 void AliITSU::AddSimDigit(Int_t branch, AliITSdigit *d)
738 // Add a simulated digit.
740 // Int_t id Detector type number.
741 // AliITSdigit *d Digit to be added to the Digits Tree. See
743 TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch));
744 int nd = ldigits.GetEntriesFast();
746 case AliITSUGeomTGeo::kDetTypePix:
747 new(ldigits[nd]) AliITSUDigitPix(*((AliITSUDigitPix*)d));
750 AliFatal(Form("Unknown digits branch %d",branch));
754 //______________________________________________________________________
755 void AliITSU::AddSimDigit(Int_t branch,Float_t /*phys*/,Int_t *digits,Int_t *tracks,
756 Int_t *hits,Float_t */*charges*/, Int_t /*sigexpanded*/)
758 // Add a simulated digit to the list.
760 // Int_t id Detector type number.
761 // Float_t phys Physics indicator. See AliITSdigits.h
762 // Int_t *digits Integer array containing the digits info. See
764 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
765 // containing the track numbers that contributed to
767 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
768 // containing the hit numbers, from AliITSmodule, that
769 // contributed to this digit.
770 // Float_t *charge Floating point array of the signals contributed
771 // to this digit by each track.
772 TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch));
773 int nd = ldigits.GetEntriesFast();
775 case AliITSUGeomTGeo::kDetTypePix:
776 new(ldigits[nd]) AliITSUDigitPix(digits,tracks,hits);
779 AliFatal(Form("Unknown digits branch %d",branch));
784 //______________________________________________________________________
785 void AliITSU::Digits2Raw()
787 AliError("Not ready");
790 //______________________________________________________________________
791 AliLoader* AliITSU::MakeLoader(const char* topfoldername)
793 //builds ITSgetter (AliLoader type)
794 //if detector wants to use castomized getter, it must overload this method
796 AliDebug(1,Form("Creating AliITSULoader. Top folder is %s.",topfoldername));
797 fLoader = new AliITSULoader(GetName(),topfoldername);
801 //______________________________________________________________________
802 Bool_t AliITSU::Raw2SDigits(AliRawReader* /*rawReader*/)
804 AliError("Not ready");
808 //______________________________________________________________________
810 AliTriggerDetector* AliITSU::CreateTriggerDetector() const
812 // create an AliITSTrigger object (and set trigger conditions as input)
813 return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
817 //______________________________________________________________________
818 void AliITSU::WriteFOSignals()
820 // This method write FO signals in Digits tree both in Hits2Digits
822 AliError("Not ready");
823 // fDetTypeSim->ProcessNoiseForFastOr();
826 //_______________________________________________________________________
827 void AliITSU::SDigits2Digits()
829 // Standard Summable digits to Digits function.
831 if (!IsSimInitDone()) InitSimulation();
832 TTree* trees = fLoader->TreeS();
833 if( !(trees && fSDigits) ) AliFatal("Error: No trees or SDigits.");
834 TBranch* brchSDigits = trees->GetBranch(GetName());
836 int nmodules = fGeomTGeo->GetNModules();
838 float roPhase=0; // synchronysation type between layers/modules
839 Bool_t randomyzeModules = kFALSE; // do we need to randomize layers
841 for (int module=0;module<nmodules;module++) {
842 int lr = fGeomTGeo->GetLayer(module);
843 AliITSUSimulation* sim = GetSimulationModel(lr);
844 sim->InitSimulationModule(GetModule(module),gAlice->GetEvNumber(),GetSegmentation(lr),GetResponseParam(lr));
846 if (prevLr!=lr) { // new layer started)
847 roPhase = fSimuParam->GetLrROCycleShift(lr);
848 if (Abs(roPhase)<1.) roPhase = roPhase*sim->GenerateReadOutCycleOffset(); // modules synchronized within layer with this offset
849 else randomyzeModules = kTRUE; // modules have random offset
851 if (randomyzeModules) sim->GenerateReadOutCycleOffset();
852 else sim->SetReadOutCycleOffset(roPhase);
855 brchSDigits->GetEvent(module);
856 sim->AddSDigitsToModule(fSDigits,0);
857 sim->FinishSDigitiseModule();
858 fLoader->TreeD()->Fill();
863 fLoader->TreeD()->GetEntries();
864 fLoader->TreeD()->AutoSave();
865 fLoader->TreeD()->Reset();
868 //_______________________________________________________________________
869 void AliITSU::InitSimulation()
871 // Initialize arrays, segmentations ets, needed for simulation
872 // Equivalent of old AliITSDetTypeSim construction
874 if (fSimInitDone) {AliInfo("Already done"); return;}
876 AliCDBEntry* cdbEnt = AliCDBManager::Instance()->Get("ITS/Calib/SimuParam"); // tmp: load it centrally
877 if (!cdbEnt) {AliFatal("Failed to find ITS/Calib/SimuParam on CDB"); exit(1);}
878 fSimuParam = (AliITSUSimuParam*)cdbEnt->GetObject();
880 fSensMap = new AliITSUSensMap("AliITSUSDigit",0,0);
881 fSimModelLr = new AliITSUSimulation*[fNLayers];
882 fSegModelLr = new AliITSsegmentation*[fNLayers];
883 fResponseLr = new AliITSUParamList*[fNLayers];
886 AliITSUSegmentationPix::LoadSegmentations(&arrSeg, AliITSUGeomTGeo::GetITSsegmentationFileName());
888 // add known simulation types used in the setup
889 for (int i=fNLayers;i--;) {
893 int dType = fGeomTGeo->GetLayerDetTypeID(i); // fine detector type: class + segmentation
894 int sType = dType/AliITSUGeomTGeo::kMaxSegmPerDetType; // detector simulation class
896 // check if the simulation of this sType was already created for preceeding layers
897 AliITSUSimulation* simUpg = 0;
898 for (int j=fNLayers-1;j>i;j--) {
899 simUpg = GetSimulationModel(j);
900 if (simUpg && int(simUpg->GetUniqueID())==sType) break;
904 if (!simUpg) { // need to create simulation for detector class sType
907 case AliITSUGeomTGeo::kDetTypePix :
908 simUpg = new AliITSUSimulationPix(fSimuParam,fSensMap);
910 default: AliFatal(Form("No %d detector type is defined",sType));
913 fSimModelLr[i] = simUpg;
915 // add segmentations used in the setup
916 if (!(fSegModelLr[i]=(AliITSsegmentation*)arrSeg[dType])) {AliFatal(Form("Segmentation for DetType#%d is not found",dType)); exit(1);}
918 // add response function for the detectors of this layer
919 if ( !(fResponseLr[i]=(AliITSUParamList*)fSimuParam->FindRespFunParams(dType)) ) {AliFatal(Form("Response for DetType#%d is not found in SimuParams",dType)); exit(1);}
921 // delete non needed segmentations
922 for (int i=fNLayers;i--;) arrSeg.Remove(fSegModelLr[i]);
927 fSimInitDone = kTRUE;