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 "AliITSDetType.h"
93 #include "AliITSLoader.h"
94 #include "AliITSRawClusterSPD.h"
95 #include "AliITSRawClusterSDD.h"
96 #include "AliITSRawClusterSSD.h"
97 #include "AliITSRecPoint.h"
98 #include "AliITSclusterV2.h"
99 #include "AliITSdigitSPD.h"
100 #include "AliITSdigitSDD.h"
101 #include "AliITSdigitSSD.h"
102 #include "AliITSgeom.h"
103 #include "AliITShit.h"
104 #include "AliITSmodule.h"
105 #include "AliITSpList.h"
106 #include "AliITSresponseSDD.h"
107 #include "AliITSresponseSPD.h"
108 #include "AliITSresponseSSD.h"
109 #include "AliITSsegmentationSDD.h"
110 #include "AliITSsegmentationSPD.h"
111 #include "AliITSsegmentationSSD.h"
112 #include "AliITSsimulationSDD.h"
113 #include "AliITSsimulationSPD.h"
114 #include "AliITSsimulationSSD.h"
116 #include "AliITSDigitizer.h"
117 #include "AliITSDDLRawData.h"
119 #include "AliRawReader.h"
123 //______________________________________________________________________
124 AliITS::AliITS() : AliDetector(),
144 fSelectedVertexer(0){
145 // Default initializer for ITS
146 // The default constructor of the AliITS class. In addition to
147 // creating the AliITS class it zeros the variables fIshunt (a member
148 // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
149 // fITSpoints, fIdSens, and fIdName. The AliDetector default constructor
158 fIshunt = 0; // not zeroed in AliDetector.
161 // SetDetectors(); // default to fOpt="All". This variable not written out.
162 SetMarkerColor(kRed);
165 //______________________________________________________________________
166 AliITS::AliITS(const char *name, const char *title):AliDetector(name,title),
186 fSelectedVertexer(0){
187 // The standard Constructor for the ITS class. In addition to
188 // creating the AliITS class, it allocates memory for the TClonesArrays
189 // fHits, fSDigits, fDigits, fITSpoints, and the TObjArray of fCtype
190 // (clusters). It also zeros the variables
191 // fIshunt (a member of AliDetector class), fEuclidOut, and fIdN, and zeros
192 // the pointers fIdSens and fIdName. To help in displaying hits via the
193 // ROOT macro display.C AliITS also sets the marker color to red. The
194 // variables passes with this constructor, const char *name and *title,
195 // are used by the constructor of AliDetector class. See AliDetector
196 // class for a description of these parameters and its constructor
199 // const char *name Detector name. Should always be "ITS"
200 // const char *title Detector title.
206 fIshunt = 0; // not zeroed in AliDetector
207 fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector
208 // Not done in AliDetector.
209 if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
214 SetDetectors(); // default to fOpt="All". This variable not written out.
220 fNDetTypes = kNTYPES;
221 fDetTypes = new TObjArray(fNDetTypes);
223 fSDigits = new TClonesArray("AliITSpListItem",1000);
226 fNdtype = new Int_t[fNDetTypes];
227 fDtype = new TObjArray(fNDetTypes);
229 fCtype = new TObjArray(fNDetTypes);
230 fNctype = new Int_t[fNDetTypes];
232 fRecPoints = new TClonesArray("AliITSRecPoint",1000);
234 fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
238 for(i=0;i<fNDetTypes;i++) {
239 fDetTypes->AddAt(new AliITSDetType(),i);
244 SetMarkerColor(kRed);
247 //______________________________________________________________________
249 // Default destructor for ITS.
250 // The default destructor of the AliITS class. In addition to deleting
251 // the AliITS class it deletes the memory pointed to by the fHits, fDigits,
252 // fSDigits, fCtype, fITSmodules, fITSgeom, fRecPoints, fIdSens, fIdName,
253 // fITSpoints, fDetType and it's contents.
277 fRecPoints->Delete();
282 fClustersV2->Delete();
286 delete[] fIdName; // Array of TStrings
289 this->ClearModules();
292 }// end if fITSmodules!=0
310 } // end if fDetTypes
313 if (fITSgeom) delete fITSgeom;
315 //______________________________________________________________________
316 AliITS::AliITS(const AliITS &source) : AliDetector(source){
317 // Copy constructor. This is a function which is not allowed to be
318 // done to the ITS. It exits with an error.
320 // AliITS &source An AliITS class.
326 if(this==&source) return;
327 Error("Copy constructor",
328 "You are not allowed to make a copy of the AliITS");
331 //______________________________________________________________________
332 AliITS& AliITS::operator=(AliITS &source){
333 // Assignment operator. This is a function which is not allowed to be
334 // done to the ITS. It exits with an error.
336 // AliITS &source An AliITS class.
342 if(this==&source) return *this;
343 Error("operator=","You are not allowed to make a copy of the AliITS");
345 return *this; //fake return
347 //______________________________________________________________________
348 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
349 // Creates the AliITSDigitizer in a standard way for use via AliModule.
350 // This function can not be included in the .h file because of problems
351 // with the order of inclusion (recursive).
353 // AliRunDigitizer *manager The Manger class for Digitization
357 // A new AliITSRunDigitizer (cast as a AliDigitizer).
359 return new AliITSDigitizer(manager);
361 //______________________________________________________________________
363 // Initializer ITS after it has been built
364 // This routine initializes the AliITS class. It is intended to be
365 // called from the Init function in AliITSv?. Besides displaying a banner
366 // indicating that it has been called it initializes the array fIdSens
367 // and sets the default segmentation, response, digit and raw cluster
368 // classes therefore it should be called after a call to CreateGeometry.
379 if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
381 //______________________________________________________________________
382 void AliITS::SetDefaults(){
383 // sets the default segmentation, response, digit and raw cluster classes.
390 AliITSsegmentation *seg;
391 AliITSresponse *resp;
392 AliITSDetType *iDetType;
394 if(fDebug) Info("SetDefauls","%s: SetDefaults",ClassName());
397 iDetType = DetType(kSPD);
399 if (!iDetType->GetSegmentationModel()) {
400 seg = new AliITSsegmentationSPD(fITSgeom);
401 SetSegmentationModel(kSPD,seg);
403 if (!iDetType->GetResponseModel()) {
404 SetResponseModel(kSPD,new AliITSresponseSPD());
406 // set digit and raw cluster classes to be used
408 const char *kData0=(iDetType->GetResponseModel())->DataType();
409 if (strstr(kData0,"real")) {
410 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD");
411 } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
415 iDetType = DetType(kSDD);
417 if (!iDetType->GetResponseModel()) {
418 SetResponseModel(kSDD,new AliITSresponseSDD("simulated"));
420 resp = iDetType->GetResponseModel();
421 if (!iDetType->GetSegmentationModel()) {
422 seg = new AliITSsegmentationSDD(fITSgeom,resp);
423 SetSegmentationModel(kSDD,seg);
425 const char *kData1 = (iDetType->GetResponseModel())->DataType();
426 const char *kopt = iDetType->GetResponseModel()->ZeroSuppOption();
427 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) ||
428 strstr(kData1,"real") ){
429 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
430 } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
434 iDetType = DetType(kSSD);
436 if (!iDetType->GetSegmentationModel()) {
437 seg = new AliITSsegmentationSSD(fITSgeom);
438 SetSegmentationModel(kSSD,seg);
440 if (!iDetType->GetResponseModel()) {
441 SetResponseModel(kSSD,new AliITSresponseSSD("simulated"));
443 const char *kData2 = (iDetType->GetResponseModel())->DataType();
444 if (strstr(kData2,"real")) {
445 iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD");
446 } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
450 Warning("SetDefaults",
451 "Only the three basic detector types are initialized!");
454 //______________________________________________________________________
455 void AliITS::SetDefaultSimulation(){
456 // sets the default simulation.
463 AliITSDetType *iDetType;
464 AliITSsimulation *sim;
465 AliITSsegmentation *seg;
468 iDetType = DetType(kSPD);
470 sim = iDetType->GetSimulationModel();
472 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
473 res = (AliITSresponse*)iDetType->GetResponseModel();
474 sim = new AliITSsimulationSPD(seg,res);
475 SetSimulationModel(kSPD,sim);
476 }else{ // simulation exists, make sure it is set up properly.
477 if(sim->GetResponseModel()==0) sim->SetResponseModel(
478 (AliITSresponse*)iDetType->GetResponseModel());
479 if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
480 (AliITSsegmentation*)iDetType->GetSegmentationModel());
484 iDetType = DetType(kSDD);
486 sim = iDetType->GetSimulationModel();
488 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
489 res = (AliITSresponse*)iDetType->GetResponseModel();
490 sim = new AliITSsimulationSDD(seg,res);
491 SetSimulationModel(kSDD,sim);
492 }else{ // simulation exists, make sure it is set up properly.
493 if(sim->GetResponseModel()==0) sim->SetResponseModel(
494 (AliITSresponse*)iDetType->GetResponseModel());
495 if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
496 (AliITSsegmentation*)iDetType->GetSegmentationModel());
500 iDetType = DetType(kSSD);
502 sim = iDetType->GetSimulationModel();
504 seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
505 res = (AliITSresponse*)iDetType->GetResponseModel();
506 sim = new AliITSsimulationSSD(seg,res);
507 SetSimulationModel(kSSD,sim);
508 }else{ // simulation exists, make sure it is set up properly.
509 if(sim->GetResponseModel()==0) sim->SetResponseModel(
510 (AliITSresponse*)iDetType->GetResponseModel());
511 if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
512 (AliITSsegmentation*)iDetType->GetSegmentationModel());
517 //______________________________________________________________________
518 void AliITS::SetDefaultClusterFinders(){
519 // Sets the default cluster finders. Used in finding RecPoints.
526 AliITSDetType *iDetType;
527 AliITSsegmentation *seg;
528 AliITSClusterFinder *clf;
534 iDetType=DetType(kSPD);
536 if (!iDetType->GetReconstructionModel()) {
537 seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
538 TClonesArray *dig0 = DigitsAddress(0);
539 TClonesArray *recp0 = ClustersAddress(0);
540 clf = new AliITSClusterFinderSPD(seg,dig0,recp0);
541 SetReconstructionModel(kSPD,clf);
546 iDetType=DetType(kSDD);
548 if (!iDetType->GetReconstructionModel()) {
549 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
550 res = (AliITSresponse*)iDetType->GetResponseModel();
551 TClonesArray *dig1 = DigitsAddress(1);
552 TClonesArray *recp1 = ClustersAddress(1);
553 clf = new AliITSClusterFinderSDD(seg,res,dig1,recp1);
554 SetReconstructionModel(kSDD,clf);
559 iDetType=DetType(kSSD);
561 if (!iDetType->GetReconstructionModel()) {
562 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
563 TClonesArray *dig2 = DigitsAddress(2);
564 clf = new AliITSClusterFinderSSD(seg,dig2);
565 SetReconstructionModel(kSSD,clf);
571 //______________________________________________________________________
572 void AliITS::SetDefaultClusterFindersV2(){
573 // Sets the default cluster finders. Used in finding RecPoints.
580 AliITSDetType *iDetType;
581 AliITSsegmentation *seg;
582 AliITSClusterFinder *clf;
587 iDetType=DetType(kSPD);
589 if (!iDetType->GetReconstructionModel()) {
590 seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
591 clf = new AliITSClusterFinderV2SPD();
592 clf->SetSegmentation(seg);
593 clf->SetDigits(DigitsAddress(0));
594 SetReconstructionModel(kSPD,clf);
599 iDetType=DetType(kSDD);
601 if (!iDetType->GetReconstructionModel()) {
602 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
603 clf = new AliITSClusterFinderV2SDD();
604 clf->SetSegmentation(seg);
605 clf->SetDigits(DigitsAddress(1));
606 SetReconstructionModel(kSDD,clf);
611 iDetType=DetType(kSSD);
613 if (!iDetType->GetReconstructionModel()) {
614 seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
615 clf = new AliITSClusterFinderV2SSD();
616 clf->SetSegmentation(seg);
617 clf->SetDigits(DigitsAddress(2));
618 SetReconstructionModel(kSSD,clf);
624 //______________________________________________________________________
625 void AliITS::MakeBranch(Option_t* option){
626 // Creates Tree branches for the ITS.
628 // Option_t *option String of Tree types S,D, and/or R.
629 // const char *file String of the file name where these branches
630 // are to be stored. If blank then these branches
631 // are written to the same tree as the Hits were
637 Bool_t cH = (strstr(option,"H")!=0);
638 Bool_t cS = (strstr(option,"S")!=0);
639 Bool_t cD = (strstr(option,"D")!=0);
640 Bool_t cR = (strstr(option,"R")!=0);
641 Bool_t cRF = (strstr(option,"RF")!=0);
642 Bool_t v2 = (strstr(option,"v2")!=0);
646 if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
648 AliDetector::MakeBranch(option);
650 if(cS) MakeBranchS(0);
651 if(cD) MakeBranchD(0);
652 if(cR) MakeBranchR(0);
653 if(cRF) MakeBranchRF(0);
654 if(v2) MakeBranchR(0,"v2");
656 //______________________________________________________________________
657 void AliITS::SetTreeAddress(){
658 // Set branch address for the Trees.
665 TTree *treeS = fLoader->TreeS();
666 TTree *treeD = fLoader->TreeD();
667 TTree *treeR = fLoader->TreeR();
668 if (fLoader->TreeH() && (fHits == 0x0))
669 fHits = new TClonesArray("AliITShit", 1560);
671 AliDetector::SetTreeAddress();
673 SetTreeAddressS(treeS);
674 SetTreeAddressD(treeD);
675 SetTreeAddressR(treeR);
677 //______________________________________________________________________
678 void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){
680 // The function to add information to the AliITShit class. See the
681 // AliITShit class for a full description. This function allocates the
682 // necessary new space for the hit information and passes the variable
683 // track, and the pointers *vol and *hits to the AliITShit constructor
686 // Int_t track Track number which produced this hit.
687 // Int_t *vol Array of Integer Hit information. See AliITShit.h
688 // Float_t *hits Array of Floating Hit information. see AliITShit.h
694 TClonesArray &lhits = *fHits;
695 new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
697 //______________________________________________________________________
698 void AliITS::InitModules(Int_t size,Int_t &nmodules){
699 // Initialize the modules array.
701 // Int_t size Size of array of the number of modules to be
702 // created. If size <=0 then the number of modules
703 // is gotten from AliITSgeom class kept in fITSgeom.
705 // Int_t &nmodules The number of modules existing.
710 fITSmodules->Delete();
712 } // end fir fITSmoudles
714 Int_t nl,indexMAX,index;
716 if(size<=0){ // default to using data stored in AliITSgeom
718 Error("InitModules","fITSgeom not defined");
720 } // end if fITSgeom==0
721 nl = fITSgeom->GetNlayers();
722 indexMAX = fITSgeom->GetIndexMax();
724 fITSmodules = new TObjArray(indexMAX);
725 for(index=0;index<indexMAX;index++){
726 fITSmodules->AddAt( new AliITSmodule(index),index);
729 fITSmodules = new TObjArray(size);
730 for(index=0;index<size;index++) {
731 fITSmodules->AddAt( new AliITSmodule(index),index);
737 //______________________________________________________________________
738 void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
739 Option_t *option, const char *filename){
740 // fill the modules with the sorted by module hits; add hits from
741 // background if option=Add.
743 // Int_t evnt Event to be processed.
744 // Int_t bgrev Background Hit tree number.
745 // Int_t nmodules Not used.
746 // Option_t *option String indicating if merging hits or not. To
747 // merge hits set equal to "Add". Otherwise no
748 // background hits are considered.
749 // Test_t *filename File name containing the background hits..
754 static TTree *trH1; //Tree with background hits
755 static Bool_t first=kTRUE;
757 const char *addBgr = strstr(option,"Add");
759 evnt = nmodules; // Dummy use of variables to remove warnings
762 file=new TFile(filename);
767 // Get Hits Tree header from file
768 if(trH1) delete trH1;
772 sprintf(treeName,"TreeH%d",bgrev);
773 trH1 = (TTree*)gDirectory->Get(treeName);
775 Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
777 // Set branch addresses
780 FillModules(fLoader->TreeH(),0); // fill from this file's tree.
783 FillModules(trH1,10000000); // Default mask 10M.
784 TTree *fAli=fLoader->GetRunLoader()->TreeK();
786 if (fAli) fileAli =fAli->GetCurrentFile();
790 //______________________________________________________________________
791 void AliITS::FillModules(TTree *treeH, Int_t mask) {
792 // fill the modules with the sorted by module hits;
793 // can be called many times to do a merging
795 // TTree *treeH The tree containing the hits to be copied into
797 // Int_t mask The track number mask to indecate which file
798 // this hits came from.
806 Error("FillModules","Tree is NULL");
808 Int_t lay,lad,det,index;
812 sprintf(branchname,"%s",GetName());
813 TBranch *branch = treeH->GetBranch(branchname);
815 Error("FillModules","%s branch in TreeH not found",branchname);
818 branch->SetAddress(&fHits);
819 Int_t nTracks =(Int_t) treeH->GetEntries();
821 for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
823 Int_t nBytes = treeH->GetEvent(iPrimTrack);
824 if (nBytes <= 0) continue;
825 Int_t nHits = fHits->GetEntriesFast();
826 for(h=0; h<nHits; h++){
827 itsHit = (AliITShit *)fHits->UncheckedAt(h);
828 itsHit->GetDetectorID(lay,lad,det);
830 index = fITSgeom->GetModuleIndex(lay,lad,det);
832 index=det-1; // This should not be used.
833 } // end if [You must have fITSgeom for this to work!]
834 mod = GetModule(index);
835 itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
836 mod->AddHit(itsHit,iPrimTrack,h);
837 } // end loop over hits
838 } // end loop over tracks
840 //______________________________________________________________________
841 void AliITS::MakeBranchS(const char *fl){
842 // Creates Tree Branch for the ITS summable digits.
844 // cont char *fl File name where SDigits branch is to be written
845 // to. If blank it write the SDigits to the same
846 // file in which the Hits were found.
851 Int_t buffersize = 4000;
854 // only one branch for SDigits.
855 sprintf(branchname,"%s",GetName());
858 if(fLoader->TreeS()){
859 if(fSDigits==0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
860 MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
863 //______________________________________________________________________
864 void AliITS::SetTreeAddressS(TTree *treeS){
865 // Set branch address for the ITS summable digits Trees.
867 // TTree *treeS Tree containing the SDigits.
875 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000);
877 sprintf(branchname,"%s",GetName());
878 branch = treeS->GetBranch(branchname);
879 if (branch) branch->SetAddress(&fSDigits);
881 //______________________________________________________________________
882 void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
883 // Creates Tree branches for the ITS.
885 // TTree *treeD Pointer to the Digits Tree.
886 // cont char *file File name where Digits branch is to be written
887 // to. If blank it write the SDigits to the same
888 // file in which the Hits were found.
893 // one branch for digits per type of detector
894 const Char_t *det[3] = {"SPD","SDD","SSD"};
897 Int_t buffersize = 4000;
898 Char_t branchname[30];
900 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
901 for (i=0; i<kNTYPES ;i++) {
902 digclass = DetType(i)->GetDigitClassName();
904 if(!(fDtype->At(i))){
905 fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i);
909 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
910 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
911 if (fDtype && treeD) {
912 MakeBranchInTree(treeD,branchname,&((*fDtype)[i]),buffersize,file);
916 for (i=0; i<kNTYPES ;i++) {
917 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
918 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
919 if (fDtype && treeD) {
920 MakeBranchInTree(treeD,branchname,&((*fDtype)[i]),buffersize,file);
925 //______________________________________________________________________
926 void AliITS::SetTreeAddressD(TTree *treeD){
927 // Set branch address for the Trees.
929 // TTree *treeD Tree containing the Digits.
934 const char *det[3] = {"SPD","SDD","SSD"};
941 if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes);
942 for (i=0; i<kNTYPES; i++) {
943 digclass = DetType(i)->GetDigitClassName();
945 if(!(fDtype->At(i))) {
946 fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i);
950 if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
951 else sprintf(branchname,"%sDigits%d",GetName(),i+1);
953 branch = treeD->GetBranch(branchname);
954 if (branch) branch->SetAddress(&((*fDtype)[i]));
958 //______________________________________________________________________
959 void AliITS::Hits2SDigits(){
960 // Standard Hits to summable Digits function.
966 fLoader->LoadHits("read");
967 fLoader->LoadSDigits("recreate");
968 AliRunLoader* rl = fLoader->GetRunLoader();
970 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
971 // Do the Hits to Digits operation. Use Standard input values.
972 // Event number from file, no background hit merging , use size from
973 // AliITSgeom class, option="All", input from this file only.
974 rl->GetEvent(iEvent);
975 if (!fLoader->TreeS()) fLoader->MakeTree("S");
978 HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
981 fLoader->UnloadHits();
982 fLoader->UnloadSDigits();
984 //______________________________________________________________________
985 void AliITS::SDigitsToDigits(Option_t *opt){
986 // Standard Summable digits to Digits function.
991 char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
993 if(!GetITSgeom()) return; // need transformations to do digitization.
994 AliITSgeom *geom = GetITSgeom();
996 const char *all = strstr(opt,"All");
997 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
999 if( !det[0] && !det[1] && !det[2] ) all = "All";
1001 static Bool_t setDef = kTRUE;
1002 if(setDef) SetDefaultSimulation();
1005 AliITSsimulation *sim = 0;
1006 AliITSDetType *iDetType = 0;
1007 TTree *trees = fLoader->TreeS();
1008 if( !(trees && this->GetSDigits()) ){
1009 Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
1012 sprintf( name, "%s", this->GetName() );
1013 TBranch *brchSDigits = trees->GetBranch( name );
1016 for(module=0;module<geom->GetIndexMax();module++){
1017 id = geom->GetModuleType(module);
1018 if (!all && !det[id]) continue;
1019 iDetType = DetType(id);
1020 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1022 Error("SDigit2Digits","The simulation class was not "
1023 "instanciated for module %d type %s!",module,
1024 geom->GetModuleTypeName(module));
1027 sim->InitSimulationModule(module,gAlice->GetEvNumber());
1029 // add summable digits to module
1030 this->GetSDigits()->Clear();
1031 brchSDigits->GetEvent(module);
1032 sim->AddSDigitsToModule(GetSDigits(),0);
1034 // Digitise current module sum(SDigits)->Digits
1035 sim->FinishSDigitiseModule();
1037 // fills all branches - wasted disk space
1038 fLoader->TreeD()->Fill();
1039 this->ResetDigits();
1042 fLoader->TreeD()->GetEntries();
1044 fLoader->TreeD()->AutoSave();
1046 fLoader->TreeD()->Reset();
1049 //______________________________________________________________________
1050 void AliITS::Hits2Digits(){
1051 // Standard Hits to Digits function.
1057 fLoader->LoadHits("read");
1058 fLoader->LoadDigits("recreate");
1059 AliRunLoader* rl = fLoader->GetRunLoader();
1061 for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
1062 // Do the Hits to Digits operation. Use Standard input values.
1063 // Event number from file, no background hit merging , use size from
1064 // AliITSgeom class, option="All", input from this file only.
1065 rl->GetEvent(iEvent);
1066 if (!fLoader->TreeD()) fLoader->MakeTree("D");
1069 HitsToDigits(iEvent,0,-1," ",fOpt," ");
1072 fLoader->UnloadHits();
1073 fLoader->UnloadDigits();
1075 //______________________________________________________________________
1076 void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1077 Option_t *option,Option_t *opt,
1078 const char *filename){
1079 // Keep galice.root for signal and name differently the file for
1080 // background when add! otherwise the track info for signal will be lost !
1081 // the condition below will disappear when the geom class will be
1082 // initialized for all versions - for the moment it is only for v5 !
1083 // 7 is the SDD beam test version.
1085 // Int_t evnt Event to be processed.
1086 // Int_t bgrev Background Hit tree number.
1087 // Int_t nmodules Not used.
1088 // Option_t *option String indicating if merging hits or not. To
1089 // merge hits set equal to "Add". Otherwise no
1090 // background hits are considered.
1091 // Test_t *filename File name containing the background hits..
1097 if(!GetITSgeom()) return; // need transformations to do digitization.
1098 AliITSgeom *geom = GetITSgeom();
1100 const char *all = strstr(opt,"All");
1101 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1103 static Bool_t setDef=kTRUE;
1104 if (setDef) SetDefaultSimulation();
1108 InitModules(size,nmodules);
1109 FillModules(evNumber,bgrev,nmodules,option,filename);
1111 AliITSsimulation *sim = 0;
1112 AliITSDetType *iDetType = 0;
1113 AliITSmodule *mod = 0;
1115 for(module=0;module<geom->GetIndexMax();module++){
1116 id = geom->GetModuleType(module);
1117 if (!all && !det[id]) continue;
1118 iDetType = DetType(id);
1119 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1121 Error("HitsToSDigits","The simulation class was not "
1122 "instanciated for module %d type %s!",module,
1123 geom->GetModuleTypeName(module));
1126 mod = (AliITSmodule *)fITSmodules->At(module);
1127 sim->SDigitiseModule(mod,module,evNumber);
1128 // fills all branches - wasted disk space
1129 fLoader->TreeS()->Fill();
1135 fLoader->TreeS()->GetEntries();
1136 fLoader->TreeS()->AutoSave();
1137 fLoader->WriteSDigits("OVERWRITE");
1139 fLoader->TreeS()->Reset();
1141 //______________________________________________________________________
1142 void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
1143 Option_t *option,Option_t *opt,
1144 const char *filename){
1145 // Keep galice.root for signal and name differently the file for
1146 // background when add! otherwise the track info for signal will be lost !
1147 // the condition below will disappear when the geom class will be
1148 // initialized for all versions - for the moment it is only for v5 !
1149 // 7 is the SDD beam test version.
1151 // Int_t evnt Event to be processed.
1152 // Int_t bgrev Background Hit tree number.
1153 // Int_t nmodules Not used.
1154 // Option_t *option String indicating if merging hits or not. To
1155 // merge hits set equal to "Add". Otherwise no
1156 // background hits are considered.
1157 // Test_t *filename File name containing the background hits..
1164 if(!GetITSgeom()) return; // need transformations to do digitization.
1165 AliITSgeom *geom = GetITSgeom();
1167 const char *all = strstr(opt,"All");
1168 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
1170 static Bool_t setDef=kTRUE;
1171 if (setDef) SetDefaultSimulation();
1175 InitModules(size,nmodules);
1176 FillModules(evNumber,bgrev,nmodules,option,filename);
1178 AliITSsimulation *sim = 0;
1179 AliITSDetType *iDetType = 0;
1180 AliITSmodule *mod = 0;
1182 for(module=0;module<geom->GetIndexMax();module++){
1183 id = geom->GetModuleType(module);
1184 if (!all && !det[id]) continue;
1185 iDetType = DetType(id);
1186 sim = (AliITSsimulation*)iDetType->GetSimulationModel();
1188 Error("HitsToDigits","The simulation class was not "
1189 "instanciated for module %d type %s!",module,
1190 geom->GetModuleTypeName(module));
1193 mod = (AliITSmodule *)fITSmodules->At(module);
1194 sim->DigitiseModule(mod,module,evNumber);
1195 // fills all branches - wasted disk space
1196 fLoader->TreeD()->Fill();
1202 fLoader->TreeD()->GetEntries();
1203 fLoader->TreeD()->AutoSave();
1205 fLoader->TreeD()->Reset();
1207 //______________________________________________________________________
1208 void AliITS::ResetDigits(){
1209 // Reset number of digits and the digits array for the ITS detector.
1215 if (!fDtype) return;
1218 for (i=0;i<kNTYPES;i++ ) {
1222 //______________________________________________________________________
1223 void AliITS::ResetDigits(Int_t i){
1224 // Reset number of digits and the digits array for this branch.
1230 if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear();
1231 if (fNdtype) fNdtype[i]=0;
1233 //______________________________________________________________________
1234 void AliITS::AddSumDigit(AliITSpListItem &sdig){
1235 // Adds the a module full of summable digits to the summable digits tree.
1237 // AliITSpListItem &sdig SDigit to be added to SDigits tree.
1243 TClonesArray &lsdig = *fSDigits;
1244 new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
1246 //______________________________________________________________________
1247 void AliITS::AddRealDigit(Int_t id, Int_t *digits){
1248 // Add a real digit - as coming from data.
1250 // Int_t id Detector type number.
1251 // Int_t *digits Integer array containing the digits info. See
1258 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1259 new(ldigits[fNdtype[id]++]) AliITSdigit(digits);
1261 //______________________________________________________________________
1262 void AliITS::AddSimDigit(Int_t id, AliITSdigit *d){
1263 // Add a simulated digit.
1265 // Int_t id Detector type number.
1266 // AliITSdigit *d Digit to be added to the Digits Tree. See
1273 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1277 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
1280 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
1283 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
1287 //______________________________________________________________________
1288 void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks,
1289 Int_t *hits,Float_t *charges){
1290 // Add a simulated digit to the list.
1292 // Int_t id Detector type number.
1293 // Float_t phys Physics indicator. See AliITSdigits.h
1294 // Int_t *digits Integer array containing the digits info. See
1296 // Int_t *tracks Integer array [AliITSdigitS?D::GetNTracks()]
1297 // containing the track numbers that contributed to
1299 // Int_t *hits Integer array [AliITSdigitS?D::GetNTracks()]
1300 // containing the hit numbers, from AliITSmodule, that
1301 // contributed to this digit.
1302 // Float_t *charge Floating point array of the signals contributed
1303 // to this digit by each track.
1309 TClonesArray &ldigits = *((TClonesArray*)fDtype->At(id));
1310 AliITSresponseSDD *resp = 0;
1313 new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits);
1316 resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel();
1317 new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks,
1321 new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits);
1325 //______________________________________________________________________
1326 void AliITS::Digits2Raw(){
1327 // convert digits of the current event to raw data
1329 fLoader->LoadDigits();
1330 TTree* digits = fLoader->TreeD();
1332 Error("Digits2Raw", "no digits tree");
1335 SetTreeAddressD(digits);
1337 AliITSDDLRawData rawWriter;
1341 // 2: txt files with digits
1342 //BE CAREFUL, verbose level 2 MUST be used only for debugging and
1343 //it is highly suggested to use this mode only for debugging digits files
1344 //reasonably small, because otherwise the size of the txt files can reach
1345 //quickly several MB wasting time and disk space.
1346 rawWriter.SetVerbose(0);
1348 //SILICON PIXEL DETECTOR
1349 Info("Digits2Raw", "Formatting raw data for SPD");
1350 rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"));
1352 //SILICON DRIFT DETECTOR
1353 Info("Digits2Raw", "Formatting raw data for SDD");
1354 rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"));
1356 //SILICON STRIP DETECTOR
1357 Info("Digits2Raw", "Formatting raw data for SSD");
1358 rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
1360 fLoader->UnloadDigits();
1363 //______________________________________________________________________
1364 void AliITS::MakeTreeC(Option_t *option){
1365 // Create a separate tree to store the clusters.
1367 // Option_t *option string which must contain "C" otherwise
1368 // no Cluster Tree is created.
1374 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1376 if (pITSLoader == 0x0) {
1377 Error("MakeTreeC","fLoader == 0x0 option=%s",option);
1380 if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C");
1383 //----------------------------------------------------------------------
1384 void AliITS::MakeBranchC(){
1385 //Makes barnches in treeC
1386 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1387 if (pITSLoader == 0x0) {
1388 Error("MakeTreeC","fLoader == 0x0");
1391 TTree * lTC = pITSLoader->TreeC();
1393 Error("MakeTreeC","Can not get TreeC from Loader");
1397 Int_t buffersize = 4000;
1398 char branchname[30];
1399 const char *det[3] = {"SPD","SDD","SSD"};
1403 // one branch for Clusters per type of detector
1405 for (i=0; i<kNTYPES ;i++) {
1406 AliITSDetType *iDetType=DetType(i);
1407 iDetType->GetClassNames(digclass,clclass);
1409 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1410 if(!ClustersAddress(i)){
1411 fCtype->AddAt(new TClonesArray(clclass,1000),i);
1413 if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1414 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1415 if (fCtype && lTC) {
1416 if (lTC->GetBranch(branchname)){
1417 Warning("MakeBranchC","Branch %s alread exists in TreeC",
1420 Info("MakeBranchC","Creating branch %s in TreeC",branchname);
1421 lTC->Branch(branchname,&((*fCtype)[i]), buffersize);
1423 } // end if fCtype && lTC
1426 //______________________________________________________________________
1427 void AliITS::GetTreeC(Int_t event){
1428 // Get the clusters tree for this event and set the branch address.
1430 // Int_t event Event number for the cluster tree.
1435 char branchname[30];
1436 const char *det[3] = {"SPD","SDD","SSD"};
1438 AliITSLoader *pITSLoader = (AliITSLoader*)fLoader;
1439 TTree * lTC = pITSLoader->TreeC();
1443 pITSLoader->CleanRawClusters();
1452 for (i=0; i<kNTYPES; i++) {
1453 AliITSDetType *iDetType=DetType(i);
1454 iDetType->GetClassNames(digclass,clclass);
1456 if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes);
1457 if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i);
1458 if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]);
1459 else sprintf(branchname,"%sClusters%d",GetName(),i+1);
1461 branch = lTC->GetBranch(branchname);
1462 if (branch) branch->SetAddress(&((*fCtype)[i]));
1466 Error("GetTreeC","cannot find Clusters Tree for event:%d",event);
1469 //______________________________________________________________________
1470 void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){
1471 // Add a cluster to the list.
1473 // Int_t id Detector type number.
1474 // AliITSRawCluster *c Cluster class to be added to the tree of
1481 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
1485 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
1488 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
1491 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
1495 //______________________________________________________________________
1496 void AliITS::ResetClusters(Int_t i){
1497 // Reset number of clusters and the clusters array for this branch.
1499 // Int_t i Detector type number.
1505 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
1506 if (fNctype) fNctype[i]=0;
1508 //______________________________________________________________________
1509 void AliITS::MakeBranchR(const char *file, Option_t *opt){
1510 // Creates Tree branches for the ITS Reconstructed points.
1512 // cont char *file File name where RecPoints branch is to be written
1513 // to. If blank it write the SDigits to the same
1514 // file in which the Hits were found.
1519 Int_t buffsz = 4000;
1520 char branchname[30];
1522 // only one branch for rec points for all detector types
1523 Bool_t oFast= (strstr(opt,"Fast")!=0);
1524 Bool_t v2 = (strstr(opt,"v2")!=0);
1528 sprintf(branchname,"%sRecPointsF",GetName());
1530 sprintf(branchname,"Clusters");
1532 sprintf(branchname,"%sRecPoints",GetName());
1537 if(!fClustersV2)fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
1538 if(fLoader->TreeR()){
1539 if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
1540 MakeBranchInTree(fLoader->TreeR(),branchname,&fClustersV2,buffsz,file);
1544 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1545 if (fLoader->TreeR()) {
1546 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",
1548 MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file);
1552 //______________________________________________________________________
1553 void AliITS::SetTreeAddressR(TTree *treeR){
1554 // Set branch address for the Reconstructed points Trees.
1556 // TTree *treeR Tree containing the RecPoints.
1561 char branchname[30];
1564 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
1566 sprintf(branchname,"Clusters");
1567 branch1 = treeR->GetBranch(branchname);
1569 if(fClustersV2==0x0) fClustersV2 = new TClonesArray("AliITSclusterV2",3000);
1570 branch1->SetAddress(&fClustersV2);
1574 sprintf(branchname,"%sRecPoints",GetName());
1575 branch = treeR->GetBranch(branchname);
1577 branch->SetAddress(&fRecPoints);
1579 sprintf(branchname,"%sRecPointsF",GetName());
1580 branch = treeR->GetBranch(branchname);
1582 branch->SetAddress(&fRecPoints);
1587 //______________________________________________________________________
1588 void AliITS::AddRecPoint(const AliITSRecPoint &r){
1589 // Add a reconstructed space point to the list
1591 // const AliITSRecPoint &r RecPoint class to be added to the tree
1592 // of reconstructed points TreeR.
1598 TClonesArray &lrecp = *fRecPoints;
1599 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
1601 //______________________________________________________________________
1602 void AliITS::AddClusterV2(const AliITSclusterV2 &r){
1603 // Add a reconstructed space point to the list
1605 // const AliITSClusterV2 &r class to be added to the tree
1606 // of reconstructed points TreeR.
1612 TClonesArray &lrecp = *fClustersV2;
1613 new(lrecp[fNClustersV2++]) AliITSclusterV2(r);
1615 //______________________________________________________________________
1616 void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
1617 Option_t *opt0,Option_t *opt1,
1619 // keep galice.root for signal and name differently the file for
1620 // background when add! otherwise the track info for signal will be lost !
1621 // the condition below will disappear when the geom class will be
1622 // initialized for all versions - for the moment it is only for v5 !
1624 // Int_t evnt Event to be processed.
1625 // Int_t bgrev Background Hit tree number.
1626 // Int_t size Size used by InitModules. See InitModules.
1627 // Option_t *opt0 Option passed to FillModules. See FillModules.
1628 // Option_t *opt1 String indicating if merging hits or not. To
1629 // merge hits set equal to "Add". Otherwise no
1630 // background hits are considered.
1631 // Test_t *flnm File name containing the background hits..
1637 if(!GetITSgeom()) return;
1638 AliITSLoader *pITSloader = (AliITSLoader*)fLoader;
1639 AliITSgeom *geom = GetITSgeom();
1641 const char *all = strstr(opt1,"All");
1642 const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
1643 strstr(opt1,"SSD")};
1645 InitModules(size,nmodules);
1646 FillModules(evNumber,bgrev,nmodules,opt0,flnm);
1648 AliITSsimulation *sim = 0;
1649 AliITSDetType *iDetType = 0;
1650 AliITSmodule *mod = 0;
1653 //m.b. : this change is nothing but a nice way to make sure
1656 if(GetDebug()) cout<<"HitsToFastRecPoints: N mod = "<<
1657 geom->GetIndexMax()<<endl;
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);