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 **************************************************************************/
19 ///////////////////////////////////////////////////////////////////////////////
21 // An overview of the basic philosophy of the ITS code development //
22 // and analysis is show in the figure below. //
25 <img src="picts/ITS/ITS_Analysis_schema.gif">
28 <font size=+2 color=red>
29 <p>Roberto Barbera is in charge of the ITS Offline code (1999).
30 <a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
36 // AliITS. Inner Traking System base class.
37 // This class contains the base procedures for the Inner Tracking System
41 <img src="picts/ITS/AliITS_Class_Diagram.gif">
44 <font size=+2 color=red>
45 <p>This show the class diagram of the different elements that are part of
53 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
56 // Modified and documented by Bjorn S. Nilsen
60 // Modified and documented by A. Bologna
63 // AliITS is the general base class for the ITS. Also see AliDetector for
64 // futher information.
66 ///////////////////////////////////////////////////////////////////////////////
69 #include <TClonesArray.h>
71 #include <TParticle.h>
74 #include <TVirtualMC.h>
75 #include "AliDetector.h"
77 #include "AliITSDetTypeSim.h"
78 #include "AliITSDDLRawData.h"
79 #include "AliITSLoader.h"
80 #include "AliITShit.h"
81 #include "AliITSmodule.h"
82 #include "AliITSpListItem.h"
83 #include "AliITSsimulation.h"
84 #include "AliITSsimulationFastPoints.h"
86 #include "AliITSDigitizer.h"
87 #include "AliITSRecPoint.h"
88 #include "AliITSsegmentationSPD.h"
89 #include "AliITSsegmentationSDD.h"
90 #include "AliITSsegmentationSSD.h"
91 #include "AliITSRawStreamSPD.h"
92 #include "AliITSRawStreamSSD.h"
93 #include "AliITSRawStreamSDD.h"
94 #include "AliRawReader.h"
97 #include "AliITSInitGeometry.h"
101 //______________________________________________________________________
102 AliITS::AliITS() : AliDetector(),
112 // Default initializer for ITS
113 // The default constructor of the AliITS class. In addition to
114 // creating the AliITS class it zeros the variables fIshunt (a member
115 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
116 // fIdSens, and fIdName. The AliDetector default constructor
119 // SetDetectors(); // default to fOpt="All". This variable not written out.
120 //PH SetMarkerColor(kRed);
122 //______________________________________________________________________
123 AliITS::AliITS(const Char_t *title):AliDetector("ITS",title),
133 // The standard Constructor for the ITS class.
134 // It also zeros the variables
135 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
136 // the pointers fIdSens and fIdName. To help in displaying hits via the
137 // ROOT macro display.C AliITS also sets the marker color to red. The
138 // variables passes with this constructor, const char *name and *title,
139 // are used by the constructor of AliDetector class. See AliDetector
140 // class for a description of these parameters and its constructor
143 // Char_t *title Simulation title for the ITS
149 fHits = new TClonesArray("AliITShit",1560); // from AliDetector
150 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
151 //fNhits=0; //done in AliDetector(name,title)
152 SetDetectors(); // default to fOpt="All". This variable not written out.
153 fDetTypeSim = new AliITSDetTypeSim();
154 //PH SetMarkerColor(kRed);
155 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
156 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
158 //______________________________________________________________________
159 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title),
169 // The standard Constructor for the ITS class.
170 // It also zeros the variables
171 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
172 // the pointers fIdSens and fIdName. To help in displaying hits via the
173 // ROOT macro display.C AliITS also sets the marker color to red. The
174 // variables passes with this constructor, const char *name and *title,
175 // are used by the constructor of AliDetector class. See AliDetector
176 // class for a description of these parameters and its constructor
179 fHits = new TClonesArray("AliITShit",1560);
180 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
181 //fNhits=0; //done in AliDetector(name,title)
183 SetDetectors(); // default to fOpt="All". This variable not written out.
185 fDetTypeSim = new AliITSDetTypeSim();
187 //PH SetMarkerColor(kRed);
188 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
189 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
192 //______________________________________________________________________
194 // Default destructor for ITS.
195 // The default destructor of the AliITS class. In addition to deleting
196 // the AliITS class it deletes the memory pointed to by
197 // fIdSens, fIdName, fDetTypeSim and it's contents.
211 this->ClearModules();
214 }// end if fITSmodules!=0
216 delete[] fIdName; // Array of TStrings
224 //______________________________________________________________________
225 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
226 // Creates the AliITSDigitizer in a standard way for use via AliModule.
227 // This function can not be included in the .h file because of problems
228 // with the order of inclusion (recursive).
230 // AliRunDigitizer *manager The Manger class for Digitization
234 // A new AliITSRunDigitizer (cast as a AliDigitizer).
236 return new AliITSDigitizer(manager);
238 //______________________________________________________________________
240 // Initializer ITS after it has been built
241 // This routine initializes the AliITS class. It is intended to be
242 // called from the Init function in AliITSv?. Besides displaying a banner
243 // indicating that it has been called it initializes the array fIdSens
244 // and sets the default segmentation, response, digit and raw cluster
245 // classes therefore it should be called after a call to CreateGeometry.
254 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
259 //______________________________________________________________________
260 void AliITS::SetDefaults(){
261 // sets the default segmentation, response, digit and raw cluster classes.
268 AliInfoClass("AliITS::Setting Defaults");
270 Error("SetDefaults()","fDetTypeSim is 0!");
274 fDetTypeSim->SetDefaults();
278 //______________________________________________________________________
279 void AliITS::SetDefaultSimulation(){
280 // sets the default simulation.
288 Error("SetDefaultSimulation()","fDetTypeSim is 0!");
292 fDetTypeSim->SetDefaultSimulation();
297 //______________________________________________________________________
298 void AliITS::MakeBranch(Option_t* option){
299 // Creates Tree branches for the ITS.
301 // Option_t *option String of Tree types S,D, and/or R.
302 // const char *file String of the file name where these branches
303 // are to be stored. If blank then these branches
304 // are written to the same tree as the Hits were
311 Error("MakeBranch","fDetTypeSim is 0!");
315 Bool_t cH = (strstr(option,"H")!=0);
316 Bool_t cS = (strstr(option,"S")!=0);
317 Bool_t cD = (strstr(option,"D")!=0);
319 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
320 AliDetector::MakeBranch(option);
322 if(cS) MakeBranchS(0);
323 if(cD) MakeBranchD(0);
327 //___________________________________________________________________
328 void AliITS::MakeBranchS(const char* fl){
330 // Creates Tree Branch for the ITS summable digits.
332 // cont char *fl File name where SDigits branch is to be written
333 // to. If blank it write the SDigits to the same
334 // file in which the Hits were found.
338 Error("MakeBranchS","fDetTypeSim is 0!");
340 Int_t buffersize = 4000;
343 // only one branch for SDigits.
344 sprintf(branchname,"%s",GetName());
346 if(fLoader->TreeS()){
347 TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
348 MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
351 //______________________________________________________________________
352 void AliITS::MakeBranchD(const char* file){
354 //Make branch for digits
356 Warning("MakeBranchD","fDetTypeSim is 0!");
359 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
360 MakeBranchInTreeD(fLoader->TreeD(),file);
363 //___________________________________________________________________
364 void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
365 // Creates Tree branches for the ITS.
368 Error("MakeBranchS","fDetTypeSim is 0!");
370 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
372 const Char_t *det[3] = {"SPD","SDD","SSD"};
374 Int_t buffersize = 4000;
375 Char_t branchname[30];
377 if(!fDetTypeSim->GetDigits()){
378 fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
380 for(Int_t i=0;i<fgkNTYPES;i++){
381 digclass = fDetTypeSim->GetDigitClassName(i);
382 TString classn = digclass;
383 if(!((fDetTypeSim->GetDigits())->At(i))){
384 (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
387 if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
388 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
389 TObjArray* dig = DigitsAddress(i);
390 if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
394 //______________________________________________________________________
395 void AliITS::SetTreeAddress(){
396 // Set branch address for the Trees.
405 Error("SetTreeAddress","fDetTypeSim is 0!");
409 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
411 TTree *treeS = fLoader->TreeS();
412 TTree *treeD = fLoader->TreeD();
413 if (fLoader->TreeH() && (fHits == 0x0)) {
414 fHits = new TClonesArray("AliITShit", 1560);
416 AliDetector::SetTreeAddress();
418 fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
419 fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
421 //______________________________________________________________________
422 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
424 // The function to add information to the AliITShit class. See the
425 // AliITShit class for a full description. This function allocates the
426 // necessary new space for the hit information and passes the variable
427 // track, and the pointers *vol and *hits to the AliITShit constructor
430 // Int_t track Track number which produced this hit.
431 // Int_t *vol Array of Integer Hit information. See AliITShit.h
432 // Float_t *hits Array of Floating Hit information. see AliITShit.h
437 TClonesArray &lhits = *fHits;
438 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
441 //______________________________________________________________________
442 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
443 Option_t *option, const char *filename){
444 // fill the modules with the sorted by module hits; add hits from
445 // background if option=Add.
447 static TTree *trH1; //Tree with background hits
448 static Bool_t first=kTRUE;
450 const char *addBgr = strstr(option,"Add");
452 evnt = nmodules; // Dummy use of variables to remove warnings
455 file=new TFile(filename);
460 // Get Hits Tree header from file
461 if(trH1) delete trH1;
465 sprintf(treeName,"TreeH%d",bgrev);
466 trH1 = (TTree*)gDirectory->Get(treeName);
468 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
470 // Set branch addresses
473 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
476 FillModules(trH1,10000000); // Default mask 10M.
477 TTree *fAli=fLoader->GetRunLoader()->TreeK();
479 if (fAli) fileAli =fAli->GetCurrentFile();
487 //______________________________________________________________________
488 void AliITS::FillModules(TTree *treeH, Int_t mask) {
489 // fill the modules with the sorted by module hits;
490 // can be called many times to do a merging
492 // TTree *treeH The tree containing the hits to be copied into
494 // Int_t mask The track number mask to indecate which file
495 // this hits came from.
503 Error("FillModules","Tree is NULL");
505 Int_t lay,lad,det,index;
509 sprintf(branchname,"%s",GetName());
510 TBranch *branch = treeH->GetBranch(branchname);
512 Error("FillModules","%s branch in TreeH not found",branchname);
515 branch->SetAddress(&fHits);
516 Int_t nTracks =(Int_t) treeH->GetEntries();
518 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
520 Int_t nBytes = treeH->GetEvent(iPrimTrack);
521 if (nBytes <= 0) continue;
522 Int_t nHits = fHits->GetEntriesFast();
523 for(h=0; h<nHits; h++){
524 itsHit = (AliITShit *)fHits->UncheckedAt(h);
525 itsHit->GetDetectorID(lay,lad,det);
527 index = GetITSgeom()->GetModuleIndex(lay,lad,det);
529 index=det-1; // This should not be used.
530 } // end if [You must have fITSgeom for this to work!]
531 mod = GetModule(index);
532 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
533 mod->AddHit(itsHit,iPrimTrack,h);
534 } // end loop over hits
535 } // end loop over tracks
538 //______________________________________________________________________
539 Bool_t AliITS::InitModules(Int_t size,Int_t &nmodules){
540 // Initialize the modules array.
542 // Int_t size Size of array of the number of modules to be
543 // created. If size <=0 then the number of modules
544 // is gotten from AliITSgeom class kept in fITSgeom.
546 // Int_t &nmodules The number of modules existing.
551 fITSmodules->Delete();
553 } // end fir fITSmoudles
556 Error("InitModules","fDetTypeSim is null!");
560 Int_t nl,indexMAX,index;
562 if(size<=0){ // default to using data stored in AliITSgeom
563 if(fDetTypeSim->GetITSgeom()==0) {
564 Error("InitModules","fITSgeom not defined");
566 } // end if fITSgeom==0
567 nl = fDetTypeSim->GetITSgeom()->GetNlayers();
568 indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
570 fITSmodules = new TObjArray(indexMAX);
571 for(index=0;index<indexMAX;index++){
572 fITSmodules->AddAt( new AliITSmodule(index),index);
575 fITSmodules = new TObjArray(size);
576 for(index=0;index<size;index++) {
577 fITSmodules->AddAt( new AliITSmodule(index),index);
584 //______________________________________________________________________
585 void AliITS::Hits2SDigits(){
586 // Standard Hits to summable Digits function.
594 Error("Hits2SDigits","fDetTypeSim is null!");
600 fLoader->LoadHits("read");
601 fLoader->LoadSDigits("recreate");
602 AliRunLoader* rl = fLoader->GetRunLoader();
603 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
604 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
605 // Do the Hits to Digits operation. Use Standard input values.
606 // Event number from file, no background hit merging , use size from
607 // AliITSgeom class, option="All", input from this file only.
608 rl->GetEvent(iEvent);
609 if (!fLoader->TreeS()) fLoader->MakeTree("S");
612 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
615 fLoader->UnloadHits();
616 fLoader->UnloadSDigits();
619 //______________________________________________________________________
620 void AliITS::Hits2Digits(){
622 //Conversion from hits to digits
624 Error("Hits2SDigits","fDetTypeSim is 0!");
628 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
631 fLoader->LoadHits("read");
632 fLoader->LoadDigits("recreate");
633 AliRunLoader* rl = fLoader->GetRunLoader();
634 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
635 rl->GetEvent(iEvent);
636 if (!fLoader->TreeD()) fLoader->MakeTree("D");
639 HitsToDigits(iEvent,0,-1," ",fOpt," ");
642 fLoader->UnloadHits();
643 fLoader->UnloadDigits();
647 //______________________________________________________________________
648 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
649 Option_t *option,Option_t *opt,
650 const char *filename){
651 // Keep galice.root for signal and name differently the file for
652 // background when add! otherwise the track info for signal will be lost !
653 // the condition below will disappear when the geom class will be
654 // initialized for all versions - for the moment it is only for v5 !
655 // 7 is the SDD beam test version.
657 // Int_t evnt Event to be processed.
658 // Int_t bgrev Background Hit tree number.
659 // Int_t nmodules Not used.
660 // Option_t *option String indicating if merging hits or not. To
661 // merge hits set equal to "Add". Otherwise no
662 // background hits are considered.
663 // Test_t *filename File name containing the background hits..
670 Error("HitsToDigits","fDetTypeSim is null!");
673 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
674 if(!GetITSgeom()) return; // need transformations to do digitization.
675 AliITSgeom *geom = GetITSgeom();
677 const char *all = strstr(opt,"All");
678 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
680 static Bool_t setDef=kTRUE;
681 if (setDef) SetDefaultSimulation();
685 InitModules(size,nmodules);
686 FillModules(evNumber,bgrev,nmodules,option,filename);
688 AliITSsimulation *sim = 0;
689 AliITSmodule *mod = 0;
691 for(Int_t module=0;module<geom->GetIndexMax();module++){
692 id = geom->GetModuleType(module);
693 if (!all && !det[id]) continue;
694 sim = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
696 Error("HitsToDigits","The simulation class was not "
697 "instanciated for module %d type %s!",module,
698 geom->GetModuleTypeName(module));
701 mod = (AliITSmodule *)fITSmodules->At(module);
702 sim->DigitiseModule(mod,module,evNumber);
703 // fills all branches - wasted disk space
704 fLoader->TreeD()->Fill();
710 fLoader->TreeD()->GetEntries();
711 fLoader->TreeD()->AutoSave();
713 fLoader->TreeD()->Reset();
715 //_____________________________________________________________________
716 void AliITS::Hits2PreDigits(){
717 // Turn hits into SDigits
720 Error("Hits2SDigits","fDetTypeSim is 0!");
724 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
727 HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
731 //______________________________________________________________________
732 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
733 Option_t *option,Option_t *opt,
734 const char *filename){
735 // Keep galice.root for signal and name differently the file for
736 // background when add! otherwise the track info for signal will be lost !
737 // the condition below will disappear when the geom class will be
738 // initialized for all versions - for the moment it is only for v5 !
739 // 7 is the SDD beam test version.
741 // Int_t evnt Event to be processed.
742 // Int_t bgrev Background Hit tree number.
743 // Int_t nmodules Not used.
744 // Option_t *option String indicating if merging hits or not. To
745 // merge hits set equal to "Add". Otherwise no
746 // background hits are considered.
747 // Test_t *filename File name containing the background hits..
755 Error("HitsToPreDigits","fDetTypeSim is null!");
758 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
761 Error("HitsToPreDigits","fGeom is null!");
762 return; // need transformations to do digitization.
764 AliITSgeom *geom = GetITSgeom();
766 const char *all = strstr(opt,"All");
767 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
769 static Bool_t setDef=kTRUE;
770 if (setDef) SetDefaultSimulation();
774 InitModules(size,nmodules);
775 FillModules(evNumber,bgrev,nmodules,option,filename);
778 AliITSsimulation *sim = 0;
779 AliITSmodule *mod = 0;
781 for(module=0;module<geom->GetIndexMax();module++){
782 id = geom->GetModuleType(module);
783 if (!all && !det[id]) continue;
784 sim = (AliITSsimulation*)GetSimulationModel(id);
786 Error("HitsToPreDigits","The simulation class was not "
787 "instanciated for module %d type %s!",module,
788 geom->GetModuleTypeName(module));
791 mod = (AliITSmodule *)fITSmodules->At(module);
792 sim->SDigitiseModule(mod,module,evNumber);
793 // fills all branches - wasted disk space
794 fLoader->TreeS()->Fill();
795 fDetTypeSim->ResetSDigits();
801 fLoader->TreeS()->GetEntries();
802 fLoader->TreeS()->AutoSave();
803 fLoader->WriteSDigits("OVERWRITE");
805 fLoader->TreeS()->Reset();
808 //_____________________________________________________________________
809 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
810 Option_t *opt0,Option_t *opt1,
812 // keep galice.root for signal and name differently the file for
813 // background when add! otherwise the track info for signal will be lost !
814 // the condition below will disappear when the geom class will be
815 // initialized for all versions - for the moment it is only for v5 !
817 // Int_t evnt Event to be processed.
818 // Int_t bgrev Background Hit tree number.
819 // Int_t size Size used by InitModules. See InitModules.
820 // Option_t *opt0 Option passed to FillModules. See FillModules.
821 // Option_t *opt1 String indicating if merging hits or not. To
822 // merge hits set equal to "Add". Otherwise no
823 // background hits are considered.
824 // Test_t *flnm File name containing the background hits..
833 Error("HitsToPreDigits","fGeom is null!");
834 return; // need transformations to do digitization.
836 AliITSgeom *geom = GetITSgeom();
838 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
840 const char *all = strstr(opt1,"All");
841 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
844 InitModules(size,nmodules);
845 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
847 AliITSsimulation *sim = 0;
848 AliITSmodule *mod = 0;
851 TTree *lTR = pITSloader->TreeR();
853 pITSloader->MakeTree("R");
854 lTR = pITSloader->TreeR();
857 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
858 TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
859 branch->SetAddress(&ptarray);
860 //m.b. : this change is nothing but a nice way to make sure
862 for(module=0;module<geom->GetIndexMax();module++){
863 id = geom->GetModuleType(module);
864 if (!all && !det[id]) continue;
865 sim = (AliITSsimulation*)GetSimulationModel(id);
867 Error("HitsToFastPoints","The simulation class was not "
868 "instanciated for module %d type %x!",module,
869 geom->GetModuleTypeName(module));
872 mod = (AliITSmodule *)fITSmodules->At(module);
873 sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
878 fLoader->WriteRecPoints("OVERWRITE");
881 //_____________________________________________________________________
882 Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
883 //------------------------------------------------------------
884 // This function creates ITS clusters
885 //------------------------------------------------------------
887 Error("HitsToPreDigits","fGeom is null!");
888 return 1; // need transformations to do digitization.
890 AliITSgeom *geom=GetITSgeom();
891 Int_t mmax=geom->GetIndexMax();
893 InitModules(-1,mmax);
894 FillModules(hTree,0);
896 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
897 TBranch *branch=cTree->GetBranch("ITSRecPoints");
898 if (!branch) cTree->Branch("ITSRecPoints",&points);
899 else branch->SetAddress(&points);
901 AliITSsimulationFastPoints sim;
903 for (Int_t m=0; m<mmax; m++) {
904 AliITSmodule *mod=GetModule(m);
905 sim.CreateFastRecPoints(mod,m,gRandom,points);
906 ncl+=points->GetEntriesFast();
911 Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
919 //_____________________________________________________________________
920 void AliITS::CheckLabels(Int_t lab[3]) const {
921 //------------------------------------------------------------
922 // Tries to find mother's labels
923 //------------------------------------------------------------
925 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
927 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
928 for (Int_t i=0;i<3;i++){
929 Int_t label = lab[i];
930 if (label>=0 && label<ntracks) {
931 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
932 if (part->P() < 0.005) {
933 Int_t m=part->GetFirstMother();
937 if (part->GetStatusCode()>0) {
947 //______________________________________________________________________
948 void AliITS::SDigitsToDigits(Option_t *opt){
949 // Standard Summable digits to Digits function.
955 Error("SDigitsToSDigits","fDetTypeSim is 0!");
959 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
961 fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
965 //______________________________________________________________________
966 void AliITS::ResetDigits(){
967 // Reset number of digits and the digits array for the ITS detector.
973 Error("ResetDigits","fDetTypeSim is 0!");
977 fDetTypeSim->ResetDigits();
981 //______________________________________________________________________
982 void AliITS::ResetDigits(Int_t branch){
983 // Reset number of digits and the digits array for this branch.
990 Error("ResetDigits","fDetTypeSim is 0!");
994 fDetTypeSim->ResetDigits(branch);
997 //______________________________________________________________________
998 void AliITS::AddSumDigit(AliITSpListItem &sdig){
999 // Adds the a module full of summable digits to the summable digits tree.
1001 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1008 Error("AddSumDigit","fDetTypeSim is 0!");
1011 fDetTypeSim->AddSumDigit(sdig);
1014 //______________________________________________________________________
1015 void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
1016 // Add a simulated digit.
1018 // Int_t id Detector type number.
1019 // AliITSdigit *d Digit to be added to the Digits Tree. See
1027 Error("AddSimDigit","fDetTypeSim is 0!");
1030 fDetTypeSim->AddSimDigit(branch,d);
1033 //______________________________________________________________________
1034 void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
1035 Int_t *hits,Float_t *charges, Int_t sigexpanded){
1036 // Add a simulated digit to the list.
1038 // Int_t id Detector type number.
1039 // Float_t phys Physics indicator. See AliITSdigits.h
1040 // Int_t *digits Integer array containing the digits info. See
1042 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1043 // containing the track numbers that contributed to
1045 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1046 // containing the hit numbers, from AliITSmodule, that
1047 // contributed to this digit.
1048 // Float_t *charge Floating point array of the signals contributed
1049 // to this digit by each track.
1056 Error("AddSimDigit","fDetTypeSim is 0!");
1059 fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
1062 //______________________________________________________________________
1063 void AliITS::Digits2Raw(){
1064 // convert digits of the current event to raw data
1067 Error("Digits2Raw","fDetTypeSim is 0!");
1070 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
1072 fDetTypeSim->GetLoader()->LoadDigits();
1073 TTree* digits = fDetTypeSim->GetLoader()->TreeD();
1075 Error("Digits2Raw", "no digits tree");
1078 fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
1079 AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
1080 Bool_t isHLTmodeC=fDetTypeSim->IsHLTmodeC();
1081 AliITSDDLRawData rawWriter;
1082 if(isHLTmodeC) rawWriter.SetUseCompressedSDDFormat(kTRUE);
1083 else rawWriter.SetUseCompressedSDDFormat(kFALSE);
1087 // 2: txt files with digits
1088 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1089 //it is highly suggested to use this mode only for debugging digits files
1090 //reasonably small, because otherwise the size of the txt files can reach
1091 //quickly several MB wasting time and disk space.
1092 rawWriter.SetVerbose(0);
1094 //SILICON PIXEL DETECTOR
1095 Info("Digits2Raw", "Formatting raw data for SPD");
1096 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"));
1098 //SILICON DRIFT DETECTOR
1099 Info("Digits2Raw", "Formatting raw data for SDD");
1100 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
1102 //SILICON STRIP DETECTOR
1103 Info("Digits2Raw", "Formatting raw data for SSD");
1104 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1106 fLoader->UnloadDigits();
1108 //______________________________________________________________________
1109 AliLoader* AliITS::MakeLoader(const char* topfoldername){
1110 //builds ITSgetter (AliLoader type)
1111 //if detector wants to use castomized getter, it must overload this method
1113 AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1115 fLoader = new AliITSLoader(GetName(),topfoldername);
1119 Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1122 // Converts RAW data to SDigits
1127 Int_t size = GetITSgeom()->GetIndexMax();
1128 TClonesArray** modA = new TClonesArray*[size];
1129 for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
1131 AliLoader* loader = (gAlice->GetRunLoader())->GetLoader("ITSLoader");
1134 Error("Open","Can not get ITS loader from Run Loader");
1139 tree = loader->TreeS();
1142 loader->MakeTree("S");
1143 tree = loader->TreeS();
1146 // Array for SDigits
1148 TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits;
1149 Int_t bufsize = 32000;
1150 tree->Branch("ITS", &itsSDigits, bufsize);
1155 AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1157 AliWarning("Set AliITS defaults");
1159 segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1161 npx = segSPD->Npx();
1162 Double_t thr, sigma;
1164 AliITSRawStreamSPD inputSPD(rawReader);
1166 Bool_t next = inputSPD.Next();
1169 Int_t module = inputSPD.GetModuleID();
1170 Int_t column = inputSPD.GetColumn();
1171 Int_t row = inputSPD.GetRow();
1172 Int_t index = npx * column + row;
1174 if (module >= size) continue;
1176 last = (modA[module])->GetEntries();
1177 TClonesArray& dum = *modA[module];
1178 fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
1180 new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1187 AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1188 npx = segSDD->Npx();
1189 AliITSRawStreamSDD inputSDD(rawReader);
1190 AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
1191 inputSDD.SetDDLModuleMap(ddlmap);
1193 Bool_t next = inputSDD.Next();
1196 Int_t module = inputSDD.GetModuleID();
1197 Int_t anode = inputSDD.GetAnode();
1198 Int_t time = inputSDD.GetTime();
1199 Int_t signal10 = inputSDD.GetSignal();
1200 Int_t index = npx * anode + time;
1202 if (module >= size) continue;
1203 last = modA[module]->GetEntries();
1204 TClonesArray& dum = *modA[module];
1205 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1206 ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
1214 AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1215 npx = segSSD->Npx();
1216 AliITSRawStreamSSD inputSSD(rawReader);
1218 Bool_t next = inputSSD.Next();
1221 Int_t module = inputSSD.GetModuleID();
1222 Int_t side = inputSSD.GetSideFlag();
1223 Int_t strip = inputSSD.GetStrip();
1224 Int_t signal = inputSSD.GetSignal();
1225 Int_t index = npx * side + strip;
1227 if (module >= size) continue;
1229 last = modA[module]->GetEntries();
1230 TClonesArray& dum = *modA[module];
1231 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1234 AliITSpListItem* sdig = 0;
1236 for (Int_t mod = 0; mod < size; mod++)
1238 Int_t nsdig = modA[mod]->GetEntries();
1239 for (Int_t ie = 0; ie < nsdig; ie++) {
1240 sdig = (AliITSpListItem*) (modA[mod]->At(ie));
1241 new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), sdig->GetSignal());
1242 Float_t sig = sdig->GetSignalAfterElect();
1244 sdig = (AliITSpListItem*)aSDigits[ie];
1245 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
1253 loader->WriteSDigits("OVERWRITE");
1259 //______________________________________________________________________
1260 void AliITS::UpdateInternalGeometry(){
1262 //reads new geometry from TGeo
1263 // AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1265 AliITSVersion_t version = (AliITSVersion_t)IsVersion();
1267 if(version==kvPPRasymmFMD) minor=2; // default minor version for this geom.
1268 AliITSInitGeometry initgeom;
1269 AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);