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 ///////////////////////////////////////////////////////////////////////////////
68 #include <Riostream.h>
72 #include <TClonesArray.h>
75 #include <TObjectTable.h>
81 #include <TVirtualMC.h>
83 #include "AliConfig.h"
84 #include "AliHeader.h"
86 #include "AliITSClusterFinderSDD.h"
87 #include "AliITSClusterFinderSPD.h"
88 #include "AliITSClusterFinderSSD.h"
89 #include "AliITSClusterFinderV2SDD.h"
90 #include "AliITSClusterFinderV2SPD.h"
91 #include "AliITSClusterFinderV2SSD.h"
92 #include "AliITSDDLRawData.h"
93 #include "AliITSDetType.h"
94 #include "AliITSDigitizer.h"
95 #include "AliITSLoader.h"
96 #include "AliITSRawClusterSDD.h"
97 #include "AliITSRawClusterSPD.h"
98 #include "AliITSRawClusterSSD.h"
99 #include "AliITSRecPoint.h"
100 #include "AliITSclusterV2.h"
101 #include "AliITSdigitSDD.h"
102 #include "AliITSdigitSPD.h"
103 #include "AliITSdigitSSD.h"
104 #include "AliITSgeom.h"
105 #include "AliITShit.h"
106 #include "AliITSmodule.h"
107 #include "AliITSpList.h"
108 #include "AliITSresponseSDD.h"
109 #include "AliITSresponseSPD.h"
110 #include "AliITSresponseSSD.h"
111 #include "AliITSsegmentationSDD.h"
112 #include "AliITSsegmentationSPD.h"
113 #include "AliITSsegmentationSSD.h"
114 #include "AliITSsimulationSDD.h"
115 #include "AliITSsimulationSPD.h"
116 #include "AliITSsimulationSSD.h"
119 #include "AliRawReader.h"
124 //______________________________________________________________________
125 AliITS::AliITS() : AliDetector(),
145 fSelectedVertexer(0){
146 // Default initializer for ITS
147 // The default constructor of the AliITS class. In addition to
148 // creating the AliITS class it zeros the variables fIshunt (a member
149 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
150 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
159 fIshunt = 0; // not zeroed in AliDetector.
162 // SetDetectors(); // default to fOpt="All". This variable not written out.
163 SetMarkerColor(kRed);
166 //______________________________________________________________________
167 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title),
187 fSelectedVertexer(0){
188 // The standard Constructor for the ITS class. In addition to
189 // creating the AliITS class, it allocates memory for the TClonesArrays
190 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
191 // (clusters). It also zeros the variables
192 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
193 // the pointers fIdSens and fIdName. To help in displaying hits via the
194 // ROOT macro display.C AliITS also sets the marker color to red. The
195 // variables passes with this constructor, const char *name and *title,
196 // are used by the constructor of AliDetector class. See AliDetector
197 // class for a description of these parameters and its constructor
200 // const char *name Detector name. Should always be "ITS"
201 // const char *title Detector title.
207 fIshunt = 0; // not zeroed in AliDetector
208 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
209 // Not done in AliDetector.
210 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
215 SetDetectors(); // default to fOpt="All". This variable not written out.
221 fNDetTypes = kNTYPES;
222 fDetTypes = new TObjArray(fNDetTypes);
224 fSDigits = new TClonesArray("AliITSpListItem",1000);
227 fNdtype = new Int_t[fNDetTypes];
228 fDtype = new TObjArray(fNDetTypes);
230 fCtype = new TObjArray(fNDetTypes);
231 fNctype = new Int_t[fNDetTypes];
233 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
235 fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
239 for(i=0;i<fNDetTypes;i++) {
240 fDetTypes->AddAt(new AliITSDetType(),i);
245 SetMarkerColor(kRed);
248 //______________________________________________________________________
250 // Default destructor for ITS.
251 // The default destructor of the AliITS class. In addition to deleting
252 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
253 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
254 // fITSpoints, fDetType and it's contents.
278 fRecPoints->Delete();
283 fClustersV2->Delete();
287 delete[] fIdName; // Array of TStrings
290 this->ClearModules();
293 }// end if fITSmodules!=0
311 } // end if fDetTypes
314 if (fITSgeom) delete fITSgeom;
316 //______________________________________________________________________
317 AliITS::AliITS(const AliITS &source) : AliDetector(source){
318 // Copy constructor. This is a function which is not allowed to be
319 // done to the ITS. It exits with an error.
321 // AliITS &source An AliITS class.
327 if(this==&source) return;
328 Error("Copy constructor",
329 "You are not allowed to make a copy of the AliITS");
332 //______________________________________________________________________
333 AliITS& AliITS::operator=(AliITS &source){
334 // Assignment operator. This is a function which is not allowed to be
335 // done to the ITS. It exits with an error.
337 // AliITS &source An AliITS class.
343 if(this==&source) return *this;
344 Error("operator=","You are not allowed to make a copy of the AliITS");
346 return *this; //fake return
348 //______________________________________________________________________
349 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
350 // Creates the AliITSDigitizer in a standard way for use via AliModule.
351 // This function can not be included in the .h file because of problems
352 // with the order of inclusion (recursive).
354 // AliRunDigitizer *manager The Manger class for Digitization
358 // A new AliITSRunDigitizer (cast as a AliDigitizer).
360 return new AliITSDigitizer(manager);
362 //______________________________________________________________________
364 // Initializer ITS after it has been built
365 // This routine initializes the AliITS class. It is intended to be
366 // called from the Init function in AliITSv?. Besides displaying a banner
367 // indicating that it has been called it initializes the array fIdSens
368 // and sets the default segmentation, response, digit and raw cluster
369 // classes therefore it should be called after a call to CreateGeometry.
380 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
382 //______________________________________________________________________
383 void AliITS::SetDefaults(){
384 // sets the default segmentation, response, digit and raw cluster classes.
391 AliITSsegmentation *seg;
392 AliITSresponse *resp;
393 AliITSDetType *iDetType;
395 AliInfoClass("Seting Defaults");
398 iDetType = DetType(kSPD);
400 if (!iDetType->GetSegmentationModel()) {
401 seg = new AliITSsegmentationSPD(fITSgeom);
402 SetSegmentationModel(kSPD,seg);
404 if (!iDetType->GetResponseModel()) {
405 SetResponseModel(kSPD,new AliITSresponseSPD());
407 // set digit and raw cluster classes to be used
409 const char *kData0=(iDetType->GetResponseModel())->DataType();
410 if (strstr(kData0,"real")) {
411 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
412 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
416 iDetType = DetType(kSDD);
418 if (!iDetType->GetResponseModel()) {
419 SetResponseModel(kSDD,new AliITSresponseSDD("simulated"));
421 resp = iDetType->GetResponseModel();
422 if (!iDetType->GetSegmentationModel()) {
423 seg = new AliITSsegmentationSDD(fITSgeom,resp);
424 SetSegmentationModel(kSDD,seg);
426 const char *kData1 = (iDetType->GetResponseModel())->DataType();
427 const char *kopt = iDetType->GetResponseModel()->ZeroSuppOption();
428 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) ||
429 strstr(kData1,"real") ){
430 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
431 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
435 iDetType = DetType(kSSD);
437 if (!iDetType->GetSegmentationModel()) {
438 seg = new AliITSsegmentationSSD(fITSgeom);
439 SetSegmentationModel(kSSD,seg);
441 if (!iDetType->GetResponseModel()) {
442 SetResponseModel(kSSD,new AliITSresponseSSD("simulated"));
444 const char *kData2 = (iDetType->GetResponseModel())->DataType();
445 if (strstr(kData2,"real")) {
446 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
447 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
451 Warning("SetDefaults",
452 "Only the three basic detector types are initialized!");
455 //______________________________________________________________________
456 void AliITS::SetDefaultSimulation(){
457 // sets the default simulation.
464 AliITSDetType *iDetType;
465 AliITSsimulation *sim;
466 AliITSsegmentation *seg;
469 iDetType = DetType(kSPD);
471 sim = iDetType->GetSimulationModel();
473 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
474 res = (AliITSresponse*)iDetType->GetResponseModel();
475 sim = new AliITSsimulationSPD(seg,res);
476 SetSimulationModel(kSPD,sim);
477 }else{ // simulation exists, make sure it is set up properly.
478 if(sim->GetResponseModel()==0) sim->SetResponseModel(
479 (AliITSresponse*)iDetType->GetResponseModel());
480 if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
481 (AliITSsegmentation*)iDetType->GetSegmentationModel());
485 iDetType = DetType(kSDD);
487 sim = iDetType->GetSimulationModel();
489 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
490 res = (AliITSresponse*)iDetType->GetResponseModel();
491 sim = new AliITSsimulationSDD(seg,res);
492 SetSimulationModel(kSDD,sim);
493 }else{ // simulation exists, make sure it is set up properly.
494 if(sim->GetResponseModel()==0) sim->SetResponseModel(
495 (AliITSresponse*)iDetType->GetResponseModel());
496 if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
497 (AliITSsegmentation*)iDetType->GetSegmentationModel());
501 iDetType = DetType(kSSD);
503 sim = iDetType->GetSimulationModel();
505 seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
506 res = (AliITSresponse*)iDetType->GetResponseModel();
507 sim = new AliITSsimulationSSD(seg,res);
508 SetSimulationModel(kSSD,sim);
509 }else{ // simulation exists, make sure it is set up properly.
510 if(sim->GetResponseModel()==0) sim->SetResponseModel(
511 (AliITSresponse*)iDetType->GetResponseModel());
512 if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
513 (AliITSsegmentation*)iDetType->GetSegmentationModel());
518 //______________________________________________________________________
519 void AliITS::SetDefaultClusterFinders(){
520 // Sets the default cluster finders. Used in finding RecPoints.
527 AliITSDetType *iDetType;
528 AliITSsegmentation *seg;
529 AliITSClusterFinder *clf;
535 iDetType=DetType(kSPD);
537 if (!iDetType->GetReconstructionModel()) {
538 seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
539 TClonesArray *dig0 = DigitsAddress(0);
540 TClonesArray *recp0 = ClustersAddress(0);
541 clf = new AliITSClusterFinderSPD(seg,dig0,recp0);
542 SetReconstructionModel(kSPD,clf);
547 iDetType=DetType(kSDD);
549 if (!iDetType->GetReconstructionModel()) {
550 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
551 res = (AliITSresponse*)iDetType->GetResponseModel();
552 TClonesArray *dig1 = DigitsAddress(1);
553 TClonesArray *recp1 = ClustersAddress(1);
554 clf = new AliITSClusterFinderSDD(seg,res,dig1,recp1);
555 SetReconstructionModel(kSDD,clf);
560 iDetType=DetType(kSSD);
562 if (!iDetType->GetReconstructionModel()) {
563 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
564 TClonesArray *dig2 = DigitsAddress(2);
565 clf = new AliITSClusterFinderSSD(seg,dig2);
566 SetReconstructionModel(kSSD,clf);
572 //______________________________________________________________________
573 void AliITS::SetDefaultClusterFindersV2(){
574 // Sets the default cluster finders. Used in finding RecPoints.
581 AliITSDetType *iDetType;
582 AliITSsegmentation *seg;
583 AliITSClusterFinder *clf;
588 iDetType=DetType(kSPD);
590 if (!iDetType->GetReconstructionModel()) {
591 seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
592 clf = new AliITSClusterFinderV2SPD();
593 clf->SetSegmentation(seg);
594 clf->SetDigits(DigitsAddress(0));
595 SetReconstructionModel(kSPD,clf);
600 iDetType=DetType(kSDD);
602 if (!iDetType->GetReconstructionModel()) {
603 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
604 clf = new AliITSClusterFinderV2SDD();
605 clf->SetSegmentation(seg);
606 clf->SetDigits(DigitsAddress(1));
607 SetReconstructionModel(kSDD,clf);
612 iDetType=DetType(kSSD);
614 if (!iDetType->GetReconstructionModel()) {
615 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
616 clf = new AliITSClusterFinderV2SSD();
617 clf->SetSegmentation(seg);
618 clf->SetDigits(DigitsAddress(2));
619 SetReconstructionModel(kSSD,clf);
625 //______________________________________________________________________
626 void AliITS::MakeBranch(Option_t* option){
627 // Creates Tree branches for the ITS.
629 // Option_t *option String of Tree types S,D, and/or R.
630 // const char *file String of the file name where these branches
631 // are to be stored. If blank then these branches
632 // are written to the same tree as the Hits were
638 Bool_t cH = (strstr(option,"H")!=0);
639 Bool_t cS = (strstr(option,"S")!=0);
640 Bool_t cD = (strstr(option,"D")!=0);
641 Bool_t cR = (strstr(option,"R")!=0);
642 Bool_t cRF = (strstr(option,"RF")!=0);
643 Bool_t v2 = (strstr(option,"v2")!=0);
647 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
649 AliDetector::MakeBranch(option);
651 if(cS) MakeBranchS(0);
652 if(cD) MakeBranchD(0);
653 if(cR) MakeBranchR(0);
654 if(cRF) MakeBranchRF(0);
655 if(v2) MakeBranchR(0,"v2");
657 //______________________________________________________________________
658 void AliITS::SetTreeAddress(){
659 // Set branch address for the Trees.
666 TTree *treeS = fLoader->TreeS();
667 TTree *treeD = fLoader->TreeD();
668 TTree *treeR = fLoader->TreeR();
669 if (fLoader->TreeH() && (fHits == 0x0))
670 fHits = new TClonesArray("AliITShit", 1560);
672 AliDetector::SetTreeAddress();
674 SetTreeAddressS(treeS);
675 SetTreeAddressD(treeD);
676 SetTreeAddressR(treeR);
678 //______________________________________________________________________
679 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
681 // The function to add information to the AliITShit class. See the
682 // AliITShit class for a full description. This function allocates the
683 // necessary new space for the hit information and passes the variable
684 // track, and the pointers *vol and *hits to the AliITShit constructor
687 // Int_t track Track number which produced this hit.
688 // Int_t *vol Array of Integer Hit information. See AliITShit.h
689 // Float_t *hits Array of Floating Hit information. see AliITShit.h
695 TClonesArray &lhits = *fHits;
696 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
698 //______________________________________________________________________
699 void AliITS::InitModules(Int_t size,Int_t &nmodules){
700 // Initialize the modules array.
702 // Int_t size Size of array of the number of modules to be
703 // created. If size <=0 then the number of modules
704 // is gotten from AliITSgeom class kept in fITSgeom.
706 // Int_t &nmodules The number of modules existing.
711 fITSmodules->Delete();
713 } // end fir fITSmoudles
715 Int_t nl,indexMAX,index;
717 if(size<=0){ // default to using data stored in AliITSgeom
719 Error("InitModules","fITSgeom not defined");
721 } // end if fITSgeom==0
722 nl = fITSgeom->GetNlayers();
723 indexMAX = fITSgeom->GetIndexMax();
725 fITSmodules = new TObjArray(indexMAX);
726 for(index=0;index<indexMAX;index++){
727 fITSmodules->AddAt( new AliITSmodule(index),index);
730 fITSmodules = new TObjArray(size);
731 for(index=0;index<size;index++) {
732 fITSmodules->AddAt( new AliITSmodule(index),index);
738 //______________________________________________________________________
739 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
740 Option_t *option, const char *filename){
741 // fill the modules with the sorted by module hits; add hits from
742 // background if option=Add.
744 // Int_t evnt Event to be processed.
745 // Int_t bgrev Background Hit tree number.
746 // Int_t nmodules Not used.
747 // Option_t *option String indicating if merging hits or not. To
748 // merge hits set equal to "Add". Otherwise no
749 // background hits are considered.
750 // Test_t *filename File name containing the background hits..
755 static TTree *trH1; //Tree with background hits
756 static Bool_t first=kTRUE;
758 const char *addBgr = strstr(option,"Add");
760 evnt = nmodules; // Dummy use of variables to remove warnings
763 file=new TFile(filename);
768 // Get Hits Tree header from file
769 if(trH1) delete trH1;
773 sprintf(treeName,"TreeH%d",bgrev);
774 trH1 = (TTree*)gDirectory->Get(treeName);
776 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
778 // Set branch addresses
781 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
784 FillModules(trH1,10000000); // Default mask 10M.
785 TTree *fAli=fLoader->GetRunLoader()->TreeK();
787 if (fAli) fileAli =fAli->GetCurrentFile();
791 //______________________________________________________________________
792 void AliITS::FillModules(TTree *treeH, Int_t mask) {
793 // fill the modules with the sorted by module hits;
794 // can be called many times to do a merging
796 // TTree *treeH The tree containing the hits to be copied into
798 // Int_t mask The track number mask to indecate which file
799 // this hits came from.
807 Error("FillModules","Tree is NULL");
809 Int_t lay,lad,det,index;
813 sprintf(branchname,"%s",GetName());
814 TBranch *branch = treeH->GetBranch(branchname);
816 Error("FillModules","%s branch in TreeH not found",branchname);
819 branch->SetAddress(&fHits);
820 Int_t nTracks =(Int_t) treeH->GetEntries();
822 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
824 Int_t nBytes = treeH->GetEvent(iPrimTrack);
825 if (nBytes <= 0) continue;
826 Int_t nHits = fHits->GetEntriesFast();
827 for(h=0; h<nHits; h++){
828 itsHit = (AliITShit *)fHits->UncheckedAt(h);
829 itsHit->GetDetectorID(lay,lad,det);
831 index = fITSgeom->GetModuleIndex(lay,lad,det);
833 index=det-1; // This should not be used.
834 } // end if [You must have fITSgeom for this to work!]
835 mod = GetModule(index);
836 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
837 mod->AddHit(itsHit,iPrimTrack,h);
838 } // end loop over hits
839 } // end loop over tracks
841 //______________________________________________________________________
842 void AliITS::MakeBranchS(const char *fl){
843 // Creates Tree Branch for the ITS summable digits.
845 // cont char *fl File name where SDigits branch is to be written
846 // to. If blank it write the SDigits to the same
847 // file in which the Hits were found.
852 Int_t buffersize = 4000;
855 // only one branch for SDigits.
856 sprintf(branchname,"%s",GetName());
859 if(fLoader->TreeS()){
860 if(fSDigits==0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
861 MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
864 //______________________________________________________________________
865 void AliITS::SetTreeAddressS(TTree *treeS){
866 // Set branch address for the ITS summable digits Trees.
868 // TTree *treeS Tree containing the SDigits.
876 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
878 sprintf(branchname,"%s",GetName());
879 branch = treeS->GetBranch(branchname);
880 if (branch) branch->SetAddress(&fSDigits);
882 //______________________________________________________________________
883 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
884 // Creates Tree branches for the ITS.
886 // TTree *treeD Pointer to the Digits Tree.
887 // cont char *file File name where Digits branch is to be written
888 // to. If blank it write the SDigits to the same
889 // file in which the Hits were found.
894 // one branch for digits per type of detector
895 const Char_t *det[3] = {"SPD","SDD","SSD"};
898 Int_t buffersize = 4000;
899 Char_t branchname[30];
901 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
902 for (i=0; i<kNTYPES ;i++) {
903 digclass = DetType(i)->GetDigitClassName();
905 if(!(fDtype->At(i))){
906 fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i);
910 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
911 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
912 if (fDtype && treeD) {
913 MakeBranchInTree(treeD,branchname,&((*fDtype)[i]),buffersize,file);
917 for (i=0; i<kNTYPES ;i++) {
918 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
919 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
920 if (fDtype && treeD) {
921 MakeBranchInTree(treeD,branchname,&((*fDtype)[i]),buffersize,file);
926 //______________________________________________________________________
927 void AliITS::SetTreeAddressD(TTree *treeD){
928 // Set branch address for the Trees.
930 // TTree *treeD Tree containing the Digits.
935 const char *det[3] = {"SPD","SDD","SSD"};
942 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
943 for (i=0; i<kNTYPES; i++) {
944 digclass = DetType(i)->GetDigitClassName();
946 if(!(fDtype->At(i))) {
947 fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i);
951 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
952 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
954 branch = treeD->GetBranch(branchname);
955 if (branch) branch->SetAddress(&((*fDtype)[i]));
959 //______________________________________________________________________
960 void AliITS::Hits2SDigits(){
961 // Standard Hits to summable Digits function.
967 fLoader->LoadHits("read");
968 fLoader->LoadSDigits("recreate");
969 AliRunLoader* rl = fLoader->GetRunLoader();
971 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
972 // Do the Hits to Digits operation. Use Standard input values.
973 // Event number from file, no background hit merging , use size from
974 // AliITSgeom class, option="All", input from this file only.
975 rl->GetEvent(iEvent);
976 if (!fLoader->TreeS()) fLoader->MakeTree("S");
979 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
982 fLoader->UnloadHits();
983 fLoader->UnloadSDigits();
985 //______________________________________________________________________
986 void AliITS::SDigitsToDigits(Option_t *opt){
987 // Standard Summable digits to Digits function.
992 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
994 if(!GetITSgeom()) return; // need transformations to do digitization.
995 AliITSgeom *geom = GetITSgeom();
997 const char *all = strstr(opt,"All");
998 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1000 if( !det[0] && !det[1] && !det[2] ) all = "All";
1002 static Bool_t setDef = kTRUE;
1003 if(setDef) SetDefaultSimulation();
1006 AliITSsimulation *sim = 0;
1007 AliITSDetType *iDetType = 0;
1008 TTree *trees = fLoader->TreeS();
1009 if( !(trees && this->GetSDigits()) ){
1010 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1013 sprintf( name, "%s", this->GetName() );
1014 TBranch *brchSDigits = trees->GetBranch( name );
1017 for(module=0;module<geom->GetIndexMax();module++){
1018 id = geom->GetModuleType(module);
1019 if (!all && !det[id]) continue;
1020 iDetType = DetType(id);
1021 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1023 Error("SDigit2Digits","The simulation class was not "
1024 "instanciated for module %d type %s!",module,
1025 geom->GetModuleTypeName(module));
1028 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1030 // add summable digits to module
1031 this->GetSDigits()->Clear();
1032 brchSDigits->GetEvent(module);
1033 sim->AddSDigitsToModule(GetSDigits(),0);
1035 // Digitise current module sum(SDigits)->Digits
1036 sim->FinishSDigitiseModule();
1038 // fills all branches - wasted disk space
1039 fLoader->TreeD()->Fill();
1040 this->ResetDigits();
1043 fLoader->TreeD()->GetEntries();
1045 fLoader->TreeD()->AutoSave();
1047 fLoader->TreeD()->Reset();
1050 //______________________________________________________________________
1051 void AliITS::Hits2Digits(){
1052 // Standard Hits to Digits function.
1058 fLoader->LoadHits("read");
1059 fLoader->LoadDigits("recreate");
1060 AliRunLoader* rl = fLoader->GetRunLoader();
1062 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
1063 // Do the Hits to Digits operation. Use Standard input values.
1064 // Event number from file, no background hit merging , use size from
1065 // AliITSgeom class, option="All", input from this file only.
1066 rl->GetEvent(iEvent);
1067 if (!fLoader->TreeD()) fLoader->MakeTree("D");
1070 HitsToDigits(iEvent,0,-1," ",fOpt," ");
1073 fLoader->UnloadHits();
1074 fLoader->UnloadDigits();
1076 //______________________________________________________________________
1077 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1078 Option_t *option,Option_t *opt,
1079 const char *filename){
1080 // Keep galice.root for signal and name differently the file for
1081 // background when add! otherwise the track info for signal will be lost !
1082 // the condition below will disappear when the geom class will be
1083 // initialized for all versions - for the moment it is only for v5 !
1084 // 7 is the SDD beam test version.
1086 // Int_t evnt Event to be processed.
1087 // Int_t bgrev Background Hit tree number.
1088 // Int_t nmodules Not used.
1089 // Option_t *option String indicating if merging hits or not. To
1090 // merge hits set equal to "Add". Otherwise no
1091 // background hits are considered.
1092 // Test_t *filename File name containing the background hits..
1098 if(!GetITSgeom()) return; // need transformations to do digitization.
1099 AliITSgeom *geom = GetITSgeom();
1101 const char *all = strstr(opt,"All");
1102 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1104 static Bool_t setDef=kTRUE;
1105 if (setDef) SetDefaultSimulation();
1109 InitModules(size,nmodules);
1110 FillModules(evNumber,bgrev,nmodules,option,filename);
1112 AliITSsimulation *sim = 0;
1113 AliITSDetType *iDetType = 0;
1114 AliITSmodule *mod = 0;
1116 for(module=0;module<geom->GetIndexMax();module++){
1117 id = geom->GetModuleType(module);
1118 if (!all && !det[id]) continue;
1119 iDetType = DetType(id);
1120 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1122 Error("HitsToSDigits","The simulation class was not "
1123 "instanciated for module %d type %s!",module,
1124 geom->GetModuleTypeName(module));
1127 mod = (AliITSmodule *)fITSmodules->At(module);
1128 sim->SDigitiseModule(mod,module,evNumber);
1129 // fills all branches - wasted disk space
1130 fLoader->TreeS()->Fill();
1136 fLoader->TreeS()->GetEntries();
1137 fLoader->TreeS()->AutoSave();
1138 fLoader->WriteSDigits("OVERWRITE");
1140 fLoader->TreeS()->Reset();
1142 //______________________________________________________________________
1143 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1144 Option_t *option,Option_t *opt,
1145 const char *filename){
1146 // Keep galice.root for signal and name differently the file for
1147 // background when add! otherwise the track info for signal will be lost !
1148 // the condition below will disappear when the geom class will be
1149 // initialized for all versions - for the moment it is only for v5 !
1150 // 7 is the SDD beam test version.
1152 // Int_t evnt Event to be processed.
1153 // Int_t bgrev Background Hit tree number.
1154 // Int_t nmodules Not used.
1155 // Option_t *option String indicating if merging hits or not. To
1156 // merge hits set equal to "Add". Otherwise no
1157 // background hits are considered.
1158 // Test_t *filename File name containing the background hits..
1165 if(!GetITSgeom()) return; // need transformations to do digitization.
1166 AliITSgeom *geom = GetITSgeom();
1168 const char *all = strstr(opt,"All");
1169 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1171 static Bool_t setDef=kTRUE;
1172 if (setDef) SetDefaultSimulation();
1176 InitModules(size,nmodules);
1177 FillModules(evNumber,bgrev,nmodules,option,filename);
1179 AliITSsimulation *sim = 0;
1180 AliITSDetType *iDetType = 0;
1181 AliITSmodule *mod = 0;
1183 for(module=0;module<geom->GetIndexMax();module++){
1184 id = geom->GetModuleType(module);
1185 if (!all && !det[id]) continue;
1186 iDetType = DetType(id);
1187 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1189 Error("HitsToDigits","The simulation class was not "
1190 "instanciated for module %d type %s!",module,
1191 geom->GetModuleTypeName(module));
1194 mod = (AliITSmodule *)fITSmodules->At(module);
1195 sim->DigitiseModule(mod,module,evNumber);
1196 // fills all branches - wasted disk space
1197 fLoader->TreeD()->Fill();
1203 fLoader->TreeD()->GetEntries();
1204 fLoader->TreeD()->AutoSave();
1206 fLoader->TreeD()->Reset();
1208 //______________________________________________________________________
1209 void AliITS::ResetDigits(){
1210 // Reset number of digits and the digits array for the ITS detector.
1216 if (!fDtype) return;
1219 for (i=0;i<kNTYPES;i++ ) {
1223 //______________________________________________________________________
1224 void AliITS::ResetDigits(Int_t i){
1225 // Reset number of digits and the digits array for this branch.
1231 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1232 if (fNdtype) fNdtype[i]=0;
1234 //______________________________________________________________________
1235 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1236 // Adds the a module full of summable digits to the summable digits tree.
1238 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1244 TClonesArray &lsdig = *fSDigits;
1245 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1247 //______________________________________________________________________
1248 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1249 // Add a real digit - as coming from data.
1251 // Int_t id Detector type number.
1252 // Int_t *digits Integer array containing the digits info. See
1259 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1260 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1262 //______________________________________________________________________
1263 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1264 // Add a simulated digit.
1266 // Int_t id Detector type number.
1267 // AliITSdigit *d Digit to be added to the Digits Tree. See
1274 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1278 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1281 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1284 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1288 //______________________________________________________________________
1289 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1290 Int_t *hits,Float_t *charges){
1291 // Add a simulated digit to the list.
1293 // Int_t id Detector type number.
1294 // Float_t phys Physics indicator. See AliITSdigits.h
1295 // Int_t *digits Integer array containing the digits info. See
1297 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1298 // containing the track numbers that contributed to
1300 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1301 // containing the hit numbers, from AliITSmodule, that
1302 // contributed to this digit.
1303 // Float_t *charge Floating point array of the signals contributed
1304 // to this digit by each track.
1310 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1311 AliITSresponseSDD *resp = 0;
1314 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1317 resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel();
1318 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1322 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1326 //______________________________________________________________________
1327 void AliITS::Digits2Raw(){
1328 // convert digits of the current event to raw data
1330 fLoader->LoadDigits();
1331 TTree* digits = fLoader->TreeD();
1333 Error("Digits2Raw", "no digits tree");
1336 SetTreeAddressD(digits);
1338 AliITSDDLRawData rawWriter;
1342 // 2: txt files with digits
1343 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1344 //it is highly suggested to use this mode only for debugging digits files
1345 //reasonably small, because otherwise the size of the txt files can reach
1346 //quickly several MB wasting time and disk space.
1347 rawWriter.SetVerbose(0);
1349 //SILICON PIXEL DETECTOR
1350 Info("Digits2Raw", "Formatting raw data for SPD");
1351 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"));
1353 //SILICON DRIFT DETECTOR
1354 Info("Digits2Raw", "Formatting raw data for SDD");
1355 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"));
1357 //SILICON STRIP DETECTOR
1358 Info("Digits2Raw", "Formatting raw data for SSD");
1359 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1361 fLoader->UnloadDigits();
1364 //______________________________________________________________________
1365 void AliITS::MakeTreeC(Option_t *option){
1366 // Create a separate tree to store the clusters.
1368 // Option_t *option string which must contain "C" otherwise
1369 // no Cluster Tree is created.
1375 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1377 if (pITSLoader == 0x0) {
1378 Error("MakeTreeC","fLoader == 0x0 option=%s",option);
1381 if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C");
1384 //----------------------------------------------------------------------
1385 void AliITS::MakeBranchC(){
1386 //Makes barnches in treeC
1387 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1388 if (pITSLoader == 0x0) {
1389 Error("MakeTreeC","fLoader == 0x0");
1392 TTree * lTC = pITSLoader->TreeC();
1394 Error("MakeTreeC","Can not get TreeC from Loader");
1398 Int_t buffersize = 4000;
1399 char branchname[30];
1400 const char *det[3] = {"SPD","SDD","SSD"};
1404 // one branch for Clusters per type of detector
1406 for (i=0; i<kNTYPES ;i++) {
1407 AliITSDetType *iDetType=DetType(i);
1408 iDetType->GetClassNames(digclass,clclass);
1410 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1411 if(!ClustersAddress(i)){
1412 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1414 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1415 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1416 if (fCtype && lTC) {
1417 if (lTC->GetBranch(branchname)){
1418 Warning("MakeBranchC","Branch %s alread exists in TreeC",
1421 Info("MakeBranchC","Creating branch %s in TreeC",branchname);
1422 lTC->Branch(branchname,&((*fCtype)[i]), buffersize);
1424 } // end if fCtype && lTC
1427 //______________________________________________________________________
1428 void AliITS::GetTreeC(Int_t event){
1429 // Get the clusters tree for this event and set the branch address.
1431 // Int_t event Event number for the cluster tree.
1436 char branchname[30];
1437 const char *det[3] = {"SPD","SDD","SSD"};
1439 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1440 TTree * lTC = pITSLoader->TreeC();
1444 pITSLoader->CleanRawClusters();
1453 for (i=0; i<kNTYPES; i++) {
1454 AliITSDetType *iDetType=DetType(i);
1455 iDetType->GetClassNames(digclass,clclass);
1457 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1458 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1459 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1460 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1462 branch = lTC->GetBranch(branchname);
1463 if (branch) branch->SetAddress(&((*fCtype)[i]));
1467 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1470 //______________________________________________________________________
1471 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1472 // Add a cluster to the list.
1474 // Int_t id Detector type number.
1475 // AliITSRawCluster *c Cluster class to be added to the tree of
1482 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1486 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1489 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1492 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1496 //______________________________________________________________________
1497 void AliITS::ResetClusters(Int_t i){
1498 // Reset number of clusters and the clusters array for this branch.
1500 // Int_t i Detector type number.
1506 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1507 if (fNctype) fNctype[i]=0;
1509 //______________________________________________________________________
1510 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1511 // Creates Tree branches for the ITS Reconstructed points.
1513 // cont char *file File name where RecPoints branch is to be written
1514 // to. If blank it write the SDigits to the same
1515 // file in which the Hits were found.
1520 Int_t buffsz = 4000;
1521 char branchname[30];
1523 // only one branch for rec points for all detector types
1524 Bool_t oFast= (strstr(opt,"Fast")!=0);
1525 Bool_t v2 = (strstr(opt,"v2")!=0);
1529 sprintf(branchname,"%sRecPointsF",GetName());
1531 sprintf(branchname,"Clusters");
1533 sprintf(branchname,"%sRecPoints",GetName());
1538 if(!fClustersV2)fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
1539 if(fLoader->TreeR()){
1540 if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
1541 MakeBranchInTree(fLoader->TreeR(),branchname,&fClustersV2,buffsz,file);
1545 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1546 if (fLoader->TreeR()) {
1547 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",
1549 MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file);
1553 //______________________________________________________________________
1554 void AliITS::SetTreeAddressR(TTree *treeR){
1555 // Set branch address for the Reconstructed points Trees.
1557 // TTree *treeR Tree containing the RecPoints.
1562 char branchname[30];
1565 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1567 sprintf(branchname,"Clusters");
1568 branch1 = treeR->GetBranch(branchname);
1570 if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
1571 branch1->SetAddress(&fClustersV2);
1575 sprintf(branchname,"%sRecPoints",GetName());
1576 branch = treeR->GetBranch(branchname);
1578 branch->SetAddress(&fRecPoints);
1580 sprintf(branchname,"%sRecPointsF",GetName());
1581 branch = treeR->GetBranch(branchname);
1583 branch->SetAddress(&fRecPoints);
1588 //______________________________________________________________________
1589 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1590 // Add a reconstructed space point to the list
1592 // const AliITSRecPoint &r RecPoint class to be added to the tree
1593 // of reconstructed points TreeR.
1599 TClonesArray &lrecp = *fRecPoints;
1600 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1602 //______________________________________________________________________
1603 void AliITS::AddClusterV2(const AliITSclusterV2 &r){
1604 // Add a reconstructed space point to the list
1606 // const AliITSClusterV2 &r class to be added to the tree
1607 // of reconstructed points TreeR.
1613 TClonesArray &lrecp = *fClustersV2;
1614 new(lrecp[fNClustersV2++]) AliITSclusterV2(r);
1616 //______________________________________________________________________
1617 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1618 Option_t *opt0,Option_t *opt1,
1620 // keep galice.root for signal and name differently the file for
1621 // background when add! otherwise the track info for signal will be lost !
1622 // the condition below will disappear when the geom class will be
1623 // initialized for all versions - for the moment it is only for v5 !
1625 // Int_t evnt Event to be processed.
1626 // Int_t bgrev Background Hit tree number.
1627 // Int_t size Size used by InitModules. See InitModules.
1628 // Option_t *opt0 Option passed to FillModules. See FillModules.
1629 // Option_t *opt1 String indicating if merging hits or not. To
1630 // merge hits set equal to "Add". Otherwise no
1631 // background hits are considered.
1632 // Test_t *flnm File name containing the background hits..
1638 if(!GetITSgeom()) return;
1639 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1640 AliITSgeom *geom = GetITSgeom();
1642 const char *all = strstr(opt1,"All");
1643 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1644 strstr(opt1,"SSD")};
1646 InitModules(size,nmodules);
1647 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1649 AliITSsimulation *sim = 0;
1650 AliITSDetType *iDetType = 0;
1651 AliITSmodule *mod = 0;
1654 //m.b. : this change is nothing but a nice way to make sure
1657 AliDebug(1,Form("N mod = %d",geom->GetIndexMax()));
1658 for(module=0;module<geom->GetIndexMax();module++){
1659 id = geom->GetModuleType(module);
1660 if (!all && !det[id]) continue;
1661 iDetType = DetType(id);
1662 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1664 Error("HitsToFastPoints","The simulation class was not "
1665 "instanciated for module %d type %x!",module,
1666 geom->GetModuleTypeName(module));
1669 mod = (AliITSmodule *)fITSmodules->At(module);
1670 sim->CreateFastRecPoints(mod,module,gRandom);
1671 cout<<module<<"\r";fflush(0);
1672 //gAlice->TreeR()->Fill();
1673 TTree *lTR = pITSloader->TreeR();
1674 TBranch *br=lTR->GetBranch("ITSRecPointsF");
1680 fLoader->WriteRecPoints("OVERWRITE");
1682 //______________________________________________________________________
1683 void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){
1684 // cluster finding and reconstruction of space points
1685 // the condition below will disappear when the geom class will be
1686 // initialized for all versions - for the moment it is only for v5 !
1687 // 7 is the SDD beam test version
1689 // Int_t evNumber Event number to be processed.
1690 // Int_t lastentry Offset for module when not all of the modules
1692 // Option_t *opt String indicating which ITS sub-detectors should
1693 // be processed. If ="All" then all of the ITS
1694 // sub detectors are processed.
1700 if(!GetITSgeom()) return;
1701 AliITSgeom *geom = GetITSgeom();
1703 const char *all = strstr(opt,"All");
1704 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1706 static Bool_t setRec=kTRUE;
1707 if (setRec) SetDefaultClusterFinders();
1710 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1711 TTree *treeC=pITSloader->TreeC();
1712 AliITSClusterFinder *rec = 0;
1713 AliITSDetType *iDetType = 0;
1714 Int_t id,module,first=0;
1715 for(module=0;module<geom->GetIndexMax();module++){
1716 id = geom->GetModuleType(module);
1717 if (!all && !det[id]) continue;
1718 if(det[id]) first = geom->GetStartDet(id);
1719 iDetType = DetType(id);
1720 rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel();
1721 TClonesArray *itsDigits = this->DigitsAddress(id);
1723 Error("DigitsToRecPoints",
1724 "The reconstruction class was not instanciated! event=%d",
1728 this->ResetDigits();
1729 TTree *lTD = pITSloader->TreeD();
1731 lTD->GetEvent(lastentry+module);
1733 lTD->GetEvent(lastentry+(module-first));
1735 Int_t ndigits = itsDigits->GetEntriesFast();
1737 rec->SetDigits(DigitsAddress(id));
1738 rec->SetClusters(ClustersAddress(id));
1739 rec->FindRawClusters(module);
1741 pITSloader->TreeR()->Fill();
1748 pITSloader->WriteRecPoints("OVERWRITE");
1749 pITSloader->WriteRawClusters("OVERWRITE");
1751 //______________________________________________________________________
1752 void AliITS::DigitsToRecPoints(AliRawReader* rawReader){
1753 // cluster finding and reconstruction of space points
1754 // the condition below will disappear when the geom class will be
1755 // initialized for all versions - for the moment it is only for v5 !
1756 // 7 is the SDD beam test version
1758 // Int_t evNumber Event number to be processed.
1759 // Int_t lastentry Offset for module when not all of the modules
1761 // Option_t *opt String indicating which ITS sub-detectors should
1762 // be processed. If ="All" then all of the ITS
1763 // sub detectors are processed.
1768 if(!GetITSgeom()) return;
1769 AliITSgeom *geom = GetITSgeom();
1772 SetDefaultClusterFindersV2();
1774 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1775 AliITSClusterFinderV2 *rec = 0;
1776 AliITSDetType *iDetType = 0;
1779 if(!pITSloader->TreeR()) pITSloader->MakeTree("R");
1780 TTree* cTree = pITSloader->TreeR();
1781 TClonesArray *array=new TClonesArray("AliITSclusterV2",1000);
1782 cTree->Branch("Clusters",&array);
1785 TClonesArray** clusters = new TClonesArray*[geom->GetIndexMax()];
1786 for (Int_t iModule = 0; iModule < geom->GetIndexMax(); iModule++) {
1787 clusters[iModule] = NULL;
1789 for(id=0;id<3;id++){
1790 iDetType = DetType(id);
1791 rec = (AliITSClusterFinderV2*)iDetType->GetReconstructionModel();
1793 Error("DigitsToRecPoints",
1794 "The reconstruction class was not instanciated");
1797 rec->RawdataToClusters(rawReader,clusters);
1800 for(Int_t iModule=0;iModule<geom->GetIndexMax();iModule++){
1801 array = clusters[iModule];
1803 Error("DigitsToRecPoints","data for module %d missing!",iModule);
1804 array = new TClonesArray("AliITSclusterV2");
1806 cTree->SetBranchAddress("Clusters",&array);
1808 nClusters+=array->GetEntriesFast();
1811 pITSloader->WriteRecPoints("OVERWRITE");
1814 Info("DigitsToRecPoints", "total number of found clustersV2 in ITS: %d\n",
1819 //______________________________________________________________________
1820 AliLoader* AliITS::MakeLoader(const char* topfoldername){
1821 //builds ITSgetter (AliLoader type)
1822 //if detector wants to use castomized getter, it must overload this method
1824 Info("MakeLoader","Creating AliITSLoader. Top folder is %s.",
1826 fLoader = new AliITSLoader(GetName(),topfoldername);