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 "AliITSclusterV2.h"
94 //______________________________________________________________________
95 AliITS::AliITS() : AliDetector(){
96 // Default initializer for ITS
97 // The default constructor of the AliITS class. In addition to
98 // creating the AliITS class it zeros the variables fIshunt (a member
99 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
100 // fIdSens, and fIdName. The AliDetector default constructor
108 fIshunt = 0; // not zeroed in AliDetector.
113 // SetDetectors(); // default to fOpt="All". This variable not written out.
114 SetMarkerColor(kRed);
116 //______________________________________________________________________
117 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title){
118 // The standard Constructor for the ITS class.
119 // It also zeros the variables
120 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
121 // the pointers fIdSens and fIdName. To help in displaying hits via the
122 // ROOT macro display.C AliITS also sets the marker color to red. The
123 // variables passes with this constructor, const char *name and *title,
124 // are used by the constructor of AliDetector class. See AliDetector
125 // class for a description of these parameters and its constructor
133 fHits = new TClonesArray("AliITShit",1560);
134 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
138 fIshunt = 0; // not zeroed in AliDetector
139 // Not done in AliDetector.
142 SetDetectors(); // default to fOpt="All". This variable not written out.
147 fDetTypeSim = new AliITSDetTypeSim();
149 SetMarkerColor(kRed);
152 //______________________________________________________________________
154 // Default destructor for ITS.
155 // The default destructor of the AliITS class. In addition to deleting
156 // the AliITS class it deletes the memory pointed to by
157 // fIdSens, fIdName, fDetTypeSim and it's contents.
170 this->ClearModules();
173 }// end if fITSmodules!=0
175 delete[] fIdName; // Array of TStrings
183 //______________________________________________________________________
184 AliITS::AliITS(const AliITS &source) : AliDetector(source){
185 // Copy constructor. This is a function which is not allowed to be
186 // done to the ITS. It exits with an error.
188 // AliITS &source An AliITS class.
194 if(this==&source) return;
195 Error("Copy constructor",
196 "You are not allowed to make a copy of the AliITS");
199 //______________________________________________________________________
200 AliITS& AliITS::operator=(const AliITS &source){
201 // Assignment operator. This is a function which is not allowed to be
202 // done to the ITS. It exits with an error.
204 // AliITS &source An AliITS class.
210 if(this==&source) return *this;
211 Error("operator=","You are not allowed to make a copy of the AliITS");
213 return *this; //fake return
215 //______________________________________________________________________
216 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
217 // Creates the AliITSDigitizer in a standard way for use via AliModule.
218 // This function can not be included in the .h file because of problems
219 // with the order of inclusion (recursive).
221 // AliRunDigitizer *manager The Manger class for Digitization
225 // A new AliITSRunDigitizer (cast as a AliDigitizer).
227 return new AliITSDigitizer(manager);
229 //______________________________________________________________________
231 // Initializer ITS after it has been built
232 // This routine initializes the AliITS class. It is intended to be
233 // called from the Init function in AliITSv?. Besides displaying a banner
234 // indicating that it has been called it initializes the array fIdSens
235 // and sets the default segmentation, response, digit and raw cluster
236 // classes therefore it should be called after a call to CreateGeometry.
247 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
252 //______________________________________________________________________
253 void AliITS::WriteGeometry(){
255 //Writes ITS geomtry on gAlice
257 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
258 AliRunLoader* rl = fLoader->GetRunLoader();
260 AliITSgeom* geom = GetITSgeom();
265 //______________________________________________________________________
266 void AliITS::SetDefaults(){
267 // sets the default segmentation, response, digit and raw cluster classes.
274 AliInfoClass("Setting Defaults");
277 Error("SetDefaults()","fDetTypeSim is 0!");
281 fDetTypeSim->SetDefaults();
285 //______________________________________________________________________
286 void AliITS::SetDefaultSimulation(){
287 // sets the default simulation.
296 Error("SetDefaultSimulation()","fDetTypeSim is 0!");
300 fDetTypeSim->SetDefaultSimulation();
305 //______________________________________________________________________
306 void AliITS::MakeBranch(Option_t* option){
307 // Creates Tree branches for the ITS.
309 // Option_t *option String of Tree types S,D, and/or R.
310 // const char *file String of the file name where these branches
311 // are to be stored. If blank then these branches
312 // are written to the same tree as the Hits were
319 Error("MakeBranch","fDetTypeSim is 0!");
323 Bool_t cH = (strstr(option,"H")!=0);
324 Bool_t cS = (strstr(option,"S")!=0);
325 Bool_t cD = (strstr(option,"D")!=0);
327 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
328 AliDetector::MakeBranch(option);
330 if(cS) MakeBranchS(0);
331 if(cD) MakeBranchD(0);
335 //___________________________________________________________________
336 void AliITS::MakeBranchS(const char* fl){
338 // Creates Tree Branch for the ITS summable digits.
340 // cont char *fl File name where SDigits branch is to be written
341 // to. If blank it write the SDigits to the same
342 // file in which the Hits were found.
346 Error("MakeBranchS","fDetTypeSim is 0!");
348 Int_t buffersize = 4000;
351 // only one branch for SDigits.
352 sprintf(branchname,"%s",GetName());
354 if(fLoader->TreeS()){
355 if(fDetTypeSim->GetSDigits()==0x0) fDetTypeSim->SetSDigits(new TClonesArray("AliITSpListItem",1000));
356 TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
357 MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
360 //______________________________________________________________________
361 void AliITS::MakeBranchD(const char* file){
363 //Make branch for digits
365 Warning("MakeBranchD","fDetTypeSim is 0!");
368 fDetTypeSim->SetLoader(fLoader);
369 MakeBranchInTreeD(fLoader->TreeD(),file);
372 //___________________________________________________________________
373 void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
374 // Creates Tree branches for the ITS.
377 Error("MakeBranchS","fDetTypeSim is 0!");
379 fDetTypeSim->SetLoader(fLoader);
381 const Char_t *det[3] = {"SPD","SDD","SSD"};
383 Int_t buffersize = 4000;
384 Char_t branchname[30];
386 if(!fDetTypeSim->GetDigits()){
387 fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
389 for(Int_t i=0;i<fgkNTYPES;i++){
390 digclass = fDetTypeSim->GetDigitClassName(i);
391 TString classn = digclass;
392 if(!((fDetTypeSim->GetDigits())->At(i))){
393 (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
396 if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
397 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
398 TObjArray* dig = DigitsAddress(i);
399 if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
403 //______________________________________________________________________
404 void AliITS::SetTreeAddress(){
405 // Set branch address for the Trees.
414 Error("SetTreeAddress","fDetTypeSim is 0!");
418 fDetTypeSim->SetLoader(fLoader);
420 TTree *treeS = fLoader->TreeS();
421 TTree *treeD = fLoader->TreeD();
422 if (fLoader->TreeH() && (fHits == 0x0)) {
423 fHits = new TClonesArray("AliITShit", 1560);
425 AliDetector::SetTreeAddress();
427 fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
428 fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
432 //______________________________________________________________________
433 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
435 // The function to add information to the AliITShit class. See the
436 // AliITShit class for a full description. This function allocates the
437 // necessary new space for the hit information and passes the variable
438 // track, and the pointers *vol and *hits to the AliITShit constructor
441 // Int_t track Track number which produced this hit.
442 // Int_t *vol Array of Integer Hit information. See AliITShit.h
443 // Float_t *hits Array of Floating Hit information. see AliITShit.h
448 TClonesArray &lhits = *fHits;
449 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
453 //______________________________________________________________________
454 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
455 Option_t *option, const char *filename){
456 // fill the modules with the sorted by module hits; add hits from
457 // background if option=Add.
459 static TTree *trH1; //Tree with background hits
460 static Bool_t first=kTRUE;
462 const char *addBgr = strstr(option,"Add");
464 evnt = nmodules; // Dummy use of variables to remove warnings
467 file=new TFile(filename);
472 // Get Hits Tree header from file
473 if(trH1) delete trH1;
477 sprintf(treeName,"TreeH%d",bgrev);
478 trH1 = (TTree*)gDirectory->Get(treeName);
480 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
482 // Set branch addresses
485 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
488 FillModules(trH1,10000000); // Default mask 10M.
489 TTree *fAli=fLoader->GetRunLoader()->TreeK();
491 if (fAli) fileAli =fAli->GetCurrentFile();
499 //______________________________________________________________________
500 void AliITS::FillModules(TTree *treeH, Int_t mask) {
501 // fill the modules with the sorted by module hits;
502 // can be called many times to do a merging
504 // TTree *treeH The tree containing the hits to be copied into
506 // Int_t mask The track number mask to indecate which file
507 // this hits came from.
515 Error("FillModules","Tree is NULL");
517 Int_t lay,lad,det,index;
521 sprintf(branchname,"%s",GetName());
522 TBranch *branch = treeH->GetBranch(branchname);
524 Error("FillModules","%s branch in TreeH not found",branchname);
527 branch->SetAddress(&fHits);
528 Int_t nTracks =(Int_t) treeH->GetEntries();
530 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
532 Int_t nBytes = treeH->GetEvent(iPrimTrack);
533 if (nBytes <= 0) continue;
534 Int_t nHits = fHits->GetEntriesFast();
535 for(h=0; h<nHits; h++){
536 itsHit = (AliITShit *)fHits->UncheckedAt(h);
537 itsHit->GetDetectorID(lay,lad,det);
539 index = GetITSgeom()->GetModuleIndex(lay,lad,det);
541 index=det-1; // This should not be used.
542 } // end if [You must have fITSgeom for this to work!]
543 mod = GetModule(index);
544 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
545 mod->AddHit(itsHit,iPrimTrack,h);
546 } // end loop over hits
547 } // end loop over tracks
550 //______________________________________________________________________
551 void AliITS::InitModules(Int_t size,Int_t &nmodules){
552 // Initialize the modules array.
554 // Int_t size Size of array of the number of modules to be
555 // created. If size <=0 then the number of modules
556 // is gotten from AliITSgeom class kept in fITSgeom.
558 // Int_t &nmodules The number of modules existing.
563 fITSmodules->Delete();
565 } // end fir fITSmoudles
568 Error("InitModules","fDetTypeSim is null!");
572 Int_t nl,indexMAX,index;
574 if(size<=0){ // default to using data stored in AliITSgeom
575 if(fDetTypeSim->GetITSgeom()==0) {
576 Error("InitModules","fITSgeom not defined");
578 } // end if fITSgeom==0
579 nl = fDetTypeSim->GetITSgeom()->GetNlayers();
580 indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
582 fITSmodules = new TObjArray(indexMAX);
583 for(index=0;index<indexMAX;index++){
584 fITSmodules->AddAt( new AliITSmodule(index),index);
587 fITSmodules = new TObjArray(size);
588 for(index=0;index<size;index++) {
589 fITSmodules->AddAt( new AliITSmodule(index),index);
595 //______________________________________________________________________
596 void AliITS::Hits2SDigits(){
597 // Standard Hits to summable Digits function.
605 Error("Hits2SDigits","fDetTypeSim is null!");
611 fLoader->LoadHits("read");
612 fLoader->LoadSDigits("recreate");
613 AliRunLoader* rl = fLoader->GetRunLoader();
614 fDetTypeSim->SetLoader(fLoader);
615 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
616 // Do the Hits to Digits operation. Use Standard input values.
617 // Event number from file, no background hit merging , use size from
618 // AliITSgeom class, option="All", input from this file only.
619 rl->GetEvent(iEvent);
620 if (!fLoader->TreeS()) fLoader->MakeTree("S");
623 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
626 fLoader->UnloadHits();
627 fLoader->UnloadSDigits();
630 //______________________________________________________________________
631 void AliITS::Hits2Digits(){
633 //Conversion from hits to digits
635 Error("Hits2SDigits","fDetTypeSim is 0!");
639 fDetTypeSim->SetLoader(fLoader);
642 fLoader->LoadHits("read");
643 fLoader->LoadDigits("recreate");
644 AliRunLoader* rl = fLoader->GetRunLoader();
645 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
646 rl->GetEvent(iEvent);
647 if (!fLoader->TreeD()) fLoader->MakeTree("D");
650 HitsToDigits(iEvent,0,-1," ",fOpt," ");
653 fLoader->UnloadHits();
654 fLoader->UnloadDigits();
658 //______________________________________________________________________
659 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
660 Option_t *option,Option_t *opt,
661 const char *filename){
662 // Keep galice.root for signal and name differently the file for
663 // background when add! otherwise the track info for signal will be lost !
664 // the condition below will disappear when the geom class will be
665 // initialized for all versions - for the moment it is only for v5 !
666 // 7 is the SDD beam test version.
668 // Int_t evnt Event to be processed.
669 // Int_t bgrev Background Hit tree number.
670 // Int_t nmodules Not used.
671 // Option_t *option String indicating if merging hits or not. To
672 // merge hits set equal to "Add". Otherwise no
673 // background hits are considered.
674 // Test_t *filename File name containing the background hits..
681 Error("HitsToDigits","fDetTypeSim is null!");
684 fDetTypeSim->SetLoader(fLoader);
685 if(!GetITSgeom()) return; // need transformations to do digitization.
686 AliITSgeom *geom = GetITSgeom();
688 const char *all = strstr(opt,"All");
689 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
691 static Bool_t setDef=kTRUE;
692 if (setDef) SetDefaultSimulation();
696 InitModules(size,nmodules);
697 FillModules(evNumber,bgrev,nmodules,option,filename);
699 AliITSsimulation *sim = 0;
700 AliITSmodule *mod = 0;
702 for(Int_t module=0;module<geom->GetIndexMax();module++){
703 id = geom->GetModuleType(module);
704 if (!all && !det[id]) continue;
705 sim = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
707 Error("HitsToDigits","The simulation class was not "
708 "instanciated for module %d type %s!",module,
709 geom->GetModuleTypeName(module));
712 mod = (AliITSmodule *)fITSmodules->At(module);
713 sim->DigitiseModule(mod,module,evNumber);
714 // fills all branches - wasted disk space
715 fLoader->TreeD()->Fill();
721 fLoader->TreeD()->GetEntries();
722 fLoader->TreeD()->AutoSave();
724 fLoader->TreeD()->Reset();
726 //_____________________________________________________________________
727 void AliITS::Hits2PreDigits(){
728 // Turn hits into SDigits
731 Error("Hits2SDigits","fDetTypeSim is 0!");
735 fDetTypeSim->SetLoader(fLoader);
738 HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
742 //______________________________________________________________________
743 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
744 Option_t *option,Option_t *opt,
745 const char *filename){
746 // Keep galice.root for signal and name differently the file for
747 // background when add! otherwise the track info for signal will be lost !
748 // the condition below will disappear when the geom class will be
749 // initialized for all versions - for the moment it is only for v5 !
750 // 7 is the SDD beam test version.
752 // Int_t evnt Event to be processed.
753 // Int_t bgrev Background Hit tree number.
754 // Int_t nmodules Not used.
755 // Option_t *option String indicating if merging hits or not. To
756 // merge hits set equal to "Add". Otherwise no
757 // background hits are considered.
758 // Test_t *filename File name containing the background hits..
766 Error("HitsToPreDigits","fDetTypeSim is null!");
769 fDetTypeSim->SetLoader(fLoader);
772 Error("HitsToPreDigits","fGeom is null!");
773 return; // need transformations to do digitization.
775 AliITSgeom *geom = GetITSgeom();
777 const char *all = strstr(opt,"All");
778 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
780 static Bool_t setDef=kTRUE;
781 if (setDef) SetDefaultSimulation();
785 InitModules(size,nmodules);
786 FillModules(evNumber,bgrev,nmodules,option,filename);
789 AliITSsimulation *sim = 0;
790 AliITSmodule *mod = 0;
792 for(module=0;module<geom->GetIndexMax();module++){
793 id = geom->GetModuleType(module);
794 if (!all && !det[id]) continue;
795 sim = (AliITSsimulation*)GetSimulationModel(id);
797 Error("HitsToPreDigits","The simulation class was not "
798 "instanciated for module %d type %s!",module,
799 geom->GetModuleTypeName(module));
802 mod = (AliITSmodule *)fITSmodules->At(module);
803 sim->SDigitiseModule(mod,module,evNumber);
804 // fills all branches - wasted disk space
805 fLoader->TreeS()->Fill();
806 fDetTypeSim->ResetSDigits();
812 fLoader->TreeS()->GetEntries();
813 fLoader->TreeS()->AutoSave();
814 fLoader->WriteSDigits("OVERWRITE");
816 fLoader->TreeS()->Reset();
819 //_____________________________________________________________________
820 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
821 Option_t *opt0,Option_t *opt1,
823 // keep galice.root for signal and name differently the file for
824 // background when add! otherwise the track info for signal will be lost !
825 // the condition below will disappear when the geom class will be
826 // initialized for all versions - for the moment it is only for v5 !
828 // Int_t evnt Event to be processed.
829 // Int_t bgrev Background Hit tree number.
830 // Int_t size Size used by InitModules. See InitModules.
831 // Option_t *opt0 Option passed to FillModules. See FillModules.
832 // Option_t *opt1 String indicating if merging hits or not. To
833 // merge hits set equal to "Add". Otherwise no
834 // background hits are considered.
835 // 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();
862 TBranch* branch = lTR->GetBranch("ITSRecPointsF");
863 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
864 if(branch) branch->SetAddress(ptarray);
865 else lTR->Branch("ITSRecPointsF",&ptarray);
868 //m.b. : this change is nothing but a nice way to make sure
870 AliDebug(1,Form("N mod = %d",geom->GetIndexMax()));
871 for(module=0;module<geom->GetIndexMax();module++){
872 id = geom->GetModuleType(module);
873 if (!all && !det[id]) continue;
874 sim = (AliITSsimulation*)GetSimulationModel(id);
876 Error("HitsToFastPoints","The simulation class was not "
877 "instanciated for module %d type %x!",module,
878 geom->GetModuleTypeName(module));
881 mod = (AliITSmodule *)fITSmodules->At(module);
882 sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
887 fLoader->WriteRecPoints("OVERWRITE");
890 //_____________________________________________________________________
891 Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
892 //------------------------------------------------------------
893 // This function creates ITS clusters
894 //------------------------------------------------------------
896 Error("HitsToPreDigits","fGeom is null!");
897 return 1; // need transformations to do digitization.
899 AliITSgeom *geom=GetITSgeom();
900 Int_t mmax=geom->GetIndexMax();
902 InitModules(-1,mmax);
903 FillModules(hTree,0);
905 TClonesArray *clusters=new TClonesArray("AliITSclusterV2",1000);
906 TBranch *branch=cTree->GetBranch("Clusters");
907 if (!branch) cTree->Branch("Clusters",&clusters);
908 else branch->SetAddress(&clusters);
910 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
912 AliITSsimulationFastPoints sim;
914 for (Int_t m=0; m<mmax; m++) {
915 AliITSmodule *mod=GetModule(m);
916 sim.CreateFastRecPoints(mod,m,gRandom,points);
917 RecPoints2Clusters(points, m, clusters);
918 ncl+=clusters->GetEntriesFast();
924 Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
932 //_____________________________________________________________________
933 void AliITS::RecPoints2Clusters
934 (const TClonesArray *points, Int_t idx, TClonesArray *clusters) {
935 //------------------------------------------------------------
936 // Conversion AliITSRecPoint -> AliITSclusterV2 for the ITS
937 // subdetector indexed by idx
938 //------------------------------------------------------------
941 Error("HitsToPreDigits","fGeom is null!");
942 return; // need transformations to do digitization.
944 AliITSgeom *g=GetITSgeom();
945 Int_t mmax = g->GetIndexMax();
946 Float_t yshift[2200];
947 Float_t zshift[2200];
949 for (Int_t m=0; m<mmax; m++) {
950 Int_t lay,lad,det; g->GetModuleId(m,lay,lad,det);
951 Float_t x,y,z; g->GetTrans(lay,lad,det,x,y,z);
952 Double_t rot[9]; g->GetRotMatrix(lay,lad,det,rot);
953 Double_t alpha=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
954 Double_t ca=TMath::Cos(alpha), sa=TMath::Sin(alpha);
955 yshift[m] = x*ca + y*sa;
956 zshift[m] = (Double_t)z;
957 ndet[m] = (lad-1)*g->GetNdetectors(lay) + (det-1);
961 Float_t lastSPD1=g->GetModuleIndex(2,1,1)-1;
963 TClonesArray &cl=*clusters;
964 Int_t ncl=points->GetEntriesFast();
965 for (Int_t i=0; i<ncl; i++) {
966 AliITSRecPoint *p = (AliITSRecPoint *)points->UncheckedAt(i);
968 lp[0]=-(-p->GetX()+yshift[idx]); if (idx<=lastSPD1) lp[0]*=-1; //SPD1
969 lp[1]= -p->GetZ()+zshift[idx];
970 lp[2]=p->GetSigmaX2();
971 lp[3]=p->GetSigmaZ2();
972 lp[4]=p->GetQ()*36./23333.; //electrons -> ADC
974 lab[0]=p->GetLabel(0); lab[1]=p->GetLabel(1); lab[2]=p->GetLabel(2);
977 Int_t dummy[3]={0,0,0};
978 new (cl[i]) AliITSclusterV2(lab,lp, dummy);
981 //_____________________________________________________________________
982 void AliITS::CheckLabels(Int_t lab[3]) const {
983 //------------------------------------------------------------
984 // Tries to find mother's labels
985 //------------------------------------------------------------
987 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
989 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
990 for (Int_t i=0;i<3;i++){
991 Int_t label = lab[i];
992 if (label>=0 && label<ntracks) {
993 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
994 if (part->P() < 0.005) {
995 Int_t m=part->GetFirstMother();
999 if (part->GetStatusCode()>0) {
1009 //______________________________________________________________________
1010 void AliITS::SDigitsToDigits(Option_t *opt){
1011 // Standard Summable digits to Digits function.
1017 Error("SDigitsToSDigits","fDetTypeSim is 0!");
1021 fDetTypeSim->SetLoader(fLoader);
1023 fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
1027 //______________________________________________________________________
1028 void AliITS::ResetDigits(){
1029 // Reset number of digits and the digits array for the ITS detector.
1035 Error("ResetDigits","fDetTypeSim is 0!");
1039 fDetTypeSim->ResetDigits();
1043 //______________________________________________________________________
1044 void AliITS::ResetDigits(Int_t branch){
1045 // Reset number of digits and the digits array for this branch.
1052 Error("ResetDigits","fDetTypeSim is 0!");
1056 fDetTypeSim->ResetDigits(branch);
1059 //______________________________________________________________________
1060 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1061 // Adds the a module full of summable digits to the summable digits tree.
1063 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1070 Error("AddSumDigit","fDetTypeSim is 0!");
1073 fDetTypeSim->AddSumDigit(sdig);
1076 //______________________________________________________________________
1077 void AliITS::AddRealDigit(Int_t branch, Int_t *digits){
1078 // Add a real digit - as coming from data.
1080 // Int_t id Detector type number.
1081 // Int_t *digits Integer array containing the digits info. See
1089 Error("AddRealDigit","fDetTypeSim is 0!");
1092 fDetTypeSim->AddRealDigit(branch,digits);
1095 //______________________________________________________________________
1096 void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
1097 // Add a simulated digit.
1099 // Int_t id Detector type number.
1100 // AliITSdigit *d Digit to be added to the Digits Tree. See
1108 Error("AddSimDigit","fDetTypeSim is 0!");
1111 fDetTypeSim->AddSimDigit(branch,d);
1114 //______________________________________________________________________
1115 void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
1116 Int_t *hits,Float_t *charges){
1117 // Add a simulated digit to the list.
1119 // Int_t id Detector type number.
1120 // Float_t phys Physics indicator. See AliITSdigits.h
1121 // Int_t *digits Integer array containing the digits info. See
1123 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1124 // containing the track numbers that contributed to
1126 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1127 // containing the hit numbers, from AliITSmodule, that
1128 // contributed to this digit.
1129 // Float_t *charge Floating point array of the signals contributed
1130 // to this digit by each track.
1137 Error("AddSimDigit","fDetTypeSim is 0!");
1140 fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges);
1143 //______________________________________________________________________
1144 void AliITS::Digits2Raw(){
1145 // convert digits of the current event to raw data
1148 Error("Digits2Raw","fDetTypeSim is 0!");
1151 fDetTypeSim->SetLoader(fLoader);
1153 fDetTypeSim->GetLoader()->LoadDigits();
1154 TTree* digits = fDetTypeSim->GetLoader()->TreeD();
1156 Error("Digits2Raw", "no digits tree");
1159 fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
1161 AliITSDDLRawData rawWriter;
1165 // 2: txt files with digits
1166 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1167 //it is highly suggested to use this mode only for debugging digits files
1168 //reasonably small, because otherwise the size of the txt files can reach
1169 //quickly several MB wasting time and disk space.
1170 rawWriter.SetVerbose(0);
1172 //SILICON PIXEL DETECTOR
1173 Info("Digits2Raw", "Formatting raw data for SPD");
1174 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"));
1176 //SILICON DRIFT DETECTOR
1177 Info("Digits2Raw", "Formatting raw data for SDD");
1178 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"));
1180 //SILICON STRIP DETECTOR
1181 Info("Digits2Raw", "Formatting raw data for SSD");
1182 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1184 fLoader->UnloadDigits();
1194 //______________________________________________________________________
1195 AliLoader* AliITS::MakeLoader(const char* topfoldername){
1196 //builds ITSgetter (AliLoader type)
1197 //if detector wants to use castomized getter, it must overload this method
1199 Info("MakeLoader","Creating AliITSLoader. Top folder is %s.",
1201 fLoader = new AliITSLoader(GetName(),topfoldername);