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 "AliITSresponseSDD.h"
95 #include "AliRawReader.h"
98 #include "AliITSInitGeometry.h"
102 //______________________________________________________________________
103 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 *name, const char *title):AliDetector(name,title),
132 // The standard Constructor for the ITS class.
133 // It also zeros the variables
134 // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
135 // the pointers fIdSens and fIdName. To help in displaying hits via the
136 // ROOT macro display.C AliITS also sets the marker color to red. The
137 // variables passes with this constructor, const char *name and *title,
138 // are used by the constructor of AliDetector class. See AliDetector
139 // class for a description of these parameters and its constructor
142 fHits = new TClonesArray("AliITShit",1560);
143 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
144 //fNhits=0; //done in AliDetector(name,title)
146 SetDetectors(); // default to fOpt="All". This variable not written out.
148 fDetTypeSim = new AliITSDetTypeSim();
150 //PH SetMarkerColor(kRed);
151 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
152 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
155 //______________________________________________________________________
157 // Default destructor for ITS.
158 // The default destructor of the AliITS class. In addition to deleting
159 // the AliITS class it deletes the memory pointed to by
160 // fIdSens, fIdName, fDetTypeSim and it's contents.
174 this->ClearModules();
177 }// end if fITSmodules!=0
179 delete[] fIdName; // Array of TStrings
187 //______________________________________________________________________
188 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
189 // Creates the AliITSDigitizer in a standard way for use via AliModule.
190 // This function can not be included in the .h file because of problems
191 // with the order of inclusion (recursive).
193 // AliRunDigitizer *manager The Manger class for Digitization
197 // A new AliITSRunDigitizer (cast as a AliDigitizer).
199 return new AliITSDigitizer(manager);
201 //______________________________________________________________________
203 // Initializer ITS after it has been built
204 // This routine initializes the AliITS class. It is intended to be
205 // called from the Init function in AliITSv?. Besides displaying a banner
206 // indicating that it has been called it initializes the array fIdSens
207 // and sets the default segmentation, response, digit and raw cluster
208 // classes therefore it should be called after a call to CreateGeometry.
219 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
224 //______________________________________________________________________
225 void AliITS::WriteGeometry(){
227 //Writes ITS geometry on gAlice
229 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
230 AliRunLoader* rl = fLoader->GetRunLoader();
232 AliITSgeom* geom = GetITSgeom();
237 //______________________________________________________________________
238 void AliITS::SetDefaults(){
239 // sets the default segmentation, response, digit and raw cluster classes.
246 AliInfoClass("AliITS::Setting Defaults");
249 Error("SetDefaults()","fDetTypeSim is 0!");
253 fDetTypeSim->SetDefaults();
257 //______________________________________________________________________
258 void AliITS::SetDefaultSimulation(){
259 // sets the default simulation.
267 Error("SetDefaultSimulation()","fDetTypeSim is 0!");
271 fDetTypeSim->SetDefaultSimulation();
276 //______________________________________________________________________
277 void AliITS::MakeBranch(Option_t* option){
278 // Creates Tree branches for the ITS.
280 // Option_t *option String of Tree types S,D, and/or R.
281 // const char *file String of the file name where these branches
282 // are to be stored. If blank then these branches
283 // are written to the same tree as the Hits were
290 Error("MakeBranch","fDetTypeSim is 0!");
294 Bool_t cH = (strstr(option,"H")!=0);
295 Bool_t cS = (strstr(option,"S")!=0);
296 Bool_t cD = (strstr(option,"D")!=0);
298 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
299 AliDetector::MakeBranch(option);
301 if(cS) MakeBranchS(0);
302 if(cD) MakeBranchD(0);
306 //___________________________________________________________________
307 void AliITS::MakeBranchS(const char* fl){
309 // Creates Tree Branch for the ITS summable digits.
311 // cont char *fl File name where SDigits branch is to be written
312 // to. If blank it write the SDigits to the same
313 // file in which the Hits were found.
317 Error("MakeBranchS","fDetTypeSim is 0!");
319 Int_t buffersize = 4000;
322 // only one branch for SDigits.
323 sprintf(branchname,"%s",GetName());
325 if(fLoader->TreeS()){
326 if(fDetTypeSim->GetSDigits()==0x0) fDetTypeSim->SetSDigits(new TClonesArray("AliITSpListItem",1000));
327 TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
328 MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
331 //______________________________________________________________________
332 void AliITS::MakeBranchD(const char* file){
334 //Make branch for digits
336 Warning("MakeBranchD","fDetTypeSim is 0!");
339 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
340 MakeBranchInTreeD(fLoader->TreeD(),file);
343 //___________________________________________________________________
344 void AliITS:: MakeBranchInTreeD(TTree* treeD, const char* file){
345 // Creates Tree branches for the ITS.
348 Error("MakeBranchS","fDetTypeSim is 0!");
350 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
352 const Char_t *det[3] = {"SPD","SDD","SSD"};
354 Int_t buffersize = 4000;
355 Char_t branchname[30];
357 if(!fDetTypeSim->GetDigits()){
358 fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
360 for(Int_t i=0;i<fgkNTYPES;i++){
361 digclass = fDetTypeSim->GetDigitClassName(i);
362 TString classn = digclass;
363 if(!((fDetTypeSim->GetDigits())->At(i))){
364 (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
367 if(fgkNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
368 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
369 TObjArray* dig = DigitsAddress(i);
370 if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
374 //______________________________________________________________________
375 void AliITS::SetTreeAddress(){
376 // Set branch address for the Trees.
385 Error("SetTreeAddress","fDetTypeSim is 0!");
389 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
391 TTree *treeS = fLoader->TreeS();
392 TTree *treeD = fLoader->TreeD();
393 if (fLoader->TreeH() && (fHits == 0x0)) {
394 fHits = new TClonesArray("AliITShit", 1560);
396 AliDetector::SetTreeAddress();
398 fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
399 fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
401 //______________________________________________________________________
402 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
404 // The function to add information to the AliITShit class. See the
405 // AliITShit class for a full description. This function allocates the
406 // necessary new space for the hit information and passes the variable
407 // track, and the pointers *vol and *hits to the AliITShit constructor
410 // Int_t track Track number which produced this hit.
411 // Int_t *vol Array of Integer Hit information. See AliITShit.h
412 // Float_t *hits Array of Floating Hit information. see AliITShit.h
417 TClonesArray &lhits = *fHits;
418 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
421 //______________________________________________________________________
422 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
423 Option_t *option, const char *filename){
424 // fill the modules with the sorted by module hits; add hits from
425 // background if option=Add.
427 static TTree *trH1; //Tree with background hits
428 static Bool_t first=kTRUE;
430 const char *addBgr = strstr(option,"Add");
432 evnt = nmodules; // Dummy use of variables to remove warnings
435 file=new TFile(filename);
440 // Get Hits Tree header from file
441 if(trH1) delete trH1;
445 sprintf(treeName,"TreeH%d",bgrev);
446 trH1 = (TTree*)gDirectory->Get(treeName);
448 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
450 // Set branch addresses
453 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
456 FillModules(trH1,10000000); // Default mask 10M.
457 TTree *fAli=fLoader->GetRunLoader()->TreeK();
459 if (fAli) fileAli =fAli->GetCurrentFile();
467 //______________________________________________________________________
468 void AliITS::FillModules(TTree *treeH, Int_t mask) {
469 // fill the modules with the sorted by module hits;
470 // can be called many times to do a merging
472 // TTree *treeH The tree containing the hits to be copied into
474 // Int_t mask The track number mask to indecate which file
475 // this hits came from.
483 Error("FillModules","Tree is NULL");
485 Int_t lay,lad,det,index;
489 sprintf(branchname,"%s",GetName());
490 TBranch *branch = treeH->GetBranch(branchname);
492 Error("FillModules","%s branch in TreeH not found",branchname);
495 branch->SetAddress(&fHits);
496 Int_t nTracks =(Int_t) treeH->GetEntries();
498 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
500 Int_t nBytes = treeH->GetEvent(iPrimTrack);
501 if (nBytes <= 0) continue;
502 Int_t nHits = fHits->GetEntriesFast();
503 for(h=0; h<nHits; h++){
504 itsHit = (AliITShit *)fHits->UncheckedAt(h);
505 itsHit->GetDetectorID(lay,lad,det);
507 index = GetITSgeom()->GetModuleIndex(lay,lad,det);
509 index=det-1; // This should not be used.
510 } // end if [You must have fITSgeom for this to work!]
511 mod = GetModule(index);
512 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
513 mod->AddHit(itsHit,iPrimTrack,h);
514 } // end loop over hits
515 } // end loop over tracks
518 //______________________________________________________________________
519 void AliITS::InitModules(Int_t size,Int_t &nmodules){
520 // Initialize the modules array.
522 // Int_t size Size of array of the number of modules to be
523 // created. If size <=0 then the number of modules
524 // is gotten from AliITSgeom class kept in fITSgeom.
526 // Int_t &nmodules The number of modules existing.
531 fITSmodules->Delete();
533 } // end fir fITSmoudles
536 Error("InitModules","fDetTypeSim is null!");
540 Int_t nl,indexMAX,index;
542 if(size<=0){ // default to using data stored in AliITSgeom
543 if(fDetTypeSim->GetITSgeom()==0) {
544 Error("InitModules","fITSgeom not defined");
546 } // end if fITSgeom==0
547 nl = fDetTypeSim->GetITSgeom()->GetNlayers();
548 indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
550 fITSmodules = new TObjArray(indexMAX);
551 for(index=0;index<indexMAX;index++){
552 fITSmodules->AddAt( new AliITSmodule(index),index);
555 fITSmodules = new TObjArray(size);
556 for(index=0;index<size;index++) {
557 fITSmodules->AddAt( new AliITSmodule(index),index);
563 //______________________________________________________________________
564 void AliITS::Hits2SDigits(){
565 // Standard Hits to summable Digits function.
573 Error("Hits2SDigits","fDetTypeSim is null!");
579 fLoader->LoadHits("read");
580 fLoader->LoadSDigits("recreate");
581 AliRunLoader* rl = fLoader->GetRunLoader();
582 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
583 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
584 // Do the Hits to Digits operation. Use Standard input values.
585 // Event number from file, no background hit merging , use size from
586 // AliITSgeom class, option="All", input from this file only.
587 rl->GetEvent(iEvent);
588 if (!fLoader->TreeS()) fLoader->MakeTree("S");
591 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
594 fLoader->UnloadHits();
595 fLoader->UnloadSDigits();
598 //______________________________________________________________________
599 void AliITS::Hits2Digits(){
601 //Conversion from hits to digits
603 Error("Hits2SDigits","fDetTypeSim is 0!");
607 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
610 fLoader->LoadHits("read");
611 fLoader->LoadDigits("recreate");
612 AliRunLoader* rl = fLoader->GetRunLoader();
613 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
614 rl->GetEvent(iEvent);
615 if (!fLoader->TreeD()) fLoader->MakeTree("D");
618 HitsToDigits(iEvent,0,-1," ",fOpt," ");
621 fLoader->UnloadHits();
622 fLoader->UnloadDigits();
626 //______________________________________________________________________
627 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
628 Option_t *option,Option_t *opt,
629 const char *filename){
630 // Keep galice.root for signal and name differently the file for
631 // background when add! otherwise the track info for signal will be lost !
632 // the condition below will disappear when the geom class will be
633 // initialized for all versions - for the moment it is only for v5 !
634 // 7 is the SDD beam test version.
636 // Int_t evnt Event to be processed.
637 // Int_t bgrev Background Hit tree number.
638 // Int_t nmodules Not used.
639 // Option_t *option String indicating if merging hits or not. To
640 // merge hits set equal to "Add". Otherwise no
641 // background hits are considered.
642 // Test_t *filename File name containing the background hits..
649 Error("HitsToDigits","fDetTypeSim is null!");
652 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
653 if(!GetITSgeom()) return; // need transformations to do digitization.
654 AliITSgeom *geom = GetITSgeom();
656 const char *all = strstr(opt,"All");
657 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
659 static Bool_t setDef=kTRUE;
660 if (setDef) SetDefaultSimulation();
664 InitModules(size,nmodules);
665 FillModules(evNumber,bgrev,nmodules,option,filename);
667 AliITSsimulation *sim = 0;
668 AliITSmodule *mod = 0;
670 for(Int_t module=0;module<geom->GetIndexMax();module++){
671 id = geom->GetModuleType(module);
672 if (!all && !det[id]) continue;
673 sim = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
675 Error("HitsToDigits","The simulation class was not "
676 "instanciated for module %d type %s!",module,
677 geom->GetModuleTypeName(module));
680 mod = (AliITSmodule *)fITSmodules->At(module);
681 sim->DigitiseModule(mod,module,evNumber);
682 // fills all branches - wasted disk space
683 fLoader->TreeD()->Fill();
689 fLoader->TreeD()->GetEntries();
690 fLoader->TreeD()->AutoSave();
692 fLoader->TreeD()->Reset();
694 //_____________________________________________________________________
695 void AliITS::Hits2PreDigits(){
696 // Turn hits into SDigits
699 Error("Hits2SDigits","fDetTypeSim is 0!");
703 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
706 HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
710 //______________________________________________________________________
711 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
712 Option_t *option,Option_t *opt,
713 const char *filename){
714 // Keep galice.root for signal and name differently the file for
715 // background when add! otherwise the track info for signal will be lost !
716 // the condition below will disappear when the geom class will be
717 // initialized for all versions - for the moment it is only for v5 !
718 // 7 is the SDD beam test version.
720 // Int_t evnt Event to be processed.
721 // Int_t bgrev Background Hit tree number.
722 // Int_t nmodules Not used.
723 // Option_t *option String indicating if merging hits or not. To
724 // merge hits set equal to "Add". Otherwise no
725 // background hits are considered.
726 // Test_t *filename File name containing the background hits..
734 Error("HitsToPreDigits","fDetTypeSim is null!");
737 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
740 Error("HitsToPreDigits","fGeom is null!");
741 return; // need transformations to do digitization.
743 AliITSgeom *geom = GetITSgeom();
745 const char *all = strstr(opt,"All");
746 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
748 static Bool_t setDef=kTRUE;
749 if (setDef) SetDefaultSimulation();
753 InitModules(size,nmodules);
754 FillModules(evNumber,bgrev,nmodules,option,filename);
757 AliITSsimulation *sim = 0;
758 AliITSmodule *mod = 0;
760 for(module=0;module<geom->GetIndexMax();module++){
761 id = geom->GetModuleType(module);
762 if (!all && !det[id]) continue;
763 sim = (AliITSsimulation*)GetSimulationModel(id);
765 Error("HitsToPreDigits","The simulation class was not "
766 "instanciated for module %d type %s!",module,
767 geom->GetModuleTypeName(module));
770 mod = (AliITSmodule *)fITSmodules->At(module);
771 sim->SDigitiseModule(mod,module,evNumber);
772 // fills all branches - wasted disk space
773 fLoader->TreeS()->Fill();
774 fDetTypeSim->ResetSDigits();
780 fLoader->TreeS()->GetEntries();
781 fLoader->TreeS()->AutoSave();
782 fLoader->WriteSDigits("OVERWRITE");
784 fLoader->TreeS()->Reset();
787 //_____________________________________________________________________
788 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
789 Option_t *opt0,Option_t *opt1,
791 // keep galice.root for signal and name differently the file for
792 // background when add! otherwise the track info for signal will be lost !
793 // the condition below will disappear when the geom class will be
794 // initialized for all versions - for the moment it is only for v5 !
796 // Int_t evnt Event to be processed.
797 // Int_t bgrev Background Hit tree number.
798 // Int_t size Size used by InitModules. See InitModules.
799 // Option_t *opt0 Option passed to FillModules. See FillModules.
800 // Option_t *opt1 String indicating if merging hits or not. To
801 // merge hits set equal to "Add". Otherwise no
802 // background hits are considered.
803 // Test_t *flnm File name containing the background hits..
812 Error("HitsToPreDigits","fGeom is null!");
813 return; // need transformations to do digitization.
815 AliITSgeom *geom = GetITSgeom();
817 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
819 const char *all = strstr(opt1,"All");
820 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
823 InitModules(size,nmodules);
824 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
826 AliITSsimulation *sim = 0;
827 AliITSmodule *mod = 0;
830 TTree *lTR = pITSloader->TreeR();
832 pITSloader->MakeTree("R");
833 lTR = pITSloader->TreeR();
836 TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
837 TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
838 branch->SetAddress(&ptarray);
839 //m.b. : this change is nothing but a nice way to make sure
841 for(module=0;module<geom->GetIndexMax();module++){
842 id = geom->GetModuleType(module);
843 if (!all && !det[id]) continue;
844 sim = (AliITSsimulation*)GetSimulationModel(id);
846 Error("HitsToFastPoints","The simulation class was not "
847 "instanciated for module %d type %x!",module,
848 geom->GetModuleTypeName(module));
851 mod = (AliITSmodule *)fITSmodules->At(module);
852 sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
857 fLoader->WriteRecPoints("OVERWRITE");
860 //_____________________________________________________________________
861 Int_t AliITS::Hits2Clusters(TTree *hTree, TTree *cTree) {
862 //------------------------------------------------------------
863 // This function creates ITS clusters
864 //------------------------------------------------------------
866 Error("HitsToPreDigits","fGeom is null!");
867 return 1; // need transformations to do digitization.
869 AliITSgeom *geom=GetITSgeom();
870 Int_t mmax=geom->GetIndexMax();
872 InitModules(-1,mmax);
873 FillModules(hTree,0);
875 TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
876 TBranch *branch=cTree->GetBranch("ITSRecPoints");
877 if (!branch) cTree->Branch("ITSRecPoints",&points);
878 else branch->SetAddress(&points);
880 AliITSsimulationFastPoints sim;
882 for (Int_t m=0; m<mmax; m++) {
883 AliITSmodule *mod=GetModule(m);
884 sim.CreateFastRecPoints(mod,m,gRandom,points);
885 ncl+=points->GetEntriesFast();
890 Info("Hits2Clusters","Number of found fast clusters : %d",ncl);
898 //_____________________________________________________________________
899 void AliITS::CheckLabels(Int_t lab[3]) const {
900 //------------------------------------------------------------
901 // Tries to find mother's labels
902 //------------------------------------------------------------
904 if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
906 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
907 for (Int_t i=0;i<3;i++){
908 Int_t label = lab[i];
909 if (label>=0 && label<ntracks) {
910 TParticle *part=(TParticle*)gAlice->GetMCApp()->Particle(label);
911 if (part->P() < 0.005) {
912 Int_t m=part->GetFirstMother();
916 if (part->GetStatusCode()>0) {
926 //______________________________________________________________________
927 void AliITS::SDigitsToDigits(Option_t *opt){
928 // Standard Summable digits to Digits function.
934 Error("SDigitsToSDigits","fDetTypeSim is 0!");
938 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
940 fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
944 //______________________________________________________________________
945 void AliITS::ResetDigits(){
946 // Reset number of digits and the digits array for the ITS detector.
952 Error("ResetDigits","fDetTypeSim is 0!");
956 fDetTypeSim->ResetDigits();
960 //______________________________________________________________________
961 void AliITS::ResetDigits(Int_t branch){
962 // Reset number of digits and the digits array for this branch.
969 Error("ResetDigits","fDetTypeSim is 0!");
973 fDetTypeSim->ResetDigits(branch);
976 //______________________________________________________________________
977 void AliITS::AddSumDigit(AliITSpListItem &sdig){
978 // Adds the a module full of summable digits to the summable digits tree.
980 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
987 Error("AddSumDigit","fDetTypeSim is 0!");
990 fDetTypeSim->AddSumDigit(sdig);
993 //______________________________________________________________________
994 void AliITS::AddRealDigit(Int_t branch, Int_t *digits){
995 // Add a real digit - as coming from data.
997 // Int_t id Detector type number.
998 // Int_t *digits Integer array containing the digits info. See
1006 Error("AddRealDigit","fDetTypeSim is 0!");
1009 fDetTypeSim->AddRealDigit(branch,digits);
1012 //______________________________________________________________________
1013 void AliITS::AddSimDigit(Int_t branch, AliITSdigit *d){
1014 // Add a simulated digit.
1016 // Int_t id Detector type number.
1017 // AliITSdigit *d Digit to be added to the Digits Tree. See
1025 Error("AddSimDigit","fDetTypeSim is 0!");
1028 fDetTypeSim->AddSimDigit(branch,d);
1031 //______________________________________________________________________
1032 void AliITS::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
1033 Int_t *hits,Float_t *charges){
1034 // Add a simulated digit to the list.
1036 // Int_t id Detector type number.
1037 // Float_t phys Physics indicator. See AliITSdigits.h
1038 // Int_t *digits Integer array containing the digits info. See
1040 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1041 // containing the track numbers that contributed to
1043 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1044 // containing the hit numbers, from AliITSmodule, that
1045 // contributed to this digit.
1046 // Float_t *charge Floating point array of the signals contributed
1047 // to this digit by each track.
1054 Error("AddSimDigit","fDetTypeSim is 0!");
1057 fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges);
1060 //______________________________________________________________________
1061 void AliITS::Digits2Raw(){
1062 // convert digits of the current event to raw data
1065 Error("Digits2Raw","fDetTypeSim is 0!");
1068 fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
1070 fDetTypeSim->GetLoader()->LoadDigits();
1071 TTree* digits = fDetTypeSim->GetLoader()->TreeD();
1073 Error("Digits2Raw", "no digits tree");
1076 fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
1078 AliITSDDLRawData rawWriter;
1082 // 2: txt files with digits
1083 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1084 //it is highly suggested to use this mode only for debugging digits files
1085 //reasonably small, because otherwise the size of the txt files can reach
1086 //quickly several MB wasting time and disk space.
1087 rawWriter.SetVerbose(0);
1089 //SILICON PIXEL DETECTOR
1090 Info("Digits2Raw", "Formatting raw data for SPD");
1091 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"));
1093 //SILICON DRIFT DETECTOR
1094 Info("Digits2Raw", "Formatting raw data for SDD");
1095 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"));
1097 //SILICON STRIP DETECTOR
1098 Info("Digits2Raw", "Formatting raw data for SSD");
1099 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1101 fLoader->UnloadDigits();
1103 //______________________________________________________________________
1104 AliLoader* AliITS::MakeLoader(const char* topfoldername){
1105 //builds ITSgetter (AliLoader type)
1106 //if detector wants to use castomized getter, it must overload this method
1108 AliDebug(1,Form("Creating AliITSLoader. Top folder is %s.",
1110 fLoader = new AliITSLoader(GetName(),topfoldername);
1114 Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
1117 // Converts RAW data to SDigits
1122 Int_t size = GetITSgeom()->GetIndexMax();
1123 TClonesArray** modA = new TClonesArray*[size];
1124 for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
1126 AliLoader* loader = (gAlice->GetRunLoader())->GetLoader("ITSLoader");
1129 Error("Open","Can not get ITS loader from Run Loader");
1134 tree = loader->TreeS();
1137 loader->MakeTree("S");
1138 tree = loader->TreeS();
1141 // Array for SDigits
1143 TClonesArray aSDigits("AliITSpListItem",10000), *itsSDigits=&aSDigits;
1144 Int_t bufsize = 32000;
1145 tree->Branch("ITS", &itsSDigits, bufsize);
1150 AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
1151 npx = segSPD->Npx();
1152 Double_t thr, sigma;
1154 AliITSRawStreamSPD inputSPD(rawReader);
1156 Bool_t next = inputSPD.Next();
1159 Int_t module = inputSPD.GetModuleID();
1160 Int_t column = inputSPD.GetColumn();
1161 Int_t row = inputSPD.GetRow();
1162 Int_t index = npx * column + row;
1164 if (module >= size) continue;
1166 last = (modA[module])->GetEntries();
1167 TClonesArray& dum = *modA[module];
1168 fDetTypeSim->GetCalibrationModel(module)->Thresholds(thr,sigma);
1170 new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
1177 AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
1178 npx = segSDD->Npx();
1179 AliITSRawStreamSDD inputSDD(rawReader);
1181 Bool_t next = inputSDD.Next();
1184 Int_t module = inputSDD.GetModuleID();
1185 Int_t anode = inputSDD.GetAnode();
1186 Int_t time = inputSDD.GetTime();
1187 Int_t signal = inputSDD.GetSignal();
1188 Int_t index = npx * anode + time;
1190 if (module >= size) continue;
1192 AliITSresponseSDD *resSDD = (AliITSresponseSDD*) fDetTypeSim->GetResponse(1);
1193 Int_t signal10 = resSDD->Convert8to10(signal); // signal is a 8 bit value (if the compression is active)
1195 last = modA[module]->GetEntries();
1196 TClonesArray& dum = *modA[module];
1197 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
1198 ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
1206 AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
1207 npx = segSSD->Npx();
1208 AliITSRawStreamSSD inputSSD(rawReader);
1210 Bool_t next = inputSSD.Next();
1213 Int_t module = inputSSD.GetModuleID();
1214 Int_t side = inputSSD.GetSideFlag();
1215 Int_t strip = inputSSD.GetStrip();
1216 Int_t signal = inputSSD.GetSignal();
1217 Int_t index = npx * side + strip;
1219 if (module >= size) continue;
1221 last = modA[module]->GetEntries();
1222 TClonesArray& dum = *modA[module];
1223 new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
1226 AliITSpListItem* sdig = 0;
1228 for (Int_t mod = 0; mod < size; mod++)
1230 Int_t nsdig = modA[mod]->GetEntries();
1231 for (Int_t ie = 0; ie < nsdig; ie++) {
1232 sdig = (AliITSpListItem*) (modA[mod]->At(ie));
1233 new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), sdig->GetSignal());
1234 Float_t sig = sdig->GetSignalAfterElect();
1236 sdig = (AliITSpListItem*)aSDigits[ie];
1237 sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
1245 loader->WriteSDigits("OVERWRITE");
1251 //______________________________________________________________________
1252 void AliITS::UpdateInternalGeometry(){
1254 //reads new geometry from TGeo
1255 AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
1256 AliITSInitGeometry initgeom("AliITSvPPRasymmFMD",2);
1257 AliITSgeom* geom = initgeom.CreateAliITSgeom();
1260 if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
1261 AliRunLoader* rl = fLoader->GetRunLoader();
1263 geom->Write(0,kOverwrite);