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"
98 #include "AliITSFOSignalsSPD.h"
102 //______________________________________________________________________
103 AliITS::AliITS() : AliDetector(),
113 // Default initializer for ITS
114 // The default constructor of the AliITS class. In addition to
115 // creating the AliITS class it zeros the variables fIshunt (a member
116 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
117 // fIdSens, and fIdName. The AliDetector default constructor
120 // SetDetectors(); // default to fOpt="All". This variable not written out.
121 //PH SetMarkerColor(kRed);
123 //______________________________________________________________________
124 AliITS::AliITS(const Char_t *title):AliDetector("ITS",title),
134 // The standard Constructor for the ITS class.
135 // It also zeros the variables
136 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
137 // the pointers fIdSens and fIdName. To help in displaying hits via the
138 // ROOT macro display.C AliITS also sets the marker color to red. The
139 // variables passes with this constructor, const char *name and *title,
140 // are used by the constructor of AliDetector class. See AliDetector
141 // class for a description of these parameters and its constructor
144 // Char_t *title Simulation title for the ITS
150 fHits = new TClonesArray("AliITShit",1560); // from AliDetector
151 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
152 //fNhits=0; //done in AliDetector(name,title)
153 SetDetectors(); // default to fOpt="All". This variable not written out.
154 fDetTypeSim = new AliITSDetTypeSim();
155 //PH SetMarkerColor(kRed);
156 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
157 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
159 //______________________________________________________________________
160 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title),
170 // The standard Constructor for the ITS class.
171 // It also zeros the variables
172 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
173 // the pointers fIdSens and fIdName. To help in displaying hits via the
174 // ROOT macro display.C AliITS also sets the marker color to red. The
175 // variables passes with this constructor, const char *name and *title,
176 // are used by the constructor of AliDetector class. See AliDetector
177 // class for a description of these parameters and its constructor
180 fHits = new TClonesArray("AliITShit",1560);
181 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
182 //fNhits=0; //done in AliDetector(name,title)
184 SetDetectors(); // default to fOpt="All". This variable not written out.
186 fDetTypeSim = new AliITSDetTypeSim();
188 //PH SetMarkerColor(kRed);
189 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
190 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
193 //______________________________________________________________________
195 // Default destructor for ITS.
196 // The default destructor of the AliITS class. In addition to deleting
197 // the AliITS class it deletes the memory pointed to by
198 // fIdSens, fIdName, fDetTypeSim and it's contents.
212 this->ClearModules();
215 }// end if fITSmodules!=0
217 delete[] fIdName; // Array of TStrings
225 //______________________________________________________________________
226 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
227 // Creates the AliITSDigitizer in a standard way for use via AliModule.
228 // This function can not be included in the .h file because of problems
229 // with the order of inclusion (recursive).
231 // AliRunDigitizer *manager The Manger class for Digitization
235 // A new AliITSRunDigitizer (cast as a AliDigitizer).
237 return new AliITSDigitizer(manager);
239 //______________________________________________________________________
241 // Initializer ITS after it has been built
242 // This routine initializes the AliITS class. It is intended to be
243 // called from the Init function in AliITSv?. Besides displaying a banner
244 // indicating that it has been called it initializes the array fIdSens
245 // and sets the default segmentation, response, digit and raw cluster
246 // classes therefore it should be called after a call to CreateGeometry.
255 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
258 //______________________________________________________________________
259 void AliITS::SetDefaults(){
260 // sets the default segmentation, response, digit and raw cluster classes.
267 AliInfoClass("AliITS::Setting Defaults");
269 Error("SetDefaults()","fDetTypeSim is 0!");
273 fDetTypeSim->SetDefaults();
277 //______________________________________________________________________
278 void AliITS::SetDefaultSimulation(){
279 // sets the default simulation.
287 Error("SetDefaultSimulation()","fDetTypeSim is 0!");
291 fDetTypeSim->SetDefaultSimulation();
296 //______________________________________________________________________
297 void AliITS::MakeBranch(Option_t* option){
298 // Creates Tree branches for the ITS.
300 // Option_t *option String of Tree types S,D, and/or R.
301 // const char *file String of the file name where these branches
302 // are to be stored. If blank then these branches
303 // are written to the same tree as the Hits were
310 Error("MakeBranch","fDetTypeSim is 0!");
314 Bool_t cH = (strstr(option,"H")!=0);
315 Bool_t cS = (strstr(option,"S")!=0);
316 Bool_t cD = (strstr(option,"D")!=0);
318 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
319 AliDetector::MakeBranch(option);
321 if(cS) MakeBranchS(0);
322 if(cD) MakeBranchD(0);
326 //___________________________________________________________________
327 void AliITS::MakeBranchS(const char* fl){
329 // Creates Tree Branch for the ITS summable digits.
331 // cont char *fl File name where SDigits branch is to be written
332 // to. If blank it write the SDigits to the same
333 // file in which the Hits were found.
337 Error("MakeBranchS","fDetTypeSim is 0!");
339 Int_t buffersize = 4000;
342 // only one branch for SDigits.
343 sprintf(branchname,"%s",GetName());
345 if(fLoader->TreeS()){
346 TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
347 MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
350 //______________________________________________________________________
351 void AliITS::MakeBranchD(const char* file){
353 //Make branch for digits
355 Warning("MakeBranchD","fDetTypeSim is 0!");
358 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
359 MakeBranchInTreeD(fLoader->TreeD(),file);
362 //___________________________________________________________________
363 void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
364 // Creates Tree branches for the ITS.
367 Error("MakeBranchS","fDetTypeSim is 0!");
369 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
371 const Char_t *det[3] = {"SPD","SDD","SSD"};
372 const Char_t* digclass;
373 Int_t buffersize = 4000;
374 Char_t branchname[30];
376 if(!fDetTypeSim->GetDigits()){
377 fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
379 for(Int_t i=0;i<fgkNTYPES;i++){
380 digclass = fDetTypeSim->GetDigitClassName(i);
381 TString classn = digclass;
382 if(!((fDetTypeSim->GetDigits())->At(i))){
383 (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
386 if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
387 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
388 TObjArray* dig = DigitsAddress(i);
389 if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
393 //______________________________________________________________________
394 void AliITS::SetTreeAddress(){
395 // Set branch address for the Trees.
404 Error("SetTreeAddress","fDetTypeSim is 0!");
408 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
410 TTree *treeS = fLoader->TreeS();
411 TTree *treeD = fLoader->TreeD();
412 if (fLoader->TreeH() && (fHits == 0x0)) {
413 fHits = new TClonesArray("AliITShit", 1560);
415 AliDetector::SetTreeAddress();
417 fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
418 fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
420 //______________________________________________________________________
421 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
423 // The function to add information to the AliITShit class. See the
424 // AliITShit class for a full description. This function allocates the
425 // necessary new space for the hit information and passes the variable
426 // track, and the pointers *vol and *hits to the AliITShit constructor
429 // Int_t track Track number which produced this hit.
430 // Int_t *vol Array of Integer Hit information. See AliITShit.h
431 // Float_t *hits Array of Floating Hit information. see AliITShit.h
436 TClonesArray &lhits = *fHits;
437 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
440 //______________________________________________________________________
441 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
442 Option_t *option, const char *filename){
443 // fill the modules with the sorted by module hits; add hits from
444 // background if option=Add.
446 static TTree *trH1; //Tree with background hits
447 static Bool_t first=kTRUE;
449 const char *addBgr = strstr(option,"Add");
451 evnt = nmodules; // Dummy use of variables to remove warnings
454 file=new TFile(filename);
459 // Get Hits Tree header from file
460 if(trH1) delete trH1;
464 sprintf(treeName,"TreeH%d",bgrev);
465 trH1 = (TTree*)gDirectory->Get(treeName);
467 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
469 // Set branch addresses
472 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
475 FillModules(trH1,10000000); // Default mask 10M.
476 TTree *fAli=fLoader->GetRunLoader()->TreeK();
478 if (fAli) fileAli =fAli->GetCurrentFile();
484 //______________________________________________________________________
485 void AliITS::FillModules(TTree *treeH, Int_t mask) {
486 // fill the modules with the sorted by module hits;
487 // can be called many times to do a merging
489 // TTree *treeH The tree containing the hits to be copied into
491 // Int_t mask The track number mask to indecate which file
492 // this hits came from.
500 Error("FillModules","Tree is NULL");
502 Int_t lay,lad,det,index;
506 sprintf(branchname,"%s",GetName());
507 TBranch *branch = treeH->GetBranch(branchname);
509 Error("FillModules","%s branch in TreeH not found",branchname);
512 branch->SetAddress(&fHits);
513 Int_t nTracks =(Int_t) treeH->GetEntries();
515 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
517 Int_t nBytes = treeH->GetEvent(iPrimTrack);
518 if (nBytes <= 0) continue;
519 Int_t nHits = fHits->GetEntriesFast();
520 for(h=0; h<nHits; h++){
521 itsHit = (AliITShit *)fHits->UncheckedAt(h);
522 itsHit->GetDetectorID(lay,lad,det);
524 index = GetITSgeom()->GetModuleIndex(lay,lad,det);
526 index=det-1; // This should not be used.
527 } // end if [You must have fITSgeom for this to work!]
528 mod = GetModule(index);
529 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
530 mod->AddHit(itsHit,iPrimTrack,h);
531 } // end loop over hits
532 } // end loop over tracks
535 //______________________________________________________________________
536 Bool_t AliITS::InitModules(Int_t size,Int_t &nmodules){
537 // Initialize the modules array.
539 // Int_t size Size of array of the number of modules to be
540 // created. If size <=0 then the number of modules
541 // is gotten from AliITSgeom class kept in fITSgeom.
543 // Int_t &nmodules The number of modules existing.
548 fITSmodules->Delete();
550 } // end fir fITSmoudles
553 Error("InitModules","fDetTypeSim is null!");
557 Int_t nl,indexMAX,index;
559 if(size<=0){ // default to using data stored in AliITSgeom
560 if(fDetTypeSim->GetITSgeom()==0) {
561 Error("InitModules","fITSgeom not defined");
563 } // end if fITSgeom==0
564 nl = fDetTypeSim->GetITSgeom()->GetNlayers();
565 indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
567 fITSmodules = new TObjArray(indexMAX);
568 for(index=0;index<indexMAX;index++){
569 fITSmodules->AddAt( new AliITSmodule(index),index);
572 fITSmodules = new TObjArray(size);
573 for(index=0;index<size;index++) {
574 fITSmodules->AddAt( new AliITSmodule(index),index);
581 //______________________________________________________________________
582 void AliITS::Hits2SDigits(){
583 // Standard Hits to summable Digits function.
591 Error("Hits2SDigits","fDetTypeSim is null!");
596 fLoader->LoadHits("read");
597 fLoader->LoadSDigits("recreate");
598 AliRunLoader* rl = fLoader->GetRunLoader();
599 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
600 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
601 // Do the Hits to Digits operation. Use Standard input values.
602 // Event number from file, no background hit merging , use size from
603 // AliITSgeom class, option="All", input from this file only.
604 rl->GetEvent(iEvent);
605 if (!fLoader->TreeS()) fLoader->MakeTree("S");
608 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
611 fLoader->UnloadHits();
612 fLoader->UnloadSDigits();
615 //______________________________________________________________________
616 void AliITS::Hits2Digits(){
618 //Conversion from hits to digits
620 Error("Hits2SDigits","fDetTypeSim is 0!");
624 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
627 fLoader->LoadHits("read");
628 fLoader->LoadDigits("recreate");
629 AliRunLoader* rl = fLoader->GetRunLoader();
630 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
631 rl->GetEvent(iEvent);
632 if (!fLoader->TreeD()) fLoader->MakeTree("D");
635 HitsToDigits(iEvent,0,-1," ",fOpt," ");
638 fLoader->UnloadHits();
639 fLoader->UnloadDigits();
643 //______________________________________________________________________
644 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
645 Option_t *option,Option_t *opt,
646 const char *filename){
647 // Keep galice.root for signal and name differently the file for
648 // background when add! otherwise the track info for signal will be lost !
649 // the condition below will disappear when the geom class will be
650 // initialized for all versions - for the moment it is only for v5 !
651 // 7 is the SDD beam test version.
653 // Int_t evnt Event to be processed.
654 // Int_t bgrev Background Hit tree number.
655 // Int_t nmodules Not used.
656 // Option_t *option String indicating if merging hits or not. To
657 // merge hits set equal to "Add". Otherwise no
658 // background hits are considered.
659 // Test_t *filename File name containing the background hits..
666 Error("HitsToDigits","fDetTypeSim is null!");
669 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
670 if(!GetITSgeom()) return; // need transformations to do digitization.
671 AliITSgeom *geom = GetITSgeom();
673 const char *all = strstr(opt,"All");
674 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
676 static Bool_t setDef=kTRUE;
677 if (setDef) SetDefaultSimulation();
681 InitModules(size,nmodules);
682 FillModules(evNumber,bgrev,nmodules,option,filename);
684 // Reset Fast-OR signals for this event
685 fDetTypeSim->ResetFOSignals();
687 AliITSsimulation *sim = 0;
688 AliITSmodule *mod = 0;
690 for(Int_t module=0;module<geom->GetIndexMax();module++){
691 id = geom->GetModuleType(module);
692 if (!all && !det[id]) continue;
693 sim = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
695 Error("HitsToDigits","The simulation class was not "
696 "instanciated for module %d type %s!",module,
697 geom->GetModuleTypeName(module));
700 mod = (AliITSmodule *)fITSmodules->At(module);
701 sim->DigitiseModule(mod,module,evNumber);
702 // fills all branches - wasted disk space
703 fLoader->TreeD()->Fill();
709 // Add random noise to FO signals
710 if (all || det[0]) { // SPD present
711 fDetTypeSim->ProcessNoiseForFastOr();
714 // Add Fast-OR signals to event (only one object per event)
715 if (all || det[0]) { // SPD present
716 fDetTypeSim->WriteFOSignals();
720 fLoader->TreeD()->GetEntries();
721 fLoader->TreeD()->AutoSave();
723 fLoader->TreeD()->Reset();
725 //_____________________________________________________________________
726 void AliITS::Hits2PreDigits(){
727 // Turn hits into SDigits
730 Error("Hits2SDigits","fDetTypeSim is 0!");
734 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
737 HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
741 //______________________________________________________________________
742 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
743 Option_t *option,Option_t *opt,
744 const char *filename){
745 // Keep galice.root for signal and name differently the file for
746 // background when add! otherwise the track info for signal will be lost !
747 // the condition below will disappear when the geom class will be
748 // initialized for all versions - for the moment it is only for v5 !
749 // 7 is the SDD beam test version.
751 // Int_t evnt Event to be processed.
752 // Int_t bgrev Background Hit tree number.
753 // Int_t nmodules Not used.
754 // Option_t *option String indicating if merging hits or not. To
755 // merge hits set equal to "Add". Otherwise no
756 // background hits are considered.
757 // Test_t *filename File name containing the background hits..
765 Error("HitsToPreDigits","fDetTypeSim is null!");
768 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
771 Error("HitsToPreDigits","fGeom is null!");
772 return; // need transformations to do digitization.
774 AliITSgeom *geom = GetITSgeom();
776 const char *all = strstr(opt,"All");
777 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
779 static Bool_t setDef=kTRUE;
780 if (setDef) SetDefaultSimulation();
784 InitModules(size,nmodules);
785 FillModules(evNumber,bgrev,nmodules,option,filename);
788 AliITSsimulation *sim = 0;
789 AliITSmodule *mod = 0;
791 for(module=0;module<geom->GetIndexMax();module++){
792 id = geom->GetModuleType(module);
793 if (!all && !det[id]) continue;
794 sim = (AliITSsimulation*)GetSimulationModel(id);
796 Error("HitsToPreDigits","The simulation class was not "
797 "instanciated for module %d type %s!",module,
798 geom->GetModuleTypeName(module));
801 mod = (AliITSmodule *)fITSmodules->At(module);
802 sim->SDigitiseModule(mod,module,evNumber);
803 // fills all branches - wasted disk space
804 fLoader->TreeS()->Fill();
805 fDetTypeSim->ResetSDigits();
811 fLoader->TreeS()->GetEntries();
812 fLoader->TreeS()->AutoSave();
813 fLoader->WriteSDigits("OVERWRITE");
815 fLoader->TreeS()->Reset();
818 //_____________________________________________________________________
819 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
820 Option_t *opt0,Option_t *opt1,
822 // keep galice.root for signal and name differently the file for
823 // background when add! otherwise the track info for signal will be lost !
824 // the condition below will disappear when the geom class will be
825 // initialized for all versions - for the moment it is only for v5 !
827 // Int_t evnt Event to be processed.
828 // Int_t bgrev Background Hit tree number.
829 // Int_t size Size used by InitModules. See InitModules.
830 // Option_t *opt0 Option passed to FillModules. See FillModules.
831 // Option_t *opt1 String indicating if merging hits or not. To
832 // merge hits set equal to "Add". Otherwise no
833 // background hits are considered.
834 // Test_t *flnm File name containing the background hits..
843 Error("HitsToPreDigits","fGeom is null!");
844 return; // need transformations to do digitization.
846 AliITSgeom *geom = GetITSgeom();
848 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
850 const char *all = strstr(opt1,"All");
851 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
854 InitModules(size,nmodules);
855 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
857 AliITSsimulation *sim = 0;
858 AliITSmodule *mod = 0;
861 TTree *lTR = pITSloader->TreeR();
863 pITSloader->MakeTree("R");
864 lTR = pITSloader->TreeR();
867 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
868 TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
869 branch->SetAddress(&ptarray);
870 //m.b. : this change is nothing but a nice way to make sure
872 for(module=0;module<geom->GetIndexMax();module++){
873 id = geom->GetModuleType(module);
874 if (!all && !det[id]) continue;
875 sim = (AliITSsimulation*)GetSimulationModel(id);
877 Error("HitsToFastPoints","The simulation class was not "
878 "instanciated for module %d type %x!",module,
879 geom->GetModuleTypeName(module));
882 mod = (AliITSmodule *)fITSmodules->At(module);
883 sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
888 fLoader->WriteRecPoints("OVERWRITE");
891 //_____________________________________________________________________
892 Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
893 //------------------------------------------------------------
894 // This function creates ITS clusters
895 //------------------------------------------------------------
897 Error("HitsToPreDigits","fGeom is null!");
898 return 1; // need transformations to do digitization.
900 AliITSgeom *geom=GetITSgeom();
901 Int_t mmax=geom->GetIndexMax();
903 InitModules(-1,mmax);
904 FillModules(hTree,0);
906 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
907 TBranch *branch=cTree->GetBranch("ITSRecPoints");
908 if (!branch) cTree->Branch("ITSRecPoints",&points);
909 else branch->SetAddress(&points);
911 AliITSsimulationFastPoints sim;
913 for (Int_t m=0; m<mmax; m++) {
914 AliITSmodule *mod=GetModule(m);
915 sim.CreateFastRecPoints(mod,m,gRandom,points);
916 ncl+=points->GetEntriesFast();
921 Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
929 //_____________________________________________________________________
930 void AliITS::CheckLabels(Int_t lab[3]) const {
931 //------------------------------------------------------------
932 // Tries to find mother's labels
933 //------------------------------------------------------------
935 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
937 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
938 for (Int_t i=0;i<3;i++){
939 Int_t label = lab[i];
940 if (label>=0 && label<ntracks) {
941 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
942 if (part->P() < 0.005) {
943 Int_t m=part->GetFirstMother();
947 if (part->GetStatusCode()>0) {
957 //______________________________________________________________________
958 void AliITS::SDigitsToDigits(Option_t *opt){
959 // Standard Summable digits to Digits function.
965 AliError("fDetTypeSim is 0!");
969 const char *all = strstr(opt,"All");
970 const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
973 // Reset Fast-OR signals for this event
974 fDetTypeSim->ResetFOSignals();
976 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
978 fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
980 // Add random noise to FO signals
981 if (all || det[0]) { // SPD present
982 fDetTypeSim->ProcessNoiseForFastOr();
984 // Add Fast-OR signals to event (only one object per event)
985 if (all || det[0]) { // SPD present
986 fDetTypeSim->WriteFOSignals();
990 //______________________________________________________________________
991 void AliITS::ResetDigits(){
992 // Reset number of digits and the digits array for the ITS detector.
998 Error("ResetDigits","fDetTypeSim is 0!");
1002 fDetTypeSim->ResetDigits();
1006 //______________________________________________________________________
1007 void AliITS::ResetDigits(Int_t branch){
1008 // Reset number of digits and the digits array for this branch.
1015 Error("ResetDigits","fDetTypeSim is 0!");
1019 fDetTypeSim->ResetDigits(branch);
1022 //______________________________________________________________________
1023 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1024 // Adds the a module full of summable digits to the summable digits tree.
1026 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1033 Error("AddSumDigit","fDetTypeSim is 0!");
1036 fDetTypeSim->AddSumDigit(sdig);
1039 //______________________________________________________________________
1040 void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
1041 // Add a simulated digit.
1043 // Int_t id Detector type number.
1044 // AliITSdigit *d Digit to be added to the Digits Tree. See
1052 Error("AddSimDigit","fDetTypeSim is 0!");
1055 fDetTypeSim->AddSimDigit(branch,d);
1058 //______________________________________________________________________
1059 void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
1060 Int_t *hits,Float_t *charges, Int_t sigexpanded){
1061 // Add a simulated digit to the list.
1063 // Int_t id Detector type number.
1064 // Float_t phys Physics indicator. See AliITSdigits.h
1065 // Int_t *digits Integer array containing the digits info. See
1067 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1068 // containing the track numbers that contributed to
1070 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1071 // containing the hit numbers, from AliITSmodule, that
1072 // contributed to this digit.
1073 // Float_t *charge Floating point array of the signals contributed
1074 // to this digit by each track.
1081 Error("AddSimDigit","fDetTypeSim is 0!");
1084 fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
1087 //______________________________________________________________________
1088 void AliITS::Digits2Raw(){
1089 // convert digits of the current event to raw data
1092 Error("Digits2Raw","fDetTypeSim is 0!");
1095 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
1097 fDetTypeSim->GetLoader()->LoadDigits();
1098 TTree* digits = fDetTypeSim->GetLoader()->TreeD();
1100 Error("Digits2Raw", "no digits tree");
1103 fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
1105 // Get the FO signals for this event
1106 AliITSFOSignalsSPD* foSignals = NULL;
1107 AliRunLoader* runLoader = AliRunLoader::Instance();
1108 AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
1110 AliError("ITS loader is NULL.");
1113 AliBaseLoader* foLoader = itsLoader->GetFOSignalsLoader();
1115 AliError("FO signals base loader not retrieved.");
1119 foSignals = (AliITSFOSignalsSPD*) foLoader->Get();
1122 Bool_t deleteFOsignalsLater = kFALSE;
1124 AliError("FO signals not available. No FO bits will be written.");
1125 foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
1126 deleteFOsignalsLater = kTRUE;
1130 AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
1131 Bool_t isHLTmodeC=fDetTypeSim->IsHLTmodeC();
1132 AliITSDDLRawData rawWriter;
1133 if(isHLTmodeC) rawWriter.SetUseCompressedSDDFormat(kTRUE);
1134 else rawWriter.SetUseCompressedSDDFormat(kFALSE);
1138 // 2: txt files with digits
1139 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1140 //it is highly suggested to use this mode only for debugging digits files
1141 //reasonably small, because otherwise the size of the txt files can reach
1142 //quickly several MB wasting time and disk space.
1143 rawWriter.SetVerbose(0);
1145 //SILICON PIXEL DETECTOR
1146 Info("Digits2Raw", "Formatting raw data for SPD");
1147 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
1148 if(deleteFOsignalsLater) delete foSignals;
1150 //SILICON DRIFT DETECTOR
1151 Info("Digits2Raw", "Formatting raw data for SDD");
1152 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
1154 //SILICON STRIP DETECTOR
1155 Info("Digits2Raw", "Formatting raw data for SSD");
1156 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1158 fLoader->UnloadDigits();
1160 //______________________________________________________________________
1161 AliLoader* AliITS::MakeLoader(const char* topfoldername){
1162 //builds ITSgetter (AliLoader type)
1163 //if detector wants to use castomized getter, it must overload this method
1165 AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1167 fLoader = new AliITSLoader(GetName(),topfoldername);
1170 //______________________________________________________________________
1171 Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1174 // Converts RAW data to SDigits
1179 Int_t size = GetITSgeom()->GetIndexMax();
1180 TClonesArray** modA = new TClonesArray*[size];
1181 for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
1183 AliLoader* loader = (AliRunLoader::Instance())->GetLoader("ITSLoader");
1185 Error("Open","Can not get ITS loader from Run Loader");
1190 tree = loader->TreeS();
1192 loader->MakeTree("S");
1193 tree = loader->TreeS();
1196 // Array for SDigits
1198 TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits;
1199 Int_t bufsize = 32000;
1200 tree->Branch("ITS", &itsSDigits, bufsize);
1205 AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1207 AliWarning("Set AliITS defaults");
1209 segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1211 npx = segSPD->Npx();
1212 Double_t thr, sigma;
1214 AliITSRawStreamSPD inputSPD(rawReader);
1216 Bool_t next = inputSPD.Next();
1219 Int_t module = inputSPD.GetModuleID();
1220 Int_t column = inputSPD.GetColumn();
1221 Int_t row = inputSPD.GetRow();
1222 Int_t index = npx * column + row;
1224 if (module >= size) continue;
1226 last = (modA[module])->GetEntries();
1227 TClonesArray& dum = *modA[module];
1228 fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
1230 new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1237 AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1238 npx = segSDD->Npx();
1239 AliITSRawStreamSDD inputSDD(rawReader);
1240 AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
1241 inputSDD.SetDDLModuleMap(ddlmap);
1243 Bool_t next = inputSDD.Next();
1246 Int_t module = inputSDD.GetModuleID();
1247 Int_t anode = inputSDD.GetAnode();
1248 Int_t time = inputSDD.GetTime();
1249 Int_t signal10 = inputSDD.GetSignal();
1250 Int_t index = npx * anode + time;
1252 if (module >= size) continue;
1253 last = modA[module]->GetEntries();
1254 TClonesArray& dum = *modA[module];
1255 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1256 ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
1264 AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1265 npx = segSSD->Npx();
1266 AliITSRawStreamSSD inputSSD(rawReader);
1268 Bool_t next = inputSSD.Next();
1271 Int_t module = inputSSD.GetModuleID();
1272 Int_t side = inputSSD.GetSideFlag();
1273 Int_t strip = inputSSD.GetStrip();
1274 Int_t signal = inputSSD.GetSignal();
1275 Int_t index = npx * side + strip;
1277 if (module >= size) continue;
1279 last = modA[module]->GetEntries();
1280 TClonesArray& dum = *modA[module];
1281 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1284 AliITSpListItem* sdig = 0;
1286 for (Int_t mod = 0; mod < size; mod++)
1288 Int_t nsdig = modA[mod]->GetEntries();
1289 for (Int_t ie = 0; ie < nsdig; ie++) {
1290 sdig = (AliITSpListItem*) (modA[mod]->At(ie));
1291 new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), sdig->GetSignal());
1292 Float_t sig = sdig->GetSignalAfterElect();
1294 sdig = (AliITSpListItem*)aSDigits[ie];
1295 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
1303 loader->WriteSDigits("OVERWRITE");
1309 //______________________________________________________________________
1310 void AliITS::UpdateInternalGeometry(){
1312 //reads new geometry from TGeo
1313 // AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1315 AliITSVersion_t version = (AliITSVersion_t)IsVersion();
1317 if(version==kvPPRasymmFMD) minor=2; // default minor version for this geom.
1318 AliITSInitGeometry initgeom;
1319 AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
1322 //______________________________________________________________________
1323 AliTriggerDetector* AliITS::CreateTriggerDetector() const {
1324 // create an AliITSTrigger object (and set trigger conditions as input)
1325 return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());