From aacedc3e54091806a9c6d356fd7f582df59fd73f Mon Sep 17 00:00:00 2001 From: nilsen Date: Thu, 10 Jun 2004 21:00:25 +0000 Subject: [PATCH] Modifications associated with remerging the Ba/Sa and Dubna pixel simulations, some cleaning of general code (including coding convensions), and adding some protections associated with SetDefaults/SetDefaultSimulations which should help with the Test beam simulations. Details below. The default SPD simulation for the general ITS runs/geometry is still the Ba/Sa, but for the Test beam geometries this has been changed to the merged versions. File: AliITS.cxx Modified File: AliITS.h Modified In lined many one-two line functions. Added some protection to SetDefaults(), SetDefaultSimulation(), and SetDefaultClusterFinders(), such that they should now even work when only one detector type has been defined (as it should be for the test beams...). Some mostly cosmetic issues associated with getting branch names for digits. And Generally some cleaning up of the code. File: AliITSClusterFinder.cxx Modified File: AliITSClusterFinder.h Modified Did some additional consolidation of data into the base class, added TClonesArray *fClusters, a fDebug, and fModule variables. Otherwise some cosmetic and coding conversion changes. File: AliITSClusterFinderSDD.cxx Modified File: AliITSClusterFinderSDD.h Modified Changes to be consistent with the modified base class, and cosmetic and coding conversion changes. File: AliITSClusterFinderSPD.cxx Modified File: AliITSClusterFinderSPD.h Modified Changes to be consistent with the modified base class, and cosmetic and coding conversion changes. File: AliITSClusterFinderSPDdubna.h Removed File: AliITSClusterFinderSPDdubna.cxx Removed Since we have ClusterFinderSPD and V2 and this version isn't being maintained, it is being retired. File: AliITSClusterFinderSSD.cxx Modified File: AliITSClusterFinderSSD.h Modified Changes to be consistent with the modified base class, and cosmetic and coding conversion changes. File: AliITSDetType.cxx Modified File: AliITSDetType.h Modified Added a new class variable to indicate what the detector type is AliITSDetector fDetType; values of kSPD, kSDD, kSSD, .... Otherwise cosmetic and Coding convention changes. File: AliITSLoader.cxx Modified File: AliITSLoader.h Modified Some changes which are not complete. The idea is to be able to get, simply via one call, a specific hit, Sdigit, digit, RecPoint,... without all of the usual over head of initializing TClonesArrays setting branch addresses and the like. Work is far form ready. File: AliITSdcsSSD.cxx Modified Some nearly cosmetic changes necessary due to changes to response and segmentation class'. File: AliITSgeom.h Modified In the definition of AliITSDetector type, added kND=-1, no detector defined. Expect to use it later(?). File: AliITSresponse.h Modified Basically cosmetic. Mostly changing Float_t to Double_t. File: AliITSresponseSDD.cxx Modified File: AliITSresponseSDD.h Modified Basically the cosmetic and Float_t to Double_t File: AliITSresponseSPD.cxx Modified File: AliITSresponseSPD.h Modified Mostly Float_t to Double_t and added in the IsPixelDead function for the dubna version (otherwise the merging had been done). File: AliITSresponseSPDdubna.h Removed File: AliITSresponseSPDdubna.cxx Removed We should be able to remove this class now. AliITSresponseSPD is now used for both the Bari-Salerno and the dubna models. File: AliITSresponseSSD.cxx Modified File: AliITSresponseSSD.h Modified Float_t to Double_t changes. File: AliITSsegmentation.h Modified Made LocaltoDet return a Bool_t. Now if the x,z location is outside of the volume, it returns kFALSE. see below. File: AliITSsegmentationSDD.cxx Modified File: AliITSsegmentationSDD.h Modified Made LocaltoDet return a Bool_t. Now if the x,z location is outside of the volume, it returns kFALSE. File: AliITSsegmentationSPD.cxx Modified File: AliITSsegmentationSPD.h Modified Made LocaltoDet return a Bool_t. Now if the x,z location is outside of the volume, it returns kFALSE. File: AliITSsegmentationSSD.cxx Modified File: AliITSsegmentationSSD.h Modified Made LocaltoDet return a Bool_t. Now if the x,z location is outside of the volume, it returns kFALSE. see below. File: AliITSsimulation.cxx Modified File: AliITSsimulation.h Modified Added fDebug variable, new Constructor for use below. Cosmetic and coding convention changes File: AliITSsimulationSDD.cxx Modified File: AliITSsimulationSDD.h Modified Added new Constructor, removed redundant variables and Cosmetic and coding convention changes. File: AliITSsimulationSPD.cxx Modified File: AliITSsimulationSPD.h Modified Removed some dead code, made changes as needed by the changes above (response and segmentation classes...). a few cosmetic and coding convention changes. File: AliITSsimulationSPDdubna.cxx Modified File: AliITSsimulationSPDdubna.h Modified New merged version, implemented new and old coupling with switch, coding convention and similar changes. (found 1 bugs, missing ! in front of if(mod-LineSegmentL(....,). File: AliITSsimulationSSD.cxx Modified File: AliITSsimulationSSD.h Modified removed redundant variables with base class. Fixed for coding convention and other cosmetic changes. File: AliITSvSDD03.cxx Modified File: AliITSvSPD02.cxx Modified File: AliITSvSSD03.cxx Modified These two have their private versions of SetDefaults and SetDefaultSimulation which have been similarly protected as in AliITS.cxx File: ITSLinkDef.h Modified File: libITS.pkg Modified Versions which include v11 geometry and other private changes --- ITS/AliITS.cxx | 835 ++++---- ITS/AliITS.h | 42 +- ITS/AliITSClusterFinder.cxx | 341 +++- ITS/AliITSClusterFinder.h | 162 +- ITS/AliITSClusterFinderSDD.cxx | 524 +++-- ITS/AliITSClusterFinderSDD.h | 95 +- ITS/AliITSClusterFinderSPD.cxx | 499 ++--- ITS/AliITSClusterFinderSPD.h | 56 +- ITS/AliITSClusterFinderSPDdubna.cxx | 358 ---- ITS/AliITSClusterFinderSPDdubna.h | 49 - ITS/AliITSClusterFinderSSD.cxx | 429 ++-- ITS/AliITSClusterFinderSSD.h | 80 +- ITS/AliITSDetType.cxx | 108 +- ITS/AliITSDetType.h | 15 +- ITS/AliITSLoader.cxx | 365 +++- ITS/AliITSLoader.h | 140 +- ITS/AliITSdcsSSD.cxx | 10 +- ITS/AliITSgeom.h | 2 +- ITS/AliITSresponse.h | 81 +- ITS/AliITSresponseSDD.cxx | 22 +- ITS/AliITSresponseSDD.h | 117 +- ITS/AliITSresponseSPD.cxx | 40 +- ITS/AliITSresponseSPD.h | 97 +- ITS/AliITSresponseSPDdubna.cxx | 130 -- ITS/AliITSresponseSPDdubna.h | 128 -- ITS/AliITSresponseSSD.cxx | 16 +- ITS/AliITSresponseSSD.h | 67 +- ITS/AliITSsegmentation.h | 2 +- ITS/AliITSsegmentationSDD.cxx | 9 +- ITS/AliITSsegmentationSDD.h | 2 +- ITS/AliITSsegmentationSPD.cxx | 41 +- ITS/AliITSsegmentationSPD.h | 2 +- ITS/AliITSsegmentationSSD.cxx | 4 +- ITS/AliITSsegmentationSSD.h | 2 +- ITS/AliITSsimulation.cxx | 78 +- ITS/AliITSsimulation.h | 18 +- ITS/AliITSsimulationSDD.cxx | 2819 ++++++++++++++------------- ITS/AliITSsimulationSDD.h | 37 +- ITS/AliITSsimulationSPD.cxx | 706 ++++--- ITS/AliITSsimulationSPD.h | 20 +- ITS/AliITSsimulationSPDdubna.cxx | 882 +++------ ITS/AliITSsimulationSPDdubna.h | 105 +- ITS/AliITSsimulationSSD.cxx | 710 +++---- ITS/AliITSsimulationSSD.h | 12 +- ITS/AliITSvSDD03.cxx | 176 +- ITS/AliITSvSPD02.cxx | 294 +-- ITS/AliITSvSSD03.cxx | 71 +- ITS/ITSLinkDef.h | 4 +- ITS/libITS.pkg | 4 +- 49 files changed, 5232 insertions(+), 5574 deletions(-) delete mode 100644 ITS/AliITSClusterFinderSPDdubna.cxx delete mode 100644 ITS/AliITSClusterFinderSPDdubna.h delete mode 100644 ITS/AliITSresponseSPDdubna.cxx delete mode 100644 ITS/AliITSresponseSPDdubna.h diff --git a/ITS/AliITS.cxx b/ITS/AliITS.cxx index a009385f76b..b155d86c497 100644 --- a/ITS/AliITS.cxx +++ b/ITS/AliITS.cxx @@ -196,7 +196,8 @@ AliITS::AliITS(const char *name, const char *title):AliDetector(name,title), fIshunt = 0; // not zeroed in AliDetector fHits = new TClonesArray("AliITShit", 1560);//not done in AliDetector - if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);// Not done in AliDetector. + // Not done in AliDetector. + if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits); fEuclidOut = 0; fITSgeom = 0; @@ -328,21 +329,18 @@ AliITS& AliITS::operator=(AliITS &source){ return *this; //fake return } //______________________________________________________________________ -Int_t AliITS::DistancetoPrimitive(Int_t,Int_t) const{ - // Distance from mouse to ITS on the screen. Dummy routine - // A dummy routine used by the ROOT macro display.C to allow for the - // use of the mouse (pointing device) in the macro. In general this should - // never be called. If it is it returns the number 9999 for any value of - // x and y. +AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{ + // Creates the AliITSDigitizer in a standard way for use via AliModule. + // This function can not be included in the .h file because of problems + // with the order of inclusion (recursive). // Inputs: - // Int_t Dummy screen coordinate. - // Int_t Dummy screen coordinate. - // Outputs: - // none. + // AliRunDigitizer *manager The Manger class for Digitization + // Output: + // none. // Return: - // Int_t Dummy = 9999 distance to ITS. + // A new AliITSRunDigitizer (cast as a AliDigitizer). - return 9999; + return new AliITSDigitizer(manager); } //______________________________________________________________________ void AliITS::Init(){ @@ -373,56 +371,64 @@ void AliITS::SetDefaults(){ // none. // Return: // none. - - if(fDebug) printf("%s: SetDefaults\n",ClassName()); - + AliITSsegmentation *seg; + AliITSresponse *resp; AliITSDetType *iDetType; + if(fDebug) Info("SetDefauls","%s: SetDefaults",ClassName()); + //SPD - iDetType=DetType(0); - if (!iDetType->GetSegmentationModel()) { - AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom); - SetSegmentationModel(0,seg0); - } // end if - if (!iDetType->GetResponseModel()) { - SetResponseModel(0,new AliITSresponseSPD()); - } // end if - // set digit and raw cluster classes to be used + iDetType = DetType(kSPD); + if(iDetType){ + if (!iDetType->GetSegmentationModel()) { + seg = new AliITSsegmentationSPD(fITSgeom); + SetSegmentationModel(kSPD,seg); + } // end if + if (!iDetType->GetResponseModel()) { + SetResponseModel(kSPD,new AliITSresponseSPD()); + } // end if + // set digit and raw cluster classes to be used - const char *kData0=(iDetType->GetResponseModel())->DataType(); - if (strstr(kData0,"real")) { - iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD"); - } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD"); + const char *kData0=(iDetType->GetResponseModel())->DataType(); + if (strstr(kData0,"real")) { + iDetType->ClassNames("AliITSdigit","AliITSRawClusterSPD"); + } else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD"); + } // end if iDetType // SDD - iDetType=DetType(1); - if (!iDetType->GetResponseModel()) { - SetResponseModel(1,new AliITSresponseSDD("simulated")); - } // end if - AliITSresponse *resp1=iDetType->GetResponseModel(); - if (!iDetType->GetSegmentationModel()) { - AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1); - SetSegmentationModel(1,seg1); - } // end if - const char *kData1=(iDetType->GetResponseModel())->DataType(); - const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption(); - if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || strstr(kData1,"real") ){ - iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD"); - } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD"); + iDetType = DetType(kSDD); + if(iDetType){ + if (!iDetType->GetResponseModel()) { + SetResponseModel(kSDD,new AliITSresponseSDD("simulated")); + } // end if + resp = iDetType->GetResponseModel(); + if (!iDetType->GetSegmentationModel()) { + seg = new AliITSsegmentationSDD(fITSgeom,resp); + SetSegmentationModel(kSDD,seg); + } // end if + const char *kData1 = (iDetType->GetResponseModel())->DataType(); + const char *kopt = iDetType->GetResponseModel()->ZeroSuppOption(); + if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D")) || + strstr(kData1,"real") ){ + iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD"); + } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD"); + } // end if iDetType // SSD - iDetType=DetType(2); - if (!iDetType->GetSegmentationModel()) { - AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom); - SetSegmentationModel(2,seg2); - } // end if - if (!iDetType->GetResponseModel()) { - SetResponseModel(2,new AliITSresponseSSD("simulated")); - } // end if - const char *kData2=(iDetType->GetResponseModel())->DataType(); - if (strstr(kData2,"real")) { - iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD"); - } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD"); + iDetType = DetType(kSSD); + if(iDetType){ + if (!iDetType->GetSegmentationModel()) { + seg = new AliITSsegmentationSSD(fITSgeom); + SetSegmentationModel(kSSD,seg); + } // end if + if (!iDetType->GetResponseModel()) { + SetResponseModel(kSSD,new AliITSresponseSSD("simulated")); + } // end if + const char *kData2 = (iDetType->GetResponseModel())->DataType(); + if (strstr(kData2,"real")) { + iDetType->ClassNames("AliITSdigit","AliITSRawClusterSSD"); + } else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD"); + } // end if iDetType if (kNTYPES>3) { Warning("SetDefaults", @@ -438,60 +444,59 @@ void AliITS::SetDefaultSimulation(){ // none. // Return: // none. - AliITSDetType *iDetType; AliITSsimulation *sim; - iDetType=DetType(0); - sim = iDetType->GetSimulationModel(); - if (!sim) { - AliITSsegmentation *seg0= - (AliITSsegmentation*)iDetType->GetSegmentationModel(); - AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel(); - AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0); - SetSimulationModel(0,sim0); - }else{ // simulation exists, make sure it is set up properly. - ((AliITSsimulationSPD*)sim)->Init( - (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(), - (AliITSresponseSPD*) iDetType->GetResponseModel()); -// if(sim->GetResponseModel()==0) sim->SetResponseModel( -// (AliITSresponse*)iDetType->GetResponseModel()); -// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( -// (AliITSsegmentation*)iDetType->GetSegmentationModel()); - } // end if - iDetType=DetType(1); - sim = iDetType->GetSimulationModel(); - if (!sim) { - AliITSsegmentation *seg1= - (AliITSsegmentation*)iDetType->GetSegmentationModel(); - AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel(); - AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1); - SetSimulationModel(1,sim1); - }else{ // simulation exists, make sure it is set up properly. - ((AliITSsimulationSDD*)sim)->Init( - (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(), - (AliITSresponseSDD*) iDetType->GetResponseModel()); -// if(sim->GetResponseModel()==0) sim->SetResponseModel( -// (AliITSresponse*)iDetType->GetResponseModel()); -// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( -// (AliITSsegmentation*)iDetType->GetSegmentationModel()); - } //end if - iDetType=DetType(2); - sim = iDetType->GetSimulationModel(); - if (!sim) { - AliITSsegmentation *seg2= - (AliITSsegmentation*)iDetType->GetSegmentationModel(); - AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel(); - AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2); - SetSimulationModel(2,sim2); - }else{ // simulation exists, make sure it is set up properly. - ((AliITSsimulationSSD*)sim)->Init( - (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(), - (AliITSresponseSSD*) iDetType->GetResponseModel()); -// if(sim->GetResponseModel()==0) sim->SetResponseModel( -// (AliITSresponse*)iDetType->GetResponseModel()); -// if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( -// (AliITSsegmentation*)iDetType->GetSegmentationModel()); - } // end if + AliITSsegmentation *seg; + AliITSresponse *res; + + iDetType = DetType(kSPD); + if(iDetType){ + sim = iDetType->GetSimulationModel(); + if (!sim) { + seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); + res = (AliITSresponse*)iDetType->GetResponseModel(); + sim = new AliITSsimulationSPD(seg,res); + SetSimulationModel(kSPD,sim); + }else{ // simulation exists, make sure it is set up properly. + if(sim->GetResponseModel()==0) sim->SetResponseModel( + (AliITSresponse*)iDetType->GetResponseModel()); + if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( + (AliITSsegmentation*)iDetType->GetSegmentationModel()); + sim->Init(); + } // end if + }// end if iDetType + iDetType = DetType(kSDD); + if(iDetType){ + sim = iDetType->GetSimulationModel(); + if (!sim) { + seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); + res = (AliITSresponse*)iDetType->GetResponseModel(); + sim = new AliITSsimulationSDD(seg,res); + SetSimulationModel(kSDD,sim); + }else{ // simulation exists, make sure it is set up properly. + if(sim->GetResponseModel()==0) sim->SetResponseModel( + (AliITSresponse*)iDetType->GetResponseModel()); + if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( + (AliITSsegmentation*)iDetType->GetSegmentationModel()); + sim->Init(); + } //end if + }// end if iDetType + iDetType = DetType(kSSD); + if(iDetType){ + sim = iDetType->GetSimulationModel(); + if (!sim) { + seg =(AliITSsegmentation*)iDetType->GetSegmentationModel(); + res = (AliITSresponse*)iDetType->GetResponseModel(); + sim = new AliITSsimulationSSD(seg,res); + SetSimulationModel(kSSD,sim); + }else{ // simulation exists, make sure it is set up properly. + if(sim->GetResponseModel()==0) sim->SetResponseModel( + (AliITSresponse*)iDetType->GetResponseModel()); + if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel( + (AliITSsegmentation*)iDetType->GetSegmentationModel()); + sim->Init(); + } // end if + } // end if iDetType } //______________________________________________________________________ void AliITS::SetDefaultClusterFinders(){ @@ -502,44 +507,48 @@ void AliITS::SetDefaultClusterFinders(){ // none. // Return: // none. + AliITSDetType *iDetType; + AliITSsegmentation *seg; + AliITSClusterFinder *clf; + AliITSresponse *res; MakeTreeC(); - AliITSDetType *iDetType; // SPD - iDetType=DetType(0); - if (!iDetType->GetReconstructionModel()) { - AliITSsegmentation *seg0 = - (AliITSsegmentation*)iDetType->GetSegmentationModel(); - TClonesArray *dig0=DigitsAddress(0); - TClonesArray *recp0=ClustersAddress(0); - AliITSClusterFinderSPD *rec0 = new AliITSClusterFinderSPD(seg0,dig0, - recp0); - SetReconstructionModel(0,rec0); - } // end if + iDetType=DetType(kSPD); + if(iDetType){ + if (!iDetType->GetReconstructionModel()) { + seg =(AliITSsegmentation*)iDetType->GetSegmentationModel(); + TClonesArray *dig0 = DigitsAddress(0); + TClonesArray *recp0 = ClustersAddress(0); + clf = new AliITSClusterFinderSPD(seg,dig0,recp0); + SetReconstructionModel(kSPD,clf); + } // end if + } // end if iDetType // SDD - iDetType=DetType(1); - if (!iDetType->GetReconstructionModel()) { - AliITSsegmentation *seg1 = - (AliITSsegmentation*)iDetType->GetSegmentationModel(); - AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel(); - TClonesArray *dig1=DigitsAddress(1); - TClonesArray *recp1=ClustersAddress(1); - AliITSClusterFinderSDD *rec1 = - new AliITSClusterFinderSDD(seg1,res1,dig1,recp1); - SetReconstructionModel(1,rec1); - } // end if + iDetType=DetType(kSDD); + if(iDetType){ + if (!iDetType->GetReconstructionModel()) { + seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); + res = (AliITSresponse*)iDetType->GetResponseModel(); + TClonesArray *dig1 = DigitsAddress(1); + TClonesArray *recp1 = ClustersAddress(1); + clf = new AliITSClusterFinderSDD(seg,res,dig1,recp1); + SetReconstructionModel(kSDD,clf); + } // end if + } // end if iDetType // SSD - iDetType=DetType(2); - if (!iDetType->GetReconstructionModel()) { - AliITSsegmentation *seg2= - (AliITSsegmentation*)iDetType->GetSegmentationModel(); - TClonesArray *dig2=DigitsAddress(2); - AliITSClusterFinderSSD *rec2= new AliITSClusterFinderSSD(seg2,dig2); - SetReconstructionModel(2,rec2); - } // end if + iDetType=DetType(kSSD); + if(iDetType){ + if (!iDetType->GetReconstructionModel()) { + seg = (AliITSsegmentation*)iDetType->GetSegmentationModel(); + TClonesArray *dig2 = DigitsAddress(2); + clf = new AliITSClusterFinderSSD(seg,dig2); + SetReconstructionModel(kSSD,clf); + } // end if + } // end if iDetType } //______________________________________________________________________ void AliITS::MakeBranch(Option_t* option){ @@ -582,8 +591,9 @@ void AliITS::SetTreeAddress(){ TTree *treeS = fLoader->TreeS(); TTree *treeD = fLoader->TreeD(); TTree *treeR = fLoader->TreeR(); - if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560); - + if (fLoader->TreeH() && (fHits == 0x0)) + fHits = new TClonesArray("AliITShit", 1560); + AliDetector::SetTreeAddress(); SetTreeAddressS(treeS); @@ -591,92 +601,6 @@ void AliITS::SetTreeAddress(){ SetTreeAddressR(treeR); } //______________________________________________________________________ -AliITSDetType* AliITS::DetType(Int_t id){ - // Return pointer to id detector type. - // Inputs: - // Int_t id detector id number. - // Outputs: - // none. - // Return: - // returned, a pointer to a AliITSDetType. - - return ((AliITSDetType*) fDetTypes->At(id)); -} -//______________________________________________________________________ -void AliITS::SetResponseModel(Int_t id, AliITSresponse *response){ - // Set the response model for the id detector type. - // Inputs: - // Int_t id detector id number. - // AliITSresponse* a pointer containing an instance of AliITSresponse - // to be stored/owned b y AliITSDetType. - // Outputs: - // none. - // Return: - // none. - - ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response); -} -//______________________________________________________________________ -void AliITS::SetSegmentationModel(Int_t id, AliITSsegmentation *seg){ - // Set the segmentation model for the id detector type. - // Inputs: - // Int_t id detector id number. - // AliITSsegmentation* a pointer containing an instance of - // AliITSsegmentation to be stored/owned b y - // AliITSDetType. - // Outputs: - // none. - // Return: - // none. - - ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg); -} -//______________________________________________________________________ -void AliITS::SetSimulationModel(Int_t id, AliITSsimulation *sim){ - // Set the simulation model for the id detector type. - // Inputs: - // Int_t id detector id number. - // AliITSresponse* a pointer containing an instance of AliITSresponse - // to be stored/owned b y AliITSDetType. - // Outputs: - // none. - // Return: - // none. - - ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim); - -} -//______________________________________________________________________ -void AliITS::SetReconstructionModel(Int_t id, AliITSClusterFinder *reconst){ - // Set the cluster finder model for the id detector type. - // Inputs: - // Int_t id detector id number. - // AliITSClusterFinder* a pointer containing an instance of - // AliITSClusterFinder to be stored/owned b y - // AliITSDetType. - // Outputs: - // none. - // Return: - // none. - - ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(reconst); -} -//______________________________________________________________________ -void AliITS::SetClasses(Int_t id, const char *digit, const char *cluster){ - // Set the digit and cluster classes name to be used for the id detector - // type. - // Inputs: - // Int_t id detector id number. - // const char *digit Digit class name for detector id. - // const char *cluster Cluster class name for detector id. - // Outputs: - // none. - // Return: - // none. - - ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster); -} -//______________________________________________________________________ void AliITS::AddHit(Int_t track, Int_t *vol, Float_t *hits){ // Add an ITS hit // The function to add information to the AliITShit class. See the @@ -841,16 +765,6 @@ void AliITS::FillModules(TTree *treeH, Int_t mask) { } // end loop over tracks } //______________________________________________________________________ -void AliITS::ClearModules(){ - // Clear the modules TObjArray. - // Inputs: - // none. - // Outputs: - // none. - - if(fITSmodules) fITSmodules->Delete(); -} -//______________________________________________________________________ void AliITS::MakeBranchS(const char *fl){ // Creates Tree Branch for the ITS summable digits. // Inputs: @@ -869,7 +783,7 @@ void AliITS::MakeBranchS(const char *fl){ if(fLoader->TreeS()){ - if (fSDigits == 0x0) fSDigits = new TClonesArray("AliITSpListItem",1000); + if(fSDigits==0x0) fSDigits = new TClonesArray("AliITSpListItem",1000); MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl); } // end if } @@ -903,29 +817,37 @@ void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){ // none. // Return: // none. - Int_t buffersize = 4000; - char branchname[30]; - - sprintf(branchname,"%s",GetName()); // one branch for digits per type of detector - const char *det[3] = {"SPD","SDD","SSD"}; - char digclass[40]; - char clclass[40]; + const Char_t *det[3] = {"SPD","SDD","SSD"}; + TString digclass; Int_t i; + Int_t buffersize = 4000; + Char_t branchname[30]; + + if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes); for (i=0; iGetClassNames(digclass,clclass); + digclass = DetType(i)->GetDigitClassName(); // digits - if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes); - if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i); - else ResetDigits(i); + if(!(fDtype->At(i))){ + fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i); + }else{ + ResetDigits(i); + } // end if + if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]); + else sprintf(branchname,"%sDigits%d",GetName(),i+1); + if (fDtype && treeD) { + MakeBranchInTree(treeD,branchname,&((*fDtype)[i]),buffersize,file); + } // end if } // end for i + /* for (i=0; iGetClassNames(digclass,clclass); + digclass = DetType(i)->GetDigitClassName(); // digits - if (fDtype == 0x0) fDtype = new TObjArray(fNDetTypes); - if(!(fDtype->At(i))) fDtype->AddAt(new TClonesArray(digclass,1000),i); - else ResetDigits(i); + if(!(fDtype->At(i))) { + fDtype->AddAt(new TClonesArray(digclass.Data(),1000),i); + }else{ + ResetDigits(i); + } // end if if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]); else sprintf(branchname,"%sDigits%d",GetName(),i+1); if (fDtype) { @@ -966,43 +890,22 @@ void AliITS::Hits2SDigits(){ // Outputs: // none. -// return; // Using Hits in place of the larger sDigits. fLoader->LoadHits("read"); fLoader->LoadSDigits("recreate"); AliRunLoader* rl = fLoader->GetRunLoader(); for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { - // Do the Hits to Digits operation. Use Standard input values. - // Event number from file, no background hit merging , use size from - // AliITSgeom class, option="All", input from this file only. - rl->GetEvent(iEvent); - if (!fLoader->TreeS()) fLoader->MakeTree("S"); - MakeBranch("S"); - SetTreeAddress(); - HitsToSDigits(iEvent,0,-1," ",fOpt," "); - } + // Do the Hits to Digits operation. Use Standard input values. + // Event number from file, no background hit merging , use size from + // AliITSgeom class, option="All", input from this file only. + rl->GetEvent(iEvent); + if (!fLoader->TreeS()) fLoader->MakeTree("S"); + MakeBranch("S"); + SetTreeAddress(); + HitsToPreDigits(iEvent,0,-1," ",fOpt," "); + } // end for iEvent fLoader->UnloadHits(); - fLoader->UnloadSDigits(); -} -//______________________________________________________________________ -void AliITS::Hits2PreDigits(){ - // Standard Hits to summable Digits function. - // Inputs: - // none. - // Outputs: - // none. - - AliHeader *header=fLoader->GetRunLoader()->GetHeader(); // Get event number from this file. - // Do the Hits to Digits operation. Use Standard input values. - // Event number from file, no background hit merging , use size from - // AliITSgeom class, option="All", input from this file only. - HitsToPreDigits(header->GetEvent(),0,-1," ",fOpt," "); -} -//______________________________________________________________________ -AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager) const -{ - return new AliITSDigitizer(manager); } //______________________________________________________________________ void AliITS::SDigitsToDigits(Option_t *opt){ @@ -1021,9 +924,9 @@ void AliITS::SDigitsToDigits(Option_t *opt){ strstr(opt,"SSD")}; if( !det[0] && !det[1] && !det[2] ) all = "All"; else all = 0; - static Bool_t setDef=kTRUE; - if (setDef) SetDefaultSimulation(); - setDef=kFALSE; + static Bool_t setDef = kTRUE; + if(setDef) SetDefaultSimulation(); + setDef = kFALSE; AliITSsimulation *sim = 0; AliITSDetType *iDetType = 0; @@ -1048,12 +951,12 @@ void AliITS::SDigitsToDigits(Option_t *opt){ exit(1); } // end if !sim sim->InitSimulationModule(module,gAlice->GetEvNumber()); -// + // // add summable digits to module this->GetSDigits()->Clear(); brchSDigits->GetEvent(module); sim->AddSDigitsToModule(GetSDigits(),0); -// + // // Digitise current module sum(SDigits)->Digits sim->FinishSDigitiseModule(); @@ -1082,47 +985,23 @@ void AliITS::Hits2Digits(){ AliRunLoader* rl = fLoader->GetRunLoader(); for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) { - // Do the Hits to Digits operation. Use Standard input values. - // Event number from file, no background hit merging , use size from - // AliITSgeom class, option="All", input from this file only. - rl->GetEvent(iEvent); - if (!fLoader->TreeD()) fLoader->MakeTree("D"); - MakeBranch("D"); - SetTreeAddress(); - HitsToDigits(iEvent,0,-1," ",fOpt," "); - } + // Do the Hits to Digits operation. Use Standard input values. + // Event number from file, no background hit merging , use size from + // AliITSgeom class, option="All", input from this file only. + rl->GetEvent(iEvent); + if (!fLoader->TreeD()) fLoader->MakeTree("D"); + MakeBranch("D"); + SetTreeAddress(); + HitsToDigits(iEvent,0,-1," ",fOpt," "); + } // end for iEvent fLoader->UnloadHits(); fLoader->UnloadDigits(); } //______________________________________________________________________ -void AliITS::HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size, - Option_t *option, Option_t *opt, const char *filename){ - // keep galice.root for signal and name differently the file for - // background when add! otherwise the track info for signal will be lost ! - // the condition below will disappear when the geom class will be - // initialized for all versions - for the moment it is only for v5 ! - // 7 is the SDD beam test version. Dummy routine. Hits are ITS's Summable - // Digits. - // Inputs: - // Int_t evnt Event to be processed. - // Int_t bgrev Background Hit tree number. - // Int_t nmodules Not used. - // Option_t *option String indicating if merging hits or not. To - // merge hits set equal to "Add". Otherwise no - // background hits are considered. - // Test_t *filename File name containing the background hits.. - // Outputs: - // none. - // Return: - // none. -// return; // using Hits instead of the larger sdigits. - - HitsToPreDigits(evNumber,bgrev,size,option,opt,filename); -} -//______________________________________________________________________ void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size, - Option_t *option, Option_t *opt, const char *filename){ + Option_t *option,Option_t *opt, + const char *filename){ // Keep galice.root for signal and name differently the file for // background when add! otherwise the track info for signal will be lost ! // the condition below will disappear when the geom class will be @@ -1187,7 +1066,8 @@ void AliITS::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size, } //______________________________________________________________________ void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, - Option_t *option, Option_t *opt, const char *filename){ + Option_t *option,Option_t *opt, + const char *filename){ // Keep galice.root for signal and name differently the file for // background when add! otherwise the track info for signal will be lost ! // the condition below will disappear when the geom class will be @@ -1250,17 +1130,6 @@ void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, fLoader->TreeD()->Reset(); } //______________________________________________________________________ -void AliITS::ResetSDigits(){ - // Reset the Summable Digits array. - // Inputs: - // none. - // Outputs: - // none. - - if (fSDigits) fSDigits->Clear(); - fNSDigits = 0; -} -//______________________________________________________________________ void AliITS::ResetDigits(){ // Reset number of digits and the digits array for the ITS detector. // Inputs: @@ -1272,8 +1141,7 @@ void AliITS::ResetDigits(){ Int_t i; for (i=0;iAt(i)) ((TClonesArray*)fDtype->At(i))->Clear(); - if (fNdtype) fNdtype[i]=0; + ResetDigits(i); } // end for i } //______________________________________________________________________ @@ -1284,8 +1152,8 @@ void AliITS::ResetDigits(Int_t i){ // Outputs: // none. - if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear(); - if (fNdtype) fNdtype[i]=0; + if (fDtype->At(i)) ((TClonesArray*)fDtype->At(i))->Clear(); + if (fNdtype) fNdtype[i]=0; } //______________________________________________________________________ void AliITS::AddSumDigit(AliITSpListItem &sdig){ @@ -1367,29 +1235,27 @@ void AliITS::AddSimDigit(Int_t id,Float_t phys,Int_t *digits,Int_t *tracks, AliITSresponseSDD *resp = 0; switch(id){ case 0: - new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits); - break; + new(ldigits[fNdtype[id]++]) AliITSdigitSPD(digits,tracks,hits); + break; case 1: - resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel(); - new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks, - hits,charges,resp); - break; + resp = (AliITSresponseSDD*)DetType(1)->GetResponseModel(); + new(ldigits[fNdtype[id]++]) AliITSdigitSDD(phys,digits,tracks, + hits,charges,resp); + break; case 2: - new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits); - break; + new(ldigits[fNdtype[id]++]) AliITSdigitSSD(digits,tracks,hits); + break; } // end switch id } - //______________________________________________________________________ -void AliITS::Digits2Raw() -{ -// convert digits of the current event to raw data +void AliITS::Digits2Raw(){ + // convert digits of the current event to raw data fLoader->LoadDigits(); TTree* digits = fLoader->TreeD(); if (!digits) { - Error("Digits2Raw", "no digits tree"); - return; + Error("Digits2Raw", "no digits tree"); + return; } SetTreeAddressD(digits); @@ -1433,107 +1299,97 @@ void AliITS::MakeTreeC(Option_t *option){ AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; if (pITSLoader == 0x0) { - Error("MakeTreeC","fLoader == 0x0 option=%s",option); - return; + Error("MakeTreeC","fLoader == 0x0 option=%s",option); + return; } if (pITSLoader->TreeC() == 0x0) pITSLoader->MakeTree("C"); MakeBranchC(); } +//---------------------------------------------------------------------- +void AliITS::MakeBranchC(){ + //Makes barnches in treeC + AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; + if (pITSLoader == 0x0) { + Error("MakeTreeC","fLoader == 0x0"); + return; + } + TTree * lTC = pITSLoader->TreeC(); + if (lTC == 0x0){ + Error("MakeTreeC","Can not get TreeC from Loader"); + return; + } -void AliITS::MakeBranchC() -{ -//Makes barnches in treeC - AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; - if (pITSLoader == 0x0) - { - Error("MakeTreeC","fLoader == 0x0"); - return; - } - TTree * lTC = pITSLoader->TreeC(); - if (lTC == 0x0) - { - Error("MakeTreeC","Can not get TreeC from Loader"); - return; - } - - Int_t buffersize = 4000; - char branchname[30]; - const char *det[3] = {"SPD","SDD","SSD"}; - char digclass[40]; - char clclass[40]; - + Int_t buffersize = 4000; + char branchname[30]; + const char *det[3] = {"SPD","SDD","SSD"}; + char digclass[40]; + char clclass[40]; + // one branch for Clusters per type of detector - Int_t i; - for (i=0; iGetClassNames(digclass,clclass); // clusters if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes); - if(!ClustersAddress(i)) - { - fCtype->AddAt(new TClonesArray(clclass,1000),i); - } + if(!ClustersAddress(i)){ + fCtype->AddAt(new TClonesArray(clclass,1000),i); + } if (kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]); else sprintf(branchname,"%sClusters%d",GetName(),i+1); - if (fCtype && lTC) - { - if (lTC->GetBranch(branchname)) - { - Warning("MakeBranchC","Branch %s alread exists in TreeC",branchname); + if (fCtype && lTC) { + if (lTC->GetBranch(branchname)){ + Warning("MakeBranchC","Branch %s alread exists in TreeC", + branchname); + }else{ + Info("MakeBranchC","Creating branch %s in TreeC",branchname); + lTC->Branch(branchname,&((*fCtype)[i]), buffersize); } - else - { - Info("MakeBranchC","Creating branch %s in TreeC",branchname); - lTC->Branch(branchname,&((*fCtype)[i]), buffersize); - } - } // end if fCtype && lTC - } // end for i + } // end if fCtype && lTC + } // end for i } - //______________________________________________________________________ void AliITS::GetTreeC(Int_t event){ - // Get the clusters tree for this event and set the branch address. - // Inputs: - // Int_t event Event number for the cluster tree. - // Outputs: - // none. - // Return: - // none. - char branchname[30]; - const char *det[3] = {"SPD","SDD","SSD"}; - - AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; - TTree * lTC = pITSLoader->TreeC(); + // Get the clusters tree for this event and set the branch address. + // Inputs: + // Int_t event Event number for the cluster tree. + // Outputs: + // none. + // Return: + // none. + char branchname[30]; + const char *det[3] = {"SPD","SDD","SSD"}; - ResetClusters(); - if (lTC) { - pITSLoader->CleanRawClusters(); - } // end if TreeC() + AliITSLoader *pITSLoader = (AliITSLoader*)fLoader; + TTree * lTC = pITSLoader->TreeC(); + ResetClusters(); + if (lTC) { + pITSLoader->CleanRawClusters(); + } // end if TreeC() - TBranch *branch; + TBranch *branch; - if (lTC) { - Int_t i; + if (lTC) { + Int_t i; char digclass[40]; char clclass[40]; for (i=0; iGetClassNames(digclass,clclass); - // clusters - if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes); - if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i); - if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]); - else sprintf(branchname,"%sClusters%d",GetName(),i+1); - if (fCtype) { + AliITSDetType *iDetType=DetType(i); + iDetType->GetClassNames(digclass,clclass); + // clusters + if (fCtype == 0x0) fCtype = new TObjArray(fNDetTypes); + if(!fCtype->At(i)) fCtype->AddAt(new TClonesArray(clclass,1000),i); + if(kNTYPES==3) sprintf(branchname,"%sClusters%s",GetName(),det[i]); + else sprintf(branchname,"%sClusters%d",GetName(),i+1); + if (fCtype) { branch = lTC->GetBranch(branchname); - if (branch) branch->SetAddress(&((*fCtype)[i])); - } // end if fCtype + if (branch) branch->SetAddress(&((*fCtype)[i])); + } // end if fCtype } // end for i - } else { + } else { Error("GetTreeC","cannot find Clusters Tree for event:%d",event); - } // end if lTC + } // end if lTC } //______________________________________________________________________ void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){ @@ -1562,17 +1418,6 @@ void AliITS::AddCluster(Int_t id, AliITSRawCluster *c){ } // end switch id } //______________________________________________________________________ -void AliITS::ResetClusters(){ - // Reset number of clusters and the clusters array for ITS. - // Inputs: - // none. - // Outputs: - // none. - - Int_t i; - for (i=0;iTreeR()) { - if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); + if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint", + 1000); MakeBranchInTree(fLoader->TreeR(),branchname,&fRecPoints,buffsz,file); } // end if } @@ -1626,19 +1471,18 @@ void AliITS::SetTreeAddressR(TTree *treeR){ char branchname[30]; if(!treeR) return; - if (fRecPoints == 0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); + if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000); TBranch *branch; sprintf(branchname,"%sRecPoints",GetName()); branch = treeR->GetBranch(branchname); if (branch) { - branch->SetAddress(&fRecPoints); - } - else { - sprintf(branchname,"%sRecPointsF",GetName()); - branch = treeR->GetBranch(branchname); - if (branch) { branch->SetAddress(&fRecPoints); - } + }else { + sprintf(branchname,"%sRecPointsF",GetName()); + branch = treeR->GetBranch(branchname); + if (branch) { + branch->SetAddress(&fRecPoints); + } } } //______________________________________________________________________ @@ -1657,7 +1501,8 @@ void AliITS::AddRecPoint(const AliITSRecPoint &r){ } //______________________________________________________________________ void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size, - Option_t *opt0,Option_t *opt1, const char *flnm){ + Option_t *opt0,Option_t *opt1, + const char *flnm){ // keep galice.root for signal and name differently the file for // background when add! otherwise the track info for signal will be lost ! // the condition below will disappear when the geom class will be @@ -1695,48 +1540,33 @@ void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size, //m.b. : this change is nothing but a nice way to make sure //the CPU goes up ! - cout<<"HitsToFastRecPoints: N mod = "<GetIndexMax()<GetModuleTypeName(module)); - exit(1); - } // end if !sim + if (!sim) { + Error("HitsToFastPoints","The simulation class was not " + "instanciated for module %d type %x!",module, + geom->GetModuleTypeName(module)); + exit(1); + } // end if !sim mod = (AliITSmodule *)fITSmodules->At(module); sim->CreateFastRecPoints(mod,module,gRandom); cout<TreeR()->Fill(); - TTree *lTR = pITSloader->TreeR(); + TTree *lTR = pITSloader->TreeR(); TBranch *br=lTR->GetBranch("ITSRecPointsF"); br->Fill(); ResetRecPoints(); } // end for module ClearModules(); - fLoader->WriteRecPoints("OVERWRITE"); } //______________________________________________________________________ -void AliITS::Digits2Reco(){ - // Find clusters and reconstruct space points. - // Inputs: - // none. - // Outputs: - // none. - - AliHeader *header=fLoader->GetRunLoader()->GetHeader(); - // to Digits to RecPoints for event in file, all digits in file, and - // all ITS detectors. - DigitsToRecPoints(header->GetEvent(),0,fOpt); -} -//______________________________________________________________________ void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){ // cluster finding and reconstruction of space points // the condition below will disappear when the geom class will be @@ -1777,49 +1607,40 @@ void AliITS::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t *opt){ rec = (AliITSClusterFinder*)iDetType->GetReconstructionModel(); TClonesArray *itsDigits = this->DigitsAddress(id); if (!rec) { - Error("DigitsToRecPoints", - "The reconstruction class was not instanciated! event=%d", - evNumber); - exit(1); + Error("DigitsToRecPoints", + "The reconstruction class was not instanciated! event=%d", + evNumber); + exit(1); } // end if !rec this->ResetDigits(); TTree *lTD = pITSloader->TreeD(); if (all) { - lTD->GetEvent(lastentry+module); + lTD->GetEvent(lastentry+module); }else { - lTD->GetEvent(lastentry+(module-first)); + lTD->GetEvent(lastentry+(module-first)); } Int_t ndigits = itsDigits->GetEntriesFast(); - if (ndigits) rec->FindRawClusters(module); + if(ndigits>0){ + rec->SetDigits(DigitsAddress(id)); + rec->SetClusters(ClustersAddress(id)); + rec->FindRawClusters(module); + } // end if pITSloader->TreeR()->Fill(); ResetRecPoints(); treeC->Fill(); ResetClusters(); } // end for module - pITSloader->WriteRecPoints("OVERWRITE"); pITSloader->WriteRawClusters("OVERWRITE"); } //______________________________________________________________________ -void AliITS::ResetRecPoints(){ - // Reset number of rec points and the rec points array. - // Inputs: - // none. - // Outputs: - // none. - - if (fRecPoints) fRecPoints->Clear(); - fNRecPoints = 0; +AliLoader* AliITS::MakeLoader(const char* topfoldername){ + //builds ITSgetter (AliLoader type) + //if detector wants to use castomized getter, it must overload this method + + Info("MakeLoader","Creating AliITSLoader. Top folder is %s.", + topfoldername); + fLoader = new AliITSLoader(GetName(),topfoldername); + return fLoader; } -//______________________________________________________________________ -AliLoader* AliITS::MakeLoader(const char* topfoldername) -{ - //builds ITSgetter (AliLoader type) - //if detector wants to use castomized getter, it must overload this method - - Info("MakeLoader","Creating AliITSLoader. Top folder is %s.",topfoldername); - fLoader = new AliITSLoader(GetName(),topfoldername); - return fLoader; -} - diff --git a/ITS/AliITS.h b/ITS/AliITS.h index acf9f37cc76..29aec99036f 100644 --- a/ITS/AliITS.h +++ b/ITS/AliITS.h @@ -34,6 +34,8 @@ class AliITSRecPoint; class AliITSRawCluster; class AliITSmodule; class AliVertexer; +class AliDigitizer; +class AliRunDigitizer; const Int_t kNTYPES=3; @@ -47,7 +49,7 @@ class AliITS : public AliDetector { AliITS(const AliITS &source); // copy constructor. Not to be used! AliITS& operator=(AliITS &source); // = operator. Not to be used! virtual Int_t IsVersion() const {return 1;} - virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) const; + virtual Int_t DistancetoPrimitive(Int_t,Int_t) const{return 999;}; //===================== Simulation Geometry ======================== // get geometry version - detailed (major) or coarse (minor) @@ -79,7 +81,8 @@ class AliITS : public AliDetector { // For a given branch from the treeH sets the TClonesArray address. virtual void SetHitsAddressBranch(TBranch *b) {b->SetAddress(&fHits);} // Return pointer to DetType #id - AliITSDetType *DetType(Int_t id); + AliITSDetType *DetType(Int_t id){ + return ((AliITSDetType*) fDetTypes->At(id));}; //Int_t NDetTypes() {return fNDetTypes;} //---------- Configuration Methods (per detector type) ------------- // Determines which ITS subdetectors will be processed. Effects @@ -88,18 +91,23 @@ class AliITS : public AliDetector { // Returns the list of ITS subdetectors that will be processed. Option_t* GetDetectors(){return fOpt;} // Set response - virtual void SetResponseModel(Int_t id, AliITSresponse *response); + virtual void SetResponseModel(Int_t id, AliITSresponse *response){ + ((AliITSDetType*) fDetTypes->At(id))->ResponseModel(response);}; // Set segmentation - virtual void SetSegmentationModel(Int_t id, AliITSsegmentation *seg); + virtual void SetSegmentationModel(Int_t id, AliITSsegmentation *seg){ + ((AliITSDetType*) fDetTypes->At(id))->SegmentationModel(seg);}; // Set simulation - temporary - virtual void SetSimulationModel(Int_t id, AliITSsimulation *sim); + virtual void SetSimulationModel(Int_t id, AliITSsimulation *sim){ + ((AliITSDetType*) fDetTypes->At(id))->SimulationModel(sim);}; // Set simulation - temporary virtual AliITSsimulation* GetSimulationModel(Int_t id){ return ((AliITSDetType*)(fDetTypes->At(id)))->GetSimulationModel();} // Set reconstruction - virtual void SetReconstructionModel(Int_t id, AliITSClusterFinder *rec); + virtual void SetReconstructionModel(Int_t id, AliITSClusterFinder *rec){ + ((AliITSDetType*) fDetTypes->At(id))->ReconstructionModel(rec);}; // Set class names for digit and rec point - virtual void SetClasses(Int_t id, const char *digit, const char *cluster); + virtual void SetClasses(Int_t id, const char *digit, const char *cluster){ + ((AliITSDetType*) fDetTypes->At(id))->ClassNames(digit,cluster);}; //=================== Hits ========================================= virtual void StepManager() {} // See Step Manager for specific geometry. @@ -109,7 +117,7 @@ class AliITS : public AliDetector { virtual void FillModules(TTree *treeH, Int_t mask = 0); virtual void FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules, Option_t *opt, const char *filename); - virtual void ClearModules(); + virtual void ClearModules(){if(fITSmodules) fITSmodules->Delete();}; //===================== Digitisation =============================== void MakeBranchS(const char *file); @@ -120,7 +128,10 @@ class AliITS : public AliDetector { MakeBranchInTreeD(GetLoader()->TreeD(),file);} void SetTreeAddressD(TTree *treeD); void Hits2SDigits(); // Turn hits into SDigits - void Hits2PreDigits(); // Turn hits into SDigits + void Hits2PreDigits(){ // Turn hits into SDigits + HitsToPreDigits(fLoader->GetEvent(), + /*fLoader->GetRunLoader()->GetHeader()->GetEvent(),*/ + 0,-1," ",fOpt," ");}; AliDigitizer* CreateDigitizer(AliRunDigitizer* manager) const; void SDigits2Digits(){SDigitsToDigits("All");} // Turn SDigits to Digits void SDigitsToDigits(Option_t *opt="All"); // Turn SDigits to Digits @@ -128,14 +139,16 @@ class AliITS : public AliDetector { //------------------ Internal functions ---------------------------- // Standard Hits To SDigits function void HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size, - Option_t *add, Option_t *det, const char *filename); + Option_t *add, Option_t *det, const char *filename) + {HitsToPreDigits(evNumber,bgrev,size,add,det,filename);}; // Standard Hits To SDigits function void HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *add, Option_t *det, const char *filename); // Standard Hits To Digits function void HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size, Option_t *add, Option_t *det, const char *filename); - void ResetSDigits(); // Resets the Summable digits. + // Resets the Summable digits. + void ResetSDigits(){if(fSDigits) fSDigits->Clear();fNSDigits = 0;}; void ResetDigits(); // depending on how the void ResetDigits(Int_t branch); // tree will be filled only void AddSumDigit(AliITSpListItem &sdig); @@ -159,7 +172,8 @@ class AliITS : public AliDetector { void MakeTreeC(Option_t *option="C"); void GetTreeC(Int_t event); void AddCluster(Int_t branch, AliITSRawCluster *c); - void ResetClusters(); // one of the methods in + // one of the methods in + void ResetClusters(){for(Int_t i=0;iGetEvent(),0,fOpt);}; void DigitsToRecPoints(Int_t evNumber,Int_t lastEntry,Option_t *det); - void ResetRecPoints(); + void ResetRecPoints(){if(fRecPoints) fRecPoints->Clear();fNRecPoints = 0;}; // Return pointer to rec points TClonesArray *RecPoints() {return fRecPoints;} diff --git a/ITS/AliITSClusterFinder.cxx b/ITS/AliITSClusterFinder.cxx index 6c1bd7ffec0..308596d43ac 100644 --- a/ITS/AliITSClusterFinder.cxx +++ b/ITS/AliITSClusterFinder.cxx @@ -23,50 +23,110 @@ #include "AliITSdigitSPD.h" #include "AliITSdigitSDD.h" #include "AliITSdigitSSD.h" +#include "AliITSMap.h" #include "AliRun.h" #include "AliITS.h" ClassImp(AliITSClusterFinder) //---------------------------------------------------------------------- -AliITSClusterFinder::AliITSClusterFinder(){ +AliITSClusterFinder::AliITSClusterFinder(): +TObject(), +fDebug(0), +fModule(0), +fDigits(0), +fNdigits(0), +fResponse(0), +fSegmentation(0), +fClusters(0), +fNRawClusters(0), +fMap(0), +fNperMax(0), +fDeclusterFlag(0), +fClusterSize(0), +fNPeaks(-1){ // default cluster finder - - fSegmentation = 0; - fResponse = 0; - fMap = 0; - fDigits = 0; - fNdigits = 0; - fNRawClusters = 0; - fNperMax = 0; - fDeclusterFlag= 0; - fClusterSize = 0; - fNPeaks = 0; + // Input: + // none. + // Output: + // none. + // Return: + // A default constructed AliITSCulsterFinder } //---------------------------------------------------------------------- AliITSClusterFinder::AliITSClusterFinder(AliITSsegmentation *seg, - AliITSresponse *response, - TClonesArray *digits){ - // cluster finder - fSegmentation=seg; - fResponse=response; - fMap = 0; - - fDigits=digits; - fNdigits = fDigits->GetEntriesFast(); - - fNRawClusters=0; + AliITSresponse *res): +TObject(), +fDebug(0), +fModule(0), +fDigits(0), +fNdigits(0), +fResponse(res), +fSegmentation(seg), +fClusters(0), +fNRawClusters(0), +fMap(0), +fNperMax(0), +fDeclusterFlag(0), +fClusterSize(0), +fNPeaks(-1){ + // Standard constructor for cluster finder + // Input: + // AliITSsegmentation *seg The segmentation class to be used + // AliITSresponse *res The response class to be used + // Output: + // none. + // Return: + // A Standard constructed AliITSCulsterFinder SetNperMax(); SetClusterSize(); SetDeclusterFlag(); +} +//---------------------------------------------------------------------- +AliITSClusterFinder::AliITSClusterFinder(AliITSsegmentation *seg, + AliITSresponse *response, + TClonesArray *digits): +TObject(), +fDebug(0), +fModule(0), +fDigits(digits), +fNdigits(0), +fResponse(response), +fSegmentation(seg), +fClusters(0), +fNRawClusters(0), +fMap(0), +fNperMax(0), +fDeclusterFlag(0), +fClusterSize(0), +fNPeaks(-1){ + // Standard + cluster finder constructor + // Input: + // AliITSsegmentation *seg The segmentation class to be used + // AliITSresponse *res The response class to be used + // TClonesArray *digits Array of digits to be used + // Output: + // none. + // Return: + // A Standard constructed AliITSCulsterFinder - fNPeaks=-1; + fNdigits = fDigits->GetEntriesFast(); + SetNperMax(); + SetClusterSize(); + SetDeclusterFlag(); } //---------------------------------------------------------------------- AliITSClusterFinder::~AliITSClusterFinder(){ // destructor cluster finder + // Input: + // none. + // Output: + // none. + // Return: + // none. + if(fMap) {delete fMap;} // Zero local pointers. Other classes own these pointers. fSegmentation = 0; fResponse = 0; @@ -82,23 +142,30 @@ AliITSClusterFinder::~AliITSClusterFinder(){ //__________________________________________________________________________ AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source) : TObject(source){ - // Copy Constructor + // Copy Constructor + // Input: + // AliITSClusterFinder &source The class which will become a copy of + // this class + // Output: + // none. + // Return: + // A copy of this class + if(&source == this) return; - this->fDigits = source.fDigits; - this->fNdigits = source.fNdigits; - this->fResponse = source.fResponse; - this->fSegmentation = source.fSegmentation; - this->fNRawClusters = source.fNRawClusters; - this->fMap = source.fMap; - this->fNperMax = source.fNperMax; - this->fDeclusterFlag = source.fDeclusterFlag; - this->fClusterSize = source.fClusterSize; - this->fNPeaks = source.fNPeaks; + *this = source; return; } //______________________________________________________________________ -AliITSClusterFinder& AliITSClusterFinder::operator=(const AliITSClusterFinder &source) { +AliITSClusterFinder& AliITSClusterFinder::operator=(const AliITSClusterFinder + &source) { // Assignment operator + // Input: + // AliITSClusterFinder &source The class which will become a copy of + // this class + // Output: + // none. + // Return: + // A copy of this class if(&source == this) return *this; this->fDigits = source.fDigits; @@ -116,6 +183,13 @@ AliITSClusterFinder& AliITSClusterFinder::operator=(const AliITSClusterFinder &s //---------------------------------------------------------------------- void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c){ // Add a raw cluster copy to the list + // Input: + // Int_t branch The branch to which the cluster is to be added to + // AliITSRawCluster *c The cluster to be added to the array of clusters + // Output: + // none. + // Return: + // none. AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); iTS->AddCluster(branch,c); @@ -124,7 +198,15 @@ void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c){ //---------------------------------------------------------------------- void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c, AliITSRecPoint &rp){ - // Add a raw cluster copy to the list + // Add a raw cluster copy to the list and the RecPoint + // Input: + // Int_t branch The branch to which the cluster is to be added to + // AliITSRawCluster *c The cluster to be added to the array of clusters + // AliITSRecPoint &rp The RecPoint to be added to the array of RecPoints + // Output: + // none. + // Return: + // none. AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); iTS->AddCluster(branch,c); @@ -150,7 +232,7 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ Int_t i=0,nc=0,j[4],k,k2=0; // Copy all digits for this module into a local TObjArray. - for(i=0;iAddAt(new AliITSdigit(*((AliITSdigit*)(fDigits->At(i)))),i); + for(i=0;iAddAt(new AliITSdigit(*(GetDigit(i))),i); digs->Sort(); // First digit is a cluster. i = 0; @@ -160,51 +242,53 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ clust0->AddAtFree(digs->At(i)); // move owner ship from digs to clusts nc++; for(i=1;iAt(j[0])); - // Add to existing cluster. Find which cluster this digis - for(k=0;kAt(k))); - if(clust0->IndexOf(dig)>=0) break; - } // end for k - if(k>=nc){ - Fatal("FindRawClusters","Digit not found as expected"); - } // end if - if(j[1]>=0){ - dig = (AliITSdigit*)(digs->At(j[1])); - // Add to existing cluster. Find which cluster this digis - for(k2=0;k2At(k2))); - if(clust1->IndexOf(dig)>=0) break; - } // end for k2 - if(k2>=nc){ - Fatal("FindRawClusters","Digit not found as expected"); - } // end if - } // end if j[1]>=0 - // Found cluster with neighboring digits add this one to it. - if(clust0==clust1){ // same cluster - clust0->AddAtFree(digs->At(i)); - clust0 = 0; // finished with cluster. zero for safty - clust1 = 0; // finished wit hcluster. zero for safty - }else{ // two different clusters which need to be merged. - clust0->AddAtFree(digs->At(i)); // Add digit to this cluster. - for(k=0;kGetEntriesFast();k++){ - // move clust1 into clust0 - clust0->AddAtFree(clust1->At(k));//move digit to this cluster - clust1->AddAt(0,k); // zero this one - } // end for k - delete clust1; - clusts->AddAt(0,k2); // zero array of clusters element clust1 - clust0 = 0; // finished with cluster. zero for safty - clust1 = 0; // finished wit hcluster. zero for safty - } // end if clust0==clust1 - }else{// New cluster - clusts->AddAt(new TObjArray(kelms),nc); - clust0 = ((TObjArray*)(clusts->At(nc))); - clust0->AddAtFree(digs->At(i));// move owner ship from digs to clusts - clust0 = 0; // finished with cluster. zero for safty - nc++; - } // End if IsNeighbor + if(IsNeighbor(digs,i,j)){ + dig = (AliITSdigit*)(digs->At(j[0])); + // Add to existing cluster. Find which cluster this digis + for(k=0;kAt(k))); + if(clust0->IndexOf(dig)>=0) break; + } // end for k + if(k>=nc){ + Fatal("FindRawClusters","Digit not found as expected"); + } // end if + if(j[1]>=0){ + dig = (AliITSdigit*)(digs->At(j[1])); + // Add to existing cluster. Find which cluster this digis + for(k2=0;k2At(k2))); + if(clust1->IndexOf(dig)>=0) break; + } // end for k2 + if(k2>=nc){ + Fatal("FindRawClusters","Digit not found as expected"); + } // end if + } // end if j[1]>=0 + // Found cluster with neighboring digits add this one to it. + if(clust0==clust1){ // same cluster + clust0->AddAtFree(digs->At(i)); + clust0 = 0; // finished with cluster. zero for safty + clust1 = 0; // finished wit hcluster. zero for safty + }else{ // two different clusters which need to be merged. + clust0->AddAtFree(digs->At(i)); // Add digit to this cluster. + for(k=0;kGetEntriesFast();k++){ + // move clust1 into clust0 + //move digit to this cluster + clust0->AddAtFree(clust1->At(k)); + clust1->AddAt(0,k); // zero this one + } // end for k + delete clust1; + clusts->AddAt(0,k2); // zero array of clusters element clust1 + clust0 = 0; // finished with cluster. zero for safty + clust1 = 0; // finished wit hcluster. zero for safty + } // end if clust0==clust1 + }else{// New cluster + clusts->AddAt(new TObjArray(kelms),nc); + clust0 = ((TObjArray*)(clusts->At(nc))); + // move owner ship from digs to clusts + clust0->AddAtFree(digs->At(i)); + clust0 = 0; // finished with cluster. zero for safty + nc++; + } // End if IsNeighbor } // end for i // There are now nc clusters in clusts. Each element of clust is an // array of digits which are clustered together. @@ -214,11 +298,11 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ // clean up at the end. for(i=0;iAt(i)); - // Digits deleted below, so zero this TObjArray - for(k=0;kGetEntriesFast();k++) clust0->AddAt(0,k); - delete clust0; // Delete this TObjArray - clusts->AddAt(0,i); // Contents deleted above, so zero it. + clust0 =(TObjArray*)(clusts->At(i)); + // Digits deleted below, so zero this TObjArray + for(k=0;kGetEntriesFast();k++) clust0->AddAt(0,k); + delete clust0; // Delete this TObjArray + clusts->AddAt(0,i); // Contents deleted above, so zero it. } // end for i delete clusts; // Delete this TObjArray/ // Delete the digits then the TObjArray which containted them. @@ -226,7 +310,7 @@ void AliITSClusterFinder::FindRawClusters(Int_t module){ delete digs; } //______________________________________________________________________ -Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[]) const{ +Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[])const{ // Locagical function which checks to see if digit i has a neighbor. // If so, then it returns kTRUE and its neighbor index j. // This routine checks if the digits are side by side or one before the @@ -256,15 +340,82 @@ Bool_t AliITSClusterFinder::IsNeighbor(TObjArray *digs,Int_t i,Int_t n[]) const{ ix = ((AliITSdigit*)(digs->At(i)))->GetCoord1(); iz = ((AliITSdigit*)(digs->At(i)))->GetCoord2(); for(j=0;jAt(j)))->GetCoord1(); - jz = ((AliITSdigit*)(digs->At(j)))->GetCoord2(); - if(jx+1==ix && jz ==iz){n[0] = j;nei[0] = kTRUE;} - if(jx ==ix && jz+1==iz){n[1] = j;nei[1] = kTRUE;} - if(jx+1==ix && jz+1==iz){n[2] = j;nei[2] = kTRUE;} - if(jx+1==ix && jz-1==iz){n[3] = j;nei[3] = kTRUE;} + jx = ((AliITSdigit*)(digs->At(j)))->GetCoord1(); + jz = ((AliITSdigit*)(digs->At(j)))->GetCoord2(); + if(jx+1==ix && jz ==iz){n[0] = j;nei[0] = kTRUE;} + if(jx ==ix && jz+1==iz){n[1] = j;nei[1] = kTRUE;} + if(jx+1==ix && jz+1==iz){n[2] = j;nei[2] = kTRUE;} + if(jx+1==ix && jz-1==iz){n[3] = j;nei[3] = kTRUE;} } // end for k if(nei[0]||nei[1]) return kTRUE; if(kdiagonal&&(nei[2]||nei[3])) return kTRUE; // no Neighbors found. return kFALSE; } + +//______________________________________________________________________ +void AliITSClusterFinder::Print(ostream *os){ + //Standard output format for this class + // Inputs: + // ostream *os Output stream + // Output: + // ostream *os Output stream + // Return: + // none. + + *os << fDebug<<","; + *os << fModule<<","; + *os << fNdigits<<","; + *os << fNRawClusters<<","; + *os << fNperMax<<","; + *os << fDeclusterFlag<<","; + *os << fClusterSize<<","; + *os << fNPeaks<> fDebug; + *is >> fModule; + *is >> fNdigits; + *is >> fNRawClusters; + *is >> fNperMax; + *is >> fDeclusterFlag; + *is >> fClusterSize; + *is >> fNPeaks; +} +//______________________________________________________________________ +ostream &operator<<(ostream &os,AliITSClusterFinder &source){ + // Standard output streaming function. + // Inputs: + // ostream *os Output stream + // AliITSClusterFinder &source Class to be printed + // Output: + // ostream *os Output stream + // Return: + // none. + + source.Print(&os); + return os; +} +//______________________________________________________________________ +istream &operator>>(istream &is,AliITSClusterFinder &source){ + // Standard output streaming function. + // Inputs: + // istream *is Input stream + // AliITSClusterFinder &source Class to be read in. + // Output: + // istream *is Input stream + // Return: + // none. + + source.Read(&is); + return is; +} diff --git a/ITS/AliITSClusterFinder.h b/ITS/AliITSClusterFinder.h index 6c9cfa91b92..1331ef87091 100644 --- a/ITS/AliITSClusterFinder.h +++ b/ITS/AliITSClusterFinder.h @@ -10,6 +10,7 @@ // ITS Cluster Finder Class // //////////////////////////////////////////////// +#include #include #include @@ -23,91 +24,111 @@ class AliITSRecPoint; //---------------------------------------------------------------------- class AliITSClusterFinder :public TObject{ - public: + public: AliITSClusterFinder(); // Default constructor + // Standard Constructor + AliITSClusterFinder(AliITSsegmentation *seg, AliITSresponse *resp); AliITSClusterFinder(AliITSsegmentation *seg, AliITSresponse *resp, - TClonesArray *digits);// Standard Constructor + TClonesArray *digits);// Standard+ Constructor virtual ~AliITSClusterFinder(); // Destructor AliITSClusterFinder(const AliITSClusterFinder &source); // copy constructor // assignment operator AliITSClusterFinder& operator=(const AliITSClusterFinder &source); - virtual void SetResponse(AliITSresponse *response) {// set response - fResponse=response;} - virtual void SetSegmentation(AliITSsegmentation *segmentation) { - // set segmentation - fSegmentation=segmentation;} - virtual void SetDigits(TClonesArray *ITSdigits) {// set digits - fDigits=ITSdigits;fNdigits = fDigits->GetEntriesFast();} - virtual AliITSdigit* GetDigit(Int_t i){ // Returns ith digit - return (AliITSdigit*) fDigits->UncheckedAt(i);} - virtual TClonesArray* Digits(){ // Gets fDigits - return fDigits;} - virtual Int_t NDigits() const {// Get Number of Digits - return fNdigits;} - // Standard Getters. - virtual AliITSresponse * GetResp(){// Returns fResponse - return fResponse;} - virtual AliITSsegmentation * GetSeg(){// Returns fSegmentation - return fSegmentation;} - virtual Int_t GetNRawClusters() const { // returns fNRawClusters - return fNRawClusters;} - AliITSMap *Map() {// map - return fMap;} - virtual Int_t GetNperMax() const { // returns fNperMax - return fNperMax;} - virtual Int_t GetDeclusterFlag() const { // returns fDeclusterFlag - return fDeclusterFlag;} - virtual Int_t GetClusterSize() const { // returns fClusterSize - return fClusterSize;} - virtual Int_t GetNPeaks() const { // returns fNPeaks - return fNPeaks;} // - virtual void AddCluster(Int_t branch, AliITSRawCluster *c); - virtual void AddCluster(Int_t branch, AliITSRawCluster *c, - AliITSRecPoint &rp); + // Do the Reconstruction. virtual void FindRawClusters(Int_t mod=0); // Finds cluster of digits. + // + // Sets the debug flag for debugging output + void SetDebug(Int_t level=1){fDebug=level;} + // Clears the debug flag so no debugging output will be generated + void SetNoDebug(){fDebug=0;} + // Returns the debug flag value + Bool_t GetDebug(Int_t level=1)const {return fDebug<=level;} + // + // Setters and Getters + // segmentation + virtual void SetSegmentation(AliITSsegmentation *segmentation) { + fSegmentation=segmentation;} + //Returns fSegmentation + virtual AliITSsegmentation* GetSegmentation()const{return fSegmentation;} + // Digit + virtual void SetDigits(TClonesArray *itsDigits) {// set digits + fDigits=itsDigits;fNdigits = fDigits->GetEntriesFast();} + virtual AliITSdigit* GetDigit(Int_t i){ // Returns ith digit + return (AliITSdigit*) fDigits->UncheckedAt(i);} + virtual TClonesArray* Digits(){return fDigits;}// Gets fDigits + virtual Int_t NDigits() const {return fNdigits;}// Get Number of Digits + // Response + //Return Response + virtual AliITSresponse* GetResponse()const{return fResponse;} + virtual void SetResponse(AliITSresponse *response) {// set response + fResponse=response;} + // clulsters + // Set fClusters up + virtual void SetClusters(TClonesArray *itsClusters){// set clusters + fClusters = itsClusters;fNRawClusters = fClusters->GetEntriesFast();} + // Get fCluters + virtual TClonesArray* Clusters(){return fClusters;} + // Get fCluter + virtual AliITSRawCluster* Cluster(Int_t i){ + return (AliITSRawCluster*)(fClusters->At(i));} + // Returns the present number of enteries + virtual Int_t NClusters()const {return fClusters->GetEntriesFast();} + // returns fNRawClusters + virtual Int_t GetNRawClusters() const {return fNRawClusters;} // Determins if digit i has a neighbor and if so that neighor index is j. - virtual Bool_t IsNeighbor(TObjArray *digs,Int_t i,Int_t j[]) const; + virtual void AddCluster(Int_t branch,AliITSRawCluster *c); + virtual void AddCluster(Int_t branch,AliITSRawCluster *c, + AliITSRecPoint &rp); + virtual void FillCluster(AliITSRawCluster *,Int_t) {}// fiil cluster + virtual void FillCluster(AliITSRawCluster *cluster) {// fill cluster + FillCluster(cluster,1);} + virtual void FindCluster(Int_t,Int_t,AliITSRawCluster *) {}// find cluster + // + virtual void SetModule(Int_t module){fModule = module;}// Set module number + virtual Int_t GetModule()const{return fModule;}// Returns module number + // + // RecPoints // Given a cluster of digits, creates the nessesary RecPoint. May also // do some peak separation. virtual void CreateRecPoints(TObjArray *,Int_t){}; - virtual void FindCluster(Int_t,Int_t,AliITSRawCluster *) {}// find cluster + // Others + virtual void SetMap(AliITSMap *m) {fMap=m;}// map + AliITSMap* Map(){return fMap;}// map + virtual Int_t GetNperMax() const {return fNperMax;}// returns fNperMax + // returns fDeclusterFlag + virtual Int_t GetDeclusterFlag()const{return fDeclusterFlag;} + // returns fClusterSize + virtual Int_t GetClusterSize() const {return fClusterSize;} + virtual Int_t GetNPeaks() const {return fNPeaks;}// returns fNPeaks + // + virtual Bool_t IsNeighbor(TObjArray *digs,Int_t i,Int_t j[]) const; virtual void Decluster(AliITSRawCluster *) {}// Decluster - virtual void SetNperMax(Int_t npermax=3) { - // Set max. Number of cells per local cluster - fNperMax = npermax; - } - virtual void SetDeclusterFlag(Int_t flag=1) { - // Decluster ? - fDeclusterFlag =flag; - } - virtual void SetClusterSize(Int_t clsize=3) { - // Set max. cluster size ; bigger clusters will be rejected - fClusterSize = clsize; - } - virtual void CalibrateCOG() { - // Self Calibration of COG - } - virtual void CorrectCOG(){ - // correct COG - } - virtual Bool_t Centered(AliITSRawCluster *) const {// cluster - return kTRUE; - } - virtual void SplitByLocalMaxima(AliITSRawCluster *){}//split by local maxima - virtual void FillCluster(AliITSRawCluster *,Int_t) {}// fiil cluster - virtual void FillCluster(AliITSRawCluster *cluster) {// fill cluster - FillCluster(cluster,1); - } - // set the fitting methods in the derived classes - // data members + // Set max. Number of cells per local cluster + virtual void SetNperMax(Int_t npermax=3) {fNperMax = npermax;} + //Decluster + virtual void SetDeclusterFlag(Int_t flag=1){fDeclusterFlag=flag;} + // Set max. cluster size ; bigger clusters will be rejected + virtual void SetClusterSize(Int_t clsize=3) {fClusterSize = clsize;} + virtual void CalibrateCOG() {}// Self Calibration of COG + virtual void CorrectCOG(){}// correct COG + virtual Bool_t Centered(AliITSRawCluster *) const {return kTRUE;}// cluster + //split by local maxima + virtual void SplitByLocalMaxima(AliITSRawCluster *){} + // IO functions + void Print(ostream *os); // Class ascii print function + void Read(istream *os); // Class ascii read function -protected: + // data members + protected: + Int_t fDebug; //! Debug flag/level + Int_t fModule; //! Module number to be reconstuctted TClonesArray *fDigits; //! digits Int_t fNdigits; //! num of digits AliITSresponse *fResponse; //! response - AliITSsegmentation *fSegmentation; //!segmentation + AliITSsegmentation *fSegmentation; //! segmentation + TClonesArray *fClusters; //! Array of clusters Int_t fNRawClusters; //! in case we split the cluster // and want to keep track of // the cluster which was splitted @@ -116,7 +137,10 @@ protected: Int_t fDeclusterFlag; //! DeclusterFlag Int_t fClusterSize; //! ClusterSize Int_t fNPeaks; //! NPeaks - - ClassDef(AliITSClusterFinder,2) //Class for clustering and reconstruction of space points + + ClassDef(AliITSClusterFinder,3) //Class for clustering and reconstruction of space points }; +// Input and output functions for standard C++ input/output. +ostream &operator<<(ostream &os,AliITSClusterFinder &source); +istream &operator>>(istream &os,AliITSClusterFinder &source); #endif diff --git a/ITS/AliITSClusterFinderSDD.cxx b/ITS/AliITSClusterFinderSDD.cxx index 14efeefb568..0bdb2776a05 100644 --- a/ITS/AliITSClusterFinderSDD.cxx +++ b/ITS/AliITSClusterFinderSDD.cxx @@ -15,6 +15,9 @@ /* $Id$ $Log$ + Revision 1.36 2004/01/27 16:12:03 masera + Coding conventions for AliITSdigitXXX classes and AliITSTrackerV1 + Revision 1.35 2003/11/10 16:33:50 masera Changes to obey our coding conventions @@ -73,76 +76,64 @@ #include "AliITSdigitSDD.h" #include "AliITSRawClusterSDD.h" #include "AliITSRecPoint.h" -#include "AliITSsegmentation.h" +#include "AliITSsegmentationSDD.h" #include "AliITSresponseSDD.h" #include "AliRun.h" ClassImp(AliITSClusterFinderSDD) +//______________________________________________________________________ +AliITSClusterFinderSDD::AliITSClusterFinderSDD(): +AliITSClusterFinder(), +fNclusters(0), +fDAnode(0.0), +fDTime(0.0), +fTimeCorr(0.0), +fCutAmplitude(0), +fMinPeak(0), +fMinCharge(0), +fMinNCells(0), +fMaxNCells(0){ + // default constructor +} //______________________________________________________________________ AliITSClusterFinderSDD::AliITSClusterFinderSDD(AliITSsegmentation *seg, AliITSresponse *response, TClonesArray *digits, - TClonesArray *recp){ + TClonesArray *recp): +AliITSClusterFinder(seg,response), +fNclusters(0), +fDAnode(0.0), +fDTime(0.0), +fTimeCorr(0.0), +fCutAmplitude(0), +fMinPeak(0), +fMinCharge(0), +fMinNCells(0), +fMaxNCells(0){ // standard constructor - fSegmentation = seg; - fResponse = response; - fDigits = digits; - fClusters = recp; - fNclusters = fClusters->GetEntriesFast(); + SetDigits(digits); + SetClusters(recp); SetCutAmplitude(); SetDAnode(); SetDTime(); - SetMinPeak((Int_t)(((AliITSresponseSDD*)fResponse)->GetNoiseAfterElectronics()*5)); + SetMinPeak((Int_t)(((AliITSresponseSDD*)GetResp())-> + GetNoiseAfterElectronics()*5)); // SetMinPeak(); SetMinNCells(); SetMaxNCells(); SetTimeCorr(); SetMinCharge(); - fMap = new AliITSMapA1(fSegmentation,fDigits,fCutAmplitude); -} -//______________________________________________________________________ -AliITSClusterFinderSDD::AliITSClusterFinderSDD(){ - // default constructor - - fSegmentation = 0; - fResponse = 0; - fDigits = 0; - fClusters = 0; - fNclusters = 0; - fMap = 0; - fCutAmplitude = 0; - fDAnode = 0; - fDTime = 0; - fMinPeak = 0; - fMinNCells = 0; - fMaxNCells = 0; - fTimeCorr = 0; - fMinCharge = 0; - /* - SetDAnode(); - SetDTime(); - SetMinPeak((Int_t)(((AliITSresponseSDD*)fResponse)->GetNoiseAfterElectronics()*5)); - SetMinNCells(); - SetMaxNCells(); - SetTimeCorr(); - SetMinCharge(); - */ -} -//____________________________________________________________________________ -AliITSClusterFinderSDD::~AliITSClusterFinderSDD(){ - // destructor - - if(fMap) delete fMap; + SetMap(new AliITSMapA1(GetSeg(),Digits(),fCutAmplitude)); } //______________________________________________________________________ -void AliITSClusterFinderSDD::SetCutAmplitude(Float_t nsigma){ +void AliITSClusterFinderSDD::SetCutAmplitude(Double_t nsigma){ // set the signal threshold for cluster finder - Float_t baseline,noise,noiseAfterEl; + Double_t baseline,noise,noiseAfterEl; - fResponse->GetNoiseParam(noise,baseline); - noiseAfterEl = ((AliITSresponseSDD*)fResponse)->GetNoiseAfterElectronics(); + GetResp()->GetNoiseParam(noise,baseline); + noiseAfterEl = ((AliITSresponseSDD*)GetResp())->GetNoiseAfterElectronics(); fCutAmplitude = (Int_t)((baseline + nsigma*noiseAfterEl)); } //______________________________________________________________________ @@ -151,31 +142,31 @@ void AliITSClusterFinderSDD::Find1DClusters(){ static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS"); // retrieve the parameters - Int_t fNofMaps = fSegmentation->Npz(); - Int_t fMaxNofSamples = fSegmentation->Npx(); + Int_t fNofMaps = GetSeg()->Npz(); + Int_t fMaxNofSamples = GetSeg()->Npx(); Int_t fNofAnodes = fNofMaps/2; Int_t dummy = 0; - Float_t fTimeStep = fSegmentation->Dpx(dummy); - Float_t fSddLength = fSegmentation->Dx(); - Float_t fDriftSpeed = fResponse->DriftSpeed(); - Float_t anodePitch = fSegmentation->Dpz(dummy); + Double_t fTimeStep = GetSeg()->Dpx(dummy); + Double_t fSddLength = GetSeg()->Dx(); + Double_t fDriftSpeed = GetResp()->DriftSpeed(); + Double_t anodePitch = GetSeg()->Dpz(dummy); // map the signal - fMap->ClearMap(); - fMap->SetThreshold(fCutAmplitude); - fMap->FillMap(); + Map()->ClearMap(); + Map()->SetThreshold(fCutAmplitude); + Map()->FillMap(); - Float_t noise; - Float_t baseline; - fResponse->GetNoiseParam(noise,baseline); + Double_t noise; + Double_t baseline; + GetResp()->GetNoiseParam(noise,baseline); Int_t nofFoundClusters = 0; Int_t i; - Float_t **dfadc = new Float_t*[fNofAnodes]; - for(i=0;iGetSignal(idx,l); - if(l>0) fadc1=(Float_t)fMap->GetSignal(idx,l-1); + fadc2=(Double_t)Map()->GetSignal(idx,l); + if(l>0) fadc1=(Double_t)Map()->GetSignal(idx,l-1); if(l>0) dfadc[k][l-1] = fadc2-fadc1; } // samples } // anodes for(k=0;k=fMaxNofSamples) break; - fadc=(float)fMap->GetSignal(idx,id); + fadc=(float)Map()->GetSignal(idx,id); if(fadc > fadcmax) { fadcmax = fadc; imax = id;} - if(fadc > (float)fCutAmplitude) { - lthrt++; - } // end if + if(fadc > (float)fCutAmplitude)lthrt++; if(dfadc[k][id] > dfadcmax) { dfadcmax = dfadc[k][id]; imaxd = id; } // end if } // end for m it = imaxd; - if(fMap->TestHit(idx,imax) == kEmpty) {it++; continue;} + if(Map()->TestHit(idx,imax) == kEmpty) {it++; continue;} // cluster charge Int_t tstart = it-2; if(tstart < 0) tstart = 0; @@ -228,11 +217,11 @@ void AliITSClusterFinderSDD::Find1DClusters(){ if(ilcl) { nofFoundClusters++; Int_t tstop = tstart; - Float_t dfadcmin = 10000.; + Double_t dfadcmin = 10000.; Int_t ij; for(ij=0; ij<20; ij++) { if(tstart+ij > 255) { tstop = 255; break; } - fadc=(float)fMap->GetSignal(idx,tstart+ij); + fadc=(float)Map()->GetSignal(idx,tstart+ij); if((dfadc[k][tstart+ij] < dfadcmin) && (fadc > fCutAmplitude)) { tstop = tstart+ij+5; @@ -241,16 +230,16 @@ void AliITSClusterFinderSDD::Find1DClusters(){ } // end if } // end for ij - Float_t clusterCharge = 0.; - Float_t clusterAnode = k+0.5; - Float_t clusterTime = 0.; + Double_t clusterCharge = 0.; + Double_t clusterAnode = k+0.5; + Double_t clusterTime = 0.; Int_t clusterMult = 0; - Float_t clusterPeakAmplitude = 0.; + Double_t clusterPeakAmplitude = 0.; Int_t its,peakpos = -1; - Float_t n, baseline; - fResponse->GetNoiseParam(n,baseline); + Double_t n, baseline; + GetResp()->GetNoiseParam(n,baseline); for(its=tstart; its<=tstop; its++) { - fadc=(float)fMap->GetSignal(idx,its); + fadc=(float)Map()->GetSignal(idx,its); if(fadc>baseline) fadc -= baseline; else fadc = 0.; clusterCharge += fadc; @@ -259,12 +248,12 @@ void AliITSClusterFinderSDD::Find1DClusters(){ // to get the list of tracks !!! if(fadc > clusterPeakAmplitude) { clusterPeakAmplitude = fadc; - //peakpos=fMap->GetHitIndex(idx,its); + //peakpos=Map()->GetHitIndex(idx,its); Int_t shift = (int)(fTimeCorr/fTimeStep); if(its>shift && its<(fMaxNofSamples-shift)) - peakpos = fMap->GetHitIndex(idx,its+shift); - else peakpos = fMap->GetHitIndex(idx,its); - if(peakpos<0) peakpos =fMap->GetHitIndex(idx,its); + peakpos = Map()->GetHitIndex(idx,its+shift); + else peakpos = Map()->GetHitIndex(idx,its); + if(peakpos<0) peakpos =Map()->GetHitIndex(idx,its); } // end if clusterTime += fadc*its; if(fadc > 0) clusterMult++; @@ -275,9 +264,9 @@ void AliITSClusterFinderSDD::Find1DClusters(){ } // end if } // end for its - Float_t clusteranodePath = (clusterAnode - fNofAnodes/2)* - anodePitch; - Float_t clusterDriftPath = clusterTime*fDriftSpeed; + Double_t clusteranodePath = (clusterAnode - fNofAnodes/2)* + anodePitch; + Double_t clusterDriftPath = clusterTime*fDriftSpeed; clusterDriftPath = fSddLength-clusterDriftPath; if(clusterCharge <= 0.) break; AliITSRawClusterSDD clust(j+1,//i @@ -302,28 +291,25 @@ void AliITSClusterFinderSDD::Find1DClusters(){ return; } - - - //______________________________________________________________________ void AliITSClusterFinderSDD::Find1DClustersE(){ // find 1D clusters static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); // retrieve the parameters - Int_t fNofMaps = fSegmentation->Npz(); - Int_t fMaxNofSamples = fSegmentation->Npx(); + Int_t fNofMaps = GetSeg()->Npz(); + Int_t fMaxNofSamples = GetSeg()->Npx(); Int_t fNofAnodes = fNofMaps/2; Int_t dummy=0; - Float_t fTimeStep = fSegmentation->Dpx( dummy ); - Float_t fSddLength = fSegmentation->Dx(); - Float_t fDriftSpeed = fResponse->DriftSpeed(); - Float_t anodePitch = fSegmentation->Dpz( dummy ); - Float_t n, baseline; - fResponse->GetNoiseParam( n, baseline ); + Double_t fTimeStep = GetSeg()->Dpx( dummy ); + Double_t fSddLength = GetSeg()->Dx(); + Double_t fDriftSpeed = GetResp()->DriftSpeed(); + Double_t anodePitch = GetSeg()->Dpz( dummy ); + Double_t n, baseline; + GetResp()->GetNoiseParam( n, baseline ); // map the signal - fMap->ClearMap(); - fMap->SetThreshold( fCutAmplitude ); - fMap->FillMap(); + Map()->ClearMap(); + Map()->SetThreshold( fCutAmplitude ); + Map()->FillMap(); Int_t nClu = 0; // cout << "Search cluster... "<< endl; @@ -333,18 +319,18 @@ void AliITSClusterFinderSDD::Find1DClustersE(){ Bool_t on = kFALSE; Int_t start = 0; Int_t nTsteps = 0; - Float_t fmax = 0.; + Double_t fmax = 0.; Int_t lmax = 0; - Float_t charge = 0.; - Float_t time = 0.; - Float_t anode = k+0.5; + Double_t charge = 0.; + Double_t time = 0.; + Double_t anode = k+0.5; Int_t peakpos = -1; for( Int_t l=0; lGetSignal( idx, l ); + Double_t fadc = (Double_t)Map()->GetSignal( idx, l ); if( fadc > 0.0 ){ if( on == kFALSE && lGetSignal( idx, l+1 ); + Double_t fadc1 = (Double_t)Map()->GetSignal( idx, l+1 ); if( fadc1 < fadc ) continue; start = l; fmax = 0.; @@ -364,10 +350,10 @@ void AliITSClusterFinderSDD::Find1DClustersE(){ lmax = l; Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5); if( l > shift && l < (fMaxNofSamples-shift) ) - peakpos = fMap->GetHitIndex( idx, l+shift ); + peakpos = Map()->GetHitIndex( idx, l+shift ); else - peakpos = fMap->GetHitIndex( idx, l ); - if( peakpos < 0) peakpos = fMap->GetHitIndex( idx, l ); + peakpos = Map()->GetHitIndex( idx, l ); + if( peakpos < 0) peakpos = Map()->GetHitIndex(idx,l); } // end if fadc }else{ // end fadc>0 if( on == kTRUE ){ @@ -378,8 +364,8 @@ void AliITSClusterFinderSDD::Find1DClustersE(){ time /= (charge/fTimeStep); // ns // time = lmax*fTimeStep; // ns if( time > fTimeCorr ) time -= fTimeCorr; // ns - Float_t anodePath = (anode - fNofAnodes/2)*anodePitch; - Float_t driftPath = time*fDriftSpeed; + Double_t anodePath =(anode-fNofAnodes/2)*anodePitch; + Double_t driftPath = time*fDriftSpeed; driftPath = fSddLength-driftPath; AliITSRawClusterSDD clust(j+1,anode,time,charge, fmax, peakpos,0.,0., @@ -387,7 +373,7 @@ void AliITSClusterFinderSDD::Find1DClustersE(){ nTsteps,start,stop, start, stop, 1, k, k ); iTS->AddCluster( 1, &clust ); - // clust.PrintInfo(); + if(GetDebug(5)) clust.PrintInfo(); nClu++; } // end if nTsteps on = kFALSE; @@ -396,22 +382,22 @@ void AliITSClusterFinderSDD::Find1DClustersE(){ } // samples } // anodes } // wings - // cout << "# Rawclusters " << nClu << endl; + if(GetDebug(3)) cout << "# Rawclusters " << nClu << endl; return; } //_______________________________________________________________________ -Int_t AliITSClusterFinderSDD::SearchPeak(Float_t *spect,Int_t xdim,Int_t zdim, +Int_t AliITSClusterFinderSDD::SearchPeak(Double_t *spect,Int_t xdim,Int_t zdim, Int_t *peakX, Int_t *peakZ, - Float_t *peakAmp, Float_t minpeak ){ + Double_t *peakAmp, Double_t minpeak ){ // search peaks on a 2D cluster Int_t npeak = 0; // # peaks Int_t i,j; // search peaks for( Int_t z=1; z= spect[(x+1)*zdim+z ] && sxz >= spect[(x-1)*zdim+z ] && @@ -469,8 +455,8 @@ Int_t AliITSClusterFinderSDD::SearchPeak(Float_t *spect,Int_t xdim,Int_t zdim, return( npeak ); } //______________________________________________________________________ -void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Float_t *par, - Float_t *spe, Float_t *integral){ +void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Double_t *par, + Double_t *spe, Double_t *integral){ // function used to fit the clusters // par -> parameters.. // par[0] number of peaks. @@ -480,23 +466,23 @@ void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Float_t *par, // par[i+2] = zpos // par[i+3] = tau // par[i+4] = sigma. - Int_t electronics = fResponse->Electronics(); // 1 = PASCAL, 2 = OLA + Int_t electronics = GetResp()->Electronics(); // 1 = PASCAL, 2 = OLA const Int_t knParam = 5; Int_t npeak = (Int_t)par[0]; - memset( spe, 0, sizeof( Float_t )*zdim*xdim ); + memset( spe, 0, sizeof( Double_t )*zdim*xdim ); Int_t k = 1; for( Int_t i=0; i0.) ? par[k]*x2*exp(-x2+1.-z2) :0.0; // RCCR2 @@ -505,7 +491,8 @@ void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Float_t *par, x2 = (x-par[k+1])*(x-par[k+1])/t2; signal = par[k] * exp( -x2 - z2 ); } else { - Warning("PeakFunc","Wrong SDD Electronics = %d",electronics); + Warning("PeakFunc","Wrong SDD Electronics = %d", + electronics); // exit( 1 ); } // end if electronicx spe[x*zdim+z] += signal; @@ -517,27 +504,27 @@ void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Float_t *par, return; } //__________________________________________________________________________ -Float_t AliITSClusterFinderSDD::ChiSqr( Int_t xdim, Int_t zdim, Float_t *spe, - Float_t *speFit ) const{ +Double_t AliITSClusterFinderSDD::ChiSqr( Int_t xdim, Int_t zdim, Double_t *spe, + Double_t *speFit ) const{ // EVALUATES UNNORMALIZED CHI-SQUARED - Float_t chi2 = 0.; + Double_t chi2 = 0.; for( Int_t z=0; z 1.0E-6 ) if ( fabs( delta/p1 ) < 1.0E-4 ) delta = p1/1000; - else delta = (Float_t)1.0E-4; + else delta = (Double_t)1.0E-4; // EVALUATE CHI-SQUARED AT FIRST TWO SEARCH POINTS PeakFunc( xdim, zdim, param, speFit ); chisq1 = ChiSqr( xdim, zdim, spe, speFit ); @@ -593,7 +580,7 @@ void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Float_t *param, if( param[k] < .5 ) param[k] = .5; break; case 4 : - if( param[k] < .288 ) param[k] = .288; // 1/sqrt(12) = 0.288 + if( param[k] < .288 ) param[k] = .288;// 1/sqrt(12) = 0.288 if( param[k] > zdim*.5 ) param[k] = zdim*.5; break; }; // end switch @@ -609,12 +596,12 @@ void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Float_t *param, // FIND MINIMUM OF PARABOLA DEFINED BY LAST THREE POINTS a = chisq1*(p2-p3)+chisq2*(p3-p1)+chisq3*(p1-p2); b = chisq1*(p2*p2-p3*p3)+chisq2*(p3*p3-p1*p1)+chisq3*(p1*p1-p2*p2); - if( a!=0 ) p0 = (Float_t)(0.5*b/a); + if( a!=0 ) p0 = (Double_t)(0.5*b/a); else p0 = 10000; //--IN CASE OF NEARLY EQUAL CHI-SQUARED AND TOO SMALL STEP SIZE PREVENT // ERRONEOUS EVALUATION OF PARABOLA MINIMUM //---NEXT TWO LINES CAN BE OMITTED FOR HIGHER PRECISION MACHINES - //dp = (Float_t) max (fabs(p3-p2), fabs(p2-p1)); + //dp = (Double_t) max (fabs(p3-p2), fabs(p2-p1)); //if( fabs( p2-p0 ) > dp ) p0 = p2; param[k] = p0; // Constrain paramiters @@ -653,27 +640,27 @@ void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Float_t *param, } //_________________________________________________________________________ Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim, - Float_t *param, Float_t *spe, - Int_t *niter, Float_t *chir ){ + Double_t *param, Double_t *spe, + Int_t *niter, Double_t *chir ){ // fit method from Comput. Phys. Commun 46(1987) 149 - const Float_t kchilmt = 0.01; // relative accuracy + const Double_t kchilmt = 0.01; // relative accuracy const Int_t knel = 3; // for parabolic minimization const Int_t knstop = 50; // Max. iteration number const Int_t knParam = 5; Int_t npeak = (Int_t)param[0]; // RETURN IF NUMBER OF DEGREES OF FREEDOM IS NOT POSITIVE if( (xdim*zdim - npeak*knParam) <= 0 ) return( -1 ); - Float_t degFree = (xdim*zdim - npeak*knParam)-1; + Double_t degFree = (xdim*zdim - npeak*knParam)-1; Int_t n, k, iterNum = 0; - Float_t *prm0 = new Float_t[npeak*knParam+1]; - Float_t *step = new Float_t[npeak*knParam+1]; - Float_t *schi = new Float_t[npeak*knParam+1]; - Float_t *sprm[3]; - sprm[0] = new Float_t[npeak*knParam+1]; - sprm[1] = new Float_t[npeak*knParam+1]; - sprm[2] = new Float_t[npeak*knParam+1]; - Float_t chi0, chi1, reldif, a, b, prmin, dp; - Float_t *speFit = new Float_t[ xdim*zdim ]; + Double_t *prm0 = new Double_t[npeak*knParam+1]; + Double_t *step = new Double_t[npeak*knParam+1]; + Double_t *schi = new Double_t[npeak*knParam+1]; + Double_t *sprm[3]; + sprm[0] = new Double_t[npeak*knParam+1]; + sprm[1] = new Double_t[npeak*knParam+1]; + sprm[2] = new Double_t[npeak*knParam+1]; + Double_t chi0, chi1, reldif, a, b, prmin, dp; + Double_t *speFit = new Double_t[ xdim*zdim ]; PeakFunc( xdim, zdim, param, speFit ); chi0 = ChiSqr( xdim, zdim, spe, speFit ); chi1 = chi0; @@ -690,7 +677,7 @@ Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim, iterNum++; chi0 = chi1; Minim( xdim, zdim, param, prm0, step, &chi1, spe, speFit ); - reldif = ( chi1 > 0 ) ? ((Float_t) fabs( chi1-chi0)/chi1 ) : 0; + reldif = ( chi1 > 0 ) ? ((Double_t) fabs( chi1-chi0)/chi1 ) : 0; // EXIT conditions if( reldif < (float) kchilmt ){ *chir = (chi1>0) ? (float) TMath::Sqrt (chi1/degFree) :0; @@ -719,9 +706,9 @@ Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim, // -EVALUATE EXTRAPOLATED VALUE OF EACH PARAMETER BY FINDING MINIMUM OF // PARABOLA DEFINED BY LAST THREE CALLS OF MINIM for( k=1; k<(npeak*knParam+1); k++ ){ - Float_t tmp0 = sprm[0][k]; - Float_t tmp1 = sprm[1][k]; - Float_t tmp2 = sprm[2][k]; + Double_t tmp0 = sprm[0][k]; + Double_t tmp1 = sprm[1][k]; + Double_t tmp2 = sprm[2][k]; a = schi[0]*(tmp1-tmp2) + schi[1]*(tmp2-tmp0); a += (schi[2]*(tmp0-tmp1)); b = schi[0]*(tmp1*tmp1-tmp2*tmp2); @@ -751,23 +738,23 @@ void AliITSClusterFinderSDD::ResolveClustersE(){ Int_t i; static AliITS *iTS = (AliITS*)gAlice->GetModule( "ITS" ); // get number of clusters for this module - Int_t nofClusters = fClusters->GetEntriesFast(); + Int_t nofClusters = NClusters(); nofClusters -= fNclusters; - Int_t fNofMaps = fSegmentation->Npz(); + Int_t fNofMaps = GetSeg()->Npz(); Int_t fNofAnodes = fNofMaps/2; -// Int_t fMaxNofSamples = fSegmentation->Npx(); + //Int_t fMaxNofSamples = GetSeg()->Npx(); Int_t dummy=0; - Double_t fTimeStep = fSegmentation->Dpx( dummy ); - Double_t fSddLength = fSegmentation->Dx(); - Double_t fDriftSpeed = fResponse->DriftSpeed(); - Double_t anodePitch = fSegmentation->Dpz( dummy ); - Float_t n, baseline; - fResponse->GetNoiseParam( n, baseline ); - Int_t electronics = fResponse->Electronics(); // 1 = PASCAL, 2 = OLA + Double_t fTimeStep = GetSeg()->Dpx( dummy ); + Double_t fSddLength = GetSeg()->Dx(); + Double_t fDriftSpeed = GetResp()->DriftSpeed(); + Double_t anodePitch = GetSeg()->Dpz( dummy ); + Double_t n, baseline; + GetResp()->GetNoiseParam( n, baseline ); + Int_t electronics = GetResp()->Electronics(); // 1 = PASCAL, 2 = OLA for( Int_t j=0; jAt(j); + AliITSRawClusterSDD *clusterJ=(AliITSRawClusterSDD*) Cluster(j); Int_t astart = clusterJ->Astart(); Int_t astop = clusterJ->Astop(); Int_t tstart = clusterJ->Tstartf(); @@ -783,13 +770,13 @@ void AliITSClusterFinderSDD::ResolveClustersE(){ Warning("ResolveClustersE","xdim: %d , zdim: %d ",xdim,zdim); continue; } - Float_t *sp = new Float_t[ xdim*zdim+1 ]; - memset( sp, 0, sizeof(Float_t)*(xdim*zdim+1) ); + Double_t *sp = new Double_t[ xdim*zdim+1 ]; + memset( sp, 0, sizeof(Double_t)*(xdim*zdim+1) ); // make a local map from cluster region for( Int_t ianode=astart; ianode<=astop; ianode++ ){ for( Int_t itime=tstart; itime<=tstop; itime++ ){ - Float_t fadc = fMap->GetSignal( ianode, itime ); + Double_t fadc = Map()->GetSignal( ianode, itime ); if( fadc > baseline ) fadc -= (Double_t)baseline; else fadc = 0.; Int_t index = (itime-tstart+1)*zdim+(ianode-astart+1); @@ -801,38 +788,35 @@ void AliITSClusterFinderSDD::ResolveClustersE(){ const Int_t kNp = 150; Int_t peakX1[kNp]; Int_t peakZ1[kNp]; - Float_t peakAmp1[kNp]; + Double_t peakAmp1[kNp]; Int_t npeak = SearchPeak(sp,xdim,zdim,peakX1,peakZ1,peakAmp1,fMinPeak); // if multiple peaks, split cluster - if( npeak >= 1 ) - { + if( npeak >= 1 ){ // cout << "npeak " << npeak << endl; // clusterJ->PrintInfo(); - Float_t *par = new Float_t[npeak*5+1]; - par[0] = (Float_t)npeak; + Double_t *par = new Double_t[npeak*5+1]; + par[0] = (Double_t)npeak; // Initial parameters in cell dimentions Int_t k1 = 1; for( i=0; i charge for each peak PeakFunc( xdim, zdim, par, sp, integral ); k1 = 1; @@ -854,14 +838,14 @@ void AliITSClusterFinderSDD::ResolveClustersE(){ // Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5); // if( newiTime > shift && newiTime < (fMaxNofSamples-shift) ) // shift = 0; - // Int_t peakpos = fMap->GetHitIndex( newAnode, newiTime+shift ); + // Int_t peakpos = Map()->GetHitIndex(newAnode,newiTime+shift ); // clusterI.SetPeakPos( peakpos ); clusterI.SetPeakAmpl( peakAmp1[i] ); - Float_t newAnodef = peakZ[i] - 0.5 + astart; - Float_t newiTimef = peakX[i] - 1 + tstart; + Double_t newAnodef = peakZ[i] - 0.5 + astart; + Double_t newiTimef = peakX[i] - 1 + tstart; if( wing == 2 ) newAnodef -= fNofAnodes; - Float_t anodePath = (newAnodef - fNofAnodes/2)*anodePitch; + Double_t anodePath = (newAnodef - fNofAnodes/2)*anodePitch; newiTimef *= fTimeStep; if( newiTimef > fTimeCorr ) newiTimef -= fTimeCorr; if( electronics == 1 ){ @@ -871,24 +855,25 @@ void AliITSClusterFinderSDD::ResolveClustersE(){ newiTimef *= 0.99714; // OLA Int_t timeBin = (Int_t)(newiTimef/fTimeStep+0.5); - Int_t peakpos = fMap->GetHitIndex( newAnode, timeBin ); + Int_t peakpos = Map()->GetHitIndex( newAnode, timeBin ); if( peakpos < 0 ) { for( Int_t ii=0; ii<3; ii++ ) { - peakpos = fMap->GetHitIndex( newAnode, timeBin+ii ); + peakpos = Map()->GetHitIndex( newAnode, timeBin+ii ); if( peakpos > 0 ) break; - peakpos = fMap->GetHitIndex( newAnode, timeBin-ii ); + peakpos = Map()->GetHitIndex( newAnode, timeBin-ii ); if( peakpos > 0 ) break; } } if( peakpos < 0 ) { - // Warning( "ResolveClustersE", "Digit not found for cluster:\n" ); - // clusterI.PrintInfo(); + //Warning("ResolveClustersE", + // "Digit not found for cluster"); + //if(GetDebug(3)) clusterI.PrintInfo(); continue; } clusterI.SetPeakPos( peakpos ); - Float_t driftPath = fSddLength - newiTimef * fDriftSpeed; - Float_t sign = ( wing == 1 ) ? -1. : 1.; + Double_t driftPath = fSddLength - newiTimef * fDriftSpeed; + Double_t sign = ( wing == 1 ) ? -1. : 1.; clusterI.SetX( driftPath*sign * 0.0001 ); clusterI.SetZ( anodePath * 0.0001 ); clusterI.SetAnode( newAnodef ); @@ -899,28 +884,28 @@ void AliITSClusterFinderSDD::ResolveClustersE(){ iTS->AddCluster( 1, &clusterI ); } // end for i - fClusters->RemoveAt( j ); + Clusters()->RemoveAt( j ); delete [] par; } else { // something odd - Warning( "ResolveClustersE","--- Peak not found!!!! minpeak=%d ,cluster peak= %f , module= %d", - fMinPeak, clusterJ->PeakAmpl(), fModule ); + Warning( "ResolveClustersE", + "--- Peak not found!!!! minpeak=%d ,cluster peak= %f" + " , module= %d", + fMinPeak, clusterJ->PeakAmpl(),GetModule()); clusterJ->PrintInfo(); Warning( "ResolveClustersE"," xdim= %d zdim= %d", xdim-2, zdim-2 ); } delete [] sp; } // cluster loop - fClusters->Compress(); -// fMap->ClearMap(); + Clusters()->Compress(); +// Map()->ClearMap(); } - - //________________________________________________________________________ void AliITSClusterFinderSDD::GroupClusters(){ // group clusters Int_t dummy=0; - Float_t fTimeStep = fSegmentation->Dpx(dummy); + Double_t fTimeStep = GetSeg()->Dpx(dummy); // get number of clusters for this module - Int_t nofClusters = fClusters->GetEntriesFast(); + Int_t nofClusters = NClusters(); nofClusters -= fNclusters; AliITSRawClusterSDD *clusterI; AliITSRawClusterSDD *clusterJ; @@ -931,23 +916,25 @@ void AliITSClusterFinderSDD::GroupClusters(){ if(label[i] != 0) continue; for(j=i+1; jAt(i); - clusterJ = (AliITSRawClusterSDD*) fClusters->At(j); + clusterI = (AliITSRawClusterSDD*) Cluster(i); + clusterJ = (AliITSRawClusterSDD*) Cluster(j); // 1.3 good if(clusterI->T() < fTimeStep*60) fDAnode = 4.2; // TB 3.2 if(clusterI->T() < fTimeStep*10) fDAnode = 1.5; // TB 1. Bool_t pair = clusterI->Brother(clusterJ,fDAnode,fDTime); if(!pair) continue; - // clusterI->PrintInfo(); - // clusterJ->PrintInfo(); + if(GetDebug(4)){ + clusterI->PrintInfo(); + clusterJ->PrintInfo(); + } // end if GetDebug clusterI->Add(clusterJ); label[j] = 1; - fClusters->RemoveAt(j); + Clusters()->RemoveAt(j); j=i; // <- Ernesto } // J clusters label[i] = 1; } // I clusters - fClusters->Compress(); + Clusters()->Compress(); delete [] label; return; @@ -955,16 +942,16 @@ void AliITSClusterFinderSDD::GroupClusters(){ //________________________________________________________________________ void AliITSClusterFinderSDD::SelectClusters(){ // get number of clusters for this module - Int_t nofClusters = fClusters->GetEntriesFast(); + Int_t nofClusters = NClusters(); nofClusters -= fNclusters; Int_t i; for(i=0; iAt(i); + AliITSRawClusterSDD *clusterI =(AliITSRawClusterSDD*) Cluster(i); Int_t rmflg = 0; - Float_t wy = 0.; + Double_t wy = 0.; if(clusterI->Anodes() != 0.) { - wy = ((Float_t) clusterI->Samples())/clusterI->Anodes(); + wy = ((Double_t) clusterI->Samples())/clusterI->Anodes(); } // end if Int_t amp = (Int_t) clusterI->PeakAmpl(); Int_t cha = (Int_t) clusterI->Q(); @@ -972,9 +959,9 @@ void AliITSClusterFinderSDD::SelectClusters(){ if(cha < fMinCharge) rmflg = 1; if(wy < fMinNCells) rmflg = 1; //if(wy > fMaxNCells) rmflg = 1; - if(rmflg) fClusters->RemoveAt(i); + if(rmflg) Clusters()->RemoveAt(i); } // I clusters - fClusters->Compress(); + Clusters()->Compress(); return; } //__________________________________________________________________________ @@ -982,28 +969,28 @@ void AliITSClusterFinderSDD::ResolveClusters(){ // The function to resolve clusters if the clusters overlapping exists /* AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); // get number of clusters for this module - Int_t nofClusters = fClusters->GetEntriesFast(); + Int_t nofClusters = NClusters(); nofClusters -= fNclusters; //cout<<"Resolve Cl: nofClusters, fNclusters ="<Npz(); + Int_t fNofMaps = GetSeg()->Npz(); Int_t fNofAnodes = fNofMaps/2; Int_t dummy=0; - Double_t fTimeStep = fSegmentation->Dpx(dummy); - Double_t fSddLength = fSegmentation->Dx(); - Double_t fDriftSpeed = fResponse->DriftSpeed(); - Double_t anodePitch = fSegmentation->Dpz(dummy); - Float_t n, baseline; - fResponse->GetNoiseParam(n,baseline); - Float_t dzz_1A = anodePitch * anodePitch / 12; + Double_t fTimeStep = GetSeg()->Dpx(dummy); + Double_t fSddLength = GetSeg()->Dx(); + Double_t fDriftSpeed = GetResp()->DriftSpeed(); + Double_t anodePitch = GetSeg()->Dpz(dummy); + Double_t n, baseline; + GetResp()->GetNoiseParam(n,baseline); + Double_t dzz_1A = anodePitch * anodePitch / 12; // fill Map of signals - fMap->FillMap(); + Map()->FillMap(); Int_t j,i,ii,ianode,anode,itime; Int_t wing,astart,astop,tstart,tstop,nanode; Double_t fadc,ClusterTime; Double_t q[400],x[400],z[400]; // digit charges and coordinates for(j=0; jAt(j); + AliITSRawClusterSDD *clusterJ=(AliITSRawClusterSDD*) Cluster(j); Int_t ndigits = 0; astart=clusterJ->Astart(); astop=clusterJ->Astop(); @@ -1026,7 +1013,7 @@ void AliITSClusterFinderSDD::ResolveClusters(){ for(ianode=astart; ianode<=astop; ianode++) { for(itime=tstart; itime<=tstop; itime++) { - fadc=fMap->GetSignal(ianode,itime); + fadc=Map()->GetSignal(ianode,itime); if(fadc>baseline) { fadc-=(Double_t)baseline; q[ndigits] = fadc*(fTimeStep/160); // KeV @@ -1231,23 +1218,23 @@ void AliITSClusterFinderSDD::ResolveClusters(){ cout << " in: " << endl; for (i=0; iPeakAmpl(); - Float_t peakpos = clusterJ->PeakPos(); - Float_t clusteranodePath = (Anode - fNofAnodes/2)*anodePitch; - Float_t clusterDriftPath = Time*fDriftSpeed; + Double_t Anode = (zfit[i]/anodePitch+fNofAnodes/2-0.5); + Double_t Time = (fSddLength - xfit[i])/fDriftSpeed; + Double_t clusterPeakAmplitude = clusterJ->PeakAmpl(); + Double_t peakpos = clusterJ->PeakPos(); + Double_t clusteranodePath = (Anode - fNofAnodes/2)*anodePitch; + Double_t clusterDriftPath = Time*fDriftSpeed; clusterDriftPath = fSddLength-clusterDriftPath; AliITSRawClusterSDD *clust = new AliITSRawClusterSDD(wing,Anode, Time,qfit[i], @@ -1257,16 +1244,16 @@ void AliITSClusterFinderSDD::ResolveClusters(){ ,tstart,tstop,0,0,0,astart,astop); clust->PrintInfo(); iTS->AddCluster(1,clust); - // cout<<"new cluster added: tstart,tstop,astart,astop,x,ncl =" + // cout<<"new cluster added: tstart,tstop,astart,astop,x,ncl =" // <RemoveAt(j); + Clusters()->RemoveAt(j); } // if nfhits = 2 } // cluster loop -fClusters->Compress(); -fMap->ClearMap(); +Clusters()->Compress(); +Map()->ClearMap(); */ return; } @@ -1275,30 +1262,30 @@ void AliITSClusterFinderSDD::GetRecPoints(){ // get rec points static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); // get number of clusters for this module - Int_t nofClusters = fClusters->GetEntriesFast(); + Int_t nofClusters = NClusters(); nofClusters -= fNclusters; - const Float_t kconvGeV = 1.e-6; // GeV -> KeV - const Float_t kconv = 1.0e-4; - const Float_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3 - const Float_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3 + const Double_t kconvGeV = 1.e-6; // GeV -> KeV + const Double_t kconv = 1.0e-4; + const Double_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3 + const Double_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3 Int_t i; Int_t ix, iz, idx=-1; AliITSdigitSDD *dig=0; - Int_t ndigits=fDigits->GetEntriesFast(); + Int_t ndigits=NDigits(); for(i=0; iAt(i); + AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*)Cluster(i); if(!clusterI) Error("SDD: GetRecPoints","i clusterI ",i,clusterI); if(clusterI) idx=clusterI->PeakPos(); if(idx>ndigits) Error("SDD: GetRecPoints","idx ndigits",idx,ndigits); // try peak neighbours - to be done - if(idx&&idx<= ndigits) dig =(AliITSdigitSDD*)fDigits->UncheckedAt(idx); + if(idx&&idx<= ndigits) dig =(AliITSdigitSDD*)GetDigit(idx); if(!dig) { // try cog - fSegmentation->GetPadIxz(clusterI->X(),clusterI->Z(),ix,iz); - dig = (AliITSdigitSDD*)fMap->GetHit(iz-1,ix-1); + GetSeg()->GetPadIxz(clusterI->X(),clusterI->Z(),ix,iz); + dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix-1); // if null try neighbours - if (!dig) dig = (AliITSdigitSDD*)fMap->GetHit(iz-1,ix); - if (!dig) dig = (AliITSdigitSDD*)fMap->GetHit(iz-1,ix+1); + if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix); + if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix+1); if (!dig) printf("SDD: cannot assign the track number!\n"); } // end if !dig AliITSRecPoint rnew; @@ -1315,14 +1302,13 @@ void AliITSClusterFinderSDD::GetRecPoints(){ iTS->AddRecPoint(rnew); } // I clusters -// fMap->ClearMap(); +// Map()->ClearMap(); } //______________________________________________________________________ void AliITSClusterFinderSDD::FindRawClusters(Int_t mod){ // find raw clusters - fModule = mod; - + SetModule(mod); Find1DClustersE(); GroupClusters(); SelectClusters(); diff --git a/ITS/AliITSClusterFinderSDD.h b/ITS/AliITSClusterFinderSDD.h index 038784d1ba9..655e09f4d39 100644 --- a/ITS/AliITSClusterFinderSDD.h +++ b/ITS/AliITSClusterFinderSDD.h @@ -11,47 +11,51 @@ #include "AliITSClusterFinder.h" class AliITSMapA2; +class AliITSresponse; +class AliITSresponseSDD; +class AliITSsegmentation; +class AliITSsegmentationSDD; class TFile; class AliITSClusterFinderSDD : public AliITSClusterFinder{ - public: + public: AliITSClusterFinderSDD - (AliITSsegmentation *seg,AliITSresponse *response, - TClonesArray *digits,TClonesArray *recpoints); + (AliITSsegmentation *seg,AliITSresponse *response, + TClonesArray *digits,TClonesArray *recpoints); AliITSClusterFinderSDD(); - virtual ~AliITSClusterFinderSDD(); - - virtual void SetCutAmplitude(Float_t nsigma=4); + virtual ~AliITSClusterFinderSDD(){}; + + virtual void SetCutAmplitude(Double_t nsigma=4); virtual Int_t CutAmplitude() const {// get cut amplitude - return fCutAmplitude;} - virtual void SetDAnode(Float_t danode=4.2) {// setDAnode - fDAnode=danode;} - virtual Float_t DAnode() const {// get DAnode - return fDAnode;} - virtual void SetDTime(Float_t dtime=75) {// SetDTime - fDTime=dtime;} - virtual Float_t DTime() const {// get DTime - return fDTime;} + return fCutAmplitude;} + virtual void SetDAnode(Double_t danode=4.2) {// setDAnode + fDAnode=danode;} + virtual Double_t DAnode() const {// get DAnode + return fDAnode;} + virtual void SetDTime(Double_t dtime=75) {// SetDTime + fDTime=dtime;} + virtual Double_t DTime() const {// get DTime + return fDTime;} virtual void SetMinPeak(Int_t minpeak=10) {// SetMinPeak - fMinPeak=minpeak;} + fMinPeak=minpeak;} virtual Int_t MinPeak() const {// get MinPeak - return fMinPeak;} + return fMinPeak;} virtual void SetMinCharge(Int_t mincharge=30) {// SetMinCharge - fMinCharge=mincharge;} + fMinCharge=mincharge;} virtual Int_t MinCharge() const {// get MinCharge - return fMinCharge;} + return fMinCharge;} virtual void SetMinNCells(Int_t minc=3) {// setNCells - fMinNCells=minc;} + fMinNCells=minc;} virtual Int_t MinNCells() const {// get MinNCells - return fMinNCells;} + return fMinNCells;} virtual void SetMaxNCells(Int_t maxc=10) {// setNCells - fMaxNCells=maxc;} + fMaxNCells=maxc;} virtual Int_t MaxNCells() const {// get MaxNCells - return fMaxNCells;} - virtual void SetTimeCorr(Float_t timec=19.3) {// setNCells - fTimeCorr=timec;} - virtual Float_t TimeCorr() const{// get Time Correction (ns) - return fTimeCorr;} + return fMaxNCells;} + virtual void SetTimeCorr(Double_t timec=19.3) {// setNCells + fTimeCorr=timec;} + virtual Double_t TimeCorr() const{// get Time Correction (ns) + return fTimeCorr;} // Search for clusters virtual void FindRawClusters(Int_t mod=0); @@ -62,34 +66,37 @@ class AliITSClusterFinderSDD : public AliITSClusterFinder{ void GetRecPoints(); void ResolveClusters(); // Boris........ void ResolveClustersE(); // Ernesto - Int_t SearchPeak(Float_t *spect,Int_t xdim,Int_t zdim,Int_t *peakX, - Int_t *peakZ,Float_t *peakAmp,Float_t minpeak); // Ernesto - Int_t NoLinearFit( Int_t xdim, Int_t zdim, Float_t *param, Float_t *spe, - Int_t *niter, Float_t *chir ); - void Minim( Int_t xdim, Int_t zdim, Float_t *param, Float_t *prm0, - Float_t *steprm, Float_t *chisqr,Float_t *spe,Float_t *speFit); - Float_t ChiSqr ( Int_t xdim, Int_t zdim, Float_t *spe, Float_t *speFit ) const; - void PeakFunc( Int_t xdim, Int_t zdim, Float_t *par, Float_t *spe, - Float_t *Integral=0 ); + Int_t SearchPeak(Double_t *spect,Int_t xdim,Int_t zdim,Int_t *peakX, + Int_t *peakZ,Double_t *peakAmp,Double_t minpeak);//Ernesto + Int_t NoLinearFit( Int_t xdim, Int_t zdim, Double_t *param, Double_t *spe, + Int_t *niter, Double_t *chir ); + void Minim(Int_t xdim,Int_t zdim,Double_t *param,Double_t *prm0, + Double_t *steprm,Double_t *chisqr,Double_t *spe,Double_t *speFit); + Double_t ChiSqr(Int_t xdim,Int_t zdim,Double_t *spe,Double_t *speFit)const; + void PeakFunc( Int_t xdim, Int_t zdim, Double_t *par, Double_t *spe, + Double_t *Integral=0 ); void Print() const; - private: + private: + virtual AliITSresponseSDD* GetResp()const{ + return (AliITSresponseSDD*) GetResponse();}//Return Response + //Returns fSegmentation + virtual AliITSsegmentationSDD* GetSeg()const{ + return (AliITSsegmentationSDD*)GetSegmentation();} AliITSClusterFinderSDD(const AliITSClusterFinderSDD &source); // copy ctor AliITSClusterFinderSDD& operator=(const AliITSClusterFinderSDD &source); - private: - Int_t fModule; //! ITS current module - TClonesArray *fClusters; //! clusters + private: Int_t fNclusters; //! num of clusters - Float_t fDAnode; //! fDanode - Float_t fDTime; //! fDtime - Float_t fTimeCorr; //! Correction factor along time coord + Double_t fDAnode; //! fDanode + Double_t fDTime; //! fDtime + Double_t fTimeCorr; //! Correction factor along time coord Int_t fCutAmplitude; //! cut amplitude Int_t fMinPeak; //! min peak Int_t fMinCharge; //! min charge Int_t fMinNCells; //! min num of cells Int_t fMaxNCells; //! max num of cells - ClassDef(AliITSClusterFinderSDD,1) // SDD clustering - Piergiorgio C. algo + ClassDef(AliITSClusterFinderSDD,2) // SDD clustering - Piergiorgio C. algo }; #endif diff --git a/ITS/AliITSClusterFinderSPD.cxx b/ITS/AliITSClusterFinderSPD.cxx index 28408dc12b5..bb4195ebad5 100644 --- a/ITS/AliITSClusterFinderSPD.cxx +++ b/ITS/AliITSClusterFinderSPD.cxx @@ -22,34 +22,45 @@ #include "AliITSdigitSPD.h" #include "AliITSRawClusterSPD.h" #include "AliITSRecPoint.h" -#include "AliITSsegmentation.h" +#include "AliITSresponseSPD.h" +#include "AliITSsegmentationSPD.h" #include "AliRun.h" //#define DEBUG ClassImp(AliITSClusterFinderSPD) +//______________________________________________________________________ +AliITSClusterFinderSPD::AliITSClusterFinderSPD():AliITSClusterFinder(), +fDz(0.0), +fDx(0.0), +fMinNCells(0){ + // constructor +} //---------------------------------------------------------- AliITSClusterFinderSPD::AliITSClusterFinderSPD(AliITSsegmentation *seg, - TClonesArray *digits, - TClonesArray *recp){ + AliITSresponse *res): +AliITSClusterFinder(seg,res), +fDz(0.0), +fDx(0.0), +fMinNCells(0){ // constructor - fSegmentation = seg; - fDigits = digits; - fClusters = recp; - fNclusters = fClusters->GetEntriesFast(); SetDx(); SetDz(); } -//______________________________________________________________________ -AliITSClusterFinderSPD::AliITSClusterFinderSPD(){ +//---------------------------------------------------------- +AliITSClusterFinderSPD::AliITSClusterFinderSPD(AliITSsegmentation *seg, + TClonesArray *digits, + TClonesArray *recp): +AliITSClusterFinder(seg,0), +fDz(0.0), +fDx(0.0), +fMinNCells(0){ // constructor - fSegmentation = 0; - fDigits = 0; - fClusters = 0; - fNclusters = 0; + SetDigits(digits); + SetClusters(recp); SetDx(); SetDz(); } @@ -59,10 +70,9 @@ AliITSClusterFinderSPD::AliITSClusterFinderSPD( // Copy Constructor if(&source == this) return; - this->fClusters = source.fClusters ; - this->fNclusters = source.fNclusters ; - this->fDz = source.fDz ; - this->fDx = source.fDx ; + this->fDz = source.fDz; + this->fDx = source.fDx; + this->fMinNCells = source.fMinNCells; return; } //______________________________________________________________________ @@ -71,10 +81,9 @@ AliITSClusterFinderSPD& AliITSClusterFinderSPD::operator=( // Assignment operator if(&source == this) return *this; - this->fClusters = source.fClusters ; - this->fNclusters = source.fNclusters ; - this->fDz = source.fDz ; - this->fDx = source.fDx ; + this->fDz = source.fDz; + this->fDx = source.fDx; + this->fMinNCells = source.fMinNCells; return *this; } //______________________________________________________________________ @@ -90,55 +99,63 @@ void AliITSClusterFinderSPD::FindRawClusters(Int_t module){ Int_t *digtr4 = new Int_t[numberd]; // output of Cluster Finder Int_t numberc = 10000; - Float_t *xcenterl = new Float_t[numberc]; - Float_t *zcenterl = new Float_t[numberc]; - Float_t *errxcenter = new Float_t[numberc]; - Float_t *errzcenter = new Float_t[numberc]; + Double_t *xcenterl = new Double_t[numberc]; + Double_t *zcenterl = new Double_t[numberc]; + Double_t *errxcenter = new Double_t[numberc]; + Double_t *errzcenter = new Double_t[numberc]; Int_t *tr1clus = new Int_t[numberc]; Int_t *tr2clus = new Int_t[numberc]; Int_t *tr3clus = new Int_t[numberc]; Int_t nclus; + SetModule(module); digitcount=0; - Int_t ndigits = fDigits->GetEntriesFast(); + Int_t ndigits = Digits()->GetEntriesFast(); if (!ndigits) return; AliITSdigitSPD *dig; - Int_t ndig,i; -// cout << "FindRawcluters"<UncheckedAt(ndig); - digx[digitcount] = dig->GetCoord2()+1; //starts at 1 - digz[digitcount] = dig->GetCoord1()+1; //starts at 1 - digtr1[digitcount] = dig->GetTrack(0); - digtr2[digitcount] = -3; - digtr3[digitcount] = -3; - //cout << "digtr1["<GetTrack(i) && iGetNTracks()) i++; - //cout << " fTracks["<fTracks[i]; - if(iGetNTracks()){ - digtr2[digitcount] = dig->GetTrack(i); - //cout << "digtr2["<GetTrack(i) || - digtr2[digitcount]==dig->GetTrack(i))&& - i<=dig->GetNTracks()) i++; - if(iGetNTracks()) digtr3[digitcount] = dig->GetTrack(i); - //cout << " fTracks["<GetNTracks()) cout <fTracks[i]; - //cout << "digtr3["<GetTrack(i) && iGetNTracks()) i++; + if(GetDebug(5)) cout << " fTracks["<GetTrack(i); + if(iGetNTracks()){ + digtr2[digitcount] = dig->GetTrack(i); + if(GetDebug(5)) cout<<"digtr2["<GetTrack(i) || + digtr2[digitcount]==dig->GetTrack(i))&& + i<=dig->GetNTracks()) i++; + if(iGetNTracks()) digtr3[digitcount] = dig->GetTrack(i); + if(GetDebug(5)){ + cout << " fTracks["<GetNTracks()) cout <GetTrack(i); + cout << "digtr3["<GetModule("ITS"); - //put the cluster center in local reference frame of the detector - // and in microns - xcenter[i] = xcenter[i] - fSegmentation->Dx()/2.; - zcenter[i] = zcenter[i] - fSegmentation->Dz()/2.; + //put the cluster center in local reference frame of the detector + // and in microns + xcenter[i] = xcenter[i] - GetSeg()->Dx()/2.; + zcenter[i] = zcenter[i] - GetSeg()->Dz()/2.; - AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i], //f - xcenter[i], //f - ndig, //f - ndz,ndx, //ii - ndxmin,ndxmax,//ii - (Float_t) ndzmin, - (Float_t) ndzmax, - 0,module); //ii - iTS->AddCluster(0,clust); - delete clust; + AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i], //f + xcenter[i], //f + ndig, //f + ndz,ndx, //ii + ndxmin,ndxmax,//ii + (Double_t) ndzmin, + (Double_t) ndzmax, + 0,GetModule()); + iTS->AddCluster(0,clust); + delete clust; }//end loop on clusters delete[] ifpad; delete[] xpad ; @@ -391,28 +408,28 @@ void AliITSClusterFinderSPD::ClusterFinder(Int_t ndigits,Int_t digx[], } //______________________________________________________---------------- void AliITSClusterFinderSPD::DigitToPoint(Int_t nclus, - Float_t *xcenter,Float_t *zcenter, - Float_t *errxcenter, - Float_t *errzcenter, + Double_t *xcenter,Double_t *zcenter, + Double_t *errxcenter, + Double_t *errzcenter, Int_t *tr1clus, Int_t *tr2clus, Int_t *tr3clus){ // A point is associated to each cluster of SPD digits. The points // and their associated errors are stored in the file galiceSP.root. - Float_t l[3],xg,zg; - const Float_t kconv = 1.0e-4; // micron -> cm + Double_t l[3],xg,zg; + const Double_t kconv = 1.0e-4; // micron -> cm // get rec points static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); for (Int_t i=0; iDy()/2.; + l[1] = kconv*GetSeg()->Dy()/2.; l[2] = kconv*zcenter[i]; xg = l[0]; zg = l[2]; - Float_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]); - Float_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]); + Double_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]); + Double_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]); AliITSRecPoint rnew; rnew.SetX(xg); rnew.SetZ(zg); diff --git a/ITS/AliITSClusterFinderSPD.h b/ITS/AliITSClusterFinderSPD.h index b202c9c13f8..4f8bcd2d7bb 100644 --- a/ITS/AliITSClusterFinderSPD.h +++ b/ITS/AliITSClusterFinderSPD.h @@ -8,43 +8,49 @@ #include "AliITSClusterFinder.h" class AliITSMapA1; +class AliITSsegmentation; +class AliITSsegmentationSPD; +class AliITSresponse; +class AliITSresponseSPD; +class TClonesArray; class AliITSClusterFinderSPD : public AliITSClusterFinder{ public: - AliITSClusterFinderSPD(AliITSsegmentation *segmentation, - TClonesArray *digits, TClonesArray *recpoints); AliITSClusterFinderSPD(); - virtual ~AliITSClusterFinderSPD(){// destructor - } + AliITSClusterFinderSPD(AliITSsegmentation *segmentation, + AliITSresponse *res); + AliITSClusterFinderSPD(AliITSsegmentation *segmentation, + TClonesArray *digits,TClonesArray *recpoints); + virtual ~AliITSClusterFinderSPD(){}// destructor // copy constructor AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source); // assignment operator AliITSClusterFinderSPD& operator=(const AliITSClusterFinderSPD &source); - - virtual void SetDx(Float_t dx=1.) {// set dx - fDx=dx;} - virtual void SetDz(Float_t dz=0.) {// set dz - fDz=dz;} + + virtual AliITSresponseSPD* GetResp()const{ + return (AliITSresponseSPD*) GetResponse();}//Return Response + //Returns fSegmentation + virtual AliITSsegmentationSPD* GetSeg()const{ + return (AliITSsegmentationSPD*)GetSegmentation();} + virtual void SetDx(Double_t dx=1.) {fDx=dx;}// set dx + virtual void SetDz(Double_t dz=0.) {fDz=dz;}// set dz // Search for clusters virtual void FindRawClusters(Int_t module); - void DigitToPoint(Int_t nclus, Float_t *xcenter, Float_t *zcenter, - Float_t *errxcenter,Float_t *errzcenter, - Int_t *tr1clus, Int_t *tr2clus, Int_t *tr3clus); + void DigitToPoint(Int_t nclus, Double_t *xcenter, Double_t *zcenter, + Double_t *errxcenter,Double_t *errzcenter, + Int_t *tr1clus, Int_t *tr2clus, Int_t *tr3clus); void ClusterFinder(Int_t ndigits,Int_t digx[],Int_t digz[], - Int_t digtr1[],Int_t digtr2[],Int_t digtr3[], - Int_t digtr4[], - Int_t &nclus, - Float_t xcenter[],Float_t zcenter[], - Float_t errxcenter[],Float_t errzcenter[], - Int_t tr1clus[],Int_t tr2clus[], Int_t tr3clus[], - Int_t module); - private: - TClonesArray *fClusters; // clusters - Int_t fNclusters; // num of clusters - Float_t fDz; // dz - Float_t fDx; // dx + Int_t digtr1[],Int_t digtr2[],Int_t digtr3[], + Int_t digtr4[], + Int_t &nclus, + Double_t xcenter[],Double_t zcenter[], + Double_t errxcenter[],Double_t errzcenter[], + Int_t tr1clus[],Int_t tr2clus[], Int_t tr3clus[]); + private: + Double_t fDz; // dz + Double_t fDx; // dx Int_t fMinNCells; // min num of cells in the cluster - ClassDef(AliITSClusterFinderSPD,1) // SPD clustering + ClassDef(AliITSClusterFinderSPD,2) // SPD clustering }; #endif diff --git a/ITS/AliITSClusterFinderSPDdubna.cxx b/ITS/AliITSClusterFinderSPDdubna.cxx deleted file mode 100644 index b380523beb1..00000000000 --- a/ITS/AliITSClusterFinderSPDdubna.cxx +++ /dev/null @@ -1,358 +0,0 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/* $Id$ */ - -// Cluster Finder for -// Silicon -// Pixel -// developed by the Dubna group -// -#include -#include "AliITSClusterFinderSPDdubna.h" -#include "AliITSMapA1.h" -#include "AliITS.h" -#include "AliITSdigitSPD.h" -#include "AliITSRawClusterSPD.h" -#include "AliITSRecPoint.h" -#include "AliITSsegmentation.h" -#include "AliRun.h" - -//#define DEBUG - -ClassImp(AliITSClusterFinderSPDdubna) - -//---------------------------------------------------------------------- -AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna( - AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp){ - // constructor - - fSegmentation = seg; - fDigits = digits; - fClusters = recp; - fNclusters = 0; - fMap = new AliITSMapA1(fSegmentation,fDigits); - SetDx(); - SetDz(); - SetNCells(); -} -//_______________________________________________________________________ -AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna(){ - // constructor - - fSegmentation = 0; - fDigits = 0; - fClusters = 0; - fNclusters = 0; - fMap = 0; - SetDx(); - SetDz(); - SetNCells(); -} -//______________________________________________________________________ -AliITSClusterFinderSPDdubna &AliITSClusterFinderSPDdubna::operator=(const - AliITSClusterFinderSPDdubna &s){ - // The = operator for the class AliITSClusterFinderSPDdugna - // Inputs: - // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna - // class to be copy constructed. - // Outputs: - // none. - // Returned: - // this, a copy of the class s. - - this->fNclusters = s.fNclusters; - this->fDz = s.fDz; - this->fDx = s.fDx; - this->fMinNCells = s.fMinNCells; - this->fClusters = new TClonesArray(*(s.fClusters)); - return *this; -} -//______________________________________________________________________ -AliITSClusterFinderSPDdubna::AliITSClusterFinderSPDdubna( - const AliITSClusterFinderSPDdubna &s): AliITSClusterFinder(s){ - // The Copy constructortor the class AliITSClusterFinderSPDdugna - // It calles the = operator. - // Inputs: - // AliITSClusterFinderSPDdubna @s The AliITSClusterFinderSPDdubna - // class to be copy constructed. - // Outputs: - // none. - // Returned: - // none. - - *this = s; - return; -} -//______________________________________________________________________ -AliITSClusterFinderSPDdubna::~AliITSClusterFinderSPDdubna(){ - // destructor - - if (fMap) delete fMap; -} -//______________________________________________________________________ -void AliITSClusterFinderSPDdubna::Find1DClusters(Int_t mod){ - // Find one dimensional clusters, i.e. - // in r*phi(x) direction for each colunm in z direction - - static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); - - // retrieve the parameters - Int_t fNofPixels = fSegmentation->Npz(); - Int_t fMaxNofSamples = fSegmentation->Npx(); - - // read in digits -> do not apply threshold - // signal in fired pixels is always 1 - fMap->FillMap(); - - Int_t nofFoundClusters = 0; - - Int_t k,it,m; - for(k=0;k= fMaxNofSamples) break; // ! no possible for the fadc - if(fMap->TestHit(k,id) == kUnused) { // start of the cluster - lclx += 1; - if(lclx == 1) xstart = id; - } // end if fMap - if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) { - // end of cluster if a gap exists - xstop = id-1; - ilcl = 1; - break; - } // end if lclx >0 ... - } // end of m-loop - if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window, - // continue the "it" loop - if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished - if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) { - // cluster end is outside of the window, - mmax += 5; // increase mmax and repeat the cluster finding - it -= 1; - } // end if id< - if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but - xstop = fMaxNofSamples - 1; // the end cluster exists - ilcl = 1; - } // end if id>= - // --- Calculate z and x coordinates for one dimensional clusters - if(ilcl == 1) { // new cluster exists - it = id; - mmax = 10; - nofFoundClusters++; - Float_t clusterCharge = 0.; - Float_t zpitch = fSegmentation->Dpz(k+1); - Int_t dummy = 0; - Float_t clusterZ, dummyX; - fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ); - Float_t zstart = clusterZ - 0.5*zpitch; - Float_t zstop = clusterZ + 0.5*zpitch; - Float_t clusterX = 0.; - Int_t clusterSizeX = lclx; - Int_t clusterSizeZ = 1; - Int_t its; - for(its=xstart; its<=xstop; its++) { - Int_t firedpixel=0; - if (fMap->GetHitIndex(k,its)>=0) firedpixel=1; - clusterCharge += firedpixel; - clusterX += its + 0.5; - } // end for its - Float_t fRphiPitch = fSegmentation->Dpx(dummy); - clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x - // Write the points (coordinates and some cluster information) - // to the AliITSRawClusterSPD object - - AliITSRawClusterSPD clust(clusterZ,clusterX,clusterCharge, - clusterSizeZ,clusterSizeX, - xstart,xstop,zstart,zstop,k,mod); - iTS->AddCluster(0,&clust); - } // new cluster (ilcl=1) - } // X direction loop (it) - } // Z direction loop (k) - //fMap->ClearMap(); - return; -} -//______________________________________________________________________ -void AliITSClusterFinderSPDdubna::GroupClusters(){ - // Find two dimensional clusters, i.e. group one dimensional clusters - // into two dimensional ones (go both in x and z directions). - // get number of clusters for this module - - Int_t nofClusters = fClusters->GetEntriesFast(); - nofClusters -= fNclusters; - AliITSRawClusterSPD *clusterI; - AliITSRawClusterSPD *clusterJ; - Int_t *label=new Int_t[nofClusters]; - Int_t i,j; - for(i=0; iAt(i); - clusterJ = (AliITSRawClusterSPD*) fClusters->At(j); - Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx); - if(pair) { -#ifndef DEBUG - cout << "clusters " << i << "," << j << " before grouping" << endl; - clusterI->PrintInfo(); - clusterJ->PrintInfo(); -#endif - clusterI->Add(clusterJ); -#ifndef DEBUG - cout << "remove cluster " << j << endl; -#endif - label[j] = 1; - fClusters->RemoveAt(j); -#ifndef DEBUG - cout << "cluster " << i << " after grouping" << endl; - clusterI->PrintInfo(); -#endif - } // pair - } // J clusters - label[i] = 1; - } // I clusters - fClusters->Compress(); -#ifndef DEBUG - Int_t totalNofClusters = fClusters->GetEntriesFast(); - cout << " Nomber of clusters at the group end ="<< totalNofClusters<GetEntriesFast(); - Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz; - const Int_t kTrmax = 100; - Int_t cltracks[kTrmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2; - - nofClusters -= fNclusters; - for(i=0; iAt(i); - nclx = clusterI->NclX(); - nclz = clusterI->NclZ(); - xstart = clusterI->XStartf(); - xstop = clusterI->XStopf(); - zstart = clusterI->Zend()-nclz+1; - zstop = clusterI->Zend(); - Int_t ind; - for(iz=0; izGetHitIndex(jz,jx); - if(ind < 0) continue; - if(ind == 0 && iz >= 0 && ix > 0) continue; - if(ind == 0 && iz > 0 && ix >= 0) continue; - if(ind == 0 && iz == 0 && ix == 0 && i > 0) continue; - AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx); - for(itr=0; itr<3; itr++) { - tracki = dig->GetTrack(i); - if(tracki >= 0) { - ii += 1; - if(ii < 99) cltracks[ii-1] = tracki; - } // end if tracki >-0 - } // end for itr - } // ix pixel - } // iz pixel - for(is=0; is= 0) { - ntr=ntr+1; - if(ntr==1) tr0=cltracks[ie]; - if(ntr==2) tr1=cltracks[ie]; - if(ntr==3) tr2=cltracks[ie]; - } // end if cltracks[ie] >-= - } // end for ie - // if delta ray only - if(ntr == 0) ntr = 1; - clusterI->SetNTracks(ntr); - clusterI->SetTracks(tr0,tr1,tr2); - } // I cluster -} -//______________________________________________________________________ -void AliITSClusterFinderSPDdubna::GetRecPoints(){ - // get rec points - static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS"); - // get number of clusters for this module - Int_t nofClusters = fClusters->GetEntriesFast(); - const Float_t kconv = 1.0e-4; - const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3 - const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3 - Float_t spdLength = fSegmentation->Dz(); - Float_t spdWidth = fSegmentation->Dx(); - Int_t dummy = 0; - Float_t xpitch = fSegmentation->Dpx(dummy); - Int_t i; - Int_t track0, track1, track2; - - nofClusters -= fNclusters; - for(i=0; iAt(i); - Int_t clustersizex = clusterI->NclX(); - Int_t clustersizez = clusterI->NclZ(); - Int_t xstart = clusterI->XStartf(); - Float_t clusterx = 0; - Float_t clusterz = clusterI->Z(); - for(Int_t ii=0; iiGetTracks(track0, track1, track2); - AliITSRecPoint rnew; - rnew.SetX((clusterx - spdWidth/2)*kconv); - rnew.SetZ((clusterz - spdLength/2)*kconv); - rnew.SetQ(1.); - rnew.SetdEdX(0.); - rnew.SetSigmaX2(kRMSx*kRMSx); - rnew.SetSigmaZ2(kRMSz*kRMSz); - rnew.fTracks[0]=track0; - rnew.fTracks[1]=track1; - rnew.fTracks[2]=track2; - iTS->AddRecPoint(rnew); - } // I clusters - fMap->ClearMap(); -} -//______________________________________________________________________ -void AliITSClusterFinderSPDdubna::FindRawClusters(Int_t mod){ - // find raw clusters - -#ifndef DEBUG - cout<<"SPDdubna: module ="<GetModule("ITS"); - fClusterP = 0; - fNClusterP =0; - fClusterN = 0; + SetDigits(digits); + SetMap(new AliITSMapA1(GetSeg(),Digits())); + fITS = (AliITS*)gAlice->GetModule("ITS"); + fClusterP = new TClonesArray ("AliITSclusterSSD",200); + fNClusterP = 0; + fClusterN = new TClonesArray ("AliITSclusterSSD",200); fNClusterN = 0; - fPackages = 0; + fPackages = new TClonesArray ("AliITSpackageSSD",200); //packages fNPackages = 0; - fDigitsIndexP = 0; + fDigitsIndexP = new TArrayI(300); fNDigitsP = 0; - fDigitsIndexN = 0; + fDigitsIndexN = new TArrayI(300); fNDigitsN = 0; - fPitch = 0; - fPNsignalRatio= 0; + fPitch = GetSeg()->Dpx(0); + fPNsignalRatio= 7./8.; // warning: hard-wired number } //______________________________________________________________________} AliITSClusterFinderSSD::AliITSClusterFinderSSD(AliITSsegmentation *seg, - TClonesArray *digits){ + AliITSresponse *res): +AliITSClusterFinder(seg,res), +fITS(0), +fClusterP(0), +fNClusterP(0), +fClusterN(0), +fNClusterN(0), +fPackages(0), +fNPackages(0), +fDigitsIndexP(0), +fNDigitsP(0), +fDigitsIndexN(0), +fNDigitsN(0), +fPitch(0.0), +fTanP(0.0), +fTanN(0.0), +fPNsignalRatio(0.0), +fSFF(0), +fSFB(0){ //Standard constructor - fSegmentation = seg; - fDigits = digits; - fMap = new AliITSMapA1(fSegmentation,fDigits); fITS = (AliITS*)gAlice->GetModule("ITS"); fClusterP = new TClonesArray ("AliITSclusterSSD",200); fNClusterP = 0; @@ -81,19 +136,19 @@ AliITSClusterFinderSSD::AliITSClusterFinderSSD(AliITSsegmentation *seg, fNDigitsP = 0; fDigitsIndexN = new TArrayI(300); fNDigitsN = 0; - fPitch = fSegmentation->Dpx(0); + fPitch = GetSeg()->Dpx(0); fPNsignalRatio= 7./8.; // warning: hard-wired number } //______________________________________________________________________ AliITSClusterFinderSSD::~AliITSClusterFinderSSD(){ // Default destructor + fITS = 0; delete fClusterP; delete fClusterN; delete fPackages; delete fDigitsIndexP; delete fDigitsIndexN; - delete fMap; } //______________________________________________________________________ void AliITSClusterFinderSSD::InitReconstruction(){ @@ -110,9 +165,9 @@ void AliITSClusterFinderSSD::InitReconstruction(){ fNDigitsP = 0; fNDigitsN = 0; Float_t stereoP,stereoN; - fSegmentation->Angles(stereoP,stereoN); + GetSeg()->Angles(stereoP,stereoN); CalcStepFactor(stereoP,stereoN); - if (debug) cout<<"fSFF = "<GetITSgeom(); - geom->GetModuleId(module,lay, lad, detect); - if ( lay == 6 ) ((AliITSsegmentationSSD*)fSegmentation)->SetLayer(6); - if ( lay == 5 ) ((AliITSsegmentationSSD*)fSegmentation)->SetLayer(5); + SetModule(module); + geom->GetModuleId(GetModule(),lay, lad, detect); + if ( lay == 6 ) ((AliITSsegmentationSSD*)GetSeg())->SetLayer(6); + if ( lay == 5 ) ((AliITSsegmentationSSD*)GetSeg())->SetLayer(5); InitReconstruction(); //ad. 1 - fMap->FillMap(); + Map()->FillMap(); FillDigitsIndex(); SortDigits(); FindNeighbouringDigits(); //ad. 2 //SeparateOverlappedClusters(); //ad. 3 ClustersToPackages(); //ad. 4 - fMap->ClearMap(); + Map()->ClearMap(); } //______________________________________________________________________ void AliITSClusterFinderSSD::FindNeighbouringDigits(){ @@ -185,30 +241,30 @@ void AliITSClusterFinderSSD::FindNeighbouringDigits(){ currentstripNo = ((AliITSdigitSSD*)(lDigits[lDigitsIndexN[i]]))-> GetStripNumber(); if ( (((AliITSdigitSSD*)lDigits[lDigitsIndexN[i-1]])-> - GetStripNumber()) + GetStripNumber()) == (currentstripNo-1) ) dbuffer[dnumber++]=lDigitsIndexN[i]; else { new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer, - Digits(), - fgkSIDEN); + Digits(), + fgkSIDEN); dbuffer[0]=lDigitsIndexN[i]; dnumber = 1; } // end if else } // end loop over fNDigitsN new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer, - Digits(),fgkSIDEN); + Digits(),fgkSIDEN); delete [] dbuffer; } // end condition on NDigits - if (debug) cout<<"\n Found clusters: fNClusterP = "<SortDigitsN(start,(start+end)/2); - right=this->SortDigitsN((start+end)/2,end); - return (left || right); + left=this->SortDigitsN(start,(start+end)/2); + right=this->SortDigitsN((start+end)/2,end); + return (left || right); }else{ - left =((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[start]]))-> - GetStripNumber(); - right=((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[end]]))-> - GetStripNumber(); - if ( left > right ){ - Int_t tmp = (*fDigitsIndexN)[start]; - (*fDigitsIndexN)[start]=(*fDigitsIndexN)[end]; - (*fDigitsIndexN)[end]=tmp; - return 1; - }else return 0; + left =((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[start]]))-> + GetStripNumber(); + right=((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[end]]))-> + GetStripNumber(); + if ( left > right ){ + Int_t tmp = (*fDigitsIndexN)[start]; + (*fDigitsIndexN)[start]=(*fDigitsIndexN)[end]; + (*fDigitsIndexN)[end]=tmp; + return 1; + }else return 0; } // end if } //______________________________________________________________________ @@ -368,7 +424,7 @@ void AliITSClusterFinderSSD::FillDigitsIndex(){ Int_t noentries; Int_t i; - noentries = fDigits->GetEntriesFast(); + noentries = NDigits(); Int_t* psidx = new Int_t [noentries*sizeof(Int_t)]; Int_t* nsidx = new Int_t [noentries*sizeof(Int_t)]; @@ -378,45 +434,45 @@ void AliITSClusterFinderSSD::FillDigitsIndex(){ AliITSdigitSSD *dig; for ( i = 0 ; i< noentries; i++ ) { - dig = (AliITSdigitSSD*)GetDigit(i); - if(dig->IsSideP()) { - bit=1; - tmp=dig->GetStripNumber(); - // I find this totally unnecessary - it's just a - // CPU consuming double check - for( k=0;kAddAt(i,fNDigitsP++); - psidx[pns++]=tmp; - } // end if bit - } else { - bit=1; - tmp=dig->GetStripNumber(); - // same as above - for( k=0;kAddAt(i,fNDigitsN++); - nsidx[nns++] =tmp; - } // end if bit - } // end if + dig = (AliITSdigitSSD*)GetDigit(i); + if(dig->IsSideP()) { + bit=1; + tmp=dig->GetStripNumber(); + // I find this totally unnecessary - it's just a + // CPU consuming double check + for( k=0;kAddAt(i,fNDigitsP++); + psidx[pns++]=tmp; + } // end if bit + } else { + bit=1; + tmp=dig->GetStripNumber(); + // same as above + for( k=0;kAddAt(i,fNDigitsN++); + nsidx[nns++] =tmp; + } // end if bit + } // end if } // end for i delete [] psidx; delete [] nsidx; - if (debug) cout<<"Digits : P = "<=fNClusterN)){ - printf("AliITSClusterFinderSSD::GetNSideCluster: index out of range\n"); - return 0; + Info("GetNSideCluster","0= %d out of range",idx,fNClusterN); + return 0; }else{ - return (AliITSclusterSSD*)((*fClusterN)[idx]); + return (AliITSclusterSSD*)((*fClusterN)[idx]); } // end if } //______________________________________________________________________ -AliITSclusterSSD* AliITSClusterFinderSSD::GetCluster(Int_t idx, Bool_t side){ - // Get cluster - - return (side) ? GetPSideCluster(idx) : GetNSideCluster(idx); -} -//______________________________________________________________________ -Bool_t AliITSClusterFinderSSD::GetCrossing (Float_t &P, Float_t &N){ +Bool_t AliITSClusterFinderSSD::GetCrossing (Double_t &P, Double_t &N){ // get crossing // This function was rivised and changed by Boris Batiounia in March 2001 - Float_t dx = fSegmentation->Dx(); // detector size in x direction, microns - Float_t dz = fSegmentation->Dz(); // detector size in z direction, microns - Float_t xL; // x local coordinate - Float_t zL; // z local coordinate - Float_t x; // x = xL + dx/2 - Float_t z; // z = zL + dz/2 - Float_t xP; // x coordinate in the P side from the first P strip - Float_t xN; // x coordinate in the N side from the first N strip + Double_t dx = GetSeg()->Dx(); // detector size in x direction, microns + Double_t dz = GetSeg()->Dz(); // detector size in z direction, microns + Double_t xL; // x local coordinate + Double_t zL; // z local coordinate + Double_t x; // x = xL + dx/2 + Double_t z; // z = zL + dz/2 + Double_t xP; // x coordinate in the P side from the first P strip + Double_t xN; // x coordinate in the N side from the first N strip Float_t stereoP,stereoN; - fSegmentation->Angles(stereoP,stereoN); + GetSeg()->Angles(stereoP,stereoN); fTanP=TMath::Tan(stereoP); fTanN=TMath::Tan(stereoN); - Float_t kP = fTanP; // Tangent of 0.0075 mrad - Float_t kN = fTanN; // Tangent of 0.0275 mrad + Double_t kP = fTanP; // Tangent of 0.0075 mrad + Double_t kN = fTanN; // Tangent of 0.0275 mrad P *= fPitch; N *= fPitch; @@ -671,13 +722,13 @@ Bool_t AliITSClusterFinderSSD::GetCrossing (Float_t &P, Float_t &N){ return kTRUE; } //______________________________________________________________________ -void AliITSClusterFinderSSD::GetCrossingError(Float_t& dP, Float_t& dN){ +void AliITSClusterFinderSSD::GetCrossingError(Double_t& dP, Double_t& dN){ // get crossing error - Float_t dz, dx; + Double_t dz, dx; dz = TMath::Abs(( dP + dN )*fPitch/(fTanP + fTanN) ); dx = fPitch*(TMath::Abs(dP*(1 - fTanP/(fTanP + fTanN))) + - TMath::Abs(dN *fTanP/(fTanP + fTanN) )); + TMath::Abs(dN *fTanP/(fTanP + fTanN) )); dN = dz; dP = dx; } diff --git a/ITS/AliITSClusterFinderSSD.h b/ITS/AliITSClusterFinderSSD.h index b80bd50dab1..2c0157d4141 100644 --- a/ITS/AliITSClusterFinderSSD.h +++ b/ITS/AliITSClusterFinderSSD.h @@ -3,46 +3,58 @@ /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ -#include +//#include #include "AliITSClusterFinder.h" -#include "AliITSsegmentationSSD.h" +//#include "AliITSsegmentationSSD.h" class TArrayI; class AliITSclusterSSD; class AliITSpackageSSD; +class AliITSsegmentation; +class AliITSsegmentationSSD; +class AliITSresponse; +class AliITSresponseSSD; class AliITSClusterFinderSSD: public AliITSClusterFinder{ - public: + public: AliITSClusterFinderSSD(); + AliITSClusterFinderSSD(AliITSsegmentation *seg,AliITSresponse *resp); AliITSClusterFinderSSD(AliITSsegmentation *seg, TClonesArray *digits); virtual ~AliITSClusterFinderSSD(); - void FindRawClusters(Int_t module); + void FindRawClusters(Int_t module); - protected: + protected: + virtual AliITSresponseSSD* GetResp()const{ + return (AliITSresponseSSD*) GetResponse();}//Return Response + //Returns fSegmentation + virtual AliITSsegmentationSSD* GetSeg()const{ + return (AliITSsegmentationSSD*)GetSegmentation();} void InitReconstruction(); - Bool_t CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN, - Float_t Sig,Float_t dSig, - AliITSclusterSSD *clusterP, - AliITSclusterSSD *clusterN,Stat_t prob); + Bool_t CreateNewRecPoint(Double_t P,Double_t dP,Double_t N,Double_t dN, + Double_t Sig,Double_t dSig, + AliITSclusterSSD *clusterP, + AliITSclusterSSD *clusterN,Stat_t prob); AliITSclusterSSD* GetPSideCluster(Int_t idx); AliITSclusterSSD* GetNSideCluster(Int_t idx); - AliITSclusterSSD* GetCluster(Int_t idx, Bool_t side); - void FindNeighbouringDigits(); - void SeparateOverlappedClusters(); - void SplitCluster(TArrayI *list,Int_t nsplits,Int_t indx,Bool_t side); - Int_t SortDigitsP(Int_t start, Int_t end); - Int_t SortDigitsN(Int_t start, Int_t end); - void FillDigitsIndex(); - void SortDigits(); - void FillClIndexArrays(Int_t* arrayP, Int_t *arrayN) const; - void SortClusters(Int_t* arrayP, Int_t *arrayN); - Int_t SortClustersP(Int_t start, Int_t end,Int_t *array); - Int_t SortClustersN(Int_t start, Int_t end,Int_t *array); - void ClustersToPackages(); - Int_t GetDiff(Float_t */*retx*/, Float_t */*rety*/) const {return 0;} - void CalcStepFactor(Float_t Psteo, Float_t Nsteo ); - Bool_t GetCrossing(Float_t &x, Float_t &z); //x, y of strips crossing - void GetCrossingError(Float_t& dp, Float_t& dn);//x, y of strips crossing err. + AliITSclusterSSD* GetCluster(Int_t idx, Bool_t side){ + return (side) ? GetPSideCluster(idx) : GetNSideCluster(idx);}; + void FindNeighbouringDigits(); + void SeparateOverlappedClusters(); + void SplitCluster(TArrayI *list,Int_t nsplits,Int_t indx,Bool_t side); + Int_t SortDigitsP(Int_t start, Int_t end); + Int_t SortDigitsN(Int_t start, Int_t end); + void FillDigitsIndex(); + void SortDigits(); + void FillClIndexArrays(Int_t* arrayP, Int_t *arrayN) const; + void SortClusters(Int_t* arrayP, Int_t *arrayN); + Int_t SortClustersP(Int_t start, Int_t end,Int_t *array); + Int_t SortClustersN(Int_t start, Int_t end,Int_t *array); + void ClustersToPackages(); + Int_t GetDiff(Double_t */*retx*/, Double_t */*rety*/) const {return 0;} + void CalcStepFactor(Double_t Psteo, Double_t Nsteo ); + Bool_t GetCrossing(Double_t &x, Double_t &z); //x, y of strips crossing + //x, y of strips crossing err. + void GetCrossingError(Double_t& dp, Double_t& dn); // Data memebers AliITS *fITS; //!Pointer to AliITS object @@ -57,19 +69,19 @@ class AliITSClusterFinderSSD: public AliITSClusterFinder{ TArrayI *fDigitsIndexN; //!Digits on N side Int_t fNDigitsN; //!Number of Digits on N side - Float_t fPitch; //!Strip pitch - Float_t fTanP; //!Pside stereo angle tangent - Float_t fTanN; //!Nside stereo angle tangent + Double_t fPitch; //!Strip pitch + Double_t fTanP; //!Pside stereo angle tangent + Double_t fTanN; //!Nside stereo angle tangent /*************************************************/ /** parameters for reconstruction ****/ /** to be tune when slow simulation raliable ****/ /*************************************************/ - //Float_t fAlpha1; //! - //Float_t fAlpha2; //! - //Float_t fAlpha3; //! - Float_t fPNsignalRatio; //! + //Double_t fAlpha1; //! + //Double_t fAlpha2; //! + //Double_t fAlpha3; //! + Double_t fPNsignalRatio; //! static const Bool_t fgkSIDEP; //! static const Bool_t fgkSIDEN; //! @@ -77,7 +89,7 @@ class AliITSClusterFinderSSD: public AliITSClusterFinder{ Int_t fSFF; //!forward stepping factor Int_t fSFB; //!backward stepping factor - ClassDef(AliITSClusterFinderSSD, 1) //Class for clustering and reconstruction of space points in SSDs + ClassDef(AliITSClusterFinderSSD,1) //Class for clustering and reconstruction of space points in SSDs }; diff --git a/ITS/AliITSDetType.cxx b/ITS/AliITSDetType.cxx index 4f3936495c1..3d80fa8ae41 100644 --- a/ITS/AliITSDetType.cxx +++ b/ITS/AliITSDetType.cxx @@ -30,17 +30,61 @@ ClassImp(AliITSDetType) //______________________________________________________________________ -AliITSDetType::AliITSDetType(){ - // constructor - - fSegmentation = 0; - fResponse = 0; - fSimulation = 0; - fReconst = 0; +AliITSDetType::AliITSDetType(): +TObject(), +fDetType(kND), +fResponse(0), +fSegmentation(0), +fSimulation(0), +fReconst(0), +fDigClassName(""), +fClustClassName(""){ + // Default constructor. + // Inputs: + // none. + // Output: + // none. + // Return: + // A default constructed AliITSDetType class. +} +//______________________________________________________________________ +AliITSDetType::AliITSDetType(AliITSDetector det,AliITSresponse *res, + AliITSsegmentation *seg,AliITSsimulation *sim, + AliITSClusterFinder *cf, + const Char_t *DigClassName, + const Char_t *ClustClassName): +TObject(), +fDetType(det), +fResponse(res), +fSegmentation(seg), +fSimulation(sim), +fReconst(cf), +fDigClassName(DigClassName), +fClustClassName(ClustClassName){ + // Standard constructor + // Inputs: + // AliITSDetector det Detector type + // AliITSresponse *res response class to use + // AliITSsegmentation *seg Segmentation class to use + // AliITSsimulation *sim Simulation class to use + // AliITSClusterFinder *cf Cluster Finder/Reconstruction class to use + // const Char_t DigClassName Name of the digit class to be used + // const Char_t ClustClassName Name of the cluster class to be + // used + // Output: + // none. + // Return: + // A Standard constructed AliITSDetType class. } //---------------------------------------------------------------------- AliITSDetType::~AliITSDetType(){ // destructor + // Inputs: + // none. + // Output: + // none. + // Return: + // none. if(fSegmentation!=0) delete fSegmentation; fSegmentation = 0; if(fResponse!=0) delete fResponse; fResponse = 0; @@ -49,27 +93,41 @@ AliITSDetType::~AliITSDetType(){ } //______________________________________________________________________ AliITSDetType::AliITSDetType(const AliITSDetType &source) : TObject(source){ - // Copy Constructor + // Copy Constructor + // Inputs: + // const AliITSDetType &source class to copy from. + // Output: + // none. + // Return: + // none. - if(&source == this) return; - this->fReconst = source.fReconst; - this->fSimulation = source.fSimulation; - this->fResponse = source.fResponse; - this->fSegmentation = source.fSegmentation; - this->fDigClassName = source.fDigClassName; - this->fClustClassName = source.fClustClassName; - return; + if(&source == this) return; + this->fDetType = source.fDetType; + this->fReconst = source.fReconst; + this->fSimulation = source.fSimulation; + this->fResponse = source.fResponse; + this->fSegmentation = source.fSegmentation; + this->fDigClassName = source.fDigClassName; + this->fClustClassName = source.fClustClassName; + return; } //______________________________________________________________________ AliITSDetType& AliITSDetType::operator=(const AliITSDetType &source){ - // Assignment operator + // Assignment operator + // Inputs: + // const AliITSDetType &source class to copy from. + // Output: + // none. + // Return: + // a new AliITSDetType class with the same values as in source. - if(&source == this) return *this; - this->fReconst = source.fReconst; - this->fSimulation = source.fSimulation; - this->fResponse = source.fResponse; - this->fSegmentation = source.fSegmentation; - this->fDigClassName = source.fDigClassName; - this->fClustClassName = source.fClustClassName; - return *this; + if(&source == this) return *this; + this->fDetType = source.fDetType; + this->fReconst = source.fReconst; + this->fSimulation = source.fSimulation; + this->fResponse = source.fResponse; + this->fSegmentation = source.fSegmentation; + this->fDigClassName = source.fDigClassName; + this->fClustClassName = source.fClustClassName; + return *this; } diff --git a/ITS/AliITSDetType.h b/ITS/AliITSDetType.h index 2e73c696736..30768c7fe8b 100644 --- a/ITS/AliITSDetType.h +++ b/ITS/AliITSDetType.h @@ -16,6 +16,7 @@ #include #include +#include "AliITSgeom.h" #include "AliITSsegmentation.h" #include "AliITSresponse.h" @@ -26,9 +27,17 @@ class AliITSDetType:public TObject{ public: AliITSDetType(); + AliITSDetType(AliITSDetector det,AliITSresponse *res, + AliITSsegmentation *seg,AliITSsimulation *sim, + AliITSClusterFinder *cf,const Char_t *DigClassName, + const Char_t *ClustClassName); virtual ~AliITSDetType(); AliITSDetType(const AliITSDetType &source); // copy constructor AliITSDetType& operator=(const AliITSDetType &source); // assign. operator + // Return the type of detector these quantities are defined for + AliITSDetector GetDetType(){return fDetType;} + // Set the type of Detector these quantities are defined for + void SetDetType(AliITSDetector det){fDetType = det;} // Set the defaults virtual void Init() {} @@ -84,17 +93,17 @@ class AliITSDetType:public TObject{ TString GetDigitClassName() const { return fDigClassName;} // Return the Cluster Class name TString GetClusterClassName() const { return fClustClassName;} - + protected: + AliITSDetector fDetType; // Type of detector AliITSresponse *fResponse; // response AliITSsegmentation *fSegmentation; // segmentation AliITSsimulation *fSimulation; // simulation AliITSClusterFinder *fReconst; // cluster finder - TString fDigClassName; // string TString fClustClassName; // string - ClassDef(AliITSDetType,1) //Detector simulation/reconstruction class holder + ClassDef(AliITSDetType,2) //Detector simulation/reconstruction class holder }; diff --git a/ITS/AliITSLoader.cxx b/ITS/AliITSLoader.cxx index 4b6fa718b63..92e5979d0e9 100644 --- a/ITS/AliITSLoader.cxx +++ b/ITS/AliITSLoader.cxx @@ -1,15 +1,17 @@ +#include "AliITS.h" +#include "AliITSgeom.h" +#include "AliITSdigit.h" +#include "AliRun.h" +#include "AliDetector.h" #include "AliITSLoader.h" - - - -////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// // Loader for ITS // it manages the I/O for: // raw clusters, primary vertices // V0 and cascade // and tracks propagated to the origin -////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// const TString AliITSLoader::fgkDefaultRawClustersContainerName = "TreeC"; const TString AliITSLoader::fgkDefaultBackTracksContainerName = "TreeB"; const TString AliITSLoader::fgkDefaultVerticesContainerName = "Vertex"; @@ -18,115 +20,270 @@ const TString AliITSLoader::fgkDefaultCascadeContainerName = "Cascade"; ClassImp(AliITSLoader) -/*****************************************************************************/ - +/**********************************************************************/ AliITSLoader::AliITSLoader():AliLoader(){ // Default constructor +} +/*********************************************************************/ +AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername): +AliLoader(name,topfoldername){ + //ctor + AliDataLoader* rawClustersDataLoader = new AliDataLoader( + fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName, + "Raw Clusters"); + fDataLoaders->Add(rawClustersDataLoader); + rawClustersDataLoader->SetEventFolder(fEventFolder); + rawClustersDataLoader->SetFolder(GetDetectorDataFolder()); + + AliDataLoader* backTracksDataLoader = new AliDataLoader( + fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName, + "Back Propagated Tracks"); + fDataLoaders->Add(backTracksDataLoader); + backTracksDataLoader->SetEventFolder(fEventFolder); + backTracksDataLoader->SetFolder(GetDetectorDataFolder()); + AliDataLoader* vertexDataLoader = new AliDataLoader( + fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName, + "Primary Vertices","O"); + fDataLoaders->Add(vertexDataLoader); + vertexDataLoader->SetEventFolder(fEventFolder); + vertexDataLoader->SetFolder(GetDetectorDataFolder()); + + AliDataLoader* v0DataLoader = new AliDataLoader( + fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices"); + fDataLoaders->Add(v0DataLoader); + v0DataLoader->SetEventFolder(fEventFolder); + v0DataLoader->SetFolder(GetDetectorDataFolder()); + + AliDataLoader* cascadeDataLoader = new AliDataLoader( + fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName, + "Cascades"); + fDataLoaders->Add(cascadeDataLoader); + cascadeDataLoader->SetEventFolder(fEventFolder); + cascadeDataLoader->SetFolder(GetDetectorDataFolder()); } +/**********************************************************************/ +AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder): +AliLoader(name,topfolder) { + //ctor + AliDataLoader* rawClustersDataLoader = new AliDataLoader( + fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName, + "Raw Clusters"); + fDataLoaders->Add(rawClustersDataLoader); + rawClustersDataLoader->SetEventFolder(fEventFolder); + rawClustersDataLoader->SetFolder(GetDetectorDataFolder()); -/*****************************************************************************/ -AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername): AliLoader(name,topfoldername){ - //ctor - AliDataLoader* rawClustersDataLoader = new AliDataLoader(fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,"Raw Clusters"); - fDataLoaders->Add(rawClustersDataLoader); - rawClustersDataLoader->SetEventFolder(fEventFolder); - rawClustersDataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* backTracksDataLoader = - new AliDataLoader(fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,"Back Propagated Tracks"); - fDataLoaders->Add(backTracksDataLoader); - backTracksDataLoader->SetEventFolder(fEventFolder); - backTracksDataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* vertexDataLoader = new AliDataLoader(fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,"Primary Vertices","O"); - fDataLoaders->Add(vertexDataLoader); - vertexDataLoader->SetEventFolder(fEventFolder); - vertexDataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* v0DataLoader = new AliDataLoader(fDetectorName + ".V0s.root",fgkDefaultV0ContainerName,"V0 Vertices"); - fDataLoaders->Add(v0DataLoader); - v0DataLoader->SetEventFolder(fEventFolder); - v0DataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* cascadeDataLoader = new AliDataLoader(fDetectorName + ".Cascades.root",fgkDefaultCascadeContainerName,"Cascades"); - fDataLoaders->Add(cascadeDataLoader); - cascadeDataLoader->SetEventFolder(fEventFolder); - cascadeDataLoader->SetFolder(GetDetectorDataFolder()); - + AliDataLoader* backTracksDataLoader = new AliDataLoader( + fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName, + "Back Propagated Tracks"); + fDataLoaders->Add(backTracksDataLoader); + backTracksDataLoader->SetEventFolder(fEventFolder); + backTracksDataLoader->SetFolder(GetDetectorDataFolder()); + + AliDataLoader* vertexDataLoader = new AliDataLoader( + fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName, + "Primary Vertices","O"); + fDataLoaders->Add(vertexDataLoader); + vertexDataLoader->SetEventFolder(fEventFolder); + vertexDataLoader->SetFolder(GetDetectorDataFolder()); + + AliDataLoader* v0DataLoader = new AliDataLoader( + fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices"); + fDataLoaders->Add(v0DataLoader); + v0DataLoader->SetEventFolder(fEventFolder); + v0DataLoader->SetFolder(GetDetectorDataFolder()); + + AliDataLoader* cascadeDataLoader = new AliDataLoader( + fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName, + "Cascades"); + fDataLoaders->Add(cascadeDataLoader); + cascadeDataLoader->SetEventFolder(fEventFolder); + cascadeDataLoader->SetFolder(GetDetectorDataFolder()); } -/*****************************************************************************/ +/**********************************************************************/ +AliITSLoader::~AliITSLoader(){ + //destructor + AliDataLoader* dl = 0; + UnloadRawClusters(); + dl = GetRawClLoader(); + fDataLoaders->Remove(dl); -AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder): AliLoader(name,topfolder) { - //ctor - AliDataLoader* rawClustersDataLoader = new AliDataLoader(fDetectorName + ".RawCl.root",fgkDefaultRawClustersContainerName,"Raw Clusters"); - fDataLoaders->Add(rawClustersDataLoader); - rawClustersDataLoader->SetEventFolder(fEventFolder); - rawClustersDataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* backTracksDataLoader = - new AliDataLoader(fDetectorName + ".BackTracks.root",fgkDefaultBackTracksContainerName,"Back Propagated Tracks"); - fDataLoaders->Add(backTracksDataLoader); - backTracksDataLoader->SetEventFolder(fEventFolder); - backTracksDataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* vertexDataLoader = new AliDataLoader(fDetectorName + ".Vertex.root",fgkDefaultVerticesContainerName,"Primary Vertices","O"); - fDataLoaders->Add(vertexDataLoader); - vertexDataLoader->SetEventFolder(fEventFolder); - vertexDataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* v0DataLoader = new AliDataLoader(fDetectorName + ".V0.root",fgkDefaultV0ContainerName,"V0 Vertices"); - fDataLoaders->Add(v0DataLoader); - v0DataLoader->SetEventFolder(fEventFolder); - v0DataLoader->SetFolder(GetDetectorDataFolder()); - - AliDataLoader* cascadeDataLoader = new AliDataLoader(fDetectorName + ".Cascade.root",fgkDefaultCascadeContainerName,"Cascades"); - fDataLoaders->Add(cascadeDataLoader); - cascadeDataLoader->SetEventFolder(fEventFolder); - cascadeDataLoader->SetFolder(GetDetectorDataFolder()); - + UnloadBackTracks(); + dl = GetBackTracksDataLoader(); + fDataLoaders->Remove(dl); + + UnloadVertices(); + dl = GetVertexDataLoader(); + fDataLoaders->Remove(dl); + + UnloadV0s(); + dl = GetV0DataLoader(); + fDataLoaders->Remove(dl); + + UnloadCascades(); + dl = GetCascadeDataLoader(); + fDataLoaders->Remove(dl); } -/*****************************************************************************/ -AliITSLoader::~AliITSLoader() -{ - //destructor - AliDataLoader* dl = 0; - UnloadRawClusters(); - dl = GetRawClLoader(); - fDataLoaders->Remove(dl); - - UnloadBackTracks(); - dl = GetBackTracksDataLoader(); - fDataLoaders->Remove(dl); - - UnloadVertices(); - dl = GetVertexDataLoader(); - fDataLoaders->Remove(dl); - - UnloadV0s(); - dl = GetV0DataLoader(); - fDataLoaders->Remove(dl); - - UnloadCascades(); - dl = GetCascadeDataLoader(); - fDataLoaders->Remove(dl); +//---------------------------------------------------------------------- +AliITS* AliITSLoader::GetITS(){ + // Returns the pointer to the ITS, kept on the file. A short cut metthod + // Inputs: + // none. + // Outputs: + // none. + // Returns: + // Returns a pointer to the ITS, if not found returns 0. + AliITS *its; + if(gAlice){ + its = dynamic_cast (gAlice->GetDetector( + GetDetectorName().Data())); + if(its) return its; + } // end if gAlice + AliRunLoader *rl=0; + rl = GetRunLoader(); + if(!rl) return 0; + AliRun *ar=0; + ar = rl->GetAliRun(); + if(!ar) return 0; + its = dynamic_cast (ar->GetDetector(GetDetectorName().Data())); + return its; } +//---------------------------------------------------------------------- +void AliITSLoader::SetupDigits(AliITS *its){ + // Sets up to store ITS Digits in side AliITS::fDtype TObjArray + // Inputs: + // AliITS *its Pointer to the ITS + // Outputs: + // none. + // Return: + // none. + its->SetTreeAddressD(TreeD()); +} +//---------------------------------------------------------------------- +void AliITSLoader::SetupDigits(TObjArray *digPerDet,Int_t n, + const Char_t **digclass){ + // Sets up digPerDet to store ITS Digits. + // Inputs: + // TObjArray *digPerDet A pointer to a TObject Array size>=3. + // Int_t n The size of the TObjArray and digclass array + // Char_t **digclass Array of digit class names + // Outputs: + // TObjArray *digPerDet Setup and linked to the tree of digits + // Return: + // none. + Int_t i,m; + TClonesArray *cl = 0; + TTree *td = 0; + TBranch *br = 0; + Char_t branch[13]; + const Char_t *det[3] = {"SPD","SDD","SSD"}; + + if(!digPerDet){ + Error("SetUpDigits","TObject Array digPerDet does not exist"); + return; + } // end if + m = digPerDet->GetSize(); + if(m2", + digPerDet); + return; + } // end if + td = TreeD(); + for(i=0;iAt(i)==0){ // set up TClones Array + digPerDet->AddAt(new TClonesArray(digclass[i],1000),i); + if(n==3) sprintf(branch,"ITSDigits%s",det[i]); + else sprintf(branch,"ITSDigits%d",i+1); + br = td->GetBranch(branch); + br->SetAddress(&((*digPerDet)[i])); + continue; // do next one. + } // end if + cl = dynamic_cast (digPerDet->At(i)); + if(!cl && digPerDet->At(i)!=0){ // not a TClonesArray + Error("SetUpDigits","TObject Array digPerDet-At(%d)=%p must be " + "zeroed or filled with TClonesArrays",i,digPerDet); + return; + } // end if + if(!(cl->GetClass()->GetBaseClass(AliITSdigit::Class()))){ + Error("SetUPDigits","TClones array at digPerDet[%d}=%p must be" + "derived from AliITSdigit",i,digPerDet->At(i)); + } // end if + cl->Clear(); + if(n==3) sprintf(branch,"ITSDigits%s",det[i]); + else sprintf(branch,"ITSDigits%d",i+1); + br = td->GetBranch(branch); + br->SetAddress(&((*digPerDet)[i])); + continue; + } // end for i +} +//--------------------------------------------------------------------- +AliITSdigit * AliITSLoader::GetDigit(TObjArray *digPerDet,Int_t module, + Int_t digit){ + // Gets the digit for for a specific detector type and module. + // To be used in conjustion with Setupdigits(AliITS *its). + // Inputs: + // TObjArray *digPereDet Pointer to the Array of digits + // Int_t module Module number + // Int_t digit Digit number + // Outputs: + // none. + // Return: + // returns the pointer to the digit. if zero then last digit for that + // module. + + if(digPerDet==0){ + Error("GetDigit","digPerDet=%p, module=%d, digit=%d", + digPerDet,module,digit); + return 0; + } // end if + return 0; +} +//--------------------------------------------------------------------- +AliITSdigit * AliITSLoader::GetDigit(AliITS *its,Int_t module,Int_t digit){ + // Gets the digit for for a specific detector type and module. + // To be used in conjustion with Setupdigits(AliITS *its). + // Inputs: + // AliITS *its Pointer to the ITS + // Int_t module Module number + // Int_t digit Digit number + // Outputs: + // none. + // Return: + // returns the pointer to the digit. if zero then last digit for that + // module. + //AliITSDetType *idtype; + AliITSgeom *geom = its->GetITSgeom(); + Int_t idet = geom->GetModuleType(module); + TClonesArray *digits; + + its->ResetDigits(); + TreeD()->GetEvent(module); + digits = its->DigitsAddress(idet); + if(digit>-1 && digitGetEntriesFast()){ // if in range. + return (AliITSdigit*) digits->At(digit); + } // end if + return 0; +} +//---------------------------------------------------------------------- void AliITSLoader::MakeTree(Option_t *opt){ - // invokes AliLoader::MakeTree + specific ITS tree(s) - // Valid options: H,S,D,R,T and C (C=raw clusters) - AliLoader::MakeTree(opt); - const char *oC = strstr(opt,"C"); - if (oC) MakeRawClustersContainer(); - - const char *oB = strstr(opt,"B"); - if (oB) MakeBackTracksContainer(); - - const char *oV0 = strstr(opt,"V0"); - if (oV0) MakeV0Container(); - - const char *oX = strstr(opt,"X"); - if (oX) MakeCascadeContainer(); - + // invokes AliLoader::MakeTree + specific ITS tree(s) + // Valid options: H,S,D,R,T and C (C=raw clusters) + AliLoader::MakeTree(opt); + const char *oC = strstr(opt,"C"); + if (oC) MakeRawClustersContainer(); + + const char *oB = strstr(opt,"B"); + if (oB) MakeBackTracksContainer(); + + const char *oV0 = strstr(opt,"V0"); + if (oV0) MakeV0Container(); + + const char *oX = strstr(opt,"X"); + if (oX) MakeCascadeContainer(); } diff --git a/ITS/AliITSLoader.h b/ITS/AliITSLoader.h index 15a82979956..ebba0445e9e 100644 --- a/ITS/AliITSLoader.h +++ b/ITS/AliITSLoader.h @@ -4,79 +4,129 @@ #include #include +class AliITS; +class AliITSdigit; +class TObjArray; -class AliITSLoader: public AliLoader - { - public: +class AliITSLoader: public AliLoader{ + public: AliITSLoader(); AliITSLoader(const Char_t *name,const Char_t *topfoldername); AliITSLoader(const Char_t *name,TFolder *topfolder); - + virtual ~AliITSLoader(); void MakeTree(Option_t* opt); + // General ITS shortcuts + virtual AliITS* GetITS(); // Return pointer to the ITS. + virtual void SetupDigits(AliITS *its); // Sets up digit using AliITS + virtual void SetupDigits(TObjArray *digPerDet,Int_t n, + const Char_t **digclass); // Sets up digits + // Gets the AliITSdigit for a given module and a specific digit in that + // module. Array of digits stored in AliITS (must use + // SetupDigits(AliITS *its)). + virtual AliITSdigit* GetDigit(AliITS *its,Int_t module,Int_t digit); + // Gets the AliITSdigit for a given module and a specific digit in that + // module. Array of digits stored in a user defined TObjArray digPerDet + virtual AliITSdigit* GetDigit(TObjArray *digPerDet,Int_t module,Int_t digit); + //Raw Clusters AliDataLoader* GetRawClLoader() {return GetDataLoader("Raw Clusters");} - virtual void CleanRawClusters() {GetRawClLoader()->GetBaseLoader(0)->Clean();} - Int_t LoadRawClusters(Option_t* opt=""){return GetRawClLoader()->GetBaseLoader(0)->Load(opt);} - void SetRawClustersFileName(const TString& fname){GetRawClLoader()->SetFileName(fname);} - TTree* TreeC(){ return GetRawClLoader()->Tree();} // returns a pointer to the tree of RawClusters - void UnloadRawClusters(){GetRawClLoader()->GetBaseLoader(0)->Unload();} - virtual Int_t WriteRawClusters(Option_t* opt=""){return GetRawClLoader()->GetBaseLoader(0)->WriteData(opt);} + virtual void CleanRawClusters() { + GetRawClLoader()->GetBaseLoader(0)->Clean();} + Int_t LoadRawClusters(Option_t* opt=""){ + return GetRawClLoader()->GetBaseLoader(0)->Load(opt);} + void SetRawClustersFileName(const TString& fname){ + GetRawClLoader()->SetFileName(fname);} + // returns a pointer to the tree of RawClusters + TTree* TreeC(){ return GetRawClLoader()->Tree();} + void UnloadRawClusters(){ + GetRawClLoader()->GetBaseLoader(0)->Unload();} + virtual Int_t WriteRawClusters(Option_t* opt=""){ + return GetRawClLoader()->GetBaseLoader(0)->WriteData(opt);} //Vertices - AliDataLoader* GetVertexDataLoader() {return GetDataLoader("Primary Vertices");} - virtual void CleanVertices() {GetVertexDataLoader()->GetBaseLoader(0)->Clean();} - Int_t LoadVertices(Option_t* opt=""){return GetVertexDataLoader()->GetBaseLoader(0)->Load(opt);} - void SetVerticesFileName(const TString& fname){GetVertexDataLoader()->SetFileName(fname);} - void UnloadVertices(){GetVertexDataLoader()->GetBaseLoader(0)->Unload();} - virtual Int_t WriteVertices(Option_t* opt=""){return GetVertexDataLoader()->GetBaseLoader(0)->WriteData(opt);} - virtual Int_t PostVertex(AliESDVertex *ptr){return GetVertexDataLoader()->GetBaseLoader(0)->Post(ptr);} - // virtual void SetVerticesContName(const char *name){GetVertexDataLoader()->GetBaseLoader(0)->SetName(name);} - AliESDVertex *GetVertex(){return static_cast (GetVertexDataLoader()->GetBaseLoader(0)->Get());} + AliDataLoader* GetVertexDataLoader() { + return GetDataLoader("Primary Vertices");} + virtual void CleanVertices() { + GetVertexDataLoader()->GetBaseLoader(0)->Clean();} + Int_t LoadVertices(Option_t* opt=""){ + return GetVertexDataLoader()->GetBaseLoader(0)->Load(opt);} + void SetVerticesFileName(const TString& fname){ + GetVertexDataLoader()->SetFileName(fname);} + void UnloadVertices(){ + GetVertexDataLoader()->GetBaseLoader(0)->Unload();} + virtual Int_t WriteVertices(Option_t* opt=""){ + return GetVertexDataLoader()->GetBaseLoader(0)->WriteData(opt);} + virtual Int_t PostVertex(AliESDVertex *ptr){ + return GetVertexDataLoader()->GetBaseLoader(0)->Post(ptr);} + // virtual void SetVerticesContName(const char *name){ + // GetVertexDataLoader()->GetBaseLoader(0)->SetName(name);} + AliESDVertex *GetVertex(){ + return static_cast (GetVertexDataLoader()-> + GetBaseLoader(0)->Get());} //V0s AliDataLoader* GetV0DataLoader() {return GetDataLoader("V0 Vertices");} virtual void CleanV0s() {GetV0DataLoader()->GetBaseLoader(0)->Clean();} - Int_t LoadV0s(Option_t* opt=""){return GetV0DataLoader()->GetBaseLoader(0)->Load(opt);} - void SetV0FileName(const TString& fname){GetV0DataLoader()->SetFileName(fname);} + Int_t LoadV0s(Option_t* opt=""){ + return GetV0DataLoader()->GetBaseLoader(0)->Load(opt);} + void SetV0FileName(const TString& fname){ + GetV0DataLoader()->SetFileName(fname);} void UnloadV0s(){GetV0DataLoader()->GetBaseLoader(0)->Unload();} - virtual Int_t WriteV0s(Option_t* opt=""){return GetV0DataLoader()->GetBaseLoader(0)->WriteData(opt);} + virtual Int_t WriteV0s(Option_t* opt=""){ + return GetV0DataLoader()->GetBaseLoader(0)->WriteData(opt);} TTree* TreeV0(){ return GetV0DataLoader()->Tree();} //Cascades AliDataLoader* GetCascadeDataLoader() {return GetDataLoader("Cascades");} - virtual void CleanCascades() {GetCascadeDataLoader()->GetBaseLoader(0)->Clean();} - Int_t LoadCascades(Option_t* opt=""){return GetCascadeDataLoader()->GetBaseLoader(0)->Load(opt);} - void SetCascadeFileName(const TString& fname){GetCascadeDataLoader()->SetFileName(fname);} - void UnloadCascades(){GetCascadeDataLoader()->GetBaseLoader(0)->Unload();} - virtual Int_t WriteCascades(Option_t* opt=""){return GetCascadeDataLoader()->GetBaseLoader(0)->WriteData(opt);} + virtual void CleanCascades() { + GetCascadeDataLoader()->GetBaseLoader(0)->Clean();} + Int_t LoadCascades(Option_t* opt=""){ + return GetCascadeDataLoader()->GetBaseLoader(0)->Load(opt);} + void SetCascadeFileName(const TString& fname){ + GetCascadeDataLoader()->SetFileName(fname);} + void UnloadCascades(){ + GetCascadeDataLoader()->GetBaseLoader(0)->Unload();} + virtual Int_t WriteCascades(Option_t* opt=""){ + return GetCascadeDataLoader()->GetBaseLoader(0)->WriteData(opt);} TTree* TreeX(){ return GetCascadeDataLoader()->Tree();} //Back Propagated Tracks - AliDataLoader* GetBackTracksDataLoader() {return GetDataLoader("Back Propagated Tracks");} - virtual void CleanBackTracks() {GetBackTracksDataLoader()->GetBaseLoader(0)->Clean();} - Int_t LoadBackTracks(Option_t* opt=""){return GetBackTracksDataLoader()->GetBaseLoader(0)->Load(opt);} - void SetBackTracksFileName(const TString& fname){GetBackTracksDataLoader()->SetFileName(fname);} - TTree* TreeB(){ return GetBackTracksDataLoader()->Tree();} // returns a pointer to the tree of BackTracks - void UnloadBackTracks(){GetBackTracksDataLoader()->GetBaseLoader(0)->Unload();} - virtual Int_t WriteBackTracks(Option_t* opt=""){return GetBackTracksDataLoader()->GetBaseLoader(0)->WriteData(opt);} - - - protected: + AliDataLoader* GetBackTracksDataLoader() { + return GetDataLoader("Back Propagated Tracks");} + virtual void CleanBackTracks() { + GetBackTracksDataLoader()->GetBaseLoader(0)->Clean();} + Int_t LoadBackTracks(Option_t* opt=""){ + return GetBackTracksDataLoader()->GetBaseLoader(0)->Load(opt);} + void SetBackTracksFileName(const TString& fname){ + GetBackTracksDataLoader()->SetFileName(fname);} + // returns a pointer to the tree of BackTracks + TTree* TreeB(){ return GetBackTracksDataLoader()->Tree();} + void UnloadBackTracks(){ + GetBackTracksDataLoader()->GetBaseLoader(0)->Unload();} + virtual Int_t WriteBackTracks(Option_t* opt=""){ + return GetBackTracksDataLoader()->GetBaseLoader(0)->WriteData(opt);} + + protected: // METHODS virtual void MakeRawClustersContainer() {GetRawClLoader()->MakeTree();} - Int_t PostRawClusters(){return GetRawClLoader()->GetBaseLoader(0)->Post();} + Int_t PostRawClusters(){ + return GetRawClLoader()->GetBaseLoader(0)->Post();} - virtual void MakeBackTracksContainer() {GetBackTracksDataLoader()->MakeTree();} - Int_t PostBackTracks(){return GetBackTracksDataLoader()->GetBaseLoader(0)->Post();} + virtual void MakeBackTracksContainer() { + GetBackTracksDataLoader()->MakeTree();} + Int_t PostBackTracks(){ + return GetBackTracksDataLoader()->GetBaseLoader(0)->Post();} virtual void MakeV0Container() {GetV0DataLoader()->MakeTree();} - Int_t PostV0s(){return GetV0DataLoader()->GetBaseLoader(0)->Post();} + Int_t PostV0s(){ + return GetV0DataLoader()->GetBaseLoader(0)->Post();} virtual void MakeCascadeContainer() {GetCascadeDataLoader()->MakeTree();} - Int_t PostCascades(){return GetCascadeDataLoader()->GetBaseLoader(0)->Post();} + Int_t PostCascades(){ + return GetCascadeDataLoader()->GetBaseLoader(0)->Post();} // DATA static const TString fgkDefaultRawClustersContainerName; //default for Raw Clusters container name @@ -85,9 +135,7 @@ class AliITSLoader: public AliLoader static const TString fgkDefaultV0ContainerName; //default for V0 container name static const TString fgkDefaultCascadeContainerName; //default fo cascade container name - ClassDef(AliITSLoader,3) - }; + ClassDef(AliITSLoader,3) // Loader for additional ITS specific trees. +}; #endif - - diff --git a/ITS/AliITSdcsSSD.cxx b/ITS/AliITSdcsSSD.cxx index 3ec6e488a63..eca282a8e04 100644 --- a/ITS/AliITSdcsSSD.cxx +++ b/ITS/AliITSdcsSSD.cxx @@ -19,19 +19,19 @@ AliITSdcsSSD::AliITSdcsSSD(){ AliITSdcsSSD::AliITSdcsSSD(AliITSsegmentation *seg, AliITSresponse *resp){ // Standard constructor - fNstrips = seg->Npx(); + fNstrips =(Float_t) (((AliITSsegmentationSSD*)seg)->Npx()); fInvalidP = new TArrayS(); fInvalidN = new TArrayS(); - Int_t npar=resp->NDetParam(); + Int_t npar=((AliITSresponseSSD*)resp)->NDetParam(); if (npar < 6) { Warning("AliITSdcsSSD","I need 6 parameters "); npar=6; } // end if - Float_t *detpar= new Float_t[npar]; - resp->GetDetParam(detpar); + Double_t *detpar= new Double_t[npar]; + ((AliITSresponseSSD*)resp)->GetDetParam(detpar); fNInvalid = detpar[0]; fISigma = detpar[1]; @@ -42,7 +42,7 @@ AliITSdcsSSD::AliITSdcsSSD(AliITSsegmentation *seg, AliITSresponse *resp){ fCouplingNL = detpar[5]; char opt[30],dummy[20]; - resp->ParamOptions(opt,dummy); + ((AliITSresponseSSD*)resp)->ParamOptions(opt,dummy); if (strstr(opt,"SetInvalid")) SetInvalidMC(fNInvalid,fISigma); delete [] detpar; diff --git a/ITS/AliITSgeom.h b/ITS/AliITSgeom.h index da35309e8c7..cadb61d17e7 100644 --- a/ITS/AliITSgeom.h +++ b/ITS/AliITSgeom.h @@ -24,7 +24,7 @@ #include "AliITSgeomMatrix.h" -typedef enum {kSPD=0, kSDD=1, kSSD=2, kSSDp=3,kSDDp=4} AliITSDetector; +typedef enum {kND=-1,kSPD=0, kSDD=1, kSSD=2, kSSDp=3,kSDDp=4} AliITSDetector; //_______________________________________________________________________ diff --git a/ITS/AliITSresponse.h b/ITS/AliITSresponse.h index ca61ec9c400..7f2f8d072df 100644 --- a/ITS/AliITSresponse.h +++ b/ITS/AliITSresponse.h @@ -28,44 +28,22 @@ class AliITSresponse : public TObject { // Configuration methods // - // Set Electronics - virtual void SetElectronics(Int_t) = 0; - // Get Electronics - virtual Int_t Electronics() const = 0; - - // Set maximum Adc-count value - virtual void SetMaxAdc(Float_t) = 0; - // Get maximum Adc-count value - virtual Float_t MaxAdc() const = 0; - - // Set maximum Adc-top value - virtual void SetDynamicRange(Float_t) = 0; - // Get maximum Adc-top value - virtual Float_t DynamicRange() const = 0; - - // Set Charge Loss Linear Coefficient - virtual void SetChargeLoss(Float_t) = 0; - // Get Charge Loss Linear Coefficient - virtual Float_t ChargeLoss() const = 0; - // Set GeVcharge value - virtual void SetGeVToCharge(Float_t gc=2.778E+8){fGeVcharge = gc;} + virtual void SetGeVToCharge(Double_t gc=2.778E+8){fGeVcharge = gc;} // Returns the value fGeVcharge - virtual Float_t GetGeVToCharge() const {return fGeVcharge;} + virtual Double_t GetGeVToCharge() const {return fGeVcharge;} // Converts deposited energy to number of electrons liberated - virtual Float_t GeVToCharge(Float_t gev) const {return gev*fGeVcharge;} + virtual Double_t GeVToCharge(Double_t gev) const {return gev*fGeVcharge;} // Diffusion coefficient - virtual void SetDiffCoeff(Float_t, Float_t) = 0; + virtual void SetDiffCoeff(Double_t, Double_t) = 0; // Get diffusion coefficients - virtual void DiffCoeff(Float_t &,Float_t &) const = 0; + virtual void DiffCoeff(Double_t &,Double_t &) const = 0; // Temperature in [degree K] - virtual void SetTemperature(Float_t t=300.0) {fT = t;} + virtual void SetTemperature(Double_t t=300.0) {fT = t;} // Get temperature [degree K] - virtual Float_t Temperature() const {return fT;} - // Type of data - real or simulated - virtual void SetDataType(const char *data="simulated") {fDataType=data;} + virtual Double_t Temperature() const {return fT;} // Set the impurity concentrations in [#/cm^3] virtual void SetImpurity(Double_t n=0.0){fN = n;} // Returns the impurity consentration in [#/cm^3] @@ -77,68 +55,71 @@ class AliITSresponse : public TObject { virtual void SetDistanceOverVoltage(Double_t dv=0.000375){fdv = dv;} // Returns the ration distance/voltage virtual Double_t DistanceOverVoltage() const {return fdv;} + // Get data type virtual const char *DataType() const {return fDataType.Data();} - + // Type of data - real or simulated + virtual void SetDataType(const char *data="simulated") {fDataType=data;} // Set parameters options: "same" or read from "file" or "SetInvalid" or... virtual void SetParamOptions(const char*,const char*) = 0; // Set noise parameters - virtual void SetNoiseParam(Float_t, Float_t) = 0; + virtual void SetNoiseParam(Double_t, Double_t) = 0; // Number of parameters to be set virtual void SetNDetParam(Int_t) = 0; // Set detector parameters: gain, coupling ... - virtual void SetDetParam(Float_t *) = 0; + virtual void SetDetParam(Double_t *) = 0; // Parameters options virtual void ParamOptions(char *,char*) const = 0; virtual Int_t NDetParam() const = 0; - virtual void GetDetParam(Float_t *) const = 0; - virtual void GetNoiseParam(Float_t&, Float_t&) const = 0; + virtual void GetDetParam(Double_t *) const = 0; + virtual void GetNoiseParam(Double_t&, Double_t&) const = 0; // Zero-suppression option - could be 1D, 2D or non-ZeroSuppressed virtual void SetZeroSupp(const char*) = 0; // Get zero-suppression option virtual const char *ZeroSuppOption() const = 0; // Set thresholds - virtual void SetThresholds(Float_t, Float_t) = 0; - virtual void Thresholds(Float_t &, Float_t &) const = 0; + virtual void SetThresholds(Double_t, Double_t) = 0; + virtual void Thresholds(Double_t &, Double_t &) const = 0; // Set filenames - virtual void SetFilenames(const char *f1="",const char *f2="",const char *f3=""){ + virtual void SetFilenames(const char *f1="",const char *f2="", + const char *f3=""){ // Set filenames - input, output, parameters .... fFileName1=f1; fFileName2=f2; fFileName3=f3;} // Filenames virtual void Filenames(char* input,char* baseline,char* param) { - strcpy(input,fFileName1.Data()); strcpy(baseline,fFileName2.Data()); - strcpy(param,fFileName3.Data());} + strcpy(input,fFileName1.Data()); strcpy(baseline,fFileName2.Data()); + strcpy(param,fFileName3.Data());} - virtual void SetDriftSpeed(Float_t p1) = 0; - virtual Float_t DriftSpeed() const = 0; - virtual void SetOutputOption(Bool_t write=kFALSE) {// set output option - fWrite = write;} + virtual Double_t DriftSpeed() const {return SpeedElectron();}; + // set output option + virtual void SetOutputOption(Bool_t write=kFALSE) {fWrite = write;} + virtual Bool_t OutputOption() const {return fWrite;} virtual Bool_t Do10to8() const {return kTRUE;} virtual void GiveCompressParam(Int_t *) const =0; // // Detector type response methods // Set number of sigmas over which cluster disintegration is performed - virtual void SetNSigmaIntegration(Float_t) = 0; + virtual void SetNSigmaIntegration(Double_t) = 0; // Get number of sigmas over which cluster disintegration is performed - virtual Float_t NSigmaIntegration() const = 0; + virtual Double_t NSigmaIntegration() const = 0; // Set number of bins for the gaussian lookup table virtual void SetNLookUp(Int_t) = 0; // Get number of bins for the gaussian lookup table virtual Int_t GausNLookUp() const {return 0;} // Get scaling factor for bin i-th from the gaussian lookup table - virtual Float_t GausLookUp(Int_t) const {return 0.;} + virtual Double_t GausLookUp(Int_t) const {return 0.;} // Set sigmas of the charge spread function - virtual void SetSigmaSpread(Float_t, Float_t) = 0; + virtual void SetSigmaSpread(Double_t, Double_t) = 0; // Get sigmas for the charge spread - virtual void SigmaSpread(Float_t &,Float_t &) const = 0; + virtual void SigmaSpread(Double_t &,Double_t &) const = 0; // Pulse height from scored quantity (eloss) - virtual Float_t IntPH(Float_t) const {return 0.;} + virtual Double_t IntPH(Double_t) const {return 0.;} // Charge disintegration - virtual Float_t IntXZ(AliITSsegmentation *) const {return 0.;} + virtual Double_t IntXZ(AliITSsegmentation *) const {return 0.;} // Electron mobility in Si. [cm^2/(Volt Sec)]. T in degree K, N in #/cm^3 virtual Double_t MobilityElectronSiEmp() const ; // Hole mobility in Si. [cm^2/(Volt Sec)] T in degree K, N in #/cm^3 diff --git a/ITS/AliITSresponseSDD.cxx b/ITS/AliITSresponseSDD.cxx index 6f3dc7b6f6f..3dffc378cf5 100644 --- a/ITS/AliITSresponseSDD.cxx +++ b/ITS/AliITSresponseSDD.cxx @@ -32,19 +32,19 @@ const Int_t AliITSresponseSDD::fgkModules; const Int_t AliITSresponseSDD::fgkChips; const Int_t AliITSresponseSDD::fgkChannels; const Int_t AliITSresponseSDD::fgkMaxAdcDefault = 1024; -const Float_t AliITSresponseSDD::fgkDynamicRangeDefault = 132.; -const Float_t AliITSresponseSDD::fgkfChargeLossDefault = 0; -const Float_t AliITSresponseSDD::fgkDiffCoeffDefault = 3.23; -const Float_t AliITSresponseSDD::fgkDiffCoeff1Default = 30.; -const Float_t AliITSresponseSDD::fgkTemperatureDefault = 296.; +const Double_t AliITSresponseSDD::fgkDynamicRangeDefault = 132.; +const Double_t AliITSresponseSDD::fgkfChargeLossDefault = 0; +const Double_t AliITSresponseSDD::fgkDiffCoeffDefault = 3.23; +const Double_t AliITSresponseSDD::fgkDiffCoeff1Default = 30.; +const Double_t AliITSresponseSDD::fgkTemperatureDefault = 296.; const TString AliITSresponseSDD::fgkParam1Default = "same"; const TString AliITSresponseSDD::fgkParam2Default = "same"; -const Float_t AliITSresponseSDD::fgkNoiseDefault = 10.; -const Float_t AliITSresponseSDD::fgkBaselineDefault = 20.; +const Double_t AliITSresponseSDD::fgkNoiseDefault = 10.; +const Double_t AliITSresponseSDD::fgkBaselineDefault = 20.; const TString AliITSresponseSDD::fgkOptionDefault = "1D"; -const Float_t AliITSresponseSDD::fgkMinValDefault = 4; -const Float_t AliITSresponseSDD::fgkDriftSpeedDefault = 7.3; -const Float_t AliITSresponseSDD::fgkNsigmasDefault = 3.; +const Double_t AliITSresponseSDD::fgkMinValDefault = 4; +const Double_t AliITSresponseSDD::fgkDriftSpeedDefault = 7.3; +const Double_t AliITSresponseSDD::fgkNsigmasDefault = 3.; const Int_t AliITSresponseSDD::fgkNcompsDefault = 121; //______________________________________________________________________ ClassImp(AliITSresponseSDD) @@ -191,7 +191,7 @@ void AliITSresponseSDD::SetNLookUp(Int_t p1){ fNcomps=p1; fGaus = new TArrayF(fNcomps+1); for(Int_t i=0; i<=fNcomps; i++) { - Float_t x = -fNsigmas + (2.*i*fNsigmas)/(fNcomps-1); + Double_t x = -fNsigmas + (2.*i*fNsigmas)/(fNcomps-1); (*fGaus)[i] = exp(-((x*x)/2)); // cout << "fGaus[" << i << "]: " << fGaus->At(i) << endl; } diff --git a/ITS/AliITSresponseSDD.h b/ITS/AliITSresponseSDD.h index c4734ccc312..dbc191cad8c 100644 --- a/ITS/AliITSresponseSDD.h +++ b/ITS/AliITSresponseSDD.h @@ -14,53 +14,53 @@ // response for SDD class AliITSresponseSDD : public AliITSresponse { - public: - // - // Configuration methods - // - + public: + // + // Configuration methods + // AliITSresponseSDD(); AliITSresponseSDD(const char *dataType); virtual ~AliITSresponseSDD(); -// Implementation of virtual member functions declared in AliITSresponse + // Implementation of virtual member functions declared in AliITSresponse virtual void SetElectronics(Int_t p1=1) {fElectronics=p1; /* Electronics: Pascal (1) or OLA (2) */ } virtual Int_t Electronics() const {// Electronics: 1 = Pascal; 2 = OLA return fElectronics;} - virtual void SetMaxAdc(Float_t p1) {// Adc-count saturation value + virtual void SetMaxAdc(Double_t p1) {// Adc-count saturation value fMaxAdc=p1;} - virtual Float_t MaxAdc() const {// Get maximum Adc-count value + virtual Double_t MaxAdc() const {// Get maximum Adc-count value return fMaxAdc;} - virtual void SetChargeLoss(Float_t p1) { + virtual void SetChargeLoss(Double_t p1) { // Set Linear Charge Loss Steepness // 0.01 for 20% fChargeLoss=p1;} - Float_t ChargeLoss() const {// Get Charge Loss Coefficient + Double_t ChargeLoss() const {// Get Charge Loss Coefficient return fChargeLoss;} - virtual void SetDynamicRange(Float_t p1) {// Set Dynamic Range + virtual void SetDynamicRange(Double_t p1) {// Set Dynamic Range fDynamicRange = p1;} - virtual Float_t DynamicRange() const {// Get Dynamic Range + virtual Double_t DynamicRange() const {// Get Dynamic Range return fDynamicRange;} // Diffusion coefficients - virtual void SetDiffCoeff(Float_t p1, Float_t p2) + virtual void SetDiffCoeff(Double_t p1, Double_t p2) {fDiffCoeff=p1;fDiffCoeff1=p2;} // Get diffusion coefficients - virtual void DiffCoeff(Float_t&diff,Float_t&diff1) const + virtual void DiffCoeff(Double_t&diff,Double_t&diff1) const {diff = fDiffCoeff;diff1 = fDiffCoeff1;} - virtual void SetDriftSpeed(Float_t p1) {// Drift velocity + virtual void SetDriftSpeed(Double_t p1) {// Drift velocity fDriftSpeed=p1;} - virtual Float_t DriftSpeed() const {// drift speed + virtual Double_t DriftSpeed() const {// drift speed return fDriftSpeed;} virtual void SetParamOptions(const char *opt1,const char *opt2){ // Parameters: "same" or read from "file" fParam1=opt1; fParam2=opt2;} virtual void ParamOptions(char *opt1,char *opt2) const {// options strcpy(opt1,fParam1.Data()); strcpy(opt2,fParam2.Data());} - virtual void SetNoiseParam(Float_t n, Float_t b){ + virtual void SetNoiseParam(Double_t n, Double_t b){ // Noise and baseline // 10 for ALICE with beam test measurements 2001 fNoise=n; fBaseline=b;} - virtual void GetNoiseParam(Float_t &n, Float_t &b) const {// get noise param - n=fNoise; b=fBaseline;} + // get noise param + virtual void GetNoiseParam(Double_t &n, Double_t &b) const + {n=fNoise; b=fBaseline;} virtual Bool_t Do10to8() const {// get 10 to 8 compression option return fBitComp;} void SetZeroSupp (const char *opt) { @@ -68,38 +68,38 @@ class AliITSresponseSDD : public AliITSresponse { fOption=opt;} const char *ZeroSuppOption() const {// Get zero-suppression option return fOption.Data();} - virtual void SetThresholds(Float_t mv, Float_t /* b */){ + virtual void SetThresholds(Double_t mv, Double_t /* b */){ // Min value used in 2D - could be used as a threshold setting fMinVal = mv;} - virtual void Thresholds(Float_t & mv, Float_t & /* b */) const + virtual void Thresholds(Double_t & mv, Double_t & /* b */) const {mv = fMinVal;} virtual void GiveCompressParam(Int_t *x) const; // Detector type response methods - virtual void SetNSigmaIntegration(Float_t p1) { + virtual void SetNSigmaIntegration(Double_t p1) { // Set number of sigmas over which cluster disintegration is performed fNsigmas=p1;} - virtual Float_t NSigmaIntegration() const { + virtual Double_t NSigmaIntegration() const { // Get number of sigmas over which cluster disintegration is performed return fNsigmas;} virtual void SetNLookUp(Int_t p1); // Get number of intervals in which the gaussian lookup table is divided virtual Int_t GausNLookUp() const {return fNcomps;} - virtual Float_t GausLookUp(Int_t i) const { + virtual Double_t GausLookUp(Int_t i) const { if(i<0 || i>=fNcomps) return 0.;return fGaus->At(i);} //Declaration of member functions peculiar to this class Int_t Convert8to10(Int_t signal) const; //undo 10 to 8 bit SDD compresion - void SetNoiseAfterElectronics(Float_t n=2.38){ + void SetNoiseAfterElectronics(Double_t n=2.38){ // Noise after electronics (ADC units) // 2.36 for ALICE from beam test measurements 2001 fNoiseAfterEl=n;} - Float_t GetNoiseAfterElectronics() const { + Double_t GetNoiseAfterElectronics() const { // Noise after electronics (ADC units) return fNoiseAfterEl;} - void SetJitterError(Float_t jitter=20) { + void SetJitterError(Double_t jitter=20) { // set Jitter error (20 um for ALICE from beam test measurements 2001) fJitterError=jitter;} - Float_t JitterError() const {// set Jitter error + Double_t JitterError() const {// set Jitter error return fJitterError;} void SetDo10to8(Bool_t bitcomp=kTRUE) { // set the option for 10 to 8 bit compression @@ -110,27 +110,28 @@ class AliITSresponseSDD : public AliITSresponse { Int_t GetDeadModules() const { return fDeadModules; } Int_t GetDeadChips() const { return fDeadChips; } Int_t GetDeadChannels() const { return fDeadChannels; } - Float_t Gain(Int_t mod,Int_t chip,Int_t ch)const {return fGain[mod][chip][ch]; } + Double_t Gain(Int_t mod,Int_t chip,Int_t ch)const + {return fGain[mod][chip][ch]; } // these functions should be move to AliITSsegmentationSDD - const Int_t Modules() const{return fgkModules;}// Total number of SDD modules + const Int_t Modules()const{return fgkModules;}//Total number of SDD modules const Int_t Chips() const{return fgkChips;} // Number of chips/module - const Int_t Channels() const { return fgkChannels;}// Number of channels/chip + const Int_t Channels() const{ return fgkChannels;}//Number of channels/chip //******** void PrintGains(); void Print(); // not implemented virtual methods (devlared in the mother class - virtual void SetDetParam(Float_t *) + virtual void SetDetParam(Double_t *) {NotImplemented("SetDetParam");} - virtual void GetDetParam(Float_t *) const + virtual void GetDetParam(Double_t *) const {NotImplemented("GetDetParam");} virtual void SetNDetParam(Int_t /* n */) {NotImplemented("SetNDetParam");} virtual Int_t NDetParam() const {NotImplemented("NDetParam"); return 0;} - virtual void SetSigmaSpread(Float_t, Float_t) + virtual void SetSigmaSpread(Double_t, Double_t) {NotImplemented("SetSigmaSpread");} - virtual void SigmaSpread(Float_t & /* p1 */,Float_t & /* p2 */) const + virtual void SigmaSpread(Double_t & /* p1 */,Double_t & /* p2 */) const {NotImplemented("SigmaSpread");} protected: @@ -140,43 +141,43 @@ class AliITSresponseSDD : public AliITSresponse { static const Int_t fgkChannels = 64; // Number of channels/chip //******* static const Int_t fgkMaxAdcDefault; // default for fMaxAdc - static const Float_t fgkDynamicRangeDefault; // default for fDynamicRange - static const Float_t fgkfChargeLossDefault; // default for fChargeLoss - static const Float_t fgkDiffCoeffDefault; // default for fDiffCoeff - static const Float_t fgkDiffCoeff1Default; // default for fDiffCoeff1 - static const Float_t fgkTemperatureDefault; // default for fT (Kelvin) + static const Double_t fgkDynamicRangeDefault; // default for fDynamicRange + static const Double_t fgkfChargeLossDefault; // default for fChargeLoss + static const Double_t fgkDiffCoeffDefault; // default for fDiffCoeff + static const Double_t fgkDiffCoeff1Default; // default for fDiffCoeff1 + static const Double_t fgkTemperatureDefault; // default for fT (Kelvin) static const TString fgkParam1Default; // default for fParam1 static const TString fgkParam2Default; // default for fParam2 - static const Float_t fgkNoiseDefault; // default for fNoise - static const Float_t fgkBaselineDefault; // default for fBaseline + static const Double_t fgkNoiseDefault; // default for fNoise + static const Double_t fgkBaselineDefault; // default for fBaseline static const TString fgkOptionDefault; // default for fOption - static const Float_t fgkMinValDefault; // default for fMinVal - static const Float_t fgkDriftSpeedDefault; // default for fDriftSpeed - static const Float_t fgkNsigmasDefault; //default for fNsigmas + static const Double_t fgkMinValDefault; // default for fMinVal + static const Double_t fgkDriftSpeedDefault; // default for fDriftSpeed + static const Double_t fgkNsigmasDefault; //default for fNsigmas static const Int_t fgkNcompsDefault; //default for fNcomps // Int_t fDeadModules; // Total number of dead SDD modules Int_t fDeadChips; // Number of dead chips Int_t fDeadChannels; // Number of dead channels - Float_t fGain[fgkModules][fgkChips][fgkChannels]; // Array for channel gains + Double_t fGain[fgkModules][fgkChips][fgkChannels];//Array for channel gains Int_t fCPar[8]; // Hardware compression parameters - Float_t fNoise; // Noise - Float_t fBaseline; // Baseline - Float_t fNoiseAfterEl; // Noise after electronics - Float_t fJitterError; // jitter error - Float_t fDynamicRange; // Set Dynamic Range - Float_t fChargeLoss; // Set Linear Coefficient for Charge Loss - Float_t fDriftSpeed; // Drift velocity + Double_t fNoise; // Noise + Double_t fBaseline; // Baseline + Double_t fNoiseAfterEl; // Noise after electronics + Double_t fJitterError; // jitter error + Double_t fDynamicRange; // Set Dynamic Range + Double_t fChargeLoss; // Set Linear Coefficient for Charge Loss + Double_t fDriftSpeed; // Drift velocity Int_t fElectronics; // Electronics - Float_t fMaxAdc; // Adc saturation value - Float_t fDiffCoeff; // Diffusion Coefficient (scaling the time) - Float_t fDiffCoeff1; // Diffusion Coefficient (constant term) - Float_t fNsigmas; // Number of sigmas over which charge disintegration + Double_t fMaxAdc; // Adc saturation value + Double_t fDiffCoeff; // Diffusion Coefficient (scaling the time) + Double_t fDiffCoeff1; // Diffusion Coefficient (constant term) + Double_t fNsigmas; // Number of sigmas over which charge disintegration // is performed TArrayF *fGaus; // Gaussian lookup table for signal generation Int_t fNcomps; // Number of samplings along the gaussian - Float_t fMinVal; // Min value used in 2D zero-suppression algo + Double_t fMinVal; // Min value used in 2D zero-suppression algo Bool_t fBitComp; // 10 to 8 bit compression option TString fOption; // Zero-suppresion option (1D, 2D or none) TString fParam1; // Read baselines from file option diff --git a/ITS/AliITSresponseSPD.cxx b/ITS/AliITSresponseSPD.cxx index 3ef7697bf0e..0c88001b106 100644 --- a/ITS/AliITSresponseSPD.cxx +++ b/ITS/AliITSresponseSPD.cxx @@ -22,19 +22,47 @@ #include "AliITSresponseSPD.h" -const Float_t AliITSresponseSPD::fgkDiffCoeffDefault = 0.; -const Float_t AliITSresponseSPD::fgkThreshDefault = 2000.; -const Float_t AliITSresponseSPD::fgkSigmaDefault = 280.; +const Double_t AliITSresponseSPD::fgkDiffCoeffDefault = 0.; +const Double_t AliITSresponseSPD::fgkThreshDefault = 2000.; +const Double_t AliITSresponseSPD::fgkSigmaDefault = 280.; ClassImp(AliITSresponseSPD) //______________________________________________________________________ -AliITSresponseSPD::AliITSresponseSPD(){ +AliITSresponseSPD::AliITSresponseSPD(): +AliITSresponse(), +fBaseline(0.0), +fNoise(0.0), +fThresh(fgkThreshDefault), +fSigma(fgkSigmaDefault), +fCouplCol(0.0), +fCouplRow(0.0), +fDeadPixels(0.01){ // constructor SetThresholds(fgkThreshDefault,fgkSigmaDefault); - SetDiffCoeff(fgkDiffCoeffDefault,0.); + //SetDiffCoeff(fgkDiffCoeffDefault,0.); SetNoiseParam(0.,0.); - SetDataType(); + SetDataType("simulated"); SetFractionDead(); } +//_________________________________________________________________________ +Bool_t AliITSresponseSPD::IsPixelDead(Int_t mod,Int_t ix,Int_t iz) const { + // Returns kTRUE if pixel is dead + // Inputs: + // Int_t mod module number + // Int_t ix x pixel number + // Int_t iz z pixel number + // Outputs: + // none. + // Return: + // kFALSE if pixel is alive, or kTRUE if pixel is dead. + Bool_t dead = kFALSE; + Int_t seed; + static TRandom ran; // don't use gRandom. This must not be a true randome + // sequence. These sequence must be random one and then fully repetable. + seed = mod*256*256+iz*256+ix; + ran.SetSeed(seed); + if(ran.Rndm(0)Gaus();} + + //Declaration of member functions peculiar to this class // Sets the fraction of Dead SPD Pixels - void SetFractionDead(Float_t d=0.01){ fDeadPixels = d;} + void SetFractionDead(Double_t d=0.01){ fDeadPixels = d;} // Retruns the fraction of Dead SPD Pixels - Float_t GetFractionDead() const {return fDeadPixels;} + Double_t GetFractionDead() const {return fDeadPixels;} + // Returns a logical if a pixels is dead or not + Bool_t IsPixelDead(Int_t mod,Int_t ix,Int_t iz) const ; //abstract methods in AliITSresponse not implemented in this class - virtual void SetDriftSpeed(Float_t /* p1 */) - {NotImplemented("SetDriftSpeed");} - virtual Float_t DriftSpeed() const - {NotImplemented("DrifSpeed"); return 0.;} + virtual void SetDiffCoeff(Double_t,Double_t) + {NotImplemented("GiveCompressParam");} + virtual void DiffCoeff(Double_t &,Double_t &)const + {NotImplemented("GiveCompressParam");} virtual void GiveCompressParam(Int_t *) const {NotImplemented("GiveCompressParam");} - virtual void SetElectronics(Int_t /* i */) - {NotImplemented("SetElectronics");} - virtual Int_t Electronics() const {NotImplemented("Electronics"); return 0;} - virtual void SetMaxAdc(Float_t /* adc */) {NotImplemented("SetMaxAdc");} - virtual Float_t MaxAdc() const {NotImplemented("MaxAdc"); return 0.;} - virtual void SetDynamicRange(Float_t /*dr */) - {NotImplemented("SetDynamicRange");} - virtual Float_t DynamicRange() const - {NotImplemented("DynamicRange"); return 0.;} - virtual void SetChargeLoss(Float_t /* cl */) - {NotImplemented("SetChargeLoss"); } - virtual Float_t ChargeLoss() const - {NotImplemented("ChargeLoss"); return 0.;} - virtual void SetDetParam(Float_t *) + virtual void SetDetParam(Double_t *) {NotImplemented("SetDetParam");} - virtual void GetDetParam(Float_t *) const + virtual void GetDetParam(Double_t *) const {NotImplemented("GetDetParam");} virtual void SetNDetParam(Int_t /* n */) {NotImplemented("SetNDetParam");} @@ -79,27 +77,28 @@ class AliITSresponseSPD : public AliITSresponse { {NotImplemented("SetZeroSupp");} virtual const char *ZeroSuppOption() const {NotImplemented("ZeroSuppression"); return "";} - virtual void SetNSigmaIntegration(Float_t) + virtual void SetNSigmaIntegration(Double_t) {NotImplemented("SetNSigmaIntegration");} - virtual Float_t NSigmaIntegration() const + virtual Double_t NSigmaIntegration() const {NotImplemented("NSigmaIntegration"); return 0.;} virtual void SetNLookUp(Int_t) {NotImplemented("SetNLookUp");} - virtual void SetSigmaSpread(Float_t, Float_t) + virtual void SetSigmaSpread(Double_t, Double_t) {NotImplemented("SetSigmaSpread");} - virtual void SigmaSpread(Float_t & /* p1 */,Float_t & /* p2 */) const + virtual void SigmaSpread(Double_t & /* p1 */,Double_t & /* p2 */) const {NotImplemented("SigmaSpread");} protected: - static const Float_t fgkDiffCoeffDefault; //default for fDiffCoeff - static const Float_t fgkThreshDefault; //default for fThresh - static const Float_t fgkSigmaDefault; //default for fSigma - Float_t fDiffCoeff; // Sigma diffusion coefficient (not used) - Float_t fThresh; // Threshold value - Float_t fSigma; // Noise + threshold fluctuations value - Float_t fCouplCol; // Coupling probability along a column - Float_t fCouplRow; // Coupling probability along a row - Float_t fDeadPixels; // the fraction of dead pixels + static const Double_t fgkDiffCoeffDefault; //default for fDiffCoeff + static const Double_t fgkThreshDefault; //default for fThresh + static const Double_t fgkSigmaDefault; //default for fSigma + Double_t fBaseline; // Base-line value + Double_t fNoise; // Gaussian noise scale + Double_t fThresh; // Threshold value + Double_t fSigma; // Noise + threshold fluctuations value + Double_t fCouplCol; // Coupling probability along a column + Double_t fCouplRow; // Coupling probability along a row + Double_t fDeadPixels; // the fraction of dead pixels ClassDef(AliITSresponseSPD,2) // SPD response diff --git a/ITS/AliITSresponseSPDdubna.cxx b/ITS/AliITSresponseSPDdubna.cxx deleted file mode 100644 index a3f5cbd4d4c..00000000000 --- a/ITS/AliITSresponseSPDdubna.cxx +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -#include -#include "AliITSresponseSPDdubna.h" -////////////////////////////////////////////////////// -// Response class for set:ITS // -// Specific subdetector implementation for // -// Silicon pixels // -// This is and alternative version // -// to the default version // -////////////////////////////////////////////////////// -const Float_t AliITSresponseSPDdubna::fgkNoiseDefault = 200.; -const Float_t AliITSresponseSPDdubna::fgkThresholdDefault = 2000.; - -//___________________________________________ -ClassImp(AliITSresponseSPDdubna) - -AliITSresponseSPDdubna::AliITSresponseSPDdubna() : AliITSresponse(){ - // Default constructor - // Inputs: - // none. - // Outputs: - // none. - // Return: - // A default constructed AliITSresponseSPD class - - SetNoiseParam(fgkNoiseDefault,0.); // fNoise, fBaseline - SetThresholds(fgkThresholdDefault,0.); // fThreshold - SetCouplings(); // fCouplCol, fCouplRow - SetFractionDeadPixels(); // fDeadPixels - SetDataType(); // fDataType -} -//_________________________________________________________________________ -Bool_t AliITSresponseSPDdubna::IsPixelDead(Int_t mod,Int_t ix,Int_t iz) const { - // Returns kTRUE if pixel is dead - // Inputs: - // Int_t mod module number - // Int_t ix x pixel number - // Int_t iz z pixel number - // Outputs: - // none. - // Return: - // kFALSE if pixel is alive, or kTRUE if pixel is dead. - Bool_t dead = kFALSE; - Int_t seed; - static TRandom ran; // don't use gRandom. This must not be a true randome - // sequence. These sequence must be random one and then fully repetable. - - seed = mod*256*256+iz*256+ix; - ran.SetSeed(seed); - if(ran.Rndm(0)> fNoise >> fBaseline >> fCouplCol >> fCouplRow; - *is >> fThreshold >> fDeadPixels >> fDataType; - return; -} -//---------------------------------------------------------------------- - -ostream &operator<<(ostream &os,AliITSresponseSPDdubna &p){ - // Standard output streaming function. - // Inputs: - // ostream *os Pointer to the output stream - // Outputs: - // none: - // Return: - // none. - - p.Print(&os); - return os; -} - -//---------------------------------------------------------------------- -istream &operator>>(istream &is,AliITSresponseSPDdubna &r){ - // Standard input streaming function. - // Inputs: - // ostream *os Pointer to the output stream - // Outputs: - // none: - // Return: - // none. - - r.Read(&is); - return is; -} -//---------------------------------------------------------------------- - diff --git a/ITS/AliITSresponseSPDdubna.h b/ITS/AliITSresponseSPDdubna.h deleted file mode 100644 index 5d99e0cbd62..00000000000 --- a/ITS/AliITSresponseSPDdubna.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef ALIITSRESPONSESPDDUBNA_H -#define ALIITSRESPONSESPDDUBNA_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/* $Id$ */ - -#include -class TString; - - -#include "AliITSresponse.h" - -//---------------------------------------------- -// ITS response class for SPD -class AliITSresponseSPDdubna : public AliITSresponse { - public: - AliITSresponseSPDdubna(); - virtual ~AliITSresponseSPDdubna(){}// destructror - -//abstract methods in AliITSresponse not implemented in this class - virtual void GiveCompressParam(Int_t *) const - {NotImplemented("GiveCompressParam");} - virtual void SetDriftSpeed(Float_t /* p1 */) - {NotImplemented("SetDriftSpeed");} - virtual Float_t DriftSpeed() const - {NotImplemented("DrifSpeed"); return 0.;} - virtual void SetElectronics(Int_t /* i */) - {NotImplemented("SetElectronics");} - virtual Int_t Electronics() const {NotImplemented("Electronics"); return 0;} - virtual void SetMaxAdc(Float_t /* adc */) {NotImplemented("SetMaxAdc");} - virtual Float_t MaxAdc() const {NotImplemented("MaxAdc"); return 0.;} - virtual void SetDynamicRange(Float_t /*dr */) - {NotImplemented("SetDynamicRange");} - virtual Float_t DynamicRange() const - {NotImplemented("DynamicRange"); return 0.;} - virtual void SetChargeLoss(Float_t /* cl */) - {NotImplemented("SetChargeLoss"); } - virtual Float_t ChargeLoss() const - {NotImplemented("ChargeLoss"); return 0.;} - virtual void SetDiffCoeff(Float_t /* a */, Float_t /* b */) - {NotImplemented("SetDiffCoeff");} - virtual void DiffCoeff(Float_t & /* a */,Float_t & /* b */) const - {NotImplemented("DiffCoeff");} - virtual void SetDetParam(Float_t *) - {NotImplemented("SetDetParam");} - virtual void GetDetParam(Float_t *) const - {NotImplemented("GetDetParam");} - virtual void SetNDetParam(Int_t /* n */) - {NotImplemented("SetNDetParam");} - virtual Int_t NDetParam() const - {NotImplemented("NDetParam"); return 0;} - virtual void SetParamOptions(const char* /* a */,const char* /* b */) - {NotImplemented("SetParamOptions");} - virtual void ParamOptions(char *,char*) const - {NotImplemented("ParamOptions");} - virtual void SetZeroSupp(const char*) - {NotImplemented("SetZeroSupp");} - virtual const char *ZeroSuppOption() const - {NotImplemented("ZeroSuppression"); return "";} - virtual void SetNSigmaIntegration(Float_t) - {NotImplemented("SetNSigmaIntegration");} - virtual Float_t NSigmaIntegration() const - {NotImplemented("NSigmaIntegration"); return 0.;} - virtual void SetNLookUp(Int_t) - {NotImplemented("SetNLookUp");} - virtual void SetSigmaSpread(Float_t, Float_t) - {NotImplemented("SetSigmaSpread");} - virtual void SigmaSpread(Float_t & /* p1 */,Float_t & /* p2 */) const - {NotImplemented("SigmaSpread");} - -// Implementation of virtual member functions declared in AliITSresponse - // set noise and baseline - virtual void SetNoiseParam(Float_t n, Float_t b) { - fNoise=n; fBaseline=b;} - virtual void GetNoiseParam(Float_t &n, Float_t &b) const { - n=fNoise; b=fBaseline;} // get noise and baseline - // Zero-suppression option threshold - virtual void SetThresholds(Float_t th, Float_t /* dum */) {fThreshold=th;} - virtual void Thresholds(Float_t & thr, Float_t & /*dum */) const - {thr = fThreshold;} - - // Prints out the content of this class in ASCII format. - virtual void Print(ostream *os) const; - - // Reads in the content of this class in the format of Print - virtual void Read(istream *is); - -//Declaration of member functions peculiar to this class - // Applies a random noise and addes the baseline - Float_t ApplyBaselineAndNoise() const {return fBaseline+ - fNoise*gRandom->Gaus();} - //Returns just baseline value - Float_t GetBaseline() const {return fBaseline;} - // Returns just noise value - Float_t GetNoise() const {return fNoise;} - // Get zero-suppression threshold - Float_t GetThreshold() const {return fThreshold;} - // Sets the coupling probabilities for columns and rows - void SetCouplings(Float_t ccol=0.,Float_t crow=0.){fCouplCol=ccol; - fCouplRow=crow;} - // Gets the coupling probabilities for columns and rows - void GetCouplings(Float_t &ccol,Float_t &crow) const - {ccol=fCouplCol; crow=fCouplRow;} - // Returns the fraction of dead pixels - Float_t GetFractionDeadPixels() const {return fDeadPixels;} - // Sets the fraction of dead pixels - void SetFractionDeadPixels(Float_t f=0.01){fDeadPixels = f;} - // Returns a logical if a pixels is dead or not - Bool_t IsPixelDead(Int_t mod,Int_t ix,Int_t iz) const ; - - ClassDef(AliITSresponseSPDdubna,3) // SPD response - - protected: - static const Float_t fgkNoiseDefault; // default for fNoise - static const Float_t fgkThresholdDefault; //default for fThreshold - Float_t fNoise; // Noise value - Float_t fBaseline; // Baseline value - Float_t fCouplCol; // Coupling Probability along columns - Float_t fCouplRow; // Coupling Probability along rows - Float_t fThreshold; // Zero-Suppression threshold - Float_t fDeadPixels; // Fraction of dead pixels. -}; -// Input and output function for standard C++ input/output. -ostream& operator<<(ostream &os,AliITSresponseSPDdubna &source); -istream& operator>>(istream &os,AliITSresponseSPDdubna &source); - -#endif diff --git a/ITS/AliITSresponseSSD.cxx b/ITS/AliITSresponseSSD.cxx index b0a0a7002b7..e5ba79eb089 100644 --- a/ITS/AliITSresponseSSD.cxx +++ b/ITS/AliITSresponseSSD.cxx @@ -23,14 +23,14 @@ // // ////////////////////////////////////////////////////// -const Float_t AliITSresponseSSD::fgkDiffCoeffDefault = 0.; +const Double_t AliITSresponseSSD::fgkDiffCoeffDefault = 0.; const TString AliITSresponseSSD::fgkOption1Default = ""; const TString AliITSresponseSSD::fgkOption2Default = ""; -const Float_t AliITSresponseSSD::fgkNoiseNDefault = 625.; -const Float_t AliITSresponseSSD::fgkNoisePDefault = 420.; +const Double_t AliITSresponseSSD::fgkNoiseNDefault = 625.; +const Double_t AliITSresponseSSD::fgkNoisePDefault = 420.; const Int_t AliITSresponseSSD::fgkNParDefault = 6; -const Float_t AliITSresponseSSD::fgkSigmaPDefault = 3.; -const Float_t AliITSresponseSSD::fgkSigmaNDefault = 2.; +const Double_t AliITSresponseSSD::fgkSigmaPDefault = 3.; +const Double_t AliITSresponseSSD::fgkSigmaNDefault = 2.; ClassImp(AliITSresponseSSD) @@ -60,7 +60,7 @@ AliITSresponseSSD::AliITSresponseSSD(const char *dataType){ SetParamOptions(fgkOption1Default.Data(),fgkOption2Default.Data()); SetNDetParam(fgkNParDefault); // Sets fNPar=6 by default. SetADCpereV(); - fDetPar = new Float_t[fNPar]; + fDetPar = new Double_t[fNPar]; if (fNPar==6) { fDetPar[0]=10.; fDetPar[1]=5.; @@ -104,7 +104,7 @@ AliITSresponseSSD::AliITSresponseSSD(const AliITSresponseSSD &src) : *this = src; } //______________________________________________________________________ -void AliITSresponseSSD::SetDetParam(Float_t *par){ +void AliITSresponseSSD::SetDetParam(Double_t *par){ // set det param Int_t i; @@ -114,7 +114,7 @@ void AliITSresponseSSD::SetDetParam(Float_t *par){ } // end for i } //______________________________________________________________________ -void AliITSresponseSSD::GetDetParam(Float_t *par) const { +void AliITSresponseSSD::GetDetParam(Double_t *par) const { // get det param Int_t i; diff --git a/ITS/AliITSresponseSSD.h b/ITS/AliITSresponseSSD.h index 770152b2b0d..0d442ce2fcd 100644 --- a/ITS/AliITSresponseSSD.h +++ b/ITS/AliITSresponseSSD.h @@ -15,19 +15,19 @@ class AliITSresponseSSD : public AliITSresponse { virtual ~AliITSresponseSSD(); // Implementation of virtual member functions declared in AliITSresponse - virtual void SetDiffCoeff(Float_t p1,Float_t /* dummy */) { + virtual void SetDiffCoeff(Double_t p1,Double_t /* dummy */) { // Diffusion coefficient fDiffCoeff=p1; } - virtual void DiffCoeff(Float_t &diffc,Float_t & /* dummy */) const { + virtual void DiffCoeff(Double_t &diffc,Double_t & /* dummy */) const { // Get diffusion coefficient diffc= fDiffCoeff; } - virtual void SetNoiseParam(Float_t np, Float_t nn) { + virtual void SetNoiseParam(Double_t np, Double_t nn) { // set noise par fNoiseP=np; fNoiseN=nn; } - virtual void GetNoiseParam(Float_t &np, Float_t &nn) const { + virtual void GetNoiseParam(Double_t &np, Double_t &nn) const { // get noise par np=fNoiseP; nn=fNoiseN; } @@ -48,21 +48,21 @@ class AliITSresponseSSD : public AliITSresponse { fNPar=npar; } - virtual void SetDetParam(Float_t *par); + virtual void SetDetParam(Double_t *par); // Parameters options virtual Int_t NDetParam() const { // number of param return fNPar; } - virtual void GetDetParam(Float_t *dpar) const; + virtual void GetDetParam(Double_t *dpar) const; - virtual void SetSigmaSpread(Float_t p1, Float_t p2) { + virtual void SetSigmaSpread(Double_t p1, Double_t p2) { // Set sigmas of the charge spread function: Pside-Nside // square of (microns) fSigmaP=p1; fSigmaN=p2; } - virtual void SigmaSpread(Float_t &sP, Float_t &sN) const { + virtual void SigmaSpread(Double_t &sP, Double_t &sN) const { // Get sigmas for the charge spread sP=fSigmaP; sN=fSigmaN; } @@ -72,7 +72,7 @@ class AliITSresponseSSD : public AliITSresponse { // Sets electron-hole pairs to ADC value conversion factor // are rather arbitrary (need tuning) // minimum ionizing particle--> ~30000 pairs--> ADC channel 50 - void SetADCpereV(Float_t a=50./30000.0){fADCpereV = a;} + void SetADCpereV(Double_t a=50./30000.0){fADCpereV = a;} // Converts electron-hole pairs to // ADC value conversion factor are rather arbitrary (need tuning) // minimum ionizing particle--> ~30000 pairs--> ADC channel 50 @@ -82,60 +82,49 @@ class AliITSresponseSSD : public AliITSresponse { return ((Int_t) DEvToADC(eV)); } //abstract methods in AliITSresponse not implemented in this class - virtual void SetDriftSpeed(Float_t /* p1 */) + virtual void SetDriftSpeed(Double_t /* p1 */) {NotImplemented("SetDriftSpeed");} - virtual Float_t DriftSpeed() const + virtual Double_t DriftSpeed() const {NotImplemented("DrifSpeed"); return 0.;} - virtual void SetElectronics(Int_t /* i */) - {NotImplemented("SetElectronics");} - virtual Int_t Electronics() const {NotImplemented("Electronics"); return 0;} virtual void GiveCompressParam(Int_t *) const {NotImplemented("GiveCompressParam");} - virtual void SetMaxAdc(Float_t /* adc */) {NotImplemented("SetMaxAdc");} - virtual Float_t MaxAdc() const {NotImplemented("MaxAdc"); return 0.;} - virtual void SetDynamicRange(Float_t /*dr */) - {NotImplemented("SetDynamicRange");} - virtual Float_t DynamicRange() const - {NotImplemented("DynamicRange"); return 0.;} - virtual void SetChargeLoss(Float_t /* cl */) - {NotImplemented("SetChargeLoss"); } - virtual Float_t ChargeLoss() const + virtual Double_t ChargeLoss() const {NotImplemented("ChargeLoss"); return 0.;} - virtual void SetThresholds(Float_t /* a */, Float_t /* b */) + virtual void SetThresholds(Double_t /* a */, Double_t /* b */) {NotImplemented("SetThresholds");} - virtual void Thresholds(Float_t & /* a */, Float_t & /* b */) const + virtual void Thresholds(Double_t & /* a */, Double_t & /* b */) const {NotImplemented("Thresholds");} virtual void SetZeroSupp(const char*) {NotImplemented("SetZeroSupp");} virtual const char *ZeroSuppOption() const {NotImplemented("ZeroSuppression"); return "";} - virtual void SetNSigmaIntegration(Float_t) + virtual void SetNSigmaIntegration(Double_t) {NotImplemented("SetNSigmaIntegration");} - virtual Float_t NSigmaIntegration() const + virtual Double_t NSigmaIntegration() const {NotImplemented("NSigmaIntegration"); return 0.;} virtual void SetNLookUp(Int_t) {NotImplemented("SetNLookUp");} protected: - static const Float_t fgkDiffCoeffDefault; //default for fDiffCoeff + static const Double_t fgkDiffCoeffDefault; //default for fDiffCoeff static const TString fgkOption1Default; // default for fOption1 static const TString fgkOption2Default; // default for fOption2 - static const Float_t fgkNoiseNDefault; // default for fNoiseN - static const Float_t fgkNoisePDefault; // default for fNoiseP + static const Double_t fgkNoiseNDefault; // default for fNoiseN + static const Double_t fgkNoisePDefault; // default for fNoiseP static const Int_t fgkNParDefault; // default for fNPar - static const Float_t fgkSigmaPDefault; //default for fSigmaP - static const Float_t fgkSigmaNDefault; //default for fSigmaP + static const Double_t fgkSigmaPDefault; //default for fSigmaP + static const Double_t fgkSigmaNDefault; //default for fSigmaP Int_t fNPar; // Number of detector param - Float_t *fDetPar; //[fNPar] Array of parameters + Double_t *fDetPar; //[fNPar] Array of parameters - Float_t fNoiseP; // Noise on Pside - Float_t fNoiseN; // Noise on Nside + Double_t fNoiseP; // Noise on Pside + Double_t fNoiseN; // Noise on Nside - Float_t fSigmaP; // Sigma charge spread on Pside - Float_t fSigmaN; // Sigma charge spread on Nside - Float_t fDiffCoeff; // Diffusion Coefficient + Double_t fSigmaP; // Sigma charge spread on Pside + Double_t fSigmaN; // Sigma charge spread on Nside + Double_t fDiffCoeff; // Diffusion Coefficient - Float_t fADCpereV; // Constant to convert eV to ADC. + Double_t fADCpereV; // Constant to convert eV to ADC. TString fOption1; // Simulate invalid strips option TString fOption2; // Not used for the moment diff --git a/ITS/AliITSsegmentation.h b/ITS/AliITSsegmentation.h index 474d7c58a75..d1472fd9bfd 100644 --- a/ITS/AliITSsegmentation.h +++ b/ITS/AliITSsegmentation.h @@ -43,7 +43,7 @@ public TObject { virtual void GetPadTxz(Float_t &,Float_t &) const = 0; // Transformation from Geant cm detector center local coordinates // to detector segmentation/cell coordiantes starting from (0,0). - virtual void LocalToDet(Float_t,Float_t,Int_t &,Int_t &) const = 0; + virtual Bool_t LocalToDet(Float_t,Float_t,Int_t &,Int_t &) const = 0; // Transformation from detector segmentation/cell coordiantes starting // from (0,0) to Geant cm detector center local coordinates. virtual void DetToLocal(Int_t,Int_t,Float_t &,Float_t &) const = 0; diff --git a/ITS/AliITSsegmentationSDD.cxx b/ITS/AliITSsegmentationSDD.cxx index 32c8f34a21d..34d559f86dd 100644 --- a/ITS/AliITSsegmentationSDD.cxx +++ b/ITS/AliITSsegmentationSDD.cxx @@ -236,7 +236,8 @@ void AliITSsegmentationSDD::PrintDefaultParameters() const { } //______________________________________________________________________ -void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const { +Bool_t AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z, + Int_t &ix,Int_t &iz) const { // Transformation from Geant detector centered local coordinates (cm) to // time bucket numbers ix and anode number iz. // Input: @@ -275,11 +276,11 @@ void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) dz = -0.5*kconv*Dz(); // lower left edge in cm. if(x-dx) { Warning("LocalToDet","input argument %f out of range (%f, %f)",x,dx,-dx); - return; // outside of defined volume. + return kFALSE; // outside of defined volume. } if(z-dz) { Warning("LocalToDet","input argument %f out of range (%f, %f)",z,dz,-dz); - return; // outside of defined volume. + return kFALSE; // outside of defined volume. } tb = fDriftSpeed*fTimeStep*kconv; // compute size of time bin. if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units @@ -288,7 +289,7 @@ void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) ix = (Int_t) dx; // time bin iz = (Int_t) dz; // anode if(x>0) iz += Npz()/2; // if x>0 then + side anodes values. - return; // Found ix and iz, return. + return kTRUE; // Found ix and iz, return. } //______________________________________________________________________ void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const diff --git a/ITS/AliITSsegmentationSDD.h b/ITS/AliITSsegmentationSDD.h index eff72a4a1a2..5d2b65327d8 100644 --- a/ITS/AliITSsegmentationSDD.h +++ b/ITS/AliITSsegmentationSDD.h @@ -43,7 +43,7 @@ public AliITSsegmentation { virtual void GetPadTxz(Float_t &x ,Float_t &z) const; // Transformation from Geant cm detector center local coordinates // to detector segmentation/cell coordiantes starting from (0,0). - virtual void LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const; + virtual Bool_t LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const; // Transformation from detector segmentation/cell coordiantes starting // from (0,0) to Geant cm detector center local coordinates. virtual void DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const; diff --git a/ITS/AliITSsegmentationSPD.cxx b/ITS/AliITSsegmentationSPD.cxx index f032beff00f..1fcf0a47c6c 100644 --- a/ITS/AliITSsegmentationSPD.cxx +++ b/ITS/AliITSsegmentationSPD.cxx @@ -379,19 +379,24 @@ Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]) con Zlist[7]=iZ-1; } //______________________________________________________________________ -void AliITSsegmentationSPD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const { -// Transformation from Geant detector centered local coordinates (cm) to -// Pixel cell numbers ix and iz. -// Input: -// Float_t x detector local coordinate x in cm with respect to the -// center of the sensitive volume. -// Float_t z detector local coordinate z in cm with respect to the -// center of the sensitive volulme. -// Output: -// Int_t ix detector x cell coordinate. Has the range 0<=ix=Npx()) return; // outside x range. + if(i>=Npx()) return kFALSE; // outside x range. for(j=0;j=Npz()) return; // outside z range. + if(j>=Npz()) return kFALSE; // outside z range. ix = i; iz = j; - return; // Found ix and iz, return. + return kTRUE; // Found ix and iz, return. } //______________________________________________________________________ void AliITSsegmentationSPD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const diff --git a/ITS/AliITSsegmentationSPD.h b/ITS/AliITSsegmentationSPD.h index f1c69a18055..35fc84a5942 100644 --- a/ITS/AliITSsegmentationSPD.h +++ b/ITS/AliITSsegmentationSPD.h @@ -37,7 +37,7 @@ public AliITSsegmentation { virtual void GetPadTxz(Float_t &x ,Float_t &z) const; // Transformation from Geant cm detector center local coordinates // to detector segmentation/cell coordiantes starting from (0,0). - virtual void LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const; + virtual Bool_t LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const; // Transformation from detector segmentation/cell coordiantes starting // from (0,0) to Geant cm detector center local coordinates. virtual void DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const; diff --git a/ITS/AliITSsegmentationSSD.cxx b/ITS/AliITSsegmentationSSD.cxx index 679d3ee087b..6dba076dade 100644 --- a/ITS/AliITSsegmentationSSD.cxx +++ b/ITS/AliITSsegmentationSSD.cxx @@ -212,7 +212,7 @@ void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z) c return; } //______________________________________________________________________ -void AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z, +Bool_t AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z, Int_t &iP,Int_t &iN) const { // Transformation from Geant cm detector center local coordinates // to detector P and N side strip numbers.. @@ -247,7 +247,7 @@ void AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z, // Now for N side) iN = (Int_t) z; if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range. - return; + return kTRUE; } //---------------------------------------------------------------------- void AliITSsegmentationSSD::DetToLocal(Int_t ix,Int_t iPN, diff --git a/ITS/AliITSsegmentationSSD.h b/ITS/AliITSsegmentationSSD.h index 3fb1793f2eb..74332009f5c 100644 --- a/ITS/AliITSsegmentationSSD.h +++ b/ITS/AliITSsegmentationSSD.h @@ -45,7 +45,7 @@ public AliITSsegmentation { virtual void GetPadTxz(Float_t &x , Float_t &z) const; // Transformation from Geant cm detector center local coordinates // to detector P and N side strip numbers.. - virtual void LocalToDet(Float_t x,Float_t z,Int_t &iP,Int_t &iN) const; + virtual Bool_t LocalToDet(Float_t x,Float_t z,Int_t &iP,Int_t &iN) const; // Transformation from detector segmentation/cell coordiantes starting // from 0. iPN=0 for P side and 1 for N side strip. Returned is z=0.0 // and the corresponding x value.. diff --git a/ITS/AliITSsimulation.cxx b/ITS/AliITSsimulation.cxx index f8b301f369a..3f61040b5c7 100644 --- a/ITS/AliITSsimulation.cxx +++ b/ITS/AliITSsimulation.cxx @@ -20,25 +20,64 @@ ClassImp(AliITSsimulation) -AliITSsimulation::AliITSsimulation(){ - // constructor - fSegmentation = 0; - fResponse = 0; - fpList = 0; - fModule = 0; - fEvent = 0; - SetDebug(kFALSE); +//______________________________________________________________________ +AliITSsimulation::AliITSsimulation(): TObject(), +fResponse(0), +fSegmentation(0), +fpList(0), +fModule(0), +fEvent(0), +fDebug(0){ + // Default constructor + // Inputs: + // none. + // Outputs: + // none. + // Return: + // a default constructed AliITSsimulation class +} +//______________________________________________________________________ +AliITSsimulation::AliITSsimulation(AliITSsegmentation *seg, + AliITSresponse *res): TObject(), +fResponse(res), +fSegmentation(seg), +fpList(0), +fModule(0), +fEvent(0), +fDebug(0){ + // Default constructor + // Inputs: + // AliITSsegmentation *seg Segmentation class to be used + // AliITSresponse *res Response class to be used. + // Outputs: + // none. + // Return: + // a default constructed AliITSsimulation class } //__________________________________________________________________________ AliITSsimulation::~AliITSsimulation(){ // destructor + // Inputs: + // none. + // Outputs: + // none. + // Return: + // none. + fSegmentation = 0; // local copies of pointer, do not delete fResponse = 0; // local copies of pointer, do not delete delete fpList; } //__________________________________________________________________________ AliITSsimulation::AliITSsimulation(const AliITSsimulation &s) : TObject(s){ - // Copy Constructor + // Copy Constructor + // Inputs: + // const AliITSsimulation &s simulation class to copy from + // Outputs: + // none. + // Return: + // a standard constructed AliITSsimulation class with values the same + // as that of s. *this = s; return; @@ -47,6 +86,13 @@ AliITSsimulation::AliITSsimulation(const AliITSsimulation &s) : TObject(s){ //_________________________________________________________________________ AliITSsimulation& AliITSsimulation::operator=(const AliITSsimulation &s){ // Assignment operator + // Inputs: + // const AliITSsimulation &s simulation class to copy from + // Outputs: + // none. + // Return: + // a standard constructed AliITSsimulation class with values the same + // as that of s. if(&s == this) return *this; this->fResponse = s.fResponse; @@ -59,6 +105,14 @@ AliITSsimulation& AliITSsimulation::operator=(const AliITSsimulation &s){ //______________________________________________________________________ Bool_t AliITSsimulation::AddSDigitsToModule(TClonesArray *pItemA,Int_t mask ){ // Add Summable digits to module maps. + // Inputs: + // TClonesArray *pItemA Array of AliITSpListItems (SDigits). + // Int_t mask Track number off set value (see + // AliITSpList::AddItemTo). + // Outputs: + // none. + // Return: + // kTRUE if there is a signal >0 else kFALSE Int_t nItems = pItemA->GetEntries(); Bool_t sig = kFALSE; @@ -67,11 +121,11 @@ Bool_t AliITSsimulation::AddSDigitsToModule(TClonesArray *pItemA,Int_t mask ){ AliITSpListItem * pItem = (AliITSpListItem *)(pItemA->At( i )); if( pItem->GetModule() != fModule ) { Error( "AddSDigitsToModule","Error reading, SDigits module %d " - "!= current module %d: exit", - pItem->GetModule(), fModule ); + "!= current module %d: exit", + pItem->GetModule(), fModule ); return sig; } // end if - if(pItem->GetSignal()>0.0 ) sig = kTRUE; + if(pItem->GetSignal()>0.0 ) sig = kTRUE; fpList->AddItemTo( mask, pItem ); } // end for i return sig; diff --git a/ITS/AliITSsimulation.h b/ITS/AliITSsimulation.h index 4b02971a6c8..329083d25c2 100644 --- a/ITS/AliITSsimulation.h +++ b/ITS/AliITSsimulation.h @@ -32,13 +32,17 @@ class TClonesArray; class AliITSsimulation : public TObject { - public: + public: AliITSsimulation(); // Default constructor + // Standard constructor + AliITSsimulation(AliITSsegmentation *seg,AliITSresponse *res); virtual ~AliITSsimulation(); // destructor // copy constructor. See detector specific implementation. AliITSsimulation(const AliITSsimulation &source); // Assignment opporator. See detector specific implementation. virtual AliITSsimulation& operator=(const AliITSsimulation &source); + // Initialize simulation + virtual void Init() {}; // ***************** Hits -> SDigits ****************** // digitize module using the "slow" detector simulator creating @@ -78,8 +82,12 @@ class AliITSsimulation : public TObject { virtual Int_t GetModuleNumber()const {return fModule;}// Gets Module number virtual void SetEventNumber(Int_t evnt){fEvent=evnt;} // Set Event number virtual Int_t GetEventNumber()const {return fEvent;}// Gets Event number - virtual Bool_t GetDebug() const {return fDebug;} - virtual void SetDebug(Bool_t db = kTRUE) {fDebug = db;} + // Sets the debug flag for debugging output + void SetDebug(Int_t level=5){fDebug=level;} + // Clears the debug flag so no debugging output will be generated + void SetNoDebug(){fDebug=0;} + // Returns the debug flag value + Bool_t GetDebug(Int_t level=1)const {return fDebug>=level;} protected: AliITSresponse *fResponse; //! response @@ -87,9 +95,9 @@ class AliITSsimulation : public TObject { AliITSpList *fpList; //! Int_t fModule; //! Int_t fEvent; //! - Bool_t fDebug; // debug flag + Int_t fDebug; // debug flag - ClassDef(AliITSsimulation,2) // Simulation base class + ClassDef(AliITSsimulation,3) // Simulation base class }; diff --git a/ITS/AliITSsimulationSDD.cxx b/ITS/AliITSsimulationSDD.cxx index 13b55de4da3..ffdf5dfab3b 100644 --- a/ITS/AliITSsimulationSDD.cxx +++ b/ITS/AliITSsimulationSDD.cxx @@ -61,1586 +61,1597 @@ ClassImp(AliITSsimulationSDD) // //Begin_Html /* - - -
- -

This show the relasionships between the ITS hit class and the rest of Aliroot. - -

- */
- //End_Html
-
+  
+  
+
+ +

This show the relasionships between the ITS hit class and the + rest of Aliroot. + +

+*/
+//End_Html
  //______________________________________________________________________
-  Int_t power(Int_t b, Int_t e) {
-  // compute b to the e power, where both b and e are Int_ts.
-  Int_t power = 1,i;
+Int_t power(Int_t b, Int_t e) {
+    // compute b to the e power, where both b and e are Int_ts.
+    Int_t power = 1,i;
 
-  for(i=0; iGetSamples();
-  Int_t l = (Int_t) ((log((Float_t) samples)/log(2.))+0.5);
-  Int_t m1 = samples;
-  Int_t m  = samples/2;
-  Int_t m2 = samples/m1;
-  Int_t i,j,k;
-  for(i=1; i<=l; i++) {
-    for(j=0; jGetWeightReal(p);
-	Double_t wsi = alisddetf->GetWeightImag(p);
-	if(direction == -1) wsi = -wsi;
-	Double_t xr = *(real+k+m);
-	Double_t xi = *(imag+k+m);
-	*(real+k+m) = wsr*(*(real+k)-xr) - wsi*(*(imag+k)-xi);
-	*(imag+k+m) = wsr*(*(imag+k)-xi) + wsi*(*(real+k)-xr);
-	*(real+k) += xr;
-	*(imag+k) += xi;
-	p += m2;
-      } // end for k
-    } // end for j
-    m1 = m;
-    m /= 2;
-    m2 += m2;
-  } // end for i
-  
-  for(j=0; j= j) {
-      Double_t xr = *(real+j);
-      Double_t xi = *(imag+j);
-      *(real+j) = *(real+p);
-      *(imag+j) = *(imag+p);
-      *(real+p) = xr;
-      *(imag+p) = xi;
-    } // end if p>=j
-  } // end for j
-  if(direction == -1) {
-    for(i=0; iGetSamples();
+    Int_t l = (Int_t) ((log((Float_t) samples)/log(2.))+0.5);
+    Int_t m1 = samples;
+    Int_t m  = samples/2;
+    Int_t m2 = samples/m1;
+    Int_t i,j,k;
+    for(i=1; i<=l; i++) {
+        for(j=0; jGetWeightReal(p);
+                Double_t wsi = alisddetf->GetWeightImag(p);
+                if(direction == -1) wsi = -wsi;
+                Double_t xr = *(real+k+m);
+                Double_t xi = *(imag+k+m);
+                *(real+k+m) = wsr*(*(real+k)-xr) - wsi*(*(imag+k)-xi);
+                *(imag+k+m) = wsr*(*(imag+k)-xi) + wsi*(*(real+k)-xr);
+                *(real+k) += xr;
+                *(imag+k) += xi;
+                p += m2;
+            } // end for k
+        } // end for j
+        m1 = m;
+        m /= 2;
+        m2 += m2;
     } // end for i
-  } // end if direction == -1
-  return;
+  
+    for(j=0; j= j) {
+            Double_t xr = *(real+j);
+            Double_t xi = *(imag+j);
+            *(real+j) = *(real+p);
+            *(imag+j) = *(imag+p);
+            *(real+p) = xr;
+            *(imag+p) = xi;
+        } // end if p>=j
+    } // end for j
+    if(direction == -1) {
+        for(i=0; iNpz(),
-			    fScaleSize*fSegmentation->Npx() );
-  fHitSigMap2 = new AliITSMapA2(fSegmentation,fScaleSize,1);
-  fHitNoiMap2 = new AliITSMapA2(fSegmentation,fScaleSize,1);
-  fHitMap2 = fHitSigMap2;
-
-  fNofMaps = fSegmentation->Npz();
-  fMaxNofSamples = fSegmentation->Npx();
-  fAnodeFire = new Bool_t [fNofMaps];
+void AliITSsimulationSDD::Init(){
+    // Standard Constructor
+
+    SetScaleFourier();
+    SetPerpendTracksFlag();
+    SetCrosstalkFlag();
+    SetDoFFT();
+    SetCheckNoise();
+
+    fpList = new AliITSpList( GetSeg()->Npz(),
+                              fScaleSize*GetSeg()->Npx() );
+    fHitSigMap2 = new AliITSMapA2(GetSeg(),fScaleSize,1);
+    fHitNoiMap2 = new AliITSMapA2(GetSeg(),fScaleSize,1);
+    fHitMap2 = fHitSigMap2;
+
+    fNofMaps = GetSeg()->Npz();
+    fMaxNofSamples = GetSeg()->Npx();
+    fAnodeFire = new Bool_t [fNofMaps];
     
-  Float_t sddLength = fSegmentation->Dx();
-  Float_t sddWidth  = fSegmentation->Dz();
-
-  Int_t dummy        = 0;
-  Float_t anodePitch = fSegmentation->Dpz(dummy);
-  Double_t timeStep  = (Double_t)fSegmentation->Dpx(dummy);
-  Float_t driftSpeed = fResponse->DriftSpeed();
-
-  if(anodePitch*(fNofMaps/2) > sddWidth) {
-    Warning("AliITSsimulationSDD",
-	    "Too many anodes %d or too big pitch %f \n",
-	    fNofMaps/2,anodePitch);
-  } // end if
-
-  if(timeStep*fMaxNofSamples < sddLength/driftSpeed) {
-    Error("AliITSsimulationSDD",
-	  "Time Interval > Allowed Time Interval: exit\n");
-    return;
-  } // end if
-
-  fElectronics = new AliITSetfSDD(timeStep/fScaleSize,
-				  fResponse->Electronics());
-
-  char opt1[20], opt2[20];
-  fResponse->ParamOptions(opt1,opt2);
-  fParam = opt2;
-  char *same = strstr(opt1,"same");
-  if (same) {
-    fNoise.Set(0);
-    fBaseline.Set(0);
-  } else {
-    fNoise.Set(fNofMaps);
-    fBaseline.Set(fNofMaps);
-  } // end if
-
-  const char *kopt=fResponse->ZeroSuppOption();
-  if (strstr(fParam.Data(),"file") ) {
-    fD.Set(fNofMaps);
-    fT1.Set(fNofMaps);
-    if (strstr(kopt,"2D")) {
-      fT2.Set(fNofMaps);
-      fTol.Set(0);
-      Init2D();       // desactivate if param change module by module
-    } else if(strstr(kopt,"1D"))  {
-      fT2.Set(2);
-      fTol.Set(2);
-      Init1D();      // desactivate if param change module by module
-    } // end if strstr
-  } else {
-    fD.Set(2);
-    fTol.Set(2);
-    fT1.Set(2);
-    fT2.Set(2);
-    SetCompressParam();
-  } // end if else strstr
-
-  Bool_t write = fResponse->OutputOption();
-  if(write && strstr(kopt,"2D")) MakeTreeB();
+    Float_t sddLength = GetSeg()->Dx();
+    Float_t sddWidth  = GetSeg()->Dz();
+
+    Int_t dummy        = 0;
+    Float_t anodePitch = GetSeg()->Dpz(dummy);
+    Double_t timeStep  = (Double_t)GetSeg()->Dpx(dummy);
+    Float_t driftSpeed = GetResp()->DriftSpeed();
+
+    if(anodePitch*(fNofMaps/2) > sddWidth) {
+        Warning("AliITSsimulationSDD",
+                "Too many anodes %d or too big pitch %f \n",
+                fNofMaps/2,anodePitch);
+    } // end if
 
-  // call here if baseline does not change by module
-  // ReadBaseline();
+    if(timeStep*fMaxNofSamples < sddLength/driftSpeed) {
+        Error("AliITSsimulationSDD",
+              "Time Interval > Allowed Time Interval: exit\n");
+        return;
+    } // end if
 
-  fITS       = (AliITS*)gAlice->GetModule("ITS");
-  Int_t size = fNofMaps*fMaxNofSamples;
-  fStream    = new AliITSInStream(size);
+    fElectronics = new AliITSetfSDD(timeStep/fScaleSize,
+                                    GetResp()->Electronics());
 
-  fInZR  = new Double_t [fScaleSize*fMaxNofSamples];
-  fInZI  = new Double_t [fScaleSize*fMaxNofSamples];
-  fOutZR = new Double_t [fScaleSize*fMaxNofSamples];
-  fOutZI = new Double_t [fScaleSize*fMaxNofSamples];  
+    char opt1[20], opt2[20];
+    GetResp()->ParamOptions(opt1,opt2);
+    fParam = opt2;
+    char *same = strstr(opt1,"same");
+    if (same) {
+        fNoise.Set(0);
+        fBaseline.Set(0);
+    } else {
+        fNoise.Set(fNofMaps);
+        fBaseline.Set(fNofMaps);
+    } // end if
 
+    const char *kopt=GetResp()->ZeroSuppOption();
+    if (strstr(fParam.Data(),"file") ) {
+        fD.Set(fNofMaps);
+        fT1.Set(fNofMaps);
+        if (strstr(kopt,"2D")) {
+            fT2.Set(fNofMaps);
+            fTol.Set(0);
+            Init2D();       // desactivate if param change module by module
+        } else if(strstr(kopt,"1D"))  {
+            fT2.Set(2);
+            fTol.Set(2);
+            Init1D();      // desactivate if param change module by module
+        } // end if strstr
+    } else {
+        fD.Set(2);
+        fTol.Set(2);
+        fT1.Set(2);
+        fT2.Set(2);
+        SetCompressParam();
+    } // end if else strstr
+
+    Bool_t write = GetResp()->OutputOption();
+    if(write && strstr(kopt,"2D")) MakeTreeB();
+
+    // call here if baseline does not change by module
+    // ReadBaseline();
+
+    fITS       = (AliITS*)gAlice->GetModule("ITS");
+    Int_t size = fNofMaps*fMaxNofSamples;
+    fStream    = new AliITSInStream(size);
+
+    fInZR  = new Double_t [fScaleSize*fMaxNofSamples];
+    fInZI  = new Double_t [fScaleSize*fMaxNofSamples];
+    fOutZR = new Double_t [fScaleSize*fMaxNofSamples];
+    fOutZI = new Double_t [fScaleSize*fMaxNofSamples];  
 }
 //______________________________________________________________________
 AliITSsimulationSDD::~AliITSsimulationSDD() { 
-  // destructor
-
-  //    delete fpList;
-  delete fHitSigMap2;
-  delete fHitNoiMap2;
-  delete fStream;
-  delete fElectronics;
-
-  fITS = 0;
-
-  if (fHis) {
-    fHis->Delete(); 
-    delete fHis;     
-  } // end if fHis
-  if(fTreeB) delete fTreeB;           
-  if(fInZR)  delete [] fInZR;
-  if(fInZI)  delete [] fInZI;        
-  if(fOutZR) delete [] fOutZR;
-  if(fOutZI) delete [] fOutZI;
-  if(fAnodeFire) delete [] fAnodeFire;
+    // destructor
+
+    //    delete fpList;
+    delete fHitSigMap2;
+    delete fHitNoiMap2;
+    delete fStream;
+    delete fElectronics;
+
+    fITS = 0;
+
+    if (fHis) {
+        fHis->Delete(); 
+        delete fHis;     
+    } // end if fHis
+    if(fTreeB) delete fTreeB;           
+    if(fInZR)  delete [] fInZR;
+    if(fInZI)  delete [] fInZI;        
+    if(fOutZR) delete [] fOutZR;
+    if(fOutZI) delete [] fOutZI;
+    if(fAnodeFire) delete [] fAnodeFire;
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::InitSimulationModule( Int_t module, Int_t event ) {
-  // create maps to build the lists of tracks for each summable digit
-  fModule = module;
-  fEvent  = event;
-  ClearMaps();
-  memset(fAnodeFire,0,sizeof(Bool_t)*fNofMaps);    
+    // create maps to build the lists of tracks for each summable digit
+    fModule = module;
+    fEvent  = event;
+    ClearMaps();
+    memset(fAnodeFire,0,sizeof(Bool_t)*fNofMaps);    
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::ClearMaps() {
-  // clear maps
-  fpList->ClearMap();
-  fHitSigMap2->ClearMap();
-  fHitNoiMap2->ClearMap();
+    // clear maps
+    fpList->ClearMap();
+    fHitSigMap2->ClearMap();
+    fHitNoiMap2->ClearMap();
 }
 //______________________________________________________________________
-void AliITSsimulationSDD::SDigitiseModule( AliITSmodule *mod, Int_t md, Int_t ev){
-  // digitize module using the "slow" detector simulator creating
-  // summable digits.
-
-  TObjArray *fHits = mod->GetHits();
-  Int_t nhits      = fHits->GetEntriesFast();
-  if( !nhits ) return;
-
-  InitSimulationModule( md, ev );
-  HitsToAnalogDigits( mod );
-  ChargeToSignal( kFALSE ); // - Process signal without add noise
-  fHitMap2 = fHitNoiMap2;   // - Swap to noise map
-  ChargeToSignal( kTRUE );  // - Process only noise
-  fHitMap2 = fHitSigMap2;   // - Return to signal map
-  WriteSDigits();
-  ClearMaps();
+void AliITSsimulationSDD::SDigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){
+    // digitize module using the "slow" detector simulator creating
+    // summable digits.
+
+    TObjArray *fHits = mod->GetHits();
+    Int_t nhits      = fHits->GetEntriesFast();
+    if( !nhits ) return;
+
+    InitSimulationModule( md, ev );
+    HitsToAnalogDigits( mod );
+    ChargeToSignal( kFALSE ); // - Process signal without add noise
+    fHitMap2 = fHitNoiMap2;   // - Swap to noise map
+    ChargeToSignal( kTRUE );  // - Process only noise
+    fHitMap2 = fHitSigMap2;   // - Return to signal map
+    WriteSDigits();
+    ClearMaps();
 }
 //______________________________________________________________________
-Bool_t AliITSsimulationSDD::AddSDigitsToModule( TClonesArray *pItemArray, Int_t mask ) {
-  // Add Summable digits to module maps.
-  Int_t    nItems = pItemArray->GetEntries();
-  Double_t maxadc = fResponse->MaxAdc();
-  Bool_t sig = kFALSE;
+Bool_t AliITSsimulationSDD::AddSDigitsToModule(TClonesArray *pItemArray,
+                                               Int_t mask ) {
+    // Add Summable digits to module maps.
+    Int_t    nItems = pItemArray->GetEntries();
+    Double_t maxadc = GetResp()->MaxAdc();
+    Bool_t sig = kFALSE;
     
-  // cout << "Adding "<< nItems <<" SDigits to module " << fModule << endl;
-  for( Int_t i=0; iAt( i ));
-    if( pItem->GetModule() != fModule ) {
-      Error( "AliITSsimulationSDD",
-	     "Error reading, SDigits module %d != current module %d: exit\n",
-	     pItem->GetModule(), fModule );
-      return sig;
-    } // end if
-
-    if(pItem->GetSignal()>0.0 ) sig = kTRUE;
+    // cout << "Adding "<< nItems <<" SDigits to module " << fModule << endl;
+    for( Int_t i=0; iAt( i ));
+        if( pItem->GetModule() != fModule ) {
+            Error( "AliITSsimulationSDD","Error reading, SDigits module "
+                   "%d != current module %d: exit",
+                   pItem->GetModule(), fModule );
+            return sig;
+        } // end if
+
+        if(pItem->GetSignal()>0.0 ) sig = kTRUE;
         
-    fpList->AddItemTo( mask, pItem ); // Add SignalAfterElect + noise
-    AliITSpListItem * pItem2 = fpList->GetpListItem( pItem->GetIndex() );
-    Double_t sigAE = pItem2->GetSignalAfterElect();
-    if( sigAE >= maxadc ) sigAE = maxadc-1; // avoid overflow signal
-    Int_t ia;
-    Int_t it;
-    fpList->GetMapIndex( pItem->GetIndex(), ia, it );
-    fHitMap2->SetHit( ia, it, sigAE );
-    fAnodeFire[ia] = kTRUE;
-  }
-  return sig;
+        fpList->AddItemTo( mask, pItem ); // Add SignalAfterElect + noise
+        AliITSpListItem * pItem2 = fpList->GetpListItem( pItem->GetIndex() );
+        Double_t sigAE = pItem2->GetSignalAfterElect();
+        if( sigAE >= maxadc ) sigAE = maxadc-1; // avoid overflow signal
+        Int_t ia;
+        Int_t it;
+        fpList->GetMapIndex( pItem->GetIndex(), ia, it );
+        fHitMap2->SetHit( ia, it, sigAE );
+        fAnodeFire[ia] = kTRUE;
+    }
+    return sig;
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::FinishSDigitiseModule() {
-  // digitize module using the "slow" detector simulator from
-  // the sum of summable digits.
-  FinishDigits() ;
-  ClearMaps();
+    // digitize module using the "slow" detector simulator from
+    // the sum of summable digits.
+    FinishDigits() ;
+    ClearMaps();
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::DigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){
-  // create maps to build the lists of tracks for each digit
+    // create maps to build the lists of tracks for each digit
 
-  TObjArray *fHits = mod->GetHits();
-  Int_t nhits      = fHits->GetEntriesFast();
+    TObjArray *fHits = mod->GetHits();
+    Int_t nhits      = fHits->GetEntriesFast();
 
-  InitSimulationModule( md, ev );
+    InitSimulationModule( md, ev );
 
-  if( !nhits && fCheckNoise ) {
-    ChargeToSignal( kTRUE );  // process noise
-    GetNoise();
-    ClearMaps();
-    return;
-  } else 
-    if( !nhits ) return;
+    if( !nhits && fCheckNoise ) {
+        ChargeToSignal( kTRUE );  // process noise
+        GetNoise();
+        ClearMaps();
+        return;
+    } else 
+        if( !nhits ) return;
         
-  HitsToAnalogDigits( mod );
-  ChargeToSignal( kTRUE );  // process signal + noise
-
-  for( Int_t i=0; iGetHitIndex( i, j );
-      AliITSpListItem pItemTmp2( fModule, index, 0. );
-      // put the fScaleSize analog digits in only one
-      for( Int_t ik=0; ikGetpListItem( i, jdx+ik );
-	if( pItemTmp == 0 ) continue;
-	pItemTmp2.Add( pItemTmp );
-      }
-      fpList->DeleteHit( i, j );
-      fpList->AddItemTo( 0, &pItemTmp2 );
+    HitsToAnalogDigits( mod );
+    ChargeToSignal( kTRUE );  // process signal + noise
+
+    for( Int_t i=0; iGetHitIndex( i, j );
+            AliITSpListItem pItemTmp2( fModule, index, 0. );
+            // put the fScaleSize analog digits in only one
+            for( Int_t ik=0; ikGetpListItem( i, jdx+ik );
+                if( pItemTmp == 0 ) continue;
+                pItemTmp2.Add( pItemTmp );
+            }
+            fpList->DeleteHit( i, j );
+            fpList->AddItemTo( 0, &pItemTmp2 );
+        }
     }
-  }
-
-  FinishDigits();
-  ClearMaps();
+    FinishDigits();
+    ClearMaps();
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::FinishDigits() {
-  // introduce the electronics effects and do zero-suppression if required
+    // introduce the electronics effects and do zero-suppression if required
 
-  ApplyDeadChannels();
-  if( fCrosstalkFlag ) ApplyCrosstalk();
+    ApplyDeadChannels();
+    if( fCrosstalkFlag ) ApplyCrosstalk();
 
-  const char *kopt = fResponse->ZeroSuppOption();
-  ZeroSuppression( kopt );
+    const char *kopt = GetResp()->ZeroSuppOption();
+    ZeroSuppression( kopt );
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::HitsToAnalogDigits( AliITSmodule *mod ) {
-  // create maps to build the lists of tracks for each digit
-
-  TObjArray *fHits    = mod->GetHits();
-  Int_t      nhits    = fHits->GetEntriesFast();
-  //    Int_t      arg[6]   = {0,0,0,0,0,0};
-  Int_t    dummy      = 0;
-  Int_t    nofAnodes  = fNofMaps/2;
-  Float_t  sddLength  = fSegmentation->Dx();
-  Float_t  sddWidth   = fSegmentation->Dz();
-  Float_t  anodePitch = fSegmentation->Dpz(dummy);
-  Float_t  timeStep   = fSegmentation->Dpx(dummy);
-  Float_t  driftSpeed = fResponse->DriftSpeed();
-  Float_t  maxadc     = fResponse->MaxAdc();    
-  Float_t  topValue   = fResponse->DynamicRange();
-  Float_t  cHloss     = fResponse->ChargeLoss();
-  Float_t  norm       = maxadc/topValue;
-  Float_t  dfCoeff, s1; fResponse->DiffCoeff(dfCoeff,s1); // Signal 2d Shape
-  Double_t eVpairs    = 3.6;  // electron pair energy eV.
-  Float_t  nsigma     = fResponse->NSigmaIntegration(); //
-  Int_t    nlookups   = fResponse->GausNLookUp();       //
-  Float_t  jitter     = ((AliITSresponseSDD*)fResponse)->JitterError(); // 
-
-  // Piergiorgio's part (apart for few variables which I made float
-  // when i thought that can be done
-  // Fill detector maps with GEANT hits
-  // loop over hits in the module
-
-  const Float_t kconv = 1.0e+6;  // GeV->KeV
-  Int_t    itrack      = 0;
-  Int_t    hitDetector; // detector number (lay,lad,hitDetector)
-  Int_t    iWing;       // which detector wing/side.
-  Int_t    detector;    // 2*(detector-1)+iWing
-  Int_t    ii,kk,ka,kt; // loop indexs
-  Int_t    ia,it,index; // sub-pixel integration indexies
-  Int_t    iAnode;      // anode number.
-  Int_t    timeSample;  // time buckett.
-  Int_t    anodeWindow; // anode direction charge integration width
-  Int_t    timeWindow;  // time direction charge integration width
-  Int_t    jamin,jamax; // anode charge integration window
-  Int_t    jtmin,jtmax; // time charge integration window
-  Int_t    ndiv;        // Anode window division factor.
-  Int_t    nsplit;      // the number of splits in anode and time windows==1.
-  Int_t    nOfSplits;   // number of times track length is split into
-  Float_t  nOfSplitsF;  // Floating point version of nOfSplits.
-  Float_t  kkF;         // Floating point version of loop index kk.
-  Float_t  pathInSDD; // Track length in SDD.
-  Float_t  drPath; // average position of track in detector. in microns
-  Float_t  drTime; // Drift time
-  Float_t  nmul;   // drift time window multiplication factor.
-  Float_t  avDrft;  // x position of path length segment in cm.
-  Float_t  avAnode; // Anode for path length segment in Anode number (float)
-  Float_t  xAnode;  // Floating point anode number.
-  Float_t  driftPath; // avDrft in microns.
-  Float_t  width;     // width of signal at anodes.
-  Double_t  depEnergy; // Energy deposited in this GEANT step.
-  Double_t  xL[3],dxL[3]; // local hit coordinates and diff.
-  Double_t sigA; // sigma of signal at anode.
-  Double_t sigT; // sigma in time/drift direction for track segment
-  Double_t aStep,aConst; // sub-pixel size and offset anode
-  Double_t tStep,tConst; // sub-pixel size and offset time
-  Double_t amplitude; // signal amplitude for track segment in nanoAmpere
-  Double_t chargeloss; // charge loss for track segment.
-  Double_t anodeAmplitude; // signal amplitude in anode direction
-  Double_t aExpo;          // exponent of Gaussian anode direction
-  Double_t timeAmplitude;  // signal amplitude in time direction
-  Double_t tExpo;          // exponent of Gaussian time direction
-  //  Double_t tof;            // Time of flight in ns of this step.    
-
-  for(ii=0; iiLineSegmentL(ii,xL[0],dxL[0],xL[1],dxL[1],xL[2],dxL[2],
-			  depEnergy,itrack)) continue;
-    xL[0] += 0.0001*gRandom->Gaus( 0, jitter ); //
-    depEnergy  *= kconv;
-    hitDetector = mod->GetDet();
-    //tof         = 1.E+09*(mod->GetHit(ii)->GetTOF()); // tof in ns.
-    //if(tof>sddLength/driftSpeed) continue; // hit happed too late.
-
-    // scale path to simulate a perpendicular track
-    // continue if the particle did not lose energy
-    // passing through detector
-    if (!depEnergy) {
-      if(GetDebug()){ 
-	Warning("HitsToAnalogDigits", 
-		"fTrack = %d hit=%d module=%d This particle has"
-		" passed without losing energy!",
-		itrack,ii,mod->GetIndex());
-      }
-      continue;
-    } // end if !depEnergy
-
-    pathInSDD = TMath::Sqrt(dxL[0]*dxL[0]+dxL[1]*dxL[1]+dxL[2]*dxL[2]);
-
-    if (fFlag && pathInSDD) { depEnergy *= (0.03/pathInSDD); }
-    drPath = 10000.*(dxL[0]+2.*xL[0])*0.5;
-    if(drPath < 0) drPath = -drPath;
-    drPath = sddLength-drPath;
-    if(drPath < 0) {
-      if(GetDebug()){ // this should be fixed at geometry level
-	Warning("HitsToAnalogDigits",
-		"negative drift path drPath=%e sddLength=%e dxL[0]=%e "
-		"xL[0]=%e",
-		drPath,sddLength,dxL[0],xL[0]);
-      }
-      continue;
-    } // end if drPath < 0
-
-    // Compute number of segments to brake step path into
-    drTime = drPath/driftSpeed;  //   Drift Time
-    sigA   = TMath::Sqrt(2.*dfCoeff*drTime+s1*s1);// Sigma along the anodes
-    // calcuate the number of time the path length should be split into.
-    nOfSplits = (Int_t) (1. + 10000.*pathInSDD/sigA);
-    if(fFlag) nOfSplits = 1;
-
-    // loop over path segments, init. some variables.
-    depEnergy /= nOfSplits;
-    nOfSplitsF = (Float_t) nOfSplits;
-    for(kk=0;kk fScaleSize*fMaxNofSamples) {
-	Warning("HitsToAnalogDigits","Wrong Time Sample: %e",
-		timeSample);
-	continue;
-      } // end if timeSample > fScaleSize*fMaxNoofSamples
-
-      //   Anode
-      xAnode = 10000.*(avAnode)/anodePitch + nofAnodes/2;  // +1?
-      if(xAnode*anodePitch > sddWidth || xAnode*anodePitch < 0.) 
-	Warning("HitsToAnalogDigits",
-		"Exceedubg sddWidth=%e Z = %e",
-		sddWidth,xAnode*anodePitch);
-      iAnode = (Int_t) (1.+xAnode); // xAnode?
-      if(iAnode < 1 || iAnode > nofAnodes) {
-	Warning("HitToAnalogDigits","Wrong iAnode: 1<%d>%d",
-		iAnode,nofAnodes);
-	continue;
-      } // end if iAnode < 1 || iAnode > nofAnodes
-
-      // store straight away the particle position in the array
-      // of particles and take idhit=ii only when part is entering (this
-      // requires FillModules() in the macro for analysis) :
+    // create maps to build the lists of tracks for each digit
+
+    TObjArray *hits     = mod->GetHits();
+    Int_t      nhits    = hits->GetEntriesFast();
+    //    Int_t      arg[6]   = {0,0,0,0,0,0};
+    Int_t    dummy      = 0;
+    Int_t    nofAnodes  = fNofMaps/2;
+    Float_t  sddLength  = GetSeg()->Dx();
+    Float_t  sddWidth   = GetSeg()->Dz();
+    Float_t  anodePitch = GetSeg()->Dpz(dummy);
+    Float_t  timeStep   = GetSeg()->Dpx(dummy);
+    Float_t  driftSpeed = GetResp()->DriftSpeed();
+    Float_t  maxadc     = GetResp()->MaxAdc();    
+    Float_t  topValue   = GetResp()->DynamicRange();
+    Float_t  cHloss     = GetResp()->ChargeLoss();
+    Float_t  norm       = maxadc/topValue;
+    Double_t dfCoeff, s1; GetResp()->DiffCoeff(dfCoeff,s1); // Signal 2d Shape
+    Double_t eVpairs    = 3.6;  // electron pair energy eV.
+                                // GetResp()->GetGeVToCharge()/1.0E8; //2.778
+    Float_t  nsigma     = GetResp()->NSigmaIntegration(); //
+    Int_t    nlookups   = GetResp()->GausNLookUp();       //
+    Float_t  jitter     = ((AliITSresponseSDD*)GetResp())->JitterError(); // 
+
+    // Piergiorgio's part (apart for few variables which I made float
+    // when i thought that can be done
+    // Fill detector maps with GEANT hits
+    // loop over hits in the module
+
+    const Float_t kconv = 1.0e+6;  // GeV->KeV
+    Int_t    itrack      = 0;
+    Int_t    hitDetector; // detector number (lay,lad,hitDetector)
+    Int_t    iWing;       // which detector wing/side.
+    Int_t    detector;    // 2*(detector-1)+iWing
+    Int_t    ii,kk,ka,kt; // loop indexs
+    Int_t    ia,it,index; // sub-pixel integration indexies
+    Int_t    iAnode;      // anode number.
+    Int_t    timeSample;  // time buckett.
+    Int_t    anodeWindow; // anode direction charge integration width
+    Int_t    timeWindow;  // time direction charge integration width
+    Int_t    jamin,jamax; // anode charge integration window
+    Int_t    jtmin,jtmax; // time charge integration window
+    Int_t    ndiv;        // Anode window division factor.
+    Int_t    nsplit;      // the number of splits in anode and time windows==1.
+    Int_t    nOfSplits;   // number of times track length is split into
+    Float_t  nOfSplitsF;  // Floating point version of nOfSplits.
+    Float_t  kkF;         // Floating point version of loop index kk.
+    Float_t  pathInSDD; // Track length in SDD.
+    Float_t  drPath; // average position of track in detector. in microns
+    Float_t  drTime; // Drift time
+    Float_t  nmul;   // drift time window multiplication factor.
+    Float_t  avDrft;  // x position of path length segment in cm.
+    Float_t  avAnode; // Anode for path length segment in Anode number (float)
+    Float_t  xAnode;  // Floating point anode number.
+    Float_t  driftPath; // avDrft in microns.
+    Float_t  width;     // width of signal at anodes.
+    Double_t  depEnergy; // Energy deposited in this GEANT step.
+    Double_t  xL[3],dxL[3]; // local hit coordinates and diff.
+    Double_t sigA; // sigma of signal at anode.
+    Double_t sigT; // sigma in time/drift direction for track segment
+    Double_t aStep,aConst; // sub-pixel size and offset anode
+    Double_t tStep,tConst; // sub-pixel size and offset time
+    Double_t amplitude; // signal amplitude for track segment in nanoAmpere
+    Double_t chargeloss; // charge loss for track segment.
+    Double_t anodeAmplitude; // signal amplitude in anode direction
+    Double_t aExpo;          // exponent of Gaussian anode direction
+    Double_t timeAmplitude;  // signal amplitude in time direction
+    Double_t tExpo;          // exponent of Gaussian time direction
+    //  Double_t tof;            // Time of flight in ns of this step.    
+
+    for(ii=0; iiLineSegmentL(ii,xL[0],dxL[0],xL[1],dxL[1],xL[2],dxL[2],
+                              depEnergy,itrack)) continue;
+        xL[0] += 0.0001*gRandom->Gaus( 0, jitter ); //
+        depEnergy  *= kconv;
+        hitDetector = mod->GetDet();
+        //tof         = 1.E+09*(mod->GetHit(ii)->GetTOF()); // tof in ns.
+        //if(tof>sddLength/driftSpeed) continue; // hit happed too late.
+        
+        // scale path to simulate a perpendicular track
+        // continue if the particle did not lose energy
+        // passing through detector
+        if (!depEnergy) {
+            if(GetDebug()){ 
+                Warning("HitsToAnalogDigits", 
+                        "fTrack = %d hit=%d module=%d This particle has"
+                        " passed without losing energy!",
+                        itrack,ii,mod->GetIndex());
+            }
+            continue;
+        } // end if !depEnergy
+
+        pathInSDD = TMath::Sqrt(dxL[0]*dxL[0]+dxL[1]*dxL[1]+dxL[2]*dxL[2]);
+
+        if (fFlag && pathInSDD) { depEnergy *= (0.03/pathInSDD); }
+        drPath = 10000.*(dxL[0]+2.*xL[0])*0.5;
+        if(drPath < 0) drPath = -drPath;
+        drPath = sddLength-drPath;
+        if(drPath < 0) {
+            if(GetDebug()){ // this should be fixed at geometry level
+                Warning("HitsToAnalogDigits",
+                        "negative drift path drPath=%e sddLength=%e dxL[0]=%e "
+                        "xL[0]=%e",
+                        drPath,sddLength,dxL[0],xL[0]);
+            }
+            continue;
+        } // end if drPath < 0
+
+        // Compute number of segments to brake step path into
+        drTime = drPath/driftSpeed;  //   Drift Time
+        sigA   = TMath::Sqrt(2.*dfCoeff*drTime+s1*s1);// Sigma along the anodes
+        // calcuate the number of time the path length should be split into.
+        nOfSplits = (Int_t) (1. + 10000.*pathInSDD/sigA);
+        if(fFlag) nOfSplits = 1;
+
+        // loop over path segments, init. some variables.
+        depEnergy /= nOfSplits;
+        nOfSplitsF = (Float_t) nOfSplits;
+        for(kk=0;kk fScaleSize*fMaxNofSamples) {
+                Warning("HitsToAnalogDigits","Wrong Time Sample: %e",
+                        timeSample);
+                continue;
+            } // end if timeSample > fScaleSize*fMaxNoofSamples
+
+            //   Anode
+            xAnode = 10000.*(avAnode)/anodePitch + nofAnodes/2;  // +1?
+            if(xAnode*anodePitch > sddWidth || xAnode*anodePitch < 0.) 
+                Warning("HitsToAnalogDigits",
+                        "Exceedubg sddWidth=%e Z = %e",
+                        sddWidth,xAnode*anodePitch);
+            iAnode = (Int_t) (1.+xAnode); // xAnode?
+            if(iAnode < 1 || iAnode > nofAnodes) {
+                Warning("HitToAnalogDigits","Wrong iAnode: 1<%d>%d",
+                        iAnode,nofAnodes);
+                continue;
+            } // end if iAnode < 1 || iAnode > nofAnodes
+
+            // store straight away the particle position in the array
+            // of particles and take idhit=ii only when part is entering (this
+            // requires FillModules() in the macro for analysis) :
     
-      // Sigma along the anodes for track segment.
-      sigA       = TMath::Sqrt(2.*dfCoeff*drTime+s1*s1);
-      sigT       = sigA/driftSpeed;
-      // Peak amplitude in nanoAmpere
-      amplitude  = fScaleSize*160.*depEnergy/
-	(timeStep*eVpairs*2.*acos(-1.)*sigT*sigA);
-      amplitude *= timeStep/25.; // WARNING!!!!! Amplitude scaling to 
-      // account for clock variations 
-      // (reference value: 40 MHz)
-      chargeloss = 1.-cHloss*driftPath/1000;
-      amplitude *= chargeloss;
-      width  = 2.*nsigma/(nlookups-1);
-      // Spread the charge 
-      // Pixel index
-      ndiv = 2;
-      nmul = 3.; 
-      if(drTime > 1200.) { 
-	ndiv = 4;
-	nmul = 1.5;
-      } // end if drTime > 1200.
-      // Sub-pixel index
-      nsplit = 4; // hard-wired //nsplit=4;nsplit = (nsplit+1)/2*2;
-      // Sub-pixel size see computation of aExpo and tExpo.
-      aStep  = anodePitch/(nsplit*fScaleSize*sigA);
-      aConst = xAnode*anodePitch/sigA;
-      tStep  = timeStep/(nsplit*fScaleSize*sigT);
-      tConst = drTime/sigT;
-      // Define SDD window corresponding to the hit
-      anodeWindow = (Int_t)(fScaleSize*nsigma*sigA/anodePitch+1);
-      timeWindow  = (Int_t) (fScaleSize*nsigma*sigT/timeStep+1.);
-      jamin = (iAnode - anodeWindow/ndiv - 1)*fScaleSize*nsplit +1;
-      jamax = (iAnode + anodeWindow/ndiv)*fScaleSize*nsplit;
-      if(jamin <= 0) jamin = 1;
-      if(jamax > fScaleSize*nofAnodes*nsplit) 
-	jamax = fScaleSize*nofAnodes*nsplit;
-      // jtmin and jtmax are Hard-wired
-      jtmin = (Int_t)(timeSample-timeWindow*nmul-1)*nsplit+1;
-      jtmax = (Int_t)(timeSample+timeWindow*nmul)*nsplit;
-      if(jtmin <= 0) jtmin = 1;
-      if(jtmax > fScaleSize*fMaxNofSamples*nsplit) 
-	jtmax = fScaleSize*fMaxNofSamples*nsplit;
-      // Spread the charge in the anode-time window
-      for(ka=jamin; ka <=jamax; ka++) {
-	ia = (ka-1)/(fScaleSize*nsplit) + 1;
-	if(ia <= 0) {
-	  Warning("HitsToAnalogDigits","ia < 1: ");
-	  continue;
-	} // end if
-	if(ia > nofAnodes) ia = nofAnodes;
-	aExpo     = (aStep*(ka-0.5)-aConst);
-	if(TMath::Abs(aExpo) > nsigma)  anodeAmplitude = 0.;
-	else {
-	  dummy          = (Int_t) ((aExpo+nsigma)/width);
-	  anodeAmplitude = amplitude*fResponse->GausLookUp(dummy);
-	} // end if TMath::Abs(aEspo) > nsigma
-	// index starts from 0
-	index = ((detector+1)%2)*nofAnodes+ia-1;
-	if(anodeAmplitude) for(kt=jtmin; kt<=jtmax; kt++) {
-	  it = (kt-1)/nsplit+1;  // it starts from 1
-	  if(it<=0){
-	    Warning("HitsToAnalogDigits","it < 1:");
-	    continue;
-	  } // end if 
-	  if(it>fScaleSize*fMaxNofSamples)
-	    it = fScaleSize*fMaxNofSamples;
-	  tExpo    = (tStep*(kt-0.5)-tConst);
-	  if(TMath::Abs(tExpo) > nsigma) timeAmplitude = 0.;
-	  else {
-	    dummy         = (Int_t) ((tExpo+nsigma)/width);
-	    timeAmplitude = anodeAmplitude*
-	      fResponse->GausLookUp(dummy);
-	  } // end if TMath::Abs(tExpo) > nsigma
-	  // build the list of Sdigits for this module        
-	  //                    arg[0]         = index;
-	  //                    arg[1]         = it;
-	  //                    arg[2]         = itrack; // track number
-	  //                    arg[3]         = ii-1; // hit number.
-	  timeAmplitude *= norm;
-	  timeAmplitude *= 10;
-	  //                    ListOfFiredCells(arg,timeAmplitude,alst,padr);
-	  Double_t charge = timeAmplitude;
-	  charge += fHitMap2->GetSignal(index,it-1);
-	  fHitMap2->SetHit(index, it-1, charge);
-	  fpList->AddSignal(index,it-1,itrack,ii-1,
-			    mod->GetIndex(),timeAmplitude);
-	  fAnodeFire[index] = kTRUE;                 
-	} // end if anodeAmplitude and loop over time in window
-      } // loop over anodes in window
-    } // end loop over "sub-hits"
-  } // end loop over hits
+            // Sigma along the anodes for track segment.
+            sigA       = TMath::Sqrt(2.*dfCoeff*drTime+s1*s1);
+            sigT       = sigA/driftSpeed;
+            // Peak amplitude in nanoAmpere
+            amplitude  = fScaleSize*160.*depEnergy/
+                (timeStep*eVpairs*2.*acos(-1.)*sigT*sigA);
+            amplitude *= timeStep/25.; // WARNING!!!!! Amplitude scaling to 
+            // account for clock variations 
+            // (reference value: 40 MHz)
+            chargeloss = 1.-cHloss*driftPath/1000;
+            amplitude *= chargeloss;
+            width  = 2.*nsigma/(nlookups-1);
+            // Spread the charge 
+            // Pixel index
+            ndiv = 2;
+            nmul = 3.; 
+            if(drTime > 1200.) { 
+                ndiv = 4;
+                nmul = 1.5;
+            } // end if drTime > 1200.
+            // Sub-pixel index
+            nsplit = 4; // hard-wired //nsplit=4;nsplit = (nsplit+1)/2*2;
+            // Sub-pixel size see computation of aExpo and tExpo.
+            aStep  = anodePitch/(nsplit*fScaleSize*sigA);
+            aConst = xAnode*anodePitch/sigA;
+            tStep  = timeStep/(nsplit*fScaleSize*sigT);
+            tConst = drTime/sigT;
+            // Define SDD window corresponding to the hit
+            anodeWindow = (Int_t)(fScaleSize*nsigma*sigA/anodePitch+1);
+            timeWindow  = (Int_t) (fScaleSize*nsigma*sigT/timeStep+1.);
+            jamin = (iAnode - anodeWindow/ndiv - 1)*fScaleSize*nsplit +1;
+            jamax = (iAnode + anodeWindow/ndiv)*fScaleSize*nsplit;
+            if(jamin <= 0) jamin = 1;
+            if(jamax > fScaleSize*nofAnodes*nsplit) 
+                jamax = fScaleSize*nofAnodes*nsplit;
+            // jtmin and jtmax are Hard-wired
+            jtmin = (Int_t)(timeSample-timeWindow*nmul-1)*nsplit+1;
+            jtmax = (Int_t)(timeSample+timeWindow*nmul)*nsplit;
+            if(jtmin <= 0) jtmin = 1;
+            if(jtmax > fScaleSize*fMaxNofSamples*nsplit) 
+                jtmax = fScaleSize*fMaxNofSamples*nsplit;
+            // Spread the charge in the anode-time window
+            for(ka=jamin; ka <=jamax; ka++) {
+                ia = (ka-1)/(fScaleSize*nsplit) + 1;
+                if(ia <= 0) {
+                    Warning("HitsToAnalogDigits","ia < 1: ");
+                    continue;
+                } // end if
+                if(ia > nofAnodes) ia = nofAnodes;
+                aExpo     = (aStep*(ka-0.5)-aConst);
+                if(TMath::Abs(aExpo) > nsigma)  anodeAmplitude = 0.;
+                else {
+                    dummy          = (Int_t) ((aExpo+nsigma)/width);
+                    anodeAmplitude = amplitude*GetResp()->GausLookUp(dummy);
+                } // end if TMath::Abs(aEspo) > nsigma
+                // index starts from 0
+                index = ((detector+1)%2)*nofAnodes+ia-1;
+                if(anodeAmplitude) for(kt=jtmin; kt<=jtmax; kt++) {
+                    it = (kt-1)/nsplit+1;  // it starts from 1
+                    if(it<=0){
+                        Warning("HitsToAnalogDigits","it < 1:");
+                        continue;
+                    } // end if 
+                    if(it>fScaleSize*fMaxNofSamples)
+                        it = fScaleSize*fMaxNofSamples;
+                    tExpo    = (tStep*(kt-0.5)-tConst);
+                    if(TMath::Abs(tExpo) > nsigma) timeAmplitude = 0.;
+                    else {
+                        dummy         = (Int_t) ((tExpo+nsigma)/width);
+                        timeAmplitude = anodeAmplitude*
+                            GetResp()->GausLookUp(dummy);
+                    } // end if TMath::Abs(tExpo) > nsigma
+                    // build the list of Sdigits for this module        
+                    //                    arg[0]     = index;
+                    //                    arg[1]     = it;
+                    //                    arg[2]     = itrack; // track number
+                    //                    arg[3]     = ii-1; // hit number.
+                    timeAmplitude *= norm;
+                    timeAmplitude *= 10;
+                    //         ListOfFiredCells(arg,timeAmplitude,alst,padr);
+                    Double_t charge = timeAmplitude;
+                    charge += fHitMap2->GetSignal(index,it-1);
+                    fHitMap2->SetHit(index, it-1, charge);
+                    fpList->AddSignal(index,it-1,itrack,ii-1,
+                                      mod->GetIndex(),timeAmplitude);
+                    fAnodeFire[index] = kTRUE;                 
+                } // end if anodeAmplitude and loop over time in window
+            } // loop over anodes in window
+        } // end loop over "sub-hits"
+    } // end loop over hits
 }
-
 /*
 //______________________________________________________________________
 void AliITSsimulationSDD::ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,
 					   TObjArray *alist,TClonesArray *padr){
-  // Returns the list of "fired" cells.
-
-  Int_t index     = arg[0];
-  Int_t ik        = arg[1];
-  Int_t idtrack   = arg[2];
-  Int_t idhit     = arg[3];
-  Int_t counter   = arg[4];
-  Int_t countadr  = arg[5];
-  Double_t charge = timeAmplitude;
-  charge += fHitMap2->GetSignal(index,ik-1);
-  fHitMap2->SetHit(index, ik-1, charge);
-
-  Int_t digits[3];
-  Int_t it = (Int_t)((ik-1)/fScaleSize);
-  digits[0] = index;
-  digits[1] = it;
-  digits[2] = (Int_t)timeAmplitude;
-  Float_t phys;
-  if (idtrack >= 0) phys = (Float_t)timeAmplitude;
-  else phys = 0;
-
-  Double_t cellcharge = 0.;
-  AliITSTransientDigit* pdigit;
-  // build the list of fired cells and update the info
-  if (!fHitMap1->TestHit(index, it)) {
-    new((*padr)[countadr++]) TVector(3);
-    TVector &trinfo=*((TVector*) (*padr)[countadr-1]);
-    trinfo(0) = (Float_t)idtrack;
-    trinfo(1) = (Float_t)idhit;
-    trinfo(2) = (Float_t)timeAmplitude;
-
-    alist->AddAtAndExpand(new AliITSTransientDigit(phys,digits),counter);
-    fHitMap1->SetHit(index, it, counter);
-    counter++;
-    pdigit=(AliITSTransientDigit*)alist->At(alist->GetLast());
-    // list of tracks
-    TObjArray *trlist=(TObjArray*)pdigit->TrackList();
-    trlist->Add(&trinfo);
-  } else {
-    pdigit = (AliITSTransientDigit*) fHitMap1->GetHit(index, it);
-    for(Int_t kk=0;kkGetSignal(index,fScaleSize*it+kk);
-    }  // end for kk
-    // update charge
-    (*pdigit).fSignal = (Int_t)cellcharge;
-    (*pdigit).fPhysics += phys;                        
-    // update list of tracks
-    TObjArray* trlist = (TObjArray*)pdigit->TrackList();
-    Int_t lastentry = trlist->GetLast();
-    TVector *ptrkp = (TVector*)trlist->At(lastentry);
-    TVector &trinfo = *ptrkp;
-    Int_t lasttrack = Int_t(trinfo(0));
-    Float_t lastcharge=(trinfo(2));
-    if (lasttrack==idtrack ) {
-      lastcharge += (Float_t)timeAmplitude;
-      trlist->RemoveAt(lastentry);
-      trinfo(0) = lasttrack;
-      trinfo(1) = idhit;
-      trinfo(2) = lastcharge;
-      trlist->AddAt(&trinfo,lastentry);
-    } else {                  
-      new((*padr)[countadr++]) TVector(3);
-      TVector &trinfo=*((TVector*) (*padr)[countadr-1]);
-      trinfo(0) = (Float_t)idtrack;
-      trinfo(1) = (Float_t)idhit;
-      trinfo(2) = (Float_t)timeAmplitude;
-      trlist->Add(&trinfo);
-    } // end if lasttrack==idtrack
-
-#ifdef print
-    // check the track list - debugging
-    Int_t trk[20], htrk[20];
-    Float_t chtrk[20];  
-    Int_t nptracks = trlist->GetEntriesFast();
-    if (nptracks > 2) {
-      Int_t tr;
-      for (tr=0;trAt(tr);
-	TVector &pptrk  = *pptrkp;
-	trk[tr]   = Int_t(pptrk(0));
-	htrk[tr]  = Int_t(pptrk(1));
-	chtrk[tr] = (pptrk(2));
-	cout << "nptracks "<GetSignal(index,ik-1);
+    fHitMap2->SetHit(index, ik-1, charge);
+
+    Int_t digits[3];
+    Int_t it = (Int_t)((ik-1)/fScaleSize);
+    digits[0] = index;
+    digits[1] = it;
+    digits[2] = (Int_t)timeAmplitude;
+    Float_t phys;
+    if (idtrack >= 0) phys = (Float_t)timeAmplitude;
+    else phys = 0;
+
+    Double_t cellcharge = 0.;
+    AliITSTransientDigit* pdigit;
+    // build the list of fired cells and update the info
+    if (!fHitMap1->TestHit(index, it)) {
+        new((*padr)[countadr++]) TVector(3);
+        TVector &trinfo=*((TVector*) (*padr)[countadr-1]);
+        trinfo(0) = (Float_t)idtrack;
+        trinfo(1) = (Float_t)idhit;
+        trinfo(2) = (Float_t)timeAmplitude;
+      
+        alist->AddAtAndExpand(new AliITSTransientDigit(phys,digits),counter);
+        fHitMap1->SetHit(index, it, counter);
+        counter++;
+        pdigit=(AliITSTransientDigit*)alist->At(alist->GetLast());
+        // list of tracks
+        TObjArray *trlist=(TObjArray*)pdigit->TrackList();
+        trlist->Add(&trinfo);
+    } else {
+        pdigit = (AliITSTransientDigit*) fHitMap1->GetHit(index, it);
+        for(Int_t kk=0;kkGetSignal(index,fScaleSize*it+kk);
+        }  // end for kk
+        // update charge
+        (*pdigit).fSignal = (Int_t)cellcharge;
+        (*pdigit).fPhysics += phys;                        
+        // update list of tracks
+        TObjArray* trlist = (TObjArray*)pdigit->TrackList();
+        Int_t lastentry = trlist->GetLast();
+        TVector *ptrkp = (TVector*)trlist->At(lastentry);
+        TVector &trinfo = *ptrkp;
+        Int_t lasttrack = Int_t(trinfo(0));
+        Float_t lastcharge=(trinfo(2));
+        if (lasttrack==idtrack ) {
+            lastcharge += (Float_t)timeAmplitude;
+            trlist->RemoveAt(lastentry);
+            trinfo(0) = lasttrack;
+            trinfo(1) = idhit;
+            trinfo(2) = lastcharge;
+            trlist->AddAt(&trinfo,lastentry);
+        } else {                  
+            new((*padr)[countadr++]) TVector(3);
+            TVector &trinfo=*((TVector*) (*padr)[countadr-1]);
+            trinfo(0) = (Float_t)idtrack;
+            trinfo(1) = (Float_t)idhit;
+            trinfo(2) = (Float_t)timeAmplitude;
+            trlist->Add(&trinfo);
+        } // end if lasttrack==idtrack
+
+        if(GetDebug()){
+            // check the track list - debugging
+            Int_t trk[20], htrk[20];
+            Float_t chtrk[20];  
+            Int_t nptracks = trlist->GetEntriesFast();
+            if (nptracks > 2) {
+                Int_t tr;
+                for (tr=0;trAt(tr);
+                    TVector &pptrk  = *pptrkp;
+                    trk[tr]   = Int_t(pptrk(0));
+                    htrk[tr]  = Int_t(pptrk(1));
+                    chtrk[tr] = (pptrk(2));
+                    cout << "nptracks "<GetpListItem( i, j );
-  if( pItem == 0 ) {
-    phys = 0.0;
-    for( Int_t l=0; lGetpListItem( i, j );
+    if( pItem == 0 ) {
+        phys = 0.0;
+        for( Int_t l=0; lGetTrack( 0 );
+        if( idtrack >= 0 ) phys = pItem->GetSignal();  
+        else phys = 0.0;
+
+        for( Int_t l=0; lGetMaxKept()) {
+            tracks[l]  = pItem->GetTrack( l );
+            hits[l]    = pItem->GetHit( l );
+            charges[l] = pItem->GetSignal( l );
+        }else{
+            tracks[l]  = -3;
+            hits[l]    = -1;
+            charges[l] = 0.0;
+        }// end for if
     }
-  } else {
-    Int_t idtrack =  pItem->GetTrack( 0 );
-    if( idtrack >= 0 ) phys = pItem->GetSignal();  
-    else phys = 0.0;
-
-    for( Int_t l=0; lGetMaxKept()) {
-      tracks[l]  = pItem->GetTrack( l );
-      hits[l]    = pItem->GetHit( l );
-      charges[l] = pItem->GetSignal( l );
-    }else{
-      tracks[l]  = -3;
-      hits[l]    = -1;
-      charges[l] = 0.0;
-    }// end for if
-  }
-
-  fITS->AddSimDigit( 1, phys, digits, tracks, hits, charges ); 
-  delete [] tracks;
-  delete [] hits;
-  delete [] charges;
-}
 
+    fITS->AddSimDigit( 1, phys, digits, tracks, hits, charges ); 
+    delete [] tracks;
+    delete [] hits;
+    delete [] charges;
+}
 //______________________________________________________________________
 void AliITSsimulationSDD::ChargeToSignal(Bool_t bAddNoise) {
-  // add baseline, noise, electronics and ADC saturation effects
-
-  char opt1[20], opt2[20];
-  fResponse->ParamOptions(opt1,opt2);
-  char *read = strstr(opt1,"file");
-  Float_t baseline, noise; 
-
-  if (read) {
-    static Bool_t readfile=kTRUE;
-    //read baseline and noise from file
-    if (readfile) ReadBaseline();
-    readfile=kFALSE;
-  } else fResponse->GetNoiseParam(noise,baseline);
-
-  Float_t contrib=0;
-  Int_t i,k,kk;
-  Float_t maxadc = fResponse->MaxAdc();    
-  if(!fDoFFT) {
+    // add baseline, noise, electronics and ADC saturation effects
+
+    char opt1[20], opt2[20];
+    GetResp()->ParamOptions(opt1,opt2);
+    char *read = strstr(opt1,"file");
+    Double_t baseline, noise; 
+
+    if (read) {
+        static Bool_t readfile=kTRUE;
+        //read baseline and noise from file
+        if (readfile) ReadBaseline();
+        readfile=kFALSE;
+    } else GetResp()->GetNoiseParam(noise,baseline);
+
+    Float_t contrib=0;
+    Int_t i,k,kk;
+    Float_t maxadc = GetResp()->MaxAdc();    
+    if(!fDoFFT) {
+        for (i=0;iGetSignal(i,k);
+                if( bAddNoise ) {
+                    contrib   = (baseline + noise*gRandom->Gaus());
+                    fInZR[k] += contrib;
+                }
+            } // end for k
+            for(k=0; k maxcont) maxcont = newcont;
+                } // end for kk
+                newcont = maxcont;
+                if (newcont >= maxadc) newcont = maxadc -1;
+                if(newcont >= baseline){
+                    Warning("","newcont=%d>=baseline=%d",newcont,baseline);
+                } // end if
+                // back to analog: ?
+                fHitMap2->SetHit(i,k,newcont);
+            }  // end for k
+        } // end for i loop over anodes
+        return;
+    } // end if DoFFT
+
     for (i=0;iGetSignal(i,k);
-	if( bAddNoise ) {
-	  contrib   = (baseline + noise*gRandom->Gaus());
-	  fInZR[k] += contrib;
-	}
-      } // end for k
-      for(k=0; k maxcont) maxcont = newcont;
-	} // end for kk
-	newcont = maxcont;
-	if (newcont >= maxadc) newcont = maxadc -1;
-	if(newcont >= baseline){
-	  Warning("","newcont=%d>=baseline=%d",newcont,baseline);
-	} // end if
-	// back to analog: ?
-	fHitMap2->SetHit(i,k,newcont);
-      }  // end for k
+        if( !fAnodeFire[i] ) continue;
+        if  (read && iGetSignal(i,k);
+            if( bAddNoise ) {
+                contrib   = (baseline + noise*gRandom->Gaus());
+                fInZR[k] += contrib;
+            }
+            fInZI[k]  = 0.;
+        } // end for k
+        FastFourierTransform(fElectronics,&fInZR[0],&fInZI[0],1);
+        for(k=0; kGetTraFunReal(k);
+            Double_t iw = fElectronics->GetTraFunImag(k);
+            fOutZR[k]   = fInZR[k]*rw - fInZI[k]*iw;
+            fOutZI[k]   = fInZR[k]*iw + fInZI[k]*rw;
+        } // end for k
+        FastFourierTransform(fElectronics,&fOutZR[0],&fOutZI[0],-1);
+        for(k=0; k maxcont1) maxcont1 = newcont1;
+            } // end for kk
+            newcont1 = maxcont1;
+            if (newcont1 >= maxadc) newcont1 = maxadc -1;
+            fHitMap2->SetHit(i,k,newcont1);
+        } // end for k
     } // end for i loop over anodes
     return;
-  } // end if DoFFT
-
-  for (i=0;iGetSignal(i,k);
-      if( bAddNoise ) {
-	contrib   = (baseline + noise*gRandom->Gaus());
-	fInZR[k] += contrib;
-      }
-      fInZI[k]  = 0.;
-    } // end for k
-    FastFourierTransform(fElectronics,&fInZR[0],&fInZI[0],1);
-    for(k=0; kGetTraFunReal(k);
-      Double_t iw = fElectronics->GetTraFunImag(k);
-      fOutZR[k]   = fInZR[k]*rw - fInZI[k]*iw;
-      fOutZI[k]   = fInZR[k]*iw + fInZI[k]*rw;
-    } // end for k
-    FastFourierTransform(fElectronics,&fOutZR[0],&fOutZI[0],-1);
-    for(k=0; k maxcont1) maxcont1 = newcont1;
-      } // end for kk
-      newcont1 = maxcont1;
-      if (newcont1 >= maxadc) newcont1 = maxadc -1;
-      fHitMap2->SetHit(i,k,newcont1);
-    } // end for k
-  } // end for i loop over anodes
-  return;
 }
 //____________________________________________________________________
 void AliITSsimulationSDD::ApplyDeadChannels() {    
-  // Set dead channel signal to zero
-  AliITSresponseSDD * response = (AliITSresponseSDD *)fResponse;
+    // Set dead channel signal to zero
+    AliITSresponseSDD * response = (AliITSresponseSDD *)GetResp();
     
-  // nothing to do
-  if( response->GetDeadModules() == 0 && 
-      response->GetDeadChips() == 0 && 
-      response->GetDeadChannels() == 0 )
-    return;  
+    // nothing to do
+    if( response->GetDeadModules() == 0 && 
+        response->GetDeadChips() == 0 && 
+        response->GetDeadChannels() == 0 )
+        return;  
     
-  static AliITS *iTS = (AliITS*)gAlice->GetModule( "ITS" );
-
-  Int_t fMaxNofSamples = fSegmentation->Npx();    
-  AliITSgeom *geom = iTS->GetITSgeom();
-  Int_t firstSDDMod = geom->GetStartDet( 1 );
-  // loop over wings
-  for( Int_t j=0; j<2; j++ ) {
-    Int_t mod = (fModule-firstSDDMod)*2 + j;
-    for( Int_t u=0; uChips(); u++ )
-      for( Int_t v=0; vChannels(); v++ ) {
-	Float_t Gain = response->Gain( mod, u, v );
-	for( Int_t k=0; kChips()*response->Channels() +
-	    u*response->Channels() + 
-	    v;
-	  Double_t signal =  Gain * fHitMap2->GetSignal( i, k );
-	  fHitMap2->SetHit( i, k, signal );  ///
-	}
-      }
-  }    
+    static AliITS *iTS = (AliITS*)gAlice->GetModule( "ITS" );
+
+    Int_t fMaxNofSamples = GetSeg()->Npx();    
+    AliITSgeom *geom = iTS->GetITSgeom();
+    Int_t firstSDDMod = geom->GetStartDet( 1 );
+    // loop over wings
+    for( Int_t j=0; j<2; j++ ) {
+        Int_t mod = (fModule-firstSDDMod)*2 + j;
+        for( Int_t u=0; uChips(); u++ )
+            for( Int_t v=0; vChannels(); v++ ) {
+                Float_t Gain = response->Gain( mod, u, v );
+                for( Int_t k=0; kChips()*response->Channels() +
+                        u*response->Channels() + 
+                        v;
+                    Double_t signal =  Gain * fHitMap2->GetSignal( i, k );
+                    fHitMap2->SetHit( i, k, signal );  ///
+                }
+            }
+    }    
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::ApplyCrosstalk() {
-  // function add the crosstalk effect to signal
-  // temporal function, should be checked...!!!
-    
-  Int_t fNofMaps = fSegmentation->Npz();
-  Int_t fMaxNofSamples = fSegmentation->Npx();
+    // function add the crosstalk effect to signal
+    // temporal function, should be checked...!!!
 
-  // create and inizialice crosstalk map
-  Float_t* ctk = new Float_t[fNofMaps*fMaxNofSamples+1];
-  if( ctk == NULL ) {
-    Error( "ApplyCrosstalk", "no memory for temporal map: exit \n" );
-    return;
-  }
-  memset( ctk, 0, sizeof(Float_t)*(fNofMaps*fMaxNofSamples+1) );
-    
-  Float_t noise, baseline;
-  fResponse->GetNoiseParam( noise, baseline );
-    
-  for( Int_t z=0; zNpz();
+    Int_t fMaxNofSamples = GetSeg()->Npx();
+
+    // create and inizialice crosstalk map
+    Float_t* ctk = new Float_t[fNofMaps*fMaxNofSamples+1];
+    if( ctk == NULL ) {
+        Error( "ApplyCrosstalk", "no memory for temporal map: exit \n" );
+        return;
+    }
+    memset( ctk, 0, sizeof(Float_t)*(fNofMaps*fMaxNofSamples+1) );
+
+    Double_t noise, baseline;
+    GetResp()->GetNoiseParam( noise, baseline );
+
+    for( Int_t z=0; zGetSignal( z, l );
-      if( fadc > baseline ) {
-	if( on == kFALSE && lGetSignal( z, l+1 );
-	  if( fadc1 < fadc ) continue;
-	  on = kTRUE;
-	  nTsteps = 0;
-	  tstart = l;
-	}
-	nTsteps++;
-      }
-      else { // end fadc > baseline
-	if( on == kTRUE ) {        
-	  if( nTsteps > 2 ) {
-	    tstop = l;
-	    // make smooth derivative
-	    Float_t* dev = new Float_t[fMaxNofSamples+1];
-	    memset( dev, 0, sizeof(Float_t)*(fMaxNofSamples+1) );
-	    if( ctk == NULL ) {
-	      Error( "ApplyCrosstalk", 
-		     "no memory for temporal array: exit \n" );
-	      return;
-	    }
-	    for( Int_t i=tstart; i 2 && i < fMaxNofSamples-2 )
-		dev[i] = -0.2*fHitMap2->GetSignal( z,i-2 ) 
-		  -0.1*fHitMap2->GetSignal( z,i-1 ) 
-		  +0.1*fHitMap2->GetSignal( z,i+1 ) 
-		  +0.2*fHitMap2->GetSignal( z,i+2 );
-	    }
+        for( Int_t l=0; lGetSignal( z, l );
+            if( fadc > baseline ) {
+                if( on == kFALSE && lGetSignal( z, l+1 );
+                    if( fadc1 < fadc ) continue;
+                    on = kTRUE;
+                    nTsteps = 0;
+                    tstart = l;
+                }
+                nTsteps++;
+            }
+            else { // end fadc > baseline
+                if( on == kTRUE ) {        
+                    if( nTsteps > 2 ) {
+                        tstop = l;
+                        // make smooth derivative
+                        Float_t* dev = new Float_t[fMaxNofSamples+1];
+                        memset( dev, 0, sizeof(Float_t)*(fMaxNofSamples+1) );
+                        if( ctk == NULL ) {
+                            Error( "ApplyCrosstalk", 
+                                   "no memory for temporal array: exit \n" );
+                            return;
+                        }
+                        for( Int_t i=tstart; i 2 && i < fMaxNofSamples-2 )
+                                dev[i] = -0.2*fHitMap2->GetSignal( z,i-2 ) 
+                                    -0.1*fHitMap2->GetSignal( z,i-1 ) 
+                                    +0.1*fHitMap2->GetSignal( z,i+1 ) 
+                                    +0.2*fHitMap2->GetSignal( z,i+2 );
+                        }
                         
-	    // add crosstalk contribution to neibourg anodes  
-	    for( Int_t i=tstart; i 0 ) {
-		ctk[anode*fMaxNofSamples+i] += ctktmp;           
-	      }
-	      anode = z + 1;
-	      if( anode < fNofMaps ) {
-		ctk[anode*fMaxNofSamples+i] += ctktmp;
-	      }
-	    }
-	    delete [] dev;
+                        // add crosstalk contribution to neibourg anodes  
+                        for( Int_t i=tstart; i 0 ) {
+                                ctk[anode*fMaxNofSamples+i] += ctktmp;
+                            }
+                            anode = z + 1;
+                            if( anode < fNofMaps ) {
+                                ctk[anode*fMaxNofSamples+i] += ctktmp;
+                            }
+                        }
+                        delete [] dev;
                         
-	  } // if( nTsteps > 2 )
-	  on = kFALSE;
-	}  // if( on == kTRUE )
-      }  // else
-    }
-  }
-    
-  for( Int_t a=0; aGetSignal( a, t ) + ctk[a*fMaxNofSamples+t];
-      fHitMap2->SetHit( a, t, signal );
+                    } // if( nTsteps > 2 )
+                    on = kFALSE;
+                }  // if( on == kTRUE )
+            }  // else
+        }
     }
     
-  delete [] ctk;
+    for( Int_t a=0; aGetSignal(a,t)+ctk[a*fMaxNofSamples+t];
+            fHitMap2->SetHit( a, t, signal );
+        }
+
+    delete [] ctk;
 }
 //______________________________________________________________________
-void AliITSsimulationSDD::GetAnodeBaseline(Int_t i,Float_t &baseline,
-                                           Float_t &noise){
-  // Returns the Baseline for a particular anode.
-  baseline = fBaseline[i];
-  noise    = fNoise[i];
+void AliITSsimulationSDD::GetAnodeBaseline(Int_t i,Double_t &baseline,
+                                           Double_t &noise){
+    // Returns the Baseline for a particular anode.
+    baseline = fBaseline[i];
+    noise    = fNoise[i];
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::CompressionParam(Int_t i,Int_t &db,Int_t &tl,
                                            Int_t &th){
-  // Returns the compression alogirthm parameters
-  Int_t size = fD.GetSize();
-  if (size > 2 ) {
-    db=fD[i]; tl=fT1[i]; th=fT2[i];
-  } else {
-    if (size <= 2 && i>=fNofMaps/2) {
-      db=fD[1]; tl=fT1[1]; th=fT2[1];
+    // Returns the compression alogirthm parameters
+    Int_t size = fD.GetSize();
+    if (size > 2 ) {
+        db=fD[i]; tl=fT1[i]; th=fT2[i];
     } else {
-      db=fD[0]; tl=fT1[0]; th=fT2[0];
-    } // end if size <=2 && i>=fNofMaps/2
-  } // end if size >2
+        if (size <= 2 && i>=fNofMaps/2) {
+            db=fD[1]; tl=fT1[1]; th=fT2[1];
+        } else {
+            db=fD[0]; tl=fT1[0]; th=fT2[0];
+        } // end if size <=2 && i>=fNofMaps/2
+    } // end if size >2
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::CompressionParam(Int_t i,Int_t &db,Int_t &tl){
-  // returns the compression alogirthm parameters
-  Int_t size = fD.GetSize();
-
-  if (size > 2 ) {
-    db=fD[i]; tl=fT1[i];
-  } else {
-    if (size <= 2 && i>=fNofMaps/2) {
-      db=fD[1]; tl=fT1[1]; 
+    // returns the compression alogirthm parameters
+    Int_t size = fD.GetSize();
+
+    if (size > 2 ) {
+        db=fD[i]; tl=fT1[i];
     } else {
-      db=fD[0]; tl=fT1[0]; 
-    } // end if size <=2 && i>=fNofMaps/2
-    //	Warning("CompressionParam","\n Size= %d . Values i=%d ; db= %d ; tl= %d",size,i,db,tl);
-  } // end if size > 2
+        if (size <= 2 && i>=fNofMaps/2) {
+            db=fD[1]; tl=fT1[1]; 
+        } else {
+            db=fD[0]; tl=fT1[0]; 
+        } // end if size <=2 && i>=fNofMaps/2
+        //	Warning("CompressionParam",
+        //             "Size= %d . Values i=%d ; db= %d ; tl= %d",
+        //              size,i,db,tl);
+    } // end if size > 2
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::SetCompressParam(){
-  // Sets the compression alogirthm parameters  
-  Int_t cp[8],i;
-
-  fResponse->GiveCompressParam(cp);
-  for (i=0; i<2; i++) {
-    fD[i]   = cp[i];
-    fT1[i]  = cp[i+2];
-    fT2[i]  = cp[i+4];
-    fTol[i] = cp[i+6];
-  } // end for i
+    // Sets the compression alogirthm parameters  
+    Int_t cp[8],i;
+
+    GetResp()->GiveCompressParam(cp);
+    for (i=0; i<2; i++) {
+        fD[i]   = cp[i];
+        fT1[i]  = cp[i+2];
+        fT2[i]  = cp[i+4];
+        fTol[i] = cp[i+6];
+    } // end for i
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::ReadBaseline(){
-  // read baseline and noise from file - either a .root file and in this
-  // case data should be organised in a tree with one entry for each
-  // module => reading should be done accordingly
-  // or a classic file and do smth. like this:
-  // Read baselines and noise for SDD
-
-  Int_t na,pos;
-  Float_t bl,n;
-  char input[100], base[100], param[100];
-  char *filtmp;
-
-  fResponse->Filenames(input,base,param);
-  fFileName=base;
-  //
-  filtmp = gSystem->ExpandPathName(fFileName.Data());
-  FILE *bline = fopen(filtmp,"r");
-  na = 0;
-
-  if(bline) {
-    while(fscanf(bline,"%d %f %f",&pos, &bl, &n) != EOF) {
-      if (pos != na+1) {
-	Error("ReadBaseline","Anode number not in increasing order!",
-	      filtmp);
-	exit(1);
-      } // end if pos != na+1
-      fBaseline[na]=bl;
-      fNoise[na]=n;
-      na++;
-    } // end while
-  } else {
-    Error("ReadBaseline"," THE BASELINE FILE %s DOES NOT EXIST !",filtmp);
-    exit(1);
-  } // end if(bline)
-
-  fclose(bline);
-  delete [] filtmp;
+    // read baseline and noise from file - either a .root file and in this
+    // case data should be organised in a tree with one entry for each
+    // module => reading should be done accordingly
+    // or a classic file and do smth. like this:
+    // Read baselines and noise for SDD
+
+    Int_t na,pos;
+    Float_t bl,n;
+    char input[100], base[100], param[100];
+    char *filtmp;
+
+    GetResp()->Filenames(input,base,param);
+    fFileName=base;
+    //
+    filtmp = gSystem->ExpandPathName(fFileName.Data());
+    FILE *bline = fopen(filtmp,"r");
+    na = 0;
+
+    if(bline) {
+        while(fscanf(bline,"%d %f %f",&pos, &bl, &n) != EOF) {
+            if (pos != na+1) {
+                Error("ReadBaseline","Anode number not in increasing order!",
+                      filtmp);
+                exit(1);
+            } // end if pos != na+1
+            fBaseline[na]=bl;
+            fNoise[na]=n;
+            na++;
+        } // end while
+    } else {
+        Error("ReadBaseline"," THE BASELINE FILE %s DOES NOT EXIST !",filtmp);
+        exit(1);
+    } // end if(bline)
+
+    fclose(bline);
+    delete [] filtmp;
 }
 //______________________________________________________________________
 Int_t AliITSsimulationSDD::Convert10to8(Int_t signal) const {
-  // To the 10 to 8 bit lossive compression.
-  // code from Davide C. and Albert W.
-
-  if (signal < 128)  return signal;
-  if (signal < 256)  return (128+((signal-128)>>1));
-  if (signal < 512)  return (192+((signal-256)>>3));
-  if (signal < 1024) return (224+((signal-512)>>4));
-  return 0;
+    // To the 10 to 8 bit lossive compression.
+    // code from Davide C. and Albert W.
+
+    if (signal < 128)  return signal;
+    if (signal < 256)  return (128+((signal-128)>>1));
+    if (signal < 512)  return (192+((signal-256)>>3));
+    if (signal < 1024) return (224+((signal-512)>>4));
+    return 0;
 }
-
 /*
 //______________________________________________________________________
 AliITSMap*   AliITSsimulationSDD::HitMap(Int_t i){
-  //Return the correct map.
+    //Return the correct map.
 
-  return ((i==0)? fHitMap1 : fHitMap2);
+    return ((i==0)? fHitMap1 : fHitMap2);
 }
 */
-
 //______________________________________________________________________
 void AliITSsimulationSDD::ZeroSuppression(const char *option) {
-  // perform the zero suppresion
-
-  if (strstr(option,"2D")) {
-    //Init2D();              // activate if param change module by module
-    Compress2D();
-  } else if (strstr(option,"1D")) {
-    //Init1D();              // activate if param change module by module
-    Compress1D();  
-  } else StoreAllDigits();
+    // perform the zero suppresion
+
+    if (strstr(option,"2D")) {
+        //Init2D();              // activate if param change module by module
+        Compress2D();
+    } else if (strstr(option,"1D")) {
+        //Init1D();              // activate if param change module by module
+        Compress1D();  
+    } else StoreAllDigits();
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::Init2D(){
-  // read in and prepare arrays: fD, fT1, fT2
-  //                         savemu[nanodes], savesigma[nanodes] 
-  // read baseline and noise from file - either a .root file and in this
-  // case data should be organised in a tree with one entry for each
-  // module => reading should be done accordingly
-  // or a classic file and do smth. like this ( code from Davide C. and
-  // Albert W.) :
-  // Read 2D zero-suppression parameters for SDD
-
-  if (!strstr(fParam.Data(),"file")) return;
-
-  Int_t na,pos,tempTh;
-  Float_t mu,sigma;
-  Float_t *savemu    = new Float_t [fNofMaps];
-  Float_t *savesigma = new Float_t [fNofMaps];
-  char input[100],basel[100],par[100];
-  char *filtmp;
-  Float_t tmp1,tmp2;
-  fResponse->Thresholds(tmp1,tmp2);
-  Int_t minval = static_cast(tmp1);
-
-  fResponse->Filenames(input,basel,par);
-  fFileName = par;
-  //
-  filtmp = gSystem->ExpandPathName(fFileName.Data());
-  FILE *param = fopen(filtmp,"r");
-  na = 0;
-
-  if(param) {
-    while(fscanf(param,"%d %f %f",&pos, &mu, &sigma) != EOF) {
-      if (pos != na+1) {
-	Error("Init2D","Anode number not in increasing order!",filtmp);
-	exit(1);
-      } // end if pos != na+1
-      savemu[na] = mu;
-      savesigma[na] = sigma;
-      if ((2.*sigma) < mu) {
-	fD[na] = (Int_t)floor(mu - 2.0*sigma + 0.5);
-	mu = 2.0 * sigma;
-      } else fD[na] = 0;
-      tempTh = (Int_t)floor(mu+2.25*sigma+0.5) - minval;
-      if (tempTh < 0) tempTh=0;
-      fT1[na] = tempTh;
-      tempTh = (Int_t)floor(mu+3.0*sigma+0.5) - minval;
-      if (tempTh < 0) tempTh=0;
-      fT2[na] = tempTh;
-      na++;
-    } // end while
-  } else {
-    Error("Init2D","THE FILE %s DOES NOT EXIST !",filtmp);
-    exit(1);
-  } // end if(param)
-
-  fclose(param);
-  delete [] filtmp;
-  delete [] savemu;
-  delete [] savesigma;
+    // read in and prepare arrays: fD, fT1, fT2
+    //                         savemu[nanodes], savesigma[nanodes] 
+    // read baseline and noise from file - either a .root file and in this
+    // case data should be organised in a tree with one entry for each
+    // module => reading should be done accordingly
+    // or a classic file and do smth. like this ( code from Davide C. and
+    // Albert W.) :
+    // Read 2D zero-suppression parameters for SDD
+
+    if (!strstr(fParam.Data(),"file")) return;
+
+    Int_t na,pos,tempTh;
+    Float_t mu,sigma;
+    Float_t *savemu    = new Float_t [fNofMaps];
+    Float_t *savesigma = new Float_t [fNofMaps];
+    char input[100],basel[100],par[100];
+    char *filtmp;
+    Double_t tmp1,tmp2;
+    GetResp()->Thresholds(tmp1,tmp2);
+    Int_t minval = static_cast(tmp1);
+
+    GetResp()->Filenames(input,basel,par);
+    fFileName = par;
+    //
+    filtmp = gSystem->ExpandPathName(fFileName.Data());
+    FILE *param = fopen(filtmp,"r");
+    na = 0;
+
+    if(param) {
+        while(fscanf(param,"%d %f %f",&pos, &mu, &sigma) != EOF) {
+            if (pos != na+1) {
+                Error("Init2D","Anode number not in increasing order!",filtmp);
+                exit(1);
+            } // end if pos != na+1
+            savemu[na] = mu;
+            savesigma[na] = sigma;
+            if ((2.*sigma) < mu) {
+                fD[na] = (Int_t)floor(mu - 2.0*sigma + 0.5);
+                mu = 2.0 * sigma;
+            } else fD[na] = 0;
+            tempTh = (Int_t)floor(mu+2.25*sigma+0.5) - minval;
+            if (tempTh < 0) tempTh=0;
+            fT1[na] = tempTh;
+            tempTh = (Int_t)floor(mu+3.0*sigma+0.5) - minval;
+            if (tempTh < 0) tempTh=0;
+            fT2[na] = tempTh;
+            na++;
+        } // end while
+    } else {
+        Error("Init2D","THE FILE %s DOES NOT EXIST !",filtmp);
+        exit(1);
+    } // end if(param)
+
+    fclose(param);
+    delete [] filtmp;
+    delete [] savemu;
+    delete [] savesigma;
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::Compress2D(){
-  // simple ITS cluster finder -- online zero-suppression conditions
-
-  Int_t db,tl,th; 
-  Float_t tmp1,tmp2;
-  fResponse->Thresholds(tmp1,tmp2); 
-  Int_t minval   = static_cast(tmp1);
-  Bool_t write   = fResponse->OutputOption();   
-  Bool_t do10to8 = fResponse->Do10to8();
-  Int_t nz, nl, nh, low, i, j; 
-
-  for (i=0; iGetSignal(i,j));
-      signal -= db; // if baseline eq. is done here
-      if (signal <= 0) {nz++; continue;}
-      if ((signal - tl) < minval) low++;
-      if ((signal - th) >= minval) {
-	nh++;
-	Bool_t cond=kTRUE;
-	FindCluster(i,j,signal,minval,cond);
-	if(cond && j &&
-	   ((TMath::Abs(fHitMap2->GetSignal(i,j-1))-th)>=minval)){
-	  if(do10to8) signal = Convert10to8(signal);
-	  AddDigit(i,j,signal);
-	} // end if cond&&j&&()
-      } else if ((signal - tl) >= minval) nl++;
-    } // end for j loop time samples
-    if (write) TreeB()->Fill(nz,nl,nh,low,i+1);
-  } //end for i loop anodes
-
-  char hname[30];
-  if (write) {
-    sprintf(hname,"TNtuple%d_%d",fModule,fEvent);
-    TreeB()->Write(hname);
-    // reset tree
-    TreeB()->Reset();
-  } // end if write
+    // simple ITS cluster finder -- online zero-suppression conditions
+
+    Int_t db,tl,th; 
+    Double_t tmp1,tmp2;
+    GetResp()->Thresholds(tmp1,tmp2); 
+    Int_t minval   = static_cast(tmp1);
+    Bool_t write   = GetResp()->OutputOption();   
+    Bool_t do10to8 = GetResp()->Do10to8();
+    Int_t nz, nl, nh, low, i, j; 
+
+    for (i=0; iGetSignal(i,j));
+            signal -= db; // if baseline eq. is done here
+            if (signal <= 0) {nz++; continue;}
+            if ((signal - tl) < minval) low++;
+            if ((signal - th) >= minval) {
+                nh++;
+                Bool_t cond=kTRUE;
+                FindCluster(i,j,signal,minval,cond);
+                if(cond && j &&
+                   ((TMath::Abs(fHitMap2->GetSignal(i,j-1))-th)>=minval)){
+                    if(do10to8) signal = Convert10to8(signal);
+                    AddDigit(i,j,signal);
+                } // end if cond&&j&&()
+            } else if ((signal - tl) >= minval) nl++;
+        } // end for j loop time samples
+        if (write) TreeB()->Fill(nz,nl,nh,low,i+1);
+    } //end for i loop anodes
+
+    char hname[30];
+    if (write) {
+        sprintf(hname,"TNtuple%d_%d",fModule,fEvent);
+        TreeB()->Write(hname);
+        // reset tree
+        TreeB()->Reset();
+    } // end if write
 }
 //______________________________________________________________________
 void  AliITSsimulationSDD::FindCluster(Int_t i,Int_t j,Int_t signal,
                                        Int_t minval,Bool_t &cond){
-  // Find clusters according to the online 2D zero-suppression algorithm
-  Bool_t do10to8 = fResponse->Do10to8();
-  Bool_t high    = kFALSE;
-
-  fHitMap2->FlagHit(i,j);
-  //
-  //  check the online zero-suppression conditions
-  //  
-  const Int_t kMaxNeighbours = 4;
-  Int_t nn;
-  Int_t dbx,tlx,thx;  
-  Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
-  fSegmentation->Neighbours(i,j,&nn,xList,yList);
-  Int_t in,ix,iy,qns;
-  for (in=0; inTestHit(ix,iy)==kUnused) {
-      CompressionParam(ix,dbx,tlx,thx);
-      Int_t qn = (Int_t)(fHitMap2->GetSignal(ix,iy));
-      qn -= dbx; // if baseline eq. is done here
-      if ((qn-tlx) < minval) {
-	fHitMap2->FlagHit(ix,iy);
-	continue;
-      } else {
-	if ((qn - thx) >= minval) high=kTRUE;
-	if (cond) {
-	  if(do10to8) signal = Convert10to8(signal);
-	  AddDigit(i,j,signal);
-	} // end if cond
-	if(do10to8) qns = Convert10to8(qn);
-	else qns=qn;
-	if (!high) AddDigit(ix,iy,qns);
-	cond=kFALSE;
-	if(!high) fHitMap2->FlagHit(ix,iy);
-      } // end if qn-tlx < minval
-    } // end if  TestHit
-  } // end for in loop over neighbours
+    // Find clusters according to the online 2D zero-suppression algorithm
+    Bool_t do10to8 = GetResp()->Do10to8();
+    Bool_t high    = kFALSE;
+
+    fHitMap2->FlagHit(i,j);
+    //
+    //  check the online zero-suppression conditions
+    //  
+    const Int_t kMaxNeighbours = 4;
+    Int_t nn;
+    Int_t dbx,tlx,thx;  
+    Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
+    GetSeg()->Neighbours(i,j,&nn,xList,yList);
+    Int_t in,ix,iy,qns;
+    for (in=0; inTestHit(ix,iy)==kUnused) {
+            CompressionParam(ix,dbx,tlx,thx);
+            Int_t qn = (Int_t)(fHitMap2->GetSignal(ix,iy));
+            qn -= dbx; // if baseline eq. is done here
+            if ((qn-tlx) < minval) {
+                fHitMap2->FlagHit(ix,iy);
+                continue;
+            } else {
+                if ((qn - thx) >= minval) high=kTRUE;
+                if (cond) {
+                    if(do10to8) signal = Convert10to8(signal);
+                    AddDigit(i,j,signal);
+                } // end if cond
+                if(do10to8) qns = Convert10to8(qn);
+                else qns=qn;
+                if (!high) AddDigit(ix,iy,qns);
+                cond=kFALSE;
+                if(!high) fHitMap2->FlagHit(ix,iy);
+            } // end if qn-tlx < minval
+        } // end if  TestHit
+    } // end for in loop over neighbours
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::Init1D(){
-  // this is just a copy-paste of input taken from 2D algo
-  // Torino people should give input
-  // Read 1D zero-suppression parameters for SDD
-
-  if (!strstr(fParam.Data(),"file")) return;
-
-  Int_t na,pos,tempTh;
-  Float_t mu,sigma;
-  Float_t *savemu    = new Float_t [fNofMaps];
-  Float_t *savesigma = new Float_t [fNofMaps];
-  char input[100],basel[100],par[100];
-  char *filtmp;
-  Float_t tmp1,tmp2;
-  fResponse->Thresholds(tmp1,tmp2);
-  Int_t minval = static_cast(tmp1);
-
-  fResponse->Filenames(input,basel,par);
-  fFileName=par;
-
-  //  set first the disable and tol param
-  SetCompressParam();
-  //
-  filtmp = gSystem->ExpandPathName(fFileName.Data());
-  FILE *param = fopen(filtmp,"r");
-  na = 0;
-
-  if (param) {
-    fscanf(param,"%d %d %d %d ", &fT2[0], &fT2[1], &fTol[0], &fTol[1]);
-    while(fscanf(param,"%d %f %f",&pos, &mu, &sigma) != EOF) {
-      if (pos != na+1) {
-	Error("Init1D","Anode number not in increasing order!",filtmp);
-	exit(1);
-      } // end if pos != na+1
-      savemu[na]=mu;
-      savesigma[na]=sigma;
-      if ((2.*sigma) < mu) {
-	fD[na] = (Int_t)floor(mu - 2.0*sigma + 0.5);
-	mu = 2.0 * sigma;
-      } else fD[na] = 0;
-      tempTh = (Int_t)floor(mu+2.25*sigma+0.5) - minval;
-      if (tempTh < 0) tempTh=0;
-      fT1[na] = tempTh;
-      na++;
-    } // end while
-  } else {
-    Error("Init1D","THE FILE %s DOES NOT EXIST !",filtmp);
-    exit(1);
-  } // end if(param)
-
-  fclose(param);
-  delete [] filtmp;
-  delete [] savemu;
-  delete [] savesigma;
+    // this is just a copy-paste of input taken from 2D algo
+    // Torino people should give input
+    // Read 1D zero-suppression parameters for SDD
+    
+    if (!strstr(fParam.Data(),"file")) return;
+
+    Int_t na,pos,tempTh;
+    Float_t mu,sigma;
+    Float_t *savemu    = new Float_t [fNofMaps];
+    Float_t *savesigma = new Float_t [fNofMaps];
+    char input[100],basel[100],par[100];
+    char *filtmp;
+    Double_t tmp1,tmp2;
+    GetResp()->Thresholds(tmp1,tmp2);
+    Int_t minval = static_cast(tmp1);
+
+    GetResp()->Filenames(input,basel,par);
+    fFileName=par;
+
+    //  set first the disable and tol param
+    SetCompressParam();
+    //
+    filtmp = gSystem->ExpandPathName(fFileName.Data());
+    FILE *param = fopen(filtmp,"r");
+    na = 0;
+ 
+    if (param) {
+        fscanf(param,"%d %d %d %d ", &fT2[0], &fT2[1], &fTol[0], &fTol[1]);
+        while(fscanf(param,"%d %f %f",&pos, &mu, &sigma) != EOF) {
+            if (pos != na+1) {
+                Error("Init1D","Anode number not in increasing order!",filtmp);
+                exit(1);
+            } // end if pos != na+1
+            savemu[na]=mu;
+            savesigma[na]=sigma;
+            if ((2.*sigma) < mu) {
+                fD[na] = (Int_t)floor(mu - 2.0*sigma + 0.5);
+                mu = 2.0 * sigma;
+            } else fD[na] = 0;
+            tempTh = (Int_t)floor(mu+2.25*sigma+0.5) - minval;
+            if (tempTh < 0) tempTh=0;
+            fT1[na] = tempTh;
+            na++;
+        } // end while
+    } else {
+        Error("Init1D","THE FILE %s DOES NOT EXIST !",filtmp);
+        exit(1);
+    } // end if(param)
+
+    fclose(param);
+    delete [] filtmp;
+    delete [] savemu;
+    delete [] savesigma;
 } 
 //______________________________________________________________________
 void AliITSsimulationSDD::Compress1D(){
-  // 1D zero-suppression algorithm (from Gianluca A.)
-  Int_t    dis,tol,thres,decr,diff;
-  UChar_t *str=fStream->Stream();
-  Int_t    counter=0;
-  Bool_t   do10to8=fResponse->Do10to8();
-  Int_t    last=0;
-  Int_t    k,i,j;
-
-  for (k=0; k<2; k++) {
-    tol = Tolerance(k);
-    dis = Disable(k);  
-    for (i=0; iGetSignal(idx,j));
-	signal -= decr;  // if baseline eq.
-	if(do10to8) signal = Convert10to8(signal);
-	if (signal <= thres) {
-	  signal=0;
-	  diff=128; 
-	  last=0; 
-	  // write diff in the buffer for HuffT
-	  str[counter]=(UChar_t)diff;
-	  counter++;
-	  continue;
-	} // end if signal <= thres
-	diff=signal-last;
-	if (diff > 127) diff=127;
-	if (diff < -128) diff=-128;
-	if (signal < dis) {
-	  // tol has changed to 8 possible cases ? - one can write
-	  // this if(TMath::Abs(diff)Stream();
+    Int_t    counter=0;
+    Bool_t   do10to8=GetResp()->Do10to8();
+    Int_t    last=0;
+    Int_t    k,i,j;
+
+    for (k=0; k<2; k++) {
+        tol = Tolerance(k);
+        dis = Disable(k);  
+        for (i=0; iGetSignal(idx,j));
+                signal -= decr;  // if baseline eq.
+                if(do10to8) signal = Convert10to8(signal);
+                if (signal <= thres) {
+                    signal=0;
+                    diff=128; 
+                    last=0; 
+                    // write diff in the buffer for HuffT
+                    str[counter]=(UChar_t)diff;
+                    counter++;
+                    continue;
+                } // end if signal <= thres
+                diff=signal-last;
+                if (diff > 127) diff=127;
+                if (diff < -128) diff=-128;
+                if (signal < dis) {
+                    // tol has changed to 8 possible cases ? - one can write
+                    // this if(TMath::Abs(diff)CheckCount(counter);
+    fStream->CheckCount(counter);
 
-  // open file and write out the stream of diff's
-  static Bool_t open=kTRUE;
-  static TFile *outFile;
-  Bool_t write = fResponse->OutputOption();
-  TDirectory *savedir = gDirectory;
+    // open file and write out the stream of diff's
+    static Bool_t open=kTRUE;
+    static TFile *outFile;
+    Bool_t write = GetResp()->OutputOption();
+    TDirectory *savedir = gDirectory;
  
-  if (write ) {
-    if(open) {
-      SetFileName("stream.root");
-      cout<<"filename "<cd();
-    fStream->Write();
-  }  // endif write        
-
-  fStream->ClearStream();
-
-  // back to galice.root file
-  if(savedir) savedir->cd();
+    if (write ) {
+        if(open) {
+            SetFileName("stream.root");
+            cout<<"filename "<cd();
+        fStream->Write();
+    }  // endif write
+
+    fStream->ClearStream();
+
+    // back to galice.root file
+    if(savedir) savedir->cd();
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::StoreAllDigits(){
-  // if non-zero-suppressed data
-  Bool_t do10to8 = fResponse->Do10to8();
-  Int_t i, j, digits[3];
-
-  for (i=0; iGetSignal(i,j));
-      if(do10to8) signal = Convert10to8(signal);
-      digits[0] = i;
-      digits[1] = j;
-      digits[2] = signal;
-      fITS->AddRealDigit(1,digits);
-    } // end for j
-  } // end for i
+    // if non-zero-suppressed data
+    Bool_t do10to8 = GetResp()->Do10to8();
+    Int_t i, j, digits[3];
+
+    for (i=0; iGetSignal(i,j));
+            if(do10to8) signal = Convert10to8(signal);
+            digits[0] = i;
+            digits[1] = j;
+            digits[2] = signal;
+            fITS->AddRealDigit(1,digits);
+        } // end for j
+    } // end for i
 } 
 //______________________________________________________________________
 void AliITSsimulationSDD::CreateHistograms(Int_t scale){
-  // Creates histograms of maps for debugging
-  Int_t i;
-
-  fHis=new TObjArray(fNofMaps);
-  for (i=0;iAddAt(new TH1F(sddName.Data(),"SDD maps",scale*fMaxNofSamples,
-			 0.,(Float_t) scale*fMaxNofSamples), i);
-  } // end for i
+    // Creates histograms of maps for debugging
+    Int_t i;
+
+    fHis=new TObjArray(fNofMaps);
+    for (i=0;iAddAt(new TH1F(sddName.Data(),"SDD maps",scale*fMaxNofSamples,
+                             0.,(Float_t) scale*fMaxNofSamples), i);
+    } // end for i
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::FillHistograms(){
-  // fill 1D histograms from map
+    // fill 1D histograms from map
 
-  if (!fHis) return;
+    if (!fHis) return;
 
-  for( Int_t i=0; iUncheckedAt(i);
-    Int_t nsamples = hist->GetNbinsX();
-    for( Int_t j=0; jGetSignal(i,j);
-      hist->Fill((Float_t)j,signal);
-    } // end for j
-  } // end for i
+    for( Int_t i=0; iUncheckedAt(i);
+        Int_t nsamples = hist->GetNbinsX();
+        for( Int_t j=0; jGetSignal(i,j);
+            hist->Fill((Float_t)j,signal);
+        } // end for j
+    } // end for i
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::ResetHistograms(){
-  // Reset histograms for this detector
-  Int_t i;
+    // Reset histograms for this detector
+    Int_t i;
 
-  for (i=0;iAt(i))    ((TH1F*)fHis->At(i))->Reset();
-  } // end for i
+    for (i=0;iAt(i))    ((TH1F*)fHis->At(i))->Reset();
+    } // end for i
 }
 //______________________________________________________________________
 TH1F *AliITSsimulationSDD::GetAnode(Int_t wing, Int_t anode) { 
-  // Fills a histogram from a give anode.  
+    // Fills a histogram from a give anode.  
 
-  if (!fHis) return 0;
+    if (!fHis) return 0;
 
-  if(wing <=0 || wing > 2) {
-    Warning("GetAnode","Wrong wing number: %d",wing);
-    return NULL;
-  } // end if wing <=0 || wing >2
-  if(anode <=0 || anode > fNofMaps/2) {
-    Warning("GetAnode","Wrong anode number: %d",anode);
-    return NULL;
-  } // end if ampde <=0 || andoe > fNofMaps/2
+    if(wing <=0 || wing > 2) {
+        Warning("GetAnode","Wrong wing number: %d",wing);
+        return NULL;
+    } // end if wing <=0 || wing >2
+    if(anode <=0 || anode > fNofMaps/2) {
+        Warning("GetAnode","Wrong anode number: %d",anode);
+        return NULL;
+    } // end if ampde <=0 || andoe > fNofMaps/2
 
-  Int_t index = (wing-1)*fNofMaps/2 + anode-1;
-  return (TH1F*)(fHis->At(index));
+    Int_t index = (wing-1)*fNofMaps/2 + anode-1;
+    return (TH1F*)(fHis->At(index));
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::WriteToFile(TFile *hfile) {
-  // Writes the histograms to a file
+    // Writes the histograms to a file
 
-  if (!fHis) return;
+    if (!fHis) return;
 
-  hfile->cd();
-  Int_t i;
-  for(i=0; iAt(i)->Write(); //fAdcs[i]->Write();
-  return;
+    hfile->cd();
+    Int_t i;
+    for(i=0; iAt(i)->Write(); //fAdcs[i]->Write();
+    return;
 }
 //______________________________________________________________________
 Float_t AliITSsimulationSDD::GetNoise() {  
-  // Returns the noise value
-  //Bool_t do10to8=fResponse->Do10to8();
-  //noise will always be in the liniar part of the signal
-  Int_t decr;
-  Int_t threshold = fT1[0];
-  char opt1[20], opt2[20];
-
-  fResponse->ParamOptions(opt1,opt2);
-  fParam=opt2;
-  char *same = strstr(opt1,"same");
-  Float_t noise,baseline;
-  if (same) {
-    fResponse->GetNoiseParam(noise,baseline);
-  } else {
-    static Bool_t readfile=kTRUE;
-    //read baseline and noise from file
-    if (readfile) ReadBaseline();
-    readfile=kFALSE;
-  } // end if same
-
-  TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c2");
-  if(c2) delete c2->GetPrimitive("noisehist");
-  if(c2) delete c2->GetPrimitive("anode");
-  else     c2=new TCanvas("c2");
-  c2->cd();
-  c2->SetFillColor(0);
-
-  TH1F *noisehist = new TH1F("noisehist","noise",100,0.,(float)2*threshold);
-  TH1F *anode = new TH1F("anode","Anode Projection",fMaxNofSamples,0.,
-			 (float)fMaxNofSamples);
-  Int_t i,k;
-  for (i=0;iReset();
-    for (k=0;kGetSignal(i,k);
-      //if (signal <= (float)threshold) noisehist->Fill(signal-baseline);
-      if (signal <= (float)(threshold+decr)) noisehist->Fill(signal);
-      anode->Fill((float)k,signal);
-    } // end for k
-    anode->Draw();
+    // Returns the noise value
+    //Bool_t do10to8=GetResp()->Do10to8();
+    //noise will always be in the liniar part of the signal
+    Int_t decr;
+    Int_t threshold = fT1[0];
+    char opt1[20], opt2[20];
+
+    GetResp()->ParamOptions(opt1,opt2);
+    fParam=opt2;
+    char *same = strstr(opt1,"same");
+    Double_t noise,baseline;
+    if (same) {
+        GetResp()->GetNoiseParam(noise,baseline);
+    } else {
+        static Bool_t readfile=kTRUE;
+        //read baseline and noise from file
+        if (readfile) ReadBaseline();
+        readfile=kFALSE;
+    } // end if same
+
+    TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c2");
+    if(c2) delete c2->GetPrimitive("noisehist");
+    if(c2) delete c2->GetPrimitive("anode");
+    else     c2=new TCanvas("c2");
+    c2->cd();
+    c2->SetFillColor(0);
+
+    TH1F *noisehist = new TH1F("noisehist","noise",100,0.,(float)2*threshold);
+    TH1F *anode = new TH1F("anode","Anode Projection",fMaxNofSamples,0.,
+                           (float)fMaxNofSamples);
+    Int_t i,k;
+    for (i=0;iReset();
+        for (k=0;kGetSignal(i,k);
+            //if (signal <= (float)threshold) noisehist->Fill(signal-baseline);
+            if (signal <= (float)(threshold+decr)) noisehist->Fill(signal);
+            anode->Fill((float)k,signal);
+        } // end for k
+        anode->Draw();
+        c2->Update();
+    } // end for i
+    TF1 *gnoise = new TF1("gnoise","gaus",0.,threshold);
+    noisehist->Fit("gnoise","RQ");
+    noisehist->Draw();
     c2->Update();
-  } // end for i
-  TF1 *gnoise = new TF1("gnoise","gaus",0.,threshold);
-  noisehist->Fit("gnoise","RQ");
-  noisehist->Draw();
-  c2->Update();
-  Float_t mnoise = gnoise->GetParameter(1);
-  cout << "mnoise : " << mnoise << endl;
-  Float_t rnoise = gnoise->GetParameter(2);
-  cout << "rnoise : " << rnoise << endl;
-  delete noisehist;
-  return rnoise;
+    Float_t mnoise = gnoise->GetParameter(1);
+    cout << "mnoise : " << mnoise << endl;
+    Float_t rnoise = gnoise->GetParameter(2);
+    cout << "rnoise : " << rnoise << endl;
+    delete noisehist;
+    return rnoise;
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::WriteSDigits(){
-  // Fills the Summable digits Tree
-  static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
-
-  for( Int_t i=0; iGetSignal( i, j );
-      if( sig > 0.2 ) {
-	Int_t jdx = j*fScaleSize;
-	Int_t index = fpList->GetHitIndex( i, j );
-	AliITSpListItem pItemTmp2( fModule, index, 0. );
-	// put the fScaleSize analog digits in only one
-	for( Int_t ik=0; ikGetpListItem( i, jdx+ik );
-	  if( pItemTmp == 0 ) continue;
-	  pItemTmp2.Add( pItemTmp );
-	}
-	pItemTmp2.AddSignalAfterElect( fModule, index, sig );
-	pItemTmp2.AddNoise( fModule, index, fHitNoiMap2->GetSignal( i, j ) );         
-	aliITS->AddSumDigit( pItemTmp2 );
-      } // end if (sig > 0.2)
+    // Fills the Summable digits Tree
+    static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+
+    for( Int_t i=0; iGetSignal( i, j );
+            if( sig > 0.2 ) {
+                Int_t jdx = j*fScaleSize;
+                Int_t index = fpList->GetHitIndex( i, j );
+                AliITSpListItem pItemTmp2( fModule, index, 0. );
+                // put the fScaleSize analog digits in only one
+                for( Int_t ik=0; ikGetpListItem(i,jdx+ik);
+                    if( pItemTmp == 0 ) continue;
+                    pItemTmp2.Add( pItemTmp );
+                }
+                pItemTmp2.AddSignalAfterElect( fModule, index, sig );
+                pItemTmp2.AddNoise(fModule,index,fHitNoiMap2->GetSignal(i,j));
+                aliITS->AddSumDigit( pItemTmp2 );
+            } // end if (sig > 0.2)
+        }
     }
-  }
-  return;
+    return;
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::Print() {
-  // Print SDD simulation Parameters
-
-  cout << "**************************************************" << endl;
-  cout << "   Silicon Drift Detector Simulation Parameters   " << endl;
-  cout << "**************************************************" << endl;
-  cout << "Flag for Perpendicular tracks: " << (Int_t) fFlag << endl;
-  cout << "Flag for noise checking: " << (Int_t) fCheckNoise << endl;
-  cout << "Flag to switch off electronics: " << (Int_t) fDoFFT << endl;
-  cout << "Number pf Anodes used: " << fNofMaps << endl;
-  cout << "Number of Time Samples: " << fMaxNofSamples << endl;
-  cout << "Scale size factor: " << fScaleSize << endl;
-  cout << "**************************************************" << endl;
+    // Print SDD simulation Parameters
+
+    cout << "**************************************************" << endl;
+    cout << "   Silicon Drift Detector Simulation Parameters   " << endl;
+    cout << "**************************************************" << endl;
+    cout << "Flag for Perpendicular tracks: " << (Int_t) fFlag << endl;
+    cout << "Flag for noise checking: " << (Int_t) fCheckNoise << endl;
+    cout << "Flag to switch off electronics: " << (Int_t) fDoFFT << endl;
+    cout << "Number pf Anodes used: " << fNofMaps << endl;
+    cout << "Number of Time Samples: " << fMaxNofSamples << endl;
+    cout << "Scale size factor: " << fScaleSize << endl;
+    cout << "**************************************************" << endl;
 }
diff --git a/ITS/AliITSsimulationSDD.h b/ITS/AliITSsimulationSDD.h
index 0863cd2117d..c751c285551 100644
--- a/ITS/AliITSsimulationSDD.h
+++ b/ITS/AliITSsimulationSDD.h
@@ -27,8 +27,7 @@ class AliITSresponse;
 class AliITSresponseSDD;
 
 class AliITSsimulationSDD : public AliITSsimulation {
-
- public:
+  public:
     AliITSsimulationSDD(); // default constructor
     //Standard Constructor
     AliITSsimulationSDD(AliITSsegmentation *seg, AliITSresponse *res);
@@ -38,11 +37,16 @@ class AliITSsimulationSDD : public AliITSsimulation {
     // = opporator
     AliITSsimulationSDD& operator=(AliITSsimulationSDD &source);
     // Initilize variables for this simulation
-    void Init(AliITSsegmentationSDD *seg,AliITSresponseSDD *resp);
+    void Init();
 
     // get the address of the array mapping the signal or pointers to arrays
-//    virtual AliITSMap*  HitMap(Int_t i);
+    //virtual AliITSMap*  HitMap(Int_t i);
 
+    // Return The Responce class
+    AliITSresponseSDD* GetResp(){return (AliITSresponseSDD*)fResponse;}
+    // Return The Segmentation class
+    AliITSsegmentationSDD* GetSeg(){
+        return (AliITSsegmentationSDD*)fSegmentation;}
     // set the scale size factor for the smples in FFT
     virtual void SetScaleFourier(Int_t scale=4) {fScaleSize=scale;}
     Int_t ScaleFourier() const {return fScaleSize;} // returns the scale factor
@@ -61,7 +65,7 @@ class AliITSsimulationSDD : public AliITSsimulation {
     // retrieve compression parameters for 2D or 1D
     void CompressionParam(Int_t i, Int_t &db, Int_t &tl);
 
-    virtual Int_t Convert10to8(Int_t signal) const;// 10 to 8 bit SDD compresion
+    virtual Int_t Convert10to8(Int_t signal) const;//10 to 8 bit SDD compresion
     virtual void ZeroSuppression(const char *opt); // Apply zero suppresion
     virtual void Init2D();   // initiilzes 2D compresion algorithm
     virtual void Compress2D(); // Applies 2D compresion algorithm
@@ -70,12 +74,12 @@ class AliITSsimulationSDD : public AliITSsimulation {
     virtual void StoreAllDigits(); // if No compresion run this.
     virtual void ReadBaseline();  // read baseline values from a file
     // returns baseline and noise for a given anode i.
-    virtual void GetAnodeBaseline(Int_t i, Float_t &baseline, Float_t &noise);
+    virtual void GetAnodeBaseline(Int_t i,Double_t &baseline,Double_t &noise);
     // local implementation of ITS->AddDigit. Specific for SDD
     virtual void AddDigit(Int_t i, Int_t j, Int_t signal);
     // Finds clulsters of signals. Use with regards to Compresion algorithms
     virtual void  FindCluster(Int_t i, Int_t j,Int_t signal,
-			      Int_t minval,Bool_t &cond);
+                              Int_t minval,Bool_t &cond);
 
     // get parameters for 1D - this could be changed when we get more
     // input from Torino after they have a look at the code 
@@ -110,10 +114,11 @@ class AliITSsimulationSDD : public AliITSsimulation {
     // Spread charge in a SDD module
     void HitsToAnalogDigits(AliITSmodule *mod);
     // Sorts tracks for the 3 most highly contributed one to be added to digit.
-    //void SortTracks(Int_t *tracks,Float_t *charges,Int_t *hits,Int_t ntracks);
+    //void SortTracks(Int_t *tracks,Float_t *charges,Int_t *hits
+    //                Int_t ntracks);
     // collects and returns the fired SDD cells (uses AliITSMapA2...).
     //void ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,TObjArray *list,
-	//		  TClonesArray *padr);
+    //		  TClonesArray *padr);
 
     // Creates histograms of maps for debugging
     void CreateHistograms(Int_t scale);
@@ -125,8 +130,8 @@ class AliITSsimulationSDD : public AliITSsimulation {
     TObjArray*  GetHistArray() {return fHis;}
     // create a separate tree for background monitoring (2D) 
     virtual  void  MakeTreeB(Option_t *option="B") 
-	{ if(strstr(option,"B"))
-	     fTreeB = new TNtuple("ntuple", "2D backgr","nz:nl:nh:low:anode");}
+        { if(strstr(option,"B"))
+            fTreeB = new TNtuple("ntuple", "2D backgr","nz:nl:nh:low:anode");}
     // presently a dummy routine use TreeB() instead
     void GetTreeB(Int_t) { }
     // Return pointer to TreeB
@@ -145,16 +150,12 @@ class AliITSsimulationSDD : public AliITSsimulation {
     // Print SSD simulation Parameters
     virtual void Print();
 
- private:
+  private:
     // Variables and pointers for local use only. Not Streamed out.
     AliITS         *fITS;          //! local pointer to ITS
-//    AliITSMapA1    *fHitMap1;      //! local pointer to map of digits
     AliITSMapA2    *fHitMap2;      //! local pointer to map of signals
     AliITSMapA2    *fHitSigMap2;   //! local pointer to map of signals
     AliITSMapA2    *fHitNoiMap2;   //! local pointer to map of signals
-//    AliITSpList    *fpList;        //! 
-//    TObjArray      *falist;        //
-//    TClonesArray   *fpadr;         //
     AliITSInStream *fStream;       //! input file stream
     AliITSetfSDD   *fElectronics;  //! local pointer to electronics simulation
     Double_t       *fInZR;         //! [fScaleSize*fMaxNofSamples] input of the
@@ -184,10 +185,8 @@ class AliITSsimulationSDD : public AliITSsimulation {
     Int_t      fNofMaps;      // Number of anodes used ( 1-2*nanodes per wing )
     Int_t      fMaxNofSamples;// Number of time samples
     Int_t      fScaleSize;    // scale size factor for the samples in FFT
-//    Int_t      fModule;       //! in case bgr,noise,param,change module-by-mod.
-//    Int_t      fEvent;        //! solely for output from bgr monitoring of 2D
 
-  ClassDef(AliITSsimulationSDD,1)  // Simulation of SDD clusters
+    ClassDef(AliITSsimulationSDD,1)  // Simulation of SDD clusters
 
 };
 #endif
diff --git a/ITS/AliITSsimulationSPD.cxx b/ITS/AliITSsimulationSPD.cxx
index 27246225a3e..e5795da733a 100644
--- a/ITS/AliITSsimulationSPD.cxx
+++ b/ITS/AliITSsimulationSPD.cxx
@@ -47,103 +47,125 @@ ClassImp(AliITSsimulationSPD)
 // AliITSsimulationSPD is the simulation of SPDs
 //
 //______________________________________________________________________
-AliITSsimulationSPD::AliITSsimulationSPD(){
+AliITSsimulationSPD::AliITSsimulationSPD() : AliITSsimulation(),
+fMapA2(0),
+fHis(0){
     // Default constructor
-
-    fResponse     = 0;
-    fSegmentation = 0;
-    fHis          = 0;
-    fMapA2        = 0;
-
-/*
-    fThresh       = 0.;
-    fSigma        = 0.;
-    fCouplCol     = 0.;
-    fCouplRow     = 0.; */
+    // Inputs: 
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    A default constructed AliITSsimulationSPD class.
 }
 //______________________________________________________________________
 AliITSsimulationSPD::AliITSsimulationSPD(AliITSsegmentation *seg,
-					 AliITSresponse *resp) {
+                                         AliITSresponse *res):
+AliITSsimulation(seg,res),
+fMapA2(0),
+fHis(0){
     // Standard constructor
+    // Inputs: 
+    //    AliITSsegmentation *seg  Segmentation class to be used
+    //    AliITSresonse      *res  Response class to be used
+    // Outputs:
+    //    none.
+    // Return:
+    //    A standard constructed AliITSsimulationSPD class.
+
+    Init();
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::Init() {
+    // Initilizes the variables of AliITSsimulation SPD.
+    // Inputs:
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    none.
 
-    fResponse     = 0;
-    fSegmentation = 0;
-    fHis          = 0;
-    fMapA2        = 0;
-    SetDebug(kFALSE);
-
-/*
-    fThresh       = 0.;
-    fSigma        = 0.;
-    fCouplCol     = 0.;
-    fCouplRow     = 0.*/
-    Init((AliITSsegmentationSPD*)seg,(AliITSresponseSPD*)resp);
+    fHis = 0;
+    if(fMapA2) delete fMapA2;
+    fMapA2  = new AliITSMapA2(fSegmentation);
+    if(fpList) delete fpList;
+    fpList  = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
 }
 //______________________________________________________________________
 void AliITSsimulationSPD::Init(AliITSsegmentationSPD *seg,
-			       AliITSresponseSPD *resp) {
+                               AliITSresponseSPD *resp) {
     // Initilizes the variables of AliITSsimulation SPD.
+    // Inputs:
+    //    AliITSsegmentationSPD   replacement segmentation class to be used
+    //    aliITSresponseSPD       replacement response class to be used
+    // Outputs:
+    //    none.
+    // Return:
+    //    none.
 
+    if(fHis){
+        fHis->Delete(); 
+        delete fHis;  
+    } // end if fHis
     fHis = 0;
+    if(fResponse) delete fResponse;
     fResponse     = resp;
+    if(fSegmentation) delete fSegmentation;
     fSegmentation = seg;
+    if(fMapA2) delete fMapA2;
     fMapA2  = new AliITSMapA2(fSegmentation);
+    if(fpList) delete fpList;
     fpList  = new AliITSpList(GetNPixelsZ()+1,GetNPixelsX()+1);
-/*
-    fResponse->Thresholds(fThresh,fSigma);
-    fResponse->GetNoiseParam(fCouplCol,fCouplRow);
-    fNPixelsZ = fSegmentation->Npz();
-    fNPixelsX = fSegmentation->Npx();
-*/
 }
 //______________________________________________________________________
 AliITSsimulationSPD::~AliITSsimulationSPD() { 
     // destructor
+    // Inputs: 
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    none.
 
-    delete fMapA2;
-//    delete fpList;
+    if(fMapA2) delete fMapA2;
 
     if (fHis) {
-	fHis->Delete(); 
-	delete fHis;     
+        fHis->Delete(); 
+        delete fHis;     
     } // end if
 }
 //______________________________________________________________________
 AliITSsimulationSPD::AliITSsimulationSPD(const AliITSsimulationSPD &source) :
     AliITSsimulation(source){
     // Copy Constructor
+    // Inputs: 
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    A new AliITSsimulationSPD class with the same parameters as source.
 
     if(&source == this) return;
 
     this->fMapA2    = source.fMapA2;
     this->fHis      = source.fHis;
-/*
-    this->fThresh   = source.fThresh;
-    this->fSigma    = source.fSigma;
-    this->fCouplCol = source.fCouplCol;
-    this->fCouplRow = source.fCouplRow;
-    this->fNPixelsX = source.fNPixelsX;
-    this->fNPixelsZ = source.fNPixelsZ;
-*/
     return;
 }
 //______________________________________________________________________
 AliITSsimulationSPD& AliITSsimulationSPD::operator=(const AliITSsimulationSPD 
 						    &source) {
     //    Assignment operator
+    // Inputs: 
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    A new AliITSsimulationSPD class with the same parameters as source.
 
     if(&source == this) return *this;
 
     this->fMapA2    = source.fMapA2;
     this->fHis      = source.fHis;
-/*
-    this->fThresh   = source.fThresh;
-    this->fSigma    = source.fSigma;
-    this->fCouplCol = source.fCouplCol;
-    this->fCouplRow = source.fCouplRow;
-    this->fNPixelsX = source.fNPixelsX;
-    this->fNPixelsZ = source.fNPixelsZ;
-*/
     return *this;
 } 
 //______________________________________________________________________
@@ -178,6 +200,14 @@ void AliITSsimulationSPD::FinishSDigitiseModule(){
 void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod, Int_t dummy0,
                                              Int_t dummy1) {
     // Sum digitize module
+    // Inputs:
+    //   AliITSmodule  *mod    The module to be SDgitized
+    //   Int_t         dummy0  Not used kept for general compatibility
+    //   Int_t         dummy1  Not used kept for general compatibility
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
     if (!(mod->GetNhits())) return; // if module has no hits then no Sdigits.
     Int_t    number     = 10000;
     Int_t    *frowpixel = new Int_t[number];
@@ -202,16 +232,20 @@ void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod, Int_t dummy0,
     fpList->ClearMap();
 }
 //______________________________________________________________________
-void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod, Int_t dummy0,
-                                             Int_t dummy1) {
+void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod, Int_t,Int_t) {
     // digitize module. Also need to digitize modules with only noise.
+    // Inputs:
+    //   AliITSmodule  *mod    The module to be SDgitized
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
 
     Int_t    number     = 10000;
     Int_t    *frowpixel = new Int_t[number];
     Int_t    *fcolpixel = new Int_t[number];
     Double_t *fenepixel = new Double_t[number];
 
-    dummy0 = dummy1; // remove unsued variable warning.
     // Array of pointers to store the track index of the digits
     // leave +1, otherwise pList crashes when col=256, row=192
     fModule = mod->GetIndex();
@@ -235,11 +269,18 @@ void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod, Int_t dummy0,
 //______________________________________________________________________
 void AliITSsimulationSPD::SDigitsToDigits(Int_t module,AliITSpList *pList) {
     // sum digits to Digits.
+    // Inputs:
+    //   AliITSmodule  *mod    The module to be SDgitized
+    //   AliITSpList   *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Return:
+    //   none.
 
-#ifdef DEBUG
-    cout << "Entering AliITSsimulatinSPD::SDigitsToDigits for module=";
-    cout << module << endl;
-#endif
+    if(GetDebug()){
+        cout << "Entering AliITSsimulatinSPD::SDigitsToDigits for module=";
+        cout << module << endl;
+    } // end if GetDebug
     fModule = module;
 
     // noise setting
@@ -264,6 +305,18 @@ void AliITSsimulationSPD::UpdateMapSignal(Int_t row,Int_t col,Int_t trk,
 					  AliITSpList *pList) {
     // updates the Map of signal, adding the energy  (ene) released by
     // the current track
+    // Inputs:
+    //   Int_t         row  pixel row number
+    //   Int_t         col  pixel column number
+    //   Int_t         trk  track number which contributed
+    //   Int_t         hit  hit number which contributed
+    //   Int_t         mod  module number
+    //   Double_t      ene  the energy associated with this contribution
+    //   AliITSpList   *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Return:
+    //   none.
 
     fMapA2->AddSignal(row,col,ene);
     pList->AddSignal(row,col,trk,hit,mod,ene);
@@ -272,6 +325,16 @@ void AliITSsimulationSPD::UpdateMapSignal(Int_t row,Int_t col,Int_t trk,
 void AliITSsimulationSPD::UpdateMapNoise(Int_t row,Int_t col,Int_t mod,
 					 Double_t ene,AliITSpList *pList) {
     // updates the Map of noise, adding the energy  (ene) give my noise
+    // Inputs:
+    //   Int_t         row  pixel row number
+    //   Int_t         col  pixel column number
+    //   Int_t         mod  module number
+    //   Double_t      ene  the energy associated with this contribution
+    //   AliITSpList   *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Return:
+    //   none.
 
     fMapA2->AddSignal(row,col,ene);
     pList->AddNoise(row,col,mod,ene);
@@ -283,11 +346,21 @@ void AliITSsimulationSPD::HitsToAnalogDigits(AliITSmodule *mod,
 					     AliITSpList *pList) {
     // Loops over all hits to produce Analog/floting point digits. This
     // is also the first task in producing standard digits.
+    // Inputs:
+    //   AliITSmodule  *mod        module class
+    //   Int_t         *frowpixel  array of pixel rows
+    //   Int_t         *fcolpixel  array of pixel columns
+    //   Double_t      *fenepiexel array of pixel energies
+    //   AliITSpList   *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Return:
+    //   none.
     
     // loop over hits in the module
     Int_t hitpos,nhits = mod->GetNhits();
     for (hitpos=0;hitpos az2l) {
-	        zb = z2l;
-	        xb = x2l;
-	    } // end if
-	    // shift to the pixel in the next cell in row direction
-	    Float_t zsizeNext = fSegmentation->Dpz(rb-1);
-	    //to account for cell at the borders of the detector
-	    if(zsizeNext==0) zsizeNext = zsize;
-	    refn += zsizeNext*dirz;
-	}else {
-	    // the track goes in the pixel in the next cell in column direction
-	    xb = refr;
-	    zb = refc;
-	    cb = c1 + dirx;
-	    rb = r1;
-	    axb = xb * dirx;
-	    ax2l = x2l * dirx;
-	    if (cb == c2) flagcol=1;
-	    if (axb > ax2l) {
-	        zb = z2l;
-	        xb = x2l;
-	    } // end ifaxb > ax2l
-
-	    // shift to the pixel in the next cell in column direction
-	    Float_t xsizeNext = fSegmentation->Dpx(cb-1);
-	    //to account for cell at the borders of the detector
-	    if(xsizeNext==0) xsizeNext = xsize;
-	    refr += xsizeNext*dirx;
-	} // end if (arefm < arefr) && (arefn < arefc)
-
-	//calculate the energy lost in the crossed pixel      
-	epar = TMath::Sqrt((xb-xa)*(xb-xa)+(zb-za)*(zb-za)); 
-	epar = etot*(epar/dtot);
-
-	//store row, column and energy lost in the crossed pixel
-	frowpixel[npixel] = r1;
-	fcolpixel[npixel] = c1;
-	fenepixel[npixel] = epar;
-	npixel++;
- 
-	// the exit point of the track is reached
-	if (epar == 0) flag = 1;
-	if ((r1 == r2) && (c1 == c2)) flag = 1;
-	if (flag!=1) {
-	    r1 = rb;
-	    c1 = cb;
-	    xa = xb;
-	    za = zb;
-	} // end if flag!=1
+        // calculate the x coordinate of the intersection with the pixel
+        // in the next cell in row  direction
+        if(dz!=0)
+            refm = dx*((refn - z1l)/dz) + x1l;
+        else
+            refm = refr+dirx*xsize;
+        
+        // calculate the z coordinate of the intersection with the pixel
+        // in the next cell in column direction
+        if (dx!=0)
+            refc = dz*((refr - x1l)/dx) + z1l;
+        else
+            refc = refn+dirz*zsize;
+        
+        arefm = refm * dirx;
+        arefr = refr * dirx;
+        arefn = refn * dirz;
+        arefc = refc * dirz;
+        
+        if ((arefm < arefr) && (arefn < arefc)){
+            // the track goes in the pixel in the next cell in row direction
+            xb = refm;
+            zb = refn;
+            cb = c1;
+            rb = r1 + dirz;
+            azb = zb * dirz;
+            az2l = z2l * dirz;
+            if (rb == r2) flagrow=1;
+            if (azb > az2l) {
+                zb = z2l;
+                xb = x2l;
+            } // end if
+            // shift to the pixel in the next cell in row direction
+            Float_t zsizeNext = fSegmentation->Dpz(rb-1);
+            //to account for cell at the borders of the detector
+            if(zsizeNext==0) zsizeNext = zsize;
+            refn += zsizeNext*dirz;
+        }else {
+            // the track goes in the pixel in the next cell in column direction
+            xb = refr;
+            zb = refc;
+            cb = c1 + dirx;
+            rb = r1;
+            axb = xb * dirx;
+            ax2l = x2l * dirx;
+            if (cb == c2) flagcol=1;
+            if (axb > ax2l) {
+                zb = z2l;
+                xb = x2l;
+            } // end ifaxb > ax2l
+            
+            // shift to the pixel in the next cell in column direction
+            Float_t xsizeNext = fSegmentation->Dpx(cb-1);
+            //to account for cell at the borders of the detector
+            if(xsizeNext==0) xsizeNext = xsize;
+            refr += xsizeNext*dirx;
+        } // end if (arefm < arefr) && (arefn < arefc)
+        
+        //calculate the energy lost in the crossed pixel      
+        epar = TMath::Sqrt((xb-xa)*(xb-xa)+(zb-za)*(zb-za)); 
+        epar = etot*(epar/dtot);
+        
+        //store row, column and energy lost in the crossed pixel
+        frowpixel[npixel] = r1;
+        fcolpixel[npixel] = c1;
+        fenepixel[npixel] = epar;
+        npixel++;
+        
+        // the exit point of the track is reached
+        if (epar == 0) flag = 1;
+        if ((r1 == r2) && (c1 == c2)) flag = 1;
+        if (flag!=1) {
+            r1 = rb;
+            c1 = cb;
+            xa = xb;
+            za = zb;
+        } // end if flag!=1
     } while (flag==0);
 }
 //______________________________________________________________________
@@ -502,6 +604,17 @@ void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
     //  The parameters probcol and probrow are the probability of the
     //  signal in one pixel shared in the two adjacent pixels along
     //  the column and row direction, respectively.
+    // Inputs:
+    //    Int_t      row    pixel row number
+    //    Int_t      col     pixel column number
+    //    Int_t      ntrack  track number of track contributing to this signal
+    //    Int_t      idhit   hit number of hit contributing to this signal
+    //    Int_t      module  module number
+    //   AliITSpList *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList *pList  the array of SDigits
+    // Return:
+    //   none.
     //
     //Begin_Html
     /*
@@ -516,7 +629,7 @@ void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
     //End_Html
     Int_t j1,j2,flag=0;
     Double_t pulse1,pulse2;
-    Float_t couplR=0.0,couplC=0.0;
+    Double_t couplR=0.0,couplC=0.0;
     Double_t xr=0.;
 
     GetCouplings(couplR,couplC);
@@ -525,35 +638,35 @@ void AliITSsimulationSPD::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
     pulse1 = fMapA2->GetSignal(row,col);
     pulse2 = pulse1;
     for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
-	do{
-	    j1 += isign;
-	    //   pulse1 *= couplR; 
-          xr = gRandom->Rndm();
-	  //   if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1GetNPixelsZ()-1) || (xr>couplR)){
-		j1 = row;
-	       	flag = 1;
-	    }else{
-		UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
-	      //  flag = 0;
-	      flag = 1; // only first next!!
-	    } // end if
-	} while(flag == 0);
-	// loop in column direction
-      do{
-	  j2 += isign;
-	  // pulse2 *= couplC; 
-          xr = gRandom->Rndm();
-	  //  if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2GetNPixelsX()-1) || (xr>couplC)){
-	      j2 = col;
-	      flag = 1;
-	  }else{
-	      UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
-	      //  flag = 0;
-	      flag = 1; // only first next!!
-	  } // end if
-      } while(flag == 0);
+        do{
+            j1 += isign;
+            //   pulse1 *= couplR; 
+            xr = gRandom->Rndm();
+            //if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1GetNPixelsZ()-1) || (xr>couplR)){
+                j1 = row;
+                flag = 1;
+            }else{
+                UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
+                //  flag = 0;
+                flag = 1; // only first next!!
+            } // end if
+        } while(flag == 0);
+        // loop in column direction
+        do{
+            j2 += isign;
+            // pulse2 *= couplC; 
+            xr = gRandom->Rndm();
+            //if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2GetNPixelsX()-1) || (xr>couplC)){
+                j2 = col;
+                flag = 1;
+            }else{
+                UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
+                //  flag = 0;
+                flag = 1; // only first next!!
+            } // end if
+        } while(flag == 0);
     } // for isign
 }
 //______________________________________________________________________
@@ -564,6 +677,17 @@ void AliITSsimulationSPD::SetCouplingOld(Int_t row, Int_t col, Int_t ntrack,
     //  The parameters probcol and probrow are the fractions of the
     //  signal in one pixel shared in the two adjacent pixels along
     //  the column and row direction, respectively.
+    // Inputs:
+    //    Int_t    row    pixel row number
+    //    Int_t    col    pixel column number
+    //    Int_t    ntrack track number of track contributing to this pixel
+    //    Int_t    idhit  hit index number of hit contributing to this pixel
+    //    Int_t    module module number
+    //   AliITSpList   *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Return:
+    //   none.
     //
     //Begin_Html
     /*
@@ -578,7 +702,7 @@ void AliITSsimulationSPD::SetCouplingOld(Int_t row, Int_t col, Int_t ntrack,
     //End_Html
     Int_t j1,j2,flag=0;
     Double_t pulse1,pulse2;
-    Float_t couplR=0.0,couplC=0.0;
+    Double_t couplR=0.0,couplC=0.0;
 
     GetCouplings(couplR,couplC);
     j1 = row;
@@ -586,31 +710,31 @@ void AliITSsimulationSPD::SetCouplingOld(Int_t row, Int_t col, Int_t ntrack,
     pulse1 = fMapA2->GetSignal(row,col);
     pulse2 = pulse1;
     for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
-	do{
-	    j1 += isign;
-	    pulse1 *= couplR;
-	    if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1GetSignal(row,col);
-		j1 = row;
-		flag = 1;
-	    }else{
-		UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
-		flag = 0;
-	    } // end if
-	} while(flag == 0);
-	// loop in column direction
-      do{
-	  j2 += isign;
-	  pulse2 *= couplC;
-	  if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2GetSignal(row,col);
-	      j2 = col;
-	      flag = 1;
-	  }else{
-	      UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
-	      flag = 0;
-	  } // end if
-      } while(flag == 0);
+        do{
+            j1 += isign;
+            pulse1 *= couplR;
+            if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1GetSignal(row,col);
+                j1 = row;
+                flag = 1;
+            }else{
+                UpdateMapSignal(j1,col,ntrack,idhit,module,pulse1,pList);
+                flag = 0;
+            } // end if
+        } while(flag == 0);
+        // loop in column direction
+        do{
+            j2 += isign;
+            pulse2 *= couplC;
+            if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2GetSignal(row,col);
+                j2 = col;
+                flag = 1;
+            }else{
+                UpdateMapSignal(row,j2,ntrack,idhit,module,pulse2,pList);
+                flag = 0;
+            } // end if
+        } while(flag == 0);
     } // for isign
 }
 //______________________________________________________________________
@@ -619,6 +743,13 @@ void AliITSsimulationSPD::CreateDigit(Int_t module,AliITSpList *pList) {
     // the threshold parameter ethr. Fired pixed are interpreted as digits
     // and stored in the file digitfilename. One also needs to write out
     // cases when there is only noise (nhits==0).
+    // Inputs:
+    //    Int_t    module
+    //   AliITSpList   *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Return:
+    //   none.
 
     static AliITS *aliITS  = (AliITS*)gAlice->GetModule("ITS");
 
@@ -632,42 +763,42 @@ void AliITSsimulationSPD::CreateDigit(Int_t module,AliITSpList *pList) {
     module=0; // remove unused variable warning.
     for(j1=0;j1GetSignal(r,c);
-	    if ( signal > GetThreshold()) {
-		digits[0] = r-1;  // digits starts from 0
-		digits[1] = c-1;  // digits starts from 0
-		//digits[2] = 1;  
-		digits[2] =  (Int_t) signal;  // the signal is stored in
+        for (Int_t c=1;c<=GetNPixelsX();c++) {
+            // check if the deposited energy in a pixel is above the
+            // threshold 
+            Float_t signal = (Float_t) fMapA2->GetSignal(r,c);
+            if ( signal > GetThreshold()) {
+                digits[0] = r-1;  // digits starts from 0
+                digits[1] = c-1;  // digits starts from 0
+                //digits[2] = 1;  
+                digits[2] =  (Int_t) signal;  // the signal is stored in
                                               //  electrons
-		for(j1=0;j1GetNEnteries()){
-			tracks[j1] = pList->GetTrack(r,c,j1);
-			hits[j1]   = pList->GetHit(r,c,j1);
-			//}else{
-			//tracks[j1] = -3;
-			//hits[j1]   = -1;
-		    } // end if
-		    //charges[j1] = 0;
-		} // end for j1
-		Float_t phys = 0;
-		aliITS->AddSimDigit(0,phys,digits,tracks,hits,charges);
-#ifdef DEBUG
-		cout << " CreateSPDDigit mod=" << fModule << " r,c=" << r;
-		cout <<","<Reset();
+        if ((*fHis)[i])    ((TH1F*)(*fHis)[i])->Reset();
     } // end for i
 }
 //______________________________________________________________________
 void AliITSsimulationSPD::WriteSDigits(AliITSpList *pList){
     // Fills the Summable digits Tree
+    // Inputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Outputs:
+    //   AliITSpList   *pList  the array of SDigits
+    // Return:
+    //   none.
     Int_t i,ni,j,nj;
     static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
 
     pList->GetMaxMapIndex(ni,nj);
     for(i=0;iGetSignalOnly(i,j)>0.0){
-	    aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
-#ifdef DEBUG
-	    cout << "pListSPD: " << *(pList->GetpListItem(i,j)) << endl;
-	    cout << " CreateSPDSDigit mod=" << fModule << " r,c=";
-	    cout << i  <<","<< j << " sig=" << fpList->GetSignalOnly(i,j);
-	    cout << " noise=" << fpList->GetNoise(i,j) <GetSignalOnly(i,j)>0.0){
+            aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
+            if(GetDebug()){
+                cout << "pListSPD: " << *(pList->GetpListItem(i,j)) << endl;
+                cout << " CreateSPDSDigit mod=" << fModule << " r,c=";
+                cout << i  <<","<< j << " sig=" << fpList->GetSignalOnly(i,j);
+                cout << " noise=" << fpList->GetNoise(i,j) <Thresholds(a,b); return a;}
     // Returns the threshold and rms noise.
-    void GetThresholds(Float_t &t,Float_t &s){
+    void GetThresholds(Double_t &t,Double_t &s){
     ((AliITSresponseSPD*)fResponse)->Thresholds(t,s);}
     // Returns the couplings Columb and Row.
-    void GetCouplings(Float_t &cc,Float_t &cr){
-	((AliITSresponseSPD*)fResponse)->GetNoiseParam(cc,cr);}
+    void GetCouplings(Double_t &cc,Double_t &cr){
+	((AliITSresponseSPD*)fResponse)->GetCouplingParam(cc,cr);}
     // Returns the number of pixels in x
     Int_t GetNPixelsX(){return ((AliITSsegmentationSPD*)fSegmentation)->Npx();}
     // Returns the number of pixels in z
     Int_t GetNPixelsZ(){return ((AliITSsegmentationSPD*)fSegmentation)->Npz();}
 
  private:
-/*    Float_t      fThresh;   //! Threshold from fResponse
-    Float_t      fSigma;    //! Noise from fResponse
-    Float_t      fCouplCol; //! Coupling along columns from fResponse
-    Float_t      fCouplRow; //! Coupling along rows from fResponse
-    Int_t        fNPixelsX; //! NPixelsX from fSegmentation
-    Int_t        fNPixelsZ; //! NPixelsZ from fSegmentation
-*/
-//    AliITSpList  *fList;    //! Internal map and sdigits
-//    Int_t         fModule;  //! Module number being simulated
-//    Int_t         fEvent;   //! Event number being simulated
     AliITSMapA2  *fMapA2;   //! MapA2 for Local internal use only
     TObjArray    *fHis;     //! just in case for histogramming for Local
                             // internal use only
diff --git a/ITS/AliITSsimulationSPDdubna.cxx b/ITS/AliITSsimulationSPDdubna.cxx
index 990aa47ebf7..13cb3d9b085 100644
--- a/ITS/AliITSsimulationSPDdubna.cxx
+++ b/ITS/AliITSsimulationSPDdubna.cxx
@@ -32,7 +32,7 @@ $Id$
 #include "AliITSpList.h"
 #include "AliITSsimulationSPDdubna.h"
 #include "AliITSsegmentationSPD.h"
-#include "AliITSresponseSPDdubna.h"
+#include "AliITSresponseSPD.h"
 
 //#define DEBUG
 
@@ -46,7 +46,11 @@ ClassImp(AliITSsimulationSPDdubna)
 //
 // AliITSsimulationSPDdubna is to do the simulation of SPDs.
 //______________________________________________________________________
-AliITSsimulationSPDdubna::AliITSsimulationSPDdubna() : AliITSsimulation(){
+AliITSsimulationSPDdubna::AliITSsimulationSPDdubna():
+AliITSsimulation(),
+fHis(0),
+fSPDname(),
+fCoupling(0){
     // Default constructor.
     // Inputs:
     //    none.
@@ -55,47 +59,57 @@ AliITSsimulationSPDdubna::AliITSsimulationSPDdubna() : AliITSsimulation(){
     // Return:
     //    A default constructed AliITSsimulationSPDdubna class.
 
-    fHis          = 0;
+    if(GetDebug(1)) Info("AliITSsimulationSPDdubda()",
+                         "Calling degault constructor");
 }
 //______________________________________________________________________
 AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSsegmentation *seg,
-						   AliITSresponse *resp){
+						                 AliITSresponse *resp,Int_t cup):
+AliITSsimulation(seg,resp),
+fHis(0),
+fSPDname(),
+fCoupling(cup){
     // standard constructor
     // Inputs:
     //    AliITSsegmentation *seg  A pointer to the segmentation class
     //                             to be used for this simulation
     //    AliITSresponse     *resp A pointer to the responce class to
     //                             be used for this simulation
+    //    Int_t              cup   The type of coupling to be used
+    //                             =1 uses SetCoupling, =2 uses SetCouplingOld
+    //                             With diffusion tured off
+    //                             =3 uses SetCoupling, =4 uses SetCouplingOld
+    //                             with diffusion on other, no coupling.
     // Outputs:
     //    none.
     // Return:
     //    A default constructed AliITSsimulationSPDdubna class.
 
-    fHis = 0;
-    Init(seg,resp);
+    if(GetDebug(1)) Info("AliITSsimulationSPDdubda",
+                         "Calling degault constructor seg=%p resp=%p cup=%d",
+                         seg,resp,cup);
+    if(cup==1||cup==2){ // For the moment, remove defusion if Coupling is
+        // set.
+        resp->SetTemperature(0.0);
+        resp->SetDistanceOverVoltage(0.0);
+    } // end if
+    Init();
 }
 //______________________________________________________________________
-void AliITSsimulationSPDdubna::Init(AliITSsegmentation *seg,
-						   AliITSresponse *resp){
+void AliITSsimulationSPDdubna::Init(){
     // Initilization
     // Inputs:
-    //    AliITSsegmentation *seg  A pointer to the segmentation class
-    //                             to be used for this simulation
-    //    AliITSresponse     *resp A pointer to the responce class to
-    //                             be used for this simulation
+    //    none.
     // Outputs:
     //    none.
     // Return:
     //    none.
     const Double_t kmictocm = 1.0e-4; // convert microns to cm.
 
-    SetResponseModel(resp);
-    SetSegmentationModel(seg);
     SetModuleNumber(0);
     SetEventNumber(0);
     SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
-
-    GetResp()->SetDistanceOverVoltage(kmictocm*GetSeg()->Dy(),50.0);
+    GetResp(0,0)->SetDistanceOverVoltage(kmictocm*GetSeg()->Dy(),50.0);
 }
 //______________________________________________________________________
 AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){
@@ -108,8 +122,8 @@ AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){
     //     none.
 
     if (fHis) {
-	fHis->Delete(); 
-	delete fHis;     
+        fHis->Delete(); 
+        delete fHis;     
     } // end if fHis
 }
 //______________________________________________________________________
@@ -139,7 +153,9 @@ AliITSsimulationSPDdubna&  AliITSsimulationSPDdubna::operator=(const
     // Return:
 
     if(&s == this) return *this;
-    this->fHis      = s.fHis;
+    this->fHis = s.fHis;
+    fCoupling  = s.fCoupling;
+    fSPDname   = s.fSPDname;
     return *this;
 }
 //______________________________________________________________________
@@ -154,27 +170,34 @@ void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){
     //  Returns:
     //    none
 
+    if(GetDebug(1)) Info("InitSimulationModule","(module=%d,event=%d)",
+                         module,event);
     SetModuleNumber(module);
     SetEventNumber(event);
     ClearMap();
 }
 //_____________________________________________________________________
-void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod, Int_t mask,
-					       Int_t event){
+void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod,Int_t,
+                                               Int_t event){
     //  This function begins the work of creating S-Digits.  Inputs defined
     //  by base class.
     //  Inputs:
     //    AliITSmodule *mod  //  module
-    //    Int_t mask         //  mask to be applied to the module
-    //    Int_t event        // Event number
+    //    Int_t              //  not used
+    //    Int_t event        //  Event number
     //  Outputs:
     //    none
     //  Return:
     //    test              //  test returns kTRUE if the module contained hits
     //                      //  test returns kFALSE if it did not contain hits
 
-    mask = mod->GetNhits();
-    if(!mask) return;// if module has no hits don't create Sdigits
+    if(GetDebug(1)) Info("SDigitiseModule","(mod=%p, ,event=%d)",mod,event);
+    if(!(mod->GetNhits())){
+        if(GetDebug(1)) Info("SDigitiseModule","In event %d module %d there "
+                             "are %d hits returning.",event,
+                             mod->GetIndex(),mod->GetNhits());
+        return;// if module has no hits don't create Sdigits
+    } // end if
     SetModuleNumber(mod->GetIndex());
     SetEventNumber(event);
     HitToSDigit(mod);
@@ -193,15 +216,17 @@ void AliITSsimulationSPDdubna::WriteSDigits(){
     Int_t ix, nix, iz, niz;
     static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
 
+    if(GetDebug(1))Info("WriteSDigits","Writing SDigits for module %d",
+                        GetModuleNumber());
     GetMap()->GetMaxMapIndex(niz, nix);
     for(iz=0; izGetSignalOnly(iz,ix)>0.0){
-	    aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
-#ifdef DEBUG
-	    cout <<"SDigits " << iz << "," << ix << "," << 
-		*(GetMap()->GetpListItem(iz,ix)) << endl;
-#endif
-	} // end if GetMap()->GetSignalOnly(iz,ix)>0.0
+        if(GetMap()->GetSignalOnly(iz,ix)>0.0){
+            aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
+            if(GetDebug(1)){
+                cout <<"AliITSsimulationSPDdubna:WriteSDigits " << iz << "," 
+                     << ix << "," << *(GetMap()->GetpListItem(iz,ix)) << endl;
+            } // end if GetDebug
+        } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
     } // end for iz,ix
     return; 
 }
@@ -215,91 +240,32 @@ void AliITSsimulationSPDdubna::FinishSDigitiseModule(){
     //  Return
     //    none
 
-    SDigitsToDigits();
-    return;
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::SDigitsToDigits(){
-    //  This function adds electronic noise to the S-Digits and then adds them
-    // to  a new pList
-    //  Inputs:
-    //    none.
-    //  Outputs:
-    //    none.
-    //  Return:
-    //    none
-
-    ChargeToSignal(); // Charge To Signal both adds noise and
+    if(GetDebug(1)) Info("SDigitiseModule","()");
+    pListToDigits(); // Charge To Signal both adds noise and
     ClearMap();
+    return;
 }
 //______________________________________________________________________
-void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod, Int_t module,
-					      Int_t dummy){
+void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod,Int_t,
+                                              Int_t){
     //  This function creates Digits straight from the hits and then adds
     //  electronic noise to the digits before adding them to pList
     //  Each of the input variables is passed along to HitToSDigit
     //  Inputs:
     //    AliITSmodule *mod     module
-    //    Int_t        module   module number  Dummy.
-    //    Int_t        dummy
+    //    Int_t                 Dummy.
+    //    Int_t                 Dummy
     //  Outputs:
     //     none.
     //  Return:
     //    none.
 
-    //This calls the module for HitToSDigit
-    fModule = dummy = module = mod->GetIndex();
+    if(GetDebug(1)) Info("DigitiseModule","(mod=%p,,)",mod);
     HitToSDigit(mod);
-    ChargeToSignal();
+    pListToDigits();
     ClearMap();
 }
 //______________________________________________________________________
-void AliITSsimulationSPDdubna::UpdateMapSignal(Int_t iz,Int_t ix,Int_t trk,
-					       Int_t ht,Double_t signal){
-    //  This function adds a signal to the pList from the pList class
-    //  Inputs:
-    //    Int_t       iz     // row number
-    //    Int_t       ix     // column number
-    //    Int_t       trk    // track number
-    //    Int_t       ht     // hit number
-    //    Double_t    signal // signal strength
-    //  Outputs:
-    //    none.
-    //  Return:
-    //    none
-
-    GetMap()->AddSignal(iz,ix,trk,ht,GetModuleNumber(),signal);
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::UpdateMapNoise(Int_t iz,Int_t ix,Float_t noise){
-    //  This function adds noise to data in the MapA2 as well as the pList
-    //  Inputs:
-    //    Int_t       iz       // row number
-    //    Int_t       ix       // column number
-    //    Int_t       mod     // module number
-    //    Double_t    sig     // signal strength
-    //    Double_t    noise   // electronic noise generated by ChargeToSignal
-    //  Outputs:
-    //    All of the inputs are passed to AliITSMapA2::AddSignal or
-    //    AliITSpList::AddNoise
-    //  Return:
-    //    none
-
-    GetMap()->AddNoise(iz,ix,GetModuleNumber(),noise);
-}
-//______________________________________________________________________
-void AliITSsimulationSPDdubna::HitToDigit(AliITSmodule *mod){
-    // Standard interface to DigitiseModule
-    // Inputs:
-    //    AliITSmodule *mod  Pointer to this module
-    // Outputs:
-    //    none.
-    // Return:
-    //    none.
-
-    DigitiseModule(mod,GetModuleNumber(),0);
-}
-//______________________________________________________________________
 void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod){
     // Does the charge distributions using Gaussian diffusion charge charing.
     // Inputs:
@@ -311,47 +277,75 @@ void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod){
     const Double_t kmictocm = 1.0e-4; // convert microns to cm.
     TObjArray *hits = mod->GetHits();
     Int_t nhits = hits->GetEntriesFast();
-    Int_t h,ix,iz;
+    Int_t h,ix,iz,i;
     Int_t idtrack;
     Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0;
     Double_t x,y,z,t,tp,st,dt=0.2,el,sig;
     Double_t thick = kmictocm*GetSeg()->Dy();
 
+    if(GetDebug(1)) Info("HitsToSDigits","(mod=%p) fCoupling=%d",
+                         mod,fCoupling);
     if(nhits<=0) return;
     for(h=0;hGetHit(h)) << endl;
-#endif
-	if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){
-	  st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
-	  if(st>0.0){
-	    st = (Double_t)((Int_t)(1.0E+04*st)); // number of microns
-	    if(st<=0.0) st = 1.0;
-	    dt = 1.0/st;
-	    for(t=0;t<1.0;t+=dt){ // Integrate over t
-	      tp  = t+0.5*dt;
-	      el  = GetResp()->GeVToCharge((Float_t)(dt*de));
-#ifdef DEBUG
-	      if(el<=0.0) cout << "el="<GetHit(h)) << endl;
+        } // end if GetDebug
+        if(!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
+        st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
+        if(st>0.0){
+            st = (Double_t)((Int_t)(1.0E+04*st)); // number of microns
+            if(st<=0.0) st = 1.0;
+            dt = 1.0/st;
+            for(t=0.0;t<1.0;t+=dt){ // Integrate over t
+                tp  = t+0.5*dt;
+                x   = x0+x1*tp;
+                y   = y0+y1*tp;
+                z   = z0+z1*tp;
+                if(!(GetSeg()->LocalToDet(x,z,ix,iz))) continue; // outside
+                el  = GetResp(ix,iz)->GeVToCharge((Double_t)(dt*de));
+                if(GetDebug(1)){
+                    if(el<=0.0) cout<<"el="<AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
-	return;
+    if(GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,"
+                         "sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
+    if(sig<=0.0) { // if sig<=0 No diffusion to simulate.
+        GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
+        if(GetDebug(2)){
+            cout << "sig<=0.0=" << sig << endl;
+        } // end if GetDebug
+        return;
     } // end if
     sp = 1.0/(sig*kRoot2);
-#ifdef DEBUG
-    cout << "sig=" << sig << " sp=" << sp << endl;
-#endif
+    if(GetDebug(2)){
+        cout << "sig=" << sig << " sp=" << sp << endl;
+    } // end if GetDebug
     ixs = TMath::Max(-knx+ix0,0);
     ixe = TMath::Min(knx+ix0,GetSeg()->Npx()-1);
     izs = TMath::Max(-knz+iz0,0);
     ize = TMath::Min(knz+iz0,GetSeg()->Npz()-1);
     for(ix=ixs;ix<=ixe;ix++) for(iz=izs;iz<=ize;iz++){
-	GetSeg()->DetToLocal(ix,iz,x,z); // pixel center
-	x1  = x;
-	z1  = z;
-	x2  = x1 + 0.5*kmictocm*GetSeg()->Dpx(ix); // Upper
-	x1 -= 0.5*kmictocm*GetSeg()->Dpx(ix);  // Lower
-	z2  = z1 + 0.5*kmictocm*GetSeg()->Dpz(iz); // Upper
-	z1 -= 0.5*kmictocm*GetSeg()->Dpz(iz);  // Lower
-	x1 -= x0; // Distance from where track traveled
-	x2 -= x0; // Distance from where track traveled
-	z1 -= z0; // Distance from where track traveled
-	z2 -= z0; // Distance from where track traveled
-	s   = 0.25; // Correction based on definision of Erfc
-	s  *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
-#ifdef DEBUG
-	cout << "el=" << el << " ix0=" << ix0 << " ix=" << ix << " x0="<< x <<
-	    " iz0=" << iz0 << " iz=" << iz << " z0=" << z  << 
-	    " sp*x1=" << sp*x1 <<" sp*x2=" << sp*x2 << " s=" << s;
-#endif
-	s  *= TMath::Erfc(sp*z1) - TMath::Erfc(sp*z2);
-#ifdef DEBUG
-	cout << " sp*z1=" << sp*z1 <<" sp*z2=" << sp*z2 << " s=" << s << endl;
-#endif
-	GetMap()->AddSignal(iz,ix,t,hi,GetModuleNumber(),s*el);
+        GetSeg()->DetToLocal(ix,iz,x,z); // pixel center
+        x1  = x;
+        z1  = z;
+        x2  = x1 + 0.5*kmictocm*GetSeg()->Dpx(ix); // Upper
+        x1 -= 0.5*kmictocm*GetSeg()->Dpx(ix);  // Lower
+        z2  = z1 + 0.5*kmictocm*GetSeg()->Dpz(iz); // Upper
+        z1 -= 0.5*kmictocm*GetSeg()->Dpz(iz);  // Lower
+        x1 -= x0; // Distance from where track traveled
+        x2 -= x0; // Distance from where track traveled
+        z1 -= z0; // Distance from where track traveled
+        z2 -= z0; // Distance from where track traveled
+        s   = 0.25; // Correction based on definision of Erfc
+        s  *= TMath::Erfc(sp*x1) - TMath::Erfc(sp*x2);
+        if(GetDebug(3)){
+            cout <<"el="<At(hit);
-#ifdef DEBUG
-	cout << "Hits=" << hit << "," << *iHit << endl;
-#endif
-	//Int_t layer = iHit->GetLayer();
-
-	// work with the idtrack=entry number in the TreeH
-	//Int_t idhit,idtrack; //!
-	//mod->GetHitTrackAndHitIndex(hit,idtrack,idhit);  //!    
-	//Int_t idtrack=mod->GetHitTrackIndex(hit);  
-        // or store straight away the particle position in the array
-	// of particles : 
-	if(iHit->StatusEntering()) idhit=hit;
-        Int_t itrack = iHit->GetTrack();
-        Int_t dray = 0;
-   
-	if (lasttrack != itrack || hit==(nhits-1)) first = kTRUE; 
-
-	//Int_t parent = iHit->GetParticle()->GetFirstMother();
-        Int_t partcode = iHit->GetParticle()->GetPdgCode();
-
-	//  partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0,
-	// 211 - pi+,  310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda
-
-	Float_t pmod = iHit->GetParticle()->P(); // total momentum at the
-	                                           // vertex
-        pmod *= 1000;
-
-        if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e-
-                                                 // at p < 6 MeV/c
-
-	//  Get hit z and x(r*phi) cordinates for each module (detector)
-	//  in local system.
-
-	Float_t zPix = kconv*iHit->GetZL();
-	Float_t xPix = kconv*iHit->GetXL();
-	Float_t yPix = kconv*iHit->GetYL();
-
-	// Get track status
-	Int_t status = iHit->GetTrackStatus();      
-
-	// Check boundaries
-	if(zPix  > spdLength/2) {
-#ifdef DEBUG
-	    cout<<"!!! SPD: z outside ="<GetThreshold();
     Int_t j,ix,iz;
-    Float_t  electronics;
+    Double_t  electronics;
     Double_t sig;
     const Int_t    nmaxtrk=AliITSdigitSPD::GetNTracks();
     static AliITSdigitSPD dig;
 
+    if(GetDebug(1)) Info("pListToDigits","()");
     for(iz=0; izIsPixelDead(GetModuleNumber(),ix,iz)) continue;
-      electronics = GetResp()->ApplyBaselineAndNoise();
-      sig = GetMap()->GetSignalOnly(iz,ix);
-      UpdateMapNoise(iz,ix,electronics);
-#ifdef DEBUG
-      cout << sig << "+" << electronics <<">threshold=" << threshold  << endl;
-#endif
-      if (sig+electronics <= threshold) continue;
-      dig.SetCoord1(iz);
-      dig.SetCoord2(ix);
-      dig.SetSignal(1);
-      dig.SetSignalSPD((Int_t) GetMap()->GetSignal(iz,ix));
-      for(j=0;jGetNEnteries()) {
-	  dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
-	  dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
-	}else { // Default values
-	  dig.SetTrack(j,-3);
-	  dig.SetHit(j,-1);
-	} // end if GetMap()
-      } // end for j
-#ifdef DEBUG
-      cout<GetpListItem(iz,ix)) << endl;
-#endif
-      aliITS->AddSimDigit(0,&dig);
+        // Apply Noise/Dead channals and the like
+        if(GetResp(ix,iz)->IsPixelDead(GetModuleNumber(),ix,iz)) continue;
+        electronics = GetResp(ix,iz)->ApplyBaselineAndNoise();
+        UpdateMapNoise(ix,iz,electronics);
+        //
+        // Apply Threshold and write Digits.
+        sig = GetMap()->GetSignalOnly(iz,ix);
+        FillHistograms(ix,iz,sig+electronics);
+        if(GetDebug(3)){
+            cout<threshold("<GetpListItem(iz,ix))<AddSimDigit(0,&dig);
     } //  for ix/iz
 }
 //______________________________________________________________________
@@ -813,19 +482,33 @@ void AliITSsimulationSPDdubna::CreateHistograms(){
     // Return:
     //     none.
 
-    printf("SPD - create histograms\n");
+    if(GetDebug(1)) Info("CreateHistograms","create histograms");
 
-    fHis=new TObjArray(GetNPixelsZ());
-    TString spdName("spd_");
-    for (Int_t i=0;iAddAt(new TH1F(spdName.Data(),"SPD maps",
-			     GetNPixelsX(),0.,(Float_t) GetNPixelsX()), i);
+    fHis = new TObjArray(GetNPixelsZ());
+    TString fSPDname("spd_");
+    for(Int_t i=0;iAddAt(new TH1F(fSPDname.Data(),"SPD maps",
+                             GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);
     } // end for i
 }
 //______________________________________________________________________
+void AliITSsimulationSPDdubna::FillHistograms(Int_t ix,Int_t iz,Double_t v){
+    // Fill the histogram
+    // Inputs:
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //     none.
+
+    if(!GetHistArray()) return; // Only fill if setup.
+    if(GetDebug(2)) Info("FillHistograms","fill histograms");
+    GetHistogram(iz)->Fill(ix,v);
+}
+//______________________________________________________________________
 void AliITSsimulationSPDdubna::ResetHistograms(){
     // Reset histograms for this detector
     // Inputs:
@@ -835,8 +518,10 @@ void AliITSsimulationSPDdubna::ResetHistograms(){
     // Return:
     //     none.
 
+    if(!GetHistArray()) return; // Only fill if setup.
+    if(GetDebug(2)) Info("FillHistograms","fill histograms");
     for ( int i=0;iAt(i))    ((TH1F*)fHis->At(i))->Reset();
+        if (fHis->At(i))    ((TH1F*)fHis->At(i))->Reset();
     } // end for i
 }
 
@@ -847,6 +532,8 @@ void AliITSsimulationSPDdubna::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
     //  The parameters probcol and probrow are the probability of the
     //  signal in one pixel shared in the two adjacent pixels along
     //  the column and row direction, respectively.
+    //  Note pList is goten via GetMap() and module is not need any more.
+    //  Otherwise it is identical to that coded by Tiziano Virgili (BSN).
     //Begin_Html
     /*
       
@@ -863,52 +550,53 @@ void AliITSsimulationSPDdubna::SetCoupling(Int_t row, Int_t col, Int_t ntrack,
     //    Int_t col            x cell index
     //    Int_t ntrack         track incex number
     //    Int_t idhit          hit index number
-    //    Int_t module         module number
     // Outputs:
     //    none.
     // Return:
     //     none.
     Int_t j1,j2,flag=0;
     Double_t pulse1,pulse2;
-    Float_t couplR=0.0,couplC=0.0;
+    Double_t couplR=0.0,couplC=0.0;
     Double_t xr=0.;
-    AliITSpList *pList = GetMap();
 
     GetCouplings(couplR,couplC);
+    if(GetDebug(3)) Info("SetCoupling","(row=%d,col=%d,ntrack=%d,idhit=%d) "
+                         "Calling SetCoupling couplR=%e couplC=%e",
+                         row,col,ntrack,idhit,couplR,couplC);
     j1 = row;
     j2 = col;
-    pulse1 = pList->GetSignalOnly(row,col);
+    pulse1 = GetMap()->GetSignalOnly(row,col);
     pulse2 = pulse1;
     for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
-      do{
-	j1 += isign;
-	//   pulse1 *= couplR; 
-	xr = gRandom->Rndm();
-	//   if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1GetNPixelsZ()-1) || (xr>couplR)){
-	  j1 = row;
-	  flag = 1;
-	}else{
-	  UpdateMapSignal(j1,col,ntrack,idhit,pulse1);
-	  //  flag = 0;
-	  flag = 1; // only first next!!
-	} // end if
-      } while(flag == 0);
-      // loop in column direction
-      do{
-	j2 += isign;
-	// pulse2 *= couplC; 
-	xr = gRandom->Rndm();
-	//  if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2GetNPixelsX()-1) || (xr>couplC)){
-	  j2 = col;
-	  flag = 1;
-	}else{
-	  UpdateMapSignal(row,j2,ntrack,idhit,pulse2);
-	  //  flag = 0;
-	  flag = 1; // only first next!!
-	} // end if
-      } while(flag == 0);
+        do{
+            j1 += isign;
+            //   pulse1 *= couplR; 
+            xr = gRandom->Rndm();
+            //if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1GetNPixelsZ()-1) || (xr>couplR)){
+                j1 = row;
+                flag = 1;
+            }else{
+                UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
+                //  flag = 0;
+                flag = 1; // only first next!!
+            } // end if
+        } while(flag == 0);
+        // loop in column direction
+        do{
+            j2 += isign;
+            // pulse2 *= couplC; 
+            xr = gRandom->Rndm();
+            //if((j2<0)||j2>(GetNPixelsX()-1)||pulse2GetNPixelsX()-1) || (xr>couplC)){
+                j2 = col;
+                flag = 1;
+            }else{
+                UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
+                //  flag = 0;
+                flag = 1; // only first next!!
+            } // end if
+        } while(flag == 0);
     } // for isign
 }
 //______________________________________________________________________
@@ -941,39 +629,41 @@ void AliITSsimulationSPDdubna::SetCouplingOld(Int_t row, Int_t col,
     //     none.
     Int_t j1,j2,flag=0;
     Double_t pulse1,pulse2;
-    Float_t couplR=0.0,couplC=0.0;
-    AliITSpList *pList = GetMap();
+    Double_t couplR=0.0,couplC=0.0;
 
     GetCouplings(couplR,couplC);
+    if(GetDebug(3)) Info("SetCouplingOld","(row=%d,col=%d,ntrack=%d,idhit=%d) "
+                         "Calling SetCoupling couplR=%e couplC=%e",
+                         row,col,ntrack,idhit,couplR,couplC);
     j1 = row;
     j2 = col;
-    pulse1 = pList->GetSignalOnly(row,col);
+    pulse1 = GetMap()->GetSignalOnly(row,col);
     pulse2 = pulse1;
     for (Int_t isign=-1;isign<=1;isign+=2){// loop in row direction
-      do{
-	j1 += isign;
-	pulse1 *= couplR;
-	if ((j1<0) || (j1>GetNPixelsZ()-1) || (pulse1GetSignalOnly(row,col);
-	  j1 = row;
-	  flag = 1;
-	}else{
-	  UpdateMapSignal(j1,col,ntrack,idhit,pulse1);
-	  flag = 0;
-	} // end if
-      } while(flag == 0);
-      // loop in column direction
-      do{
-	j2 += isign;
-	pulse2 *= couplC;
-	if ((j2<0) || (j2>(GetNPixelsX()-1)) || (pulse2GetSignalOnly(row,col);
-	  j2 = col;
-	  flag = 1;
-	}else{
-	  UpdateMapSignal(row,j2,ntrack,idhit,pulse2);
-	  flag = 0;
-	} // end if
-      } while(flag == 0);
+        do{
+            j1 += isign;
+            pulse1 *= couplR;
+            if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1GetSignalOnly(row,col);
+                j1 = row;
+                flag = 1;
+            }else{
+                UpdateMapSignal(col,j1,ntrack,idhit,pulse1);
+                flag = 0;
+            } // end if
+        } while(flag == 0);
+        // loop in column direction
+        do{
+            j2 += isign;
+            pulse2 *= couplC;
+            if((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2GetSignalOnly(row,col);
+                j2 = col;
+                flag = 1;
+            }else{
+                UpdateMapSignal(j2,row,ntrack,idhit,pulse2);
+                flag = 0;
+            } // end if
+        } while(flag == 0);
     } // for isign
 }
diff --git a/ITS/AliITSsimulationSPDdubna.h b/ITS/AliITSsimulationSPDdubna.h
index d744d36a12b..b00b0ada24e 100644
--- a/ITS/AliITSsimulationSPDdubna.h
+++ b/ITS/AliITSsimulationSPDdubna.h
@@ -4,8 +4,11 @@
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
+#include "TH1F.h"
+#include "TObjArray.h"
+
 #include "AliITSsimulation.h"
-#include "AliITSresponseSPDdubna.h"
+#include "AliITSresponseSPD.h"
 #include "AliITSsegmentationSPD.h"
 
 class AliITSmodule;
@@ -15,56 +18,110 @@ class AliITSmodule;
 class AliITSsimulationSPDdubna : public AliITSsimulation {
  public:
     AliITSsimulationSPDdubna();
-    AliITSsimulationSPDdubna(AliITSsegmentation *seg, AliITSresponse *res);
+    AliITSsimulationSPDdubna(AliITSsegmentation *seg,AliITSresponse *res,
+                             Int_t cup=1);
     virtual ~AliITSsimulationSPDdubna();
     // copy constructor
     AliITSsimulationSPDdubna(const AliITSsimulationSPDdubna &source); 
      // ass. operator
     AliITSsimulationSPDdubna& operator=(const AliITSsimulationSPDdubna &s);
     // Initilizes the variables
-    void Init(AliITSsegmentation *seg, AliITSresponse *resp);
+    void Init();
 
+    // General User calling routines
+    // Initilize simulation for a specific event and module
     void InitSimulationModule(Int_t module, Int_t event);
+    // Finish and write S Digitization
+    void FinishSDigitiseModule();
+    // From hits to Digits, without creating SDigits
+    void DigitiseModule(AliITSmodule *mod,Int_t,Int_t);
+
+    // More or less Internal Routines
+    // Create S Digits from specific module
     void SDigitiseModule(AliITSmodule *mod, Int_t mask, Int_t event);
+    // Write S Digits to the tree of SDigits.
     void WriteSDigits();
-    void FinishSDigitiseModule();
-    void SDigitsToDigits();
-    void DigitiseModule(AliITSmodule *mod,Int_t module,Int_t dummy);
-    void UpdateMapSignal(Int_t i,Int_t j,Int_t trk,Int_t ht,Double_t signal);
-    void UpdateMapNoise(Int_t ix,Int_t iz,Float_t noise);
-    void HitToDigit(AliITSmodule *mod);
+    // fill pList from hits, charge sharing, diffusion, coupling
     void HitToSDigit(AliITSmodule *mod);
-    void HitToSDigitOld(AliITSmodule *mod);
-    void ChargeToSignal();
+    // Take pList of signals and apply noise... create Digis
+    void pListToDigits();
+    //
     void CreateHistograms();
+    void FillHistograms(Int_t ix,Int_t iz,Double_t v=1.0);
     void ResetHistograms();
+    TH1F* GetHistogram(Int_t i){return (TH1F*)(fHis->At(i));}// get histogram
     TObjArray*  GetHistArray() {return fHis;}// get hist array
+    TString& GetHistName(){return fSPDname;}
+    void SetHistName(TString &n){fSPDname = n;}
+    //
+    // For backwards compatibility
+    void SDigitsToDigits(){ FinishSDigitiseModule();};
+    void HitToDigit(AliITSmodule *mod){
+        // Standard interface to DigitiseModule
+        // Inputs:
+        //    AliITSmodule *mod  Pointer to this module
+        // Outputs:
+        //    none.
+        // Return:
+        //    none.
+        DigitiseModule(mod,GetModuleNumber(),0);};
 
  private:
     void SpreadCharge(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,
 		      Double_t el,Double_t sig,Int_t t,Int_t hi);
+    void UpdateMapSignal(Int_t ix,Int_t iz,Int_t trk,Int_t ht,Double_t signal){
+        //  This function adds a signal to the pList from the pList class
+        //  Inputs:
+        //    Int_t       iz     // row number
+        //    Int_t       ix     // column number
+        //    Int_t       trk    // track number
+        //    Int_t       ht     // hit number
+        //    Double_t    signal // signal strength
+        //  Outputs:
+        //    none.
+        //  Return:
+        //    none
+        GetMap()->AddSignal(iz,ix,trk,ht,GetModuleNumber(),signal);};
+    void UpdateMapNoise(Int_t ix,Int_t iz,Float_t noise){
+        //  This function adds noise to data in the MapA2 as well as the pList
+        //  Inputs:
+        //    Int_t       iz       // row number
+        //    Int_t       ix       // column number
+        //    Double_t    ns    // electronic noise generated by pListToDigits
+        //  Outputs:
+        //    none.
+        //  Return:
+        //    none
+        GetMap()->AddNoise(iz,ix,GetModuleNumber(),noise);};
     AliITSsegmentationSPD* GetSeg(){ // Return pointer to Segmentation class
-	return (AliITSsegmentationSPD*)fSegmentation;}
-    AliITSresponseSPDdubna* GetResp(){ // Return pointer to Responce class
-	return (AliITSresponseSPDdubna*)fResponse;}
-    //Double_t * CreateFindCellEdges(Double_t x0,Double_t x1,Double_t z0,
-    //                               Double_t z1,Int_t &n);
+        return (AliITSsegmentationSPD*)fSegmentation;};
+    // Return pointer to Responce class
+    AliITSresponseSPD* GetResp(Int_t ix,Int_t iz){ // ix iz dummy for now
+        ix=iz; return (AliITSresponseSPD*)GetResponseModel();};
+    // Bari-Salerno Coupling parameters
+    // "New" coupling routine  Tiziano Virgili
     void SetCoupling(Int_t row,Int_t col,Int_t ntrack,Int_t idhit);
+    // "Old" coupling routine  Rocco Caliandro
     void SetCouplingOld(Int_t row, Int_t col,Int_t ntrack,Int_t idhit);
     // Getters for data kept in fSegmentation and fResponse.
     // Returns the Threshold in electrons
-    Double_t GetThreshold(){ return GetResp()->GetThreshold();}
+    Double_t GetThreshold(Int_t ix,Int_t iz){
+        Double_t th,sig;GetResp(ix,iz)->Thresholds(th,sig);return th;};
     // Returns the couplings Columb and Row.
-    void GetCouplings(Float_t &cc,Float_t &cr){
-	((AliITSresponseSPDdubna*)GetResp())->GetNoiseParam(cc,cr);}
+    void GetCouplings(Double_t &cc,Double_t &cr){
+        ((AliITSresponseSPD*)GetResp(0,0))->GetCouplingParam(cc,cr);};
     // Returns the number of pixels in x
-    Int_t GetNPixelsX(){return GetSeg()->Npx();}
+    Int_t GetNPixelsX(){return GetSeg()->Npx();};
     // Returns the number of pixels in z
-    Int_t GetNPixelsZ(){return GetSeg()->Npz();}
-
-    ClassDef(AliITSsimulationSPDdubna,2)  // Simulation of SPD clusters
+    Int_t GetNPixelsZ(){return GetSeg()->Npz();};
 
     TObjArray    *fHis;          //! just in case for histogramming
-
+    TString       fSPDname;      //! Histogram name
+    Int_t         fCoupling;     // Sets the coupling to be used.
+                                 // ==1 use SetCoupling, ==2 use SetCouplingOld
+                                 // with diffusion turned off (by constructor)
+                                 // ==3 use SetCoupling, ==4 use SetCouplingOld
+                                 // with diffusion, else no coupling.
+    ClassDef(AliITSsimulationSPDdubna,3)  // Simulation of SPD clusters
 };
 #endif 
diff --git a/ITS/AliITSsimulationSSD.cxx b/ITS/AliITSsimulationSSD.cxx
index 593ee7ef060..5de9dc84ea3 100644
--- a/ITS/AliITSsimulationSSD.cxx
+++ b/ITS/AliITSsimulationSSD.cxx
@@ -47,18 +47,29 @@ ClassImp(AliITSsimulationSSD);
 // AliITSsimulationSSD is the simulation of SSDs.
 
 //----------------------------------------------------------------------
-AliITSsimulationSSD::AliITSsimulationSSD(){
-  //default Constructor
-
-  fDCS     = 0;
-  fDifConst[0] = fDifConst[1] = 0.0;
-  fDriftVel[0] = fDriftVel[1] = 0.0;
-  fMapA2   = 0;
-//  fpList    = 0;
+AliITSsimulationSSD::AliITSsimulationSSD():AliITSsimulation(),
+fDCS(0),
+fMapA2(0),
+fIonE(0.0),
+fDifConst(),
+fDriftVel(){
+    //default Constructor
+    //Inputs:
+    // none.
+    // Outputs:
+    // none.
+    // Return:
+    //  A default construction AliITSsimulationSSD class
 }
 //----------------------------------------------------------------------
 AliITSsimulationSSD::AliITSsimulationSSD(AliITSsegmentation *seg,
-                                         AliITSresponse *resp){
+                                         AliITSresponse *res):
+AliITSsimulation(seg,res),
+fDCS(0),
+fMapA2(0),
+fIonE(0.0),
+fDifConst(),
+fDriftVel(){
     // Constructor 
     // Input:
     //   AliITSsegmentationSSD *seg  Pointer to the SSD segmentation to be used
@@ -66,19 +77,12 @@ AliITSsimulationSSD::AliITSsimulationSSD(AliITSsegmentation *seg,
     // Outputs:
     //   none.
     // Return
-    //   none.
+    //   A standard constructed AliITSsimulationSSD class
 
-    fDCS     = 0;
-    fDifConst[0] = fDifConst[1] = 0.0;
-    fDriftVel[0] = fDriftVel[1] = 0.0;
-    fMapA2   = 0;
-    SetDebug(kFALSE);
-//    fpList    = 0;
-    Init((AliITSsegmentationSSD*)seg,(AliITSresponseSSD*)resp);
+    Init();
 }
 //----------------------------------------------------------------------
-void AliITSsimulationSSD::Init(AliITSsegmentationSSD *seg,
-                               AliITSresponseSSD *resp){
+void AliITSsimulationSSD::Init(){
     // Inilizer, Inilizes all of the variable as needed in a standard place.
     // Input:
     //   AliITSsegmentationSSD *seg  Pointer to the SSD segmentation to be used
@@ -88,17 +92,16 @@ void AliITSsimulationSSD::Init(AliITSsegmentationSSD *seg,
     // Return
     //   none.
 
-    fSegmentation    = seg;
-    fResponse        = resp;
-    Float_t noise[2] = {0.,0.};
-    fResponse->GetNoiseParam(noise[0],noise[1]); // retrieves noise parameters
-    fDCS             = new AliITSdcsSSD(seg,resp); 
+    Double_t noise[2] = {0.,0.};
+    GetResp()->GetNoiseParam(noise[0],noise[1]); // retrieves noise parameters
+    fDCS = new AliITSdcsSSD((AliITSsegmentationSSD*)GetSegmentationModel(),
+                            (AliITSresponseSSD*)GetResponseModel()); 
 
     SetDriftVelocity(); // use default values in .h file
     SetIonizeE();       // use default values in .h file
     SetDiffConst();     // use default values in .h file
     fpList           = new AliITSpList(2,GetNStrips());
-    fMapA2           = new AliITSMapA2(fSegmentation);
+    fMapA2           = new AliITSMapA2(GetSegmentationModel());
 }
 //______________________________________________________________________
 AliITSsimulationSSD& AliITSsimulationSSD::operator=(
@@ -140,8 +143,8 @@ void AliITSsimulationSSD::InitSimulationModule(Int_t module,Int_t event){
     // Return
     //    none.
 
-    fModule = module;
-    fEvent  = event;
+    SetModuleNumber(module);
+    SetEventNumber(event);
     fMapA2->ClearMap();
     fpList->ClearMap();
 }
@@ -161,24 +164,20 @@ void AliITSsimulationSSD::FinishSDigitiseModule(){
     fMapA2->ClearMap();
 }
 //______________________________________________________________________
-void AliITSsimulationSSD::DigitiseModule(AliITSmodule *mod,
-                                         Int_t dummy0,Int_t dummy1) {
+void AliITSsimulationSSD::DigitiseModule(AliITSmodule *mod,Int_t,Int_t) {
   // Digitizes hits for one SSD module
-  Int_t module     = mod->GetIndex();
+  SetModuleNumber(mod->GetIndex());
 
-  dummy0 = dummy1 = 0;  // remove unused variable warning.
   HitsToAnalogDigits(mod,fpList);
-  SDigitToDigit(module,fpList);
+  SDigitToDigit(GetModuleNumber(),fpList);
 
   fpList->ClearMap();
   fMapA2->ClearMap();
 }
 //______________________________________________________________________
-void AliITSsimulationSSD::SDigitiseModule(AliITSmodule *mod,Int_t dummy0,
-                                          Int_t dummy1) {
+void AliITSsimulationSSD::SDigitiseModule(AliITSmodule *mod,Int_t,Int_t) {
   // Produces Summable/Analog digits and writes them to the SDigit tree. 
 
-    dummy0 = dummy1 = 0; // remove unused variable warning
     HitsToAnalogDigits(mod,fpList);
 
     WriteSDigits(fpList);
@@ -189,9 +188,6 @@ void AliITSsimulationSSD::SDigitiseModule(AliITSmodule *mod,Int_t dummy0,
 //______________________________________________________________________
 void AliITSsimulationSSD::SDigitToDigit(Int_t module,AliITSpList *pList){
   // Takes the pList and finishes the digitization.
-                               
-  //    FillMapFrompList(pList);  //commented out to avoid double counting of the
-                                //charge
 
   ApplyNoise(pList,module);
   ApplyCoupling(pList,module);
@@ -218,20 +214,22 @@ void AliITSsimulationSSD::HitsToAnalogDigits(AliITSmodule *mod,
     if ( mod->GetLayer() == 6 ) GetSegmentation()->SetLayer(6);
     if ( mod->GetLayer() == 5 ) GetSegmentation()->SetLayer(5);
     for(Int_t i=0; iGetHit(i)->GetXL() << " "<GetHit(i)->GetYL();
-//	cout << " " << mod->GetHit(i)->GetZL();
-//	cout << endl;
-	if (mod->LineSegmentL(i, x0, x1, y0, y1, z0, z1, de, idtrack)) {
-	    HitToDigit(module, x0, y0, z0, x1, y1, z1, de,tav);
-	    if (lasttrack != idtrack || i==(nhits-1)) {
-		GetList(idtrack,i,module,pList,tav);
-	    } // end if
-	    lasttrack=idtrack;
-	} // end if
+        // LineSegmentL returns 0 if the hit is entering
+        // If hits is exiting returns positions of entering and exiting hits
+        // Returns also energy loss
+        if(GetDebug(4)){
+            cout << i << " ";
+            cout << mod->GetHit(i)->GetXL() << " "<GetHit(i)->GetYL();
+            cout << " " << mod->GetHit(i)->GetZL();
+            cout << endl;
+        } // end if
+        if (mod->LineSegmentL(i, x0, x1, y0, y1, z0, z1, de, idtrack)) {
+            HitToDigit(module, x0, y0, z0, x1, y1, z1, de,tav);
+            if (lasttrack != idtrack || i==(nhits-1)) {
+                GetList(idtrack,i,module,pList,tav);
+            } // end if
+            lasttrack=idtrack;
+        } // end if
     }  // end loop over hits
     delete tav; tav=0;
     return;
@@ -259,360 +257,364 @@ void AliITSsimulationSSD::HitToDigit(Int_t module, Double_t x0, Double_t y0,
     de    = de/numOfSteps;
     pairs = de/GetIonizeE(); // e-h pairs generated
     for(Int_t j=0; j (GetSegmentation()->Dy()/2+10)*1.0E-4 ) {
-	    // check if particle is within the detector
-	    Warning("HitToDigit",
-		    "hit out of detector y0=%e,y=%e,dey=%e,j =%e module=%d",
-		    y0,y,dey,j,module);
-	    return;
-	} // end if
-	z = z0 + (j+0.5)*dez;
-//	cout <<"HitToDigit "<Dy()*1.0E-4)/2)/GetDriftVelocity(0);
-	tdrift[1] = ((GetSegmentation()->Dy()*1.0E-4)/2-y)/GetDriftVelocity(1);
-
-	for(Int_t k=0; k<2; k++) {   // both sides    remember: 0=Pside 1=Nside
-
-	    tang[k]=TMath::Tan(tang[k]);
-
-	    // w is the coord. perpendicular to the strips
-	    /*
-	    if(k==0) {
-		w = (x+(GetSegmentation()->Dx()*1.0E-4)/2) -
+        x = x0 + (j+0.5)*dex;
+        y = y0 + (j+0.5)*dey;
+        if ( y > (GetSegmentation()->Dy()/2+10)*1.0E-4 ) {
+            // check if particle is within the detector
+            Warning("HitToDigit",
+                    "hit out of detector y0=%e,y=%e,dey=%e,j =%e module=%d",
+                    y0,y,dey,j,module);
+            return;
+        } // end if
+        z = z0 + (j+0.5)*dez;
+        if(GetDebug(4)) cout <<"HitToDigit "<Dy()*1.0E-4)/2)/GetDriftVelocity(0);
+        tdrift[1] = ((GetSegmentation()->Dy()*1.0E-4)/2-y)/GetDriftVelocity(1);
+
+        for(Int_t k=0; k<2; k++) {   // both sides    remember: 0=Pside 1=Nside
+
+            tang[k]=TMath::Tan(tang[k]);
+
+            // w is the coord. perpendicular to the strips
+            /*
+              if(k==0) {
+              w = (x+(GetSegmentation()->Dx()*1.0E-4)/2) -
 		    (z+(GetSegmentation()->Dz()*1.0E-4)/2)*tang[k]; 
-	    }else{
-		w = (x+(GetSegmentation()->Dx()*1.0E-4)/2) + 
+              }else{
+              w = (x+(GetSegmentation()->Dx()*1.0E-4)/2) + 
 		    (z-(GetSegmentation()->Dz()*1.0E-4)/2)*tang[k];
-	    } // end if
-	    w /= (GetStripPitch()*1.0E-4); // w is converted in units of pitch
-	    */
-	    { // replacement block for the above.
-		Float_t xp=x*1.e+4,zp=z*1.e+4; // microns
-		GetSegmentation()->GetPadTxz(xp,zp);
-		if(k==0) w = xp; // P side strip number
-		else w = zp; // N side strip number
-	    } // end test block
-
-	    if((w<(-0.5)) || (w>(GetNStrips()-0.5))) {
-		// this check rejects hits in regions not covered by strips
-		// 0.5 takes into account boundaries 
-		//cout << "x,z="<GetPadTxz(xp,zp);
+                if(k==0) w = xp; // P side strip number
+                else w = zp; // N side strip number
+            } // end test block
+
+            if((w<(-0.5)) || (w>(GetNStrips()-0.5))) {
+                // this check rejects hits in regions not covered by strips
+                // 0.5 takes into account boundaries 
+                if(GetDebug(4)) cout << "x,z="<GetNoiseParam(a,b); // retrieves noise parameters
-  noiseP[0] = (Double_t) a; noiseP[1] = (Double_t) b;
-  for(k=0;k<2;k++){                    // both sides (0=Pside, 1=Nside)
-	for(ix=0;ixGaus(0,noiseP[k]);// get noise to signal
-	    signal = noise + fMapA2->GetSignal(k,ix);//get signal from map
-	    if(signal<0.) signal=0.0;           // in case noise is negative...
-	    fMapA2->SetHit(k,ix,signal); // give back signal to map
-	    if(signal>0.0) pList->AddNoise(k,ix,module,noise);
-	} // loop over strip 
-  } // loop over k (P or N side)
+    // Apply Noise.
+    Int_t    k,ix;
+    Double_t signal,noise;
+    Double_t noiseP[2] = {0.,0.};
+    Double_t a,b;
+
+    GetResp()->GetNoiseParam(a,b); // retrieves noise parameters
+    noiseP[0] = a; noiseP[1] = b;
+    for(k=0;k<2;k++){                    // both sides (0=Pside, 1=Nside)
+        for(ix=0;ixGaus(0,noiseP[k]);// get noise to signal
+            signal = noise + fMapA2->GetSignal(k,ix);//get signal from map
+            if(signal<0.) signal=0.0;           // in case noise is negative...
+            fMapA2->SetHit(k,ix,signal); // give back signal to map
+            if(signal>0.0) pList->AddNoise(k,ix,module,noise);
+        } // loop over strip 
+    } // loop over k (P or N side)
 }
 //______________________________________________________________________
 void AliITSsimulationSSD::ApplyCoupling(AliITSpList *pList,Int_t module) {
-  // Apply the effect of electronic coupling between channels
-  Int_t ix;
-  Double_t signalLeft=0, signalRight=0,signal=0;
-
-  for(ix=0;ix0.)signalLeft = fMapA2->GetSignal(0,ix-1)*fDCS->GetCouplingPL();
-	else signalLeft = 0.0;
-	if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(0,ix+1)*
-                              fDCS->GetCouplingPR();
-	else signalRight = 0.0;
-	signal = signalLeft + signalRight;
-	fMapA2->AddSignal(0,ix,signal);
-	if(signal>0.0) pList->AddNoise(0,ix,module,signal);
-
-	signalLeft = signalRight = signal = 0.0;
-	// N side coupling
-	if(ix>0.) signalLeft = fMapA2->GetSignal(1,ix-1)*fDCS->GetCouplingNL();
-	else signalLeft = 0.0;
-	if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(1,ix+1)*
-                              fDCS->GetCouplingNR();
-	else signalRight = 0.0;
-	signal = signalLeft + signalRight;
-	fMapA2->AddSignal(1,ix,signal);
-	if(signal>0.0) pList->AddNoise(1,ix,module,signal);
-  } // loop over strips 
+    // Apply the effect of electronic coupling between channels
+    Int_t ix;
+    Double_t signalLeft=0, signalRight=0,signal=0;
+
+    for(ix=0;ix0.)signalLeft = fMapA2->GetSignal(0,ix-1)*fDCS->GetCouplingPL();
+        else signalLeft = 0.0;
+        if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(0,ix+1)*
+                                    fDCS->GetCouplingPR();
+        else signalRight = 0.0;
+        signal = signalLeft + signalRight;
+        fMapA2->AddSignal(0,ix,signal);
+        if(signal>0.0) pList->AddNoise(0,ix,module,signal);
+
+        signalLeft = signalRight = signal = 0.0;
+        // N side coupling
+        if(ix>0.) signalLeft = fMapA2->GetSignal(1,ix-1)*fDCS->GetCouplingNL();
+        else signalLeft = 0.0;
+        if(ix<(GetNStrips()-1)) signalRight = fMapA2->GetSignal(1,ix+1)*
+                                    fDCS->GetCouplingNR();
+        else signalRight = 0.0;
+        signal = signalLeft + signalRight;
+        fMapA2->AddSignal(1,ix,signal);
+        if(signal>0.0) pList->AddNoise(1,ix,module,signal);
+    } // loop over strips 
 }
 //______________________________________________________________________
 Float_t AliITSsimulationSSD::F(Float_t av, Float_t x, Float_t s) {
-  // Computes the integral of a gaussian using Error Function
-  Float_t sqrt2 = TMath::Sqrt(2.0);
-  Float_t sigm2 = sqrt2*s;
-  Float_t integral;
+    // Computes the integral of a gaussian using Error Function
+    Float_t sqrt2 = TMath::Sqrt(2.0);
+    Float_t sigm2 = sqrt2*s;
+    Float_t integral;
 
-  integral = 0.5 * TMath::Erf( (x - av) / sigm2);
-  return integral;
+    integral = 0.5 * TMath::Erf( (x - av) / sigm2);
+    return integral;
 }
 //______________________________________________________________________
 void AliITSsimulationSSD::IntegrateGaussian(Int_t k,Double_t par, Double_t w,
                                             Double_t sigma, 
                                             Double_t inf, Double_t sup,
                                             AliITSTableSSD *tav) {
-  // integrate the diffusion gaussian
-  // remind: inf and sup are w-3sigma and w+3sigma
-  //         we could define them here instead of passing them
-  //         this way we are free to introduce asimmetry
-
-  Double_t a=0.0, b=0.0;
-  Double_t dXCharge1 = 0.0, dXCharge2 = 0.0;
-  // dXCharge1 and 2 are the charge to two neighbouring strips
-  // Watch that we only involve at least two strips
-  // Numbers greater than 2 of strips in a cluster depend on
-  //  geometry of the track and delta rays, not charge diffusion!   
-  
-  Double_t strip = TMath::Floor(w);         // closest strip on the left
-
-  if ( TMath::Abs((strip - w)) < 0.5) { 
-      // gaussian mean is closer to strip on the left
-      a = inf;                         // integration starting point
-      if((strip+0.5)<=sup) {
-	  // this means that the tail of the gaussian goes beyond
-	  // the middle point between strips ---> part of the signal
-	  // is given to the strip on the right
-	  b = strip + 0.5;               // integration stopping point
-	  dXCharge1 = F( w, b, sigma) - F(w, a, sigma);
-	  dXCharge2 = F( w, sup, sigma) - F(w ,b, sigma); 
-      }else { 
-	  // this means that all the charge is given to the strip on the left
-	  b = sup;
-	  dXCharge1 = 0.9973;   // gaussian integral at 3 sigmas
-	  dXCharge2 = 0.0;
-      } // end if
-      dXCharge1 = par * dXCharge1;// normalize by mean of number of carriers
-      dXCharge2 = par * dXCharge2;
-
-      // for the time being, signal is the charge
-      // in ChargeToSignal signal is converted in ADC channel
-      fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
-      tav->Add(k,(Int_t)strip);
-      if(((Int_t) strip) < (GetNStrips()-1)) {
-	  // strip doesn't have to be the last (remind: last=GetNStrips()-1)
-	  // otherwise part of the charge is lost
-	  fMapA2->AddSignal(k,((Int_t)strip+1),dXCharge2);
-	  tav->Add(k,((Int_t)(strip+1)));
-      } // end if
-  }else{
-      // gaussian mean is closer to strip on the right
-      strip++;     // move to strip on the rigth
-      b = sup;     // now you know where to stop integrating
-      if((strip-0.5)>=inf) { 
-	  // tail of diffusion gaussian on the left goes left of
-	  // middle point between strips
-	  a = strip - 0.5;        // integration starting point
-	  dXCharge1 = F(w, b, sigma) - F(w, a, sigma);
-	  dXCharge2 = F(w, a, sigma) - F(w, inf, sigma);
-      }else {
-	  a = inf;
-	  dXCharge1 = 0.9973;   // gaussian integral at 3 sigmas
-	  dXCharge2 = 0.0;
-      } // end if
-      dXCharge1 = par * dXCharge1;    // normalize by means of carriers
-      dXCharge2 = par * dXCharge2;
-      // for the time being, signal is the charge
-      // in ChargeToSignal signal is converted in ADC channel
-      fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
-      tav->Add(k,(Int_t)strip);
-      if(((Int_t) strip) > 0) {
-	  // strip doesn't have to be the first
-	  // otherwise part of the charge is lost
-	  fMapA2->AddSignal(k,((Int_t)strip-1),dXCharge2);
-	  tav->Add(k,((Int_t)(strip-1)));
-      } // end if
-  } // end if
+    // integrate the diffusion gaussian
+    // remind: inf and sup are w-3sigma and w+3sigma
+    //         we could define them here instead of passing them
+    //         this way we are free to introduce asimmetry
+
+    Double_t a=0.0, b=0.0;
+    Double_t dXCharge1 = 0.0, dXCharge2 = 0.0;
+    // dXCharge1 and 2 are the charge to two neighbouring strips
+    // Watch that we only involve at least two strips
+    // Numbers greater than 2 of strips in a cluster depend on
+    //  geometry of the track and delta rays, not charge diffusion!   
+
+    Double_t strip = TMath::Floor(w);         // closest strip on the left
+
+    if ( TMath::Abs((strip - w)) < 0.5) { 
+        // gaussian mean is closer to strip on the left
+        a = inf;                         // integration starting point
+        if((strip+0.5)<=sup) {
+            // this means that the tail of the gaussian goes beyond
+            // the middle point between strips ---> part of the signal
+            // is given to the strip on the right
+            b = strip + 0.5;               // integration stopping point
+            dXCharge1 = F( w, b, sigma) - F(w, a, sigma);
+            dXCharge2 = F( w, sup, sigma) - F(w ,b, sigma); 
+        }else { 
+            // this means that all the charge is given to the strip on the left
+            b = sup;
+            dXCharge1 = 0.9973;   // gaussian integral at 3 sigmas
+            dXCharge2 = 0.0;
+        } // end if
+        dXCharge1 = par * dXCharge1;// normalize by mean of number of carriers
+        dXCharge2 = par * dXCharge2;
+
+        // for the time being, signal is the charge
+        // in ChargeToSignal signal is converted in ADC channel
+        fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
+        tav->Add(k,(Int_t)strip);
+        if(((Int_t) strip) < (GetNStrips()-1)) {
+            // strip doesn't have to be the last (remind: last=GetNStrips()-1)
+            // otherwise part of the charge is lost
+            fMapA2->AddSignal(k,((Int_t)strip+1),dXCharge2);
+            tav->Add(k,((Int_t)(strip+1)));
+        } // end if
+    }else{
+        // gaussian mean is closer to strip on the right
+        strip++;     // move to strip on the rigth
+        b = sup;     // now you know where to stop integrating
+        if((strip-0.5)>=inf) { 
+            // tail of diffusion gaussian on the left goes left of
+            // middle point between strips
+            a = strip - 0.5;        // integration starting point
+            dXCharge1 = F(w, b, sigma) - F(w, a, sigma);
+            dXCharge2 = F(w, a, sigma) - F(w, inf, sigma);
+        }else {
+            a = inf;
+            dXCharge1 = 0.9973;   // gaussian integral at 3 sigmas
+            dXCharge2 = 0.0;
+        } // end if
+        dXCharge1 = par * dXCharge1;    // normalize by means of carriers
+        dXCharge2 = par * dXCharge2;
+        // for the time being, signal is the charge
+        // in ChargeToSignal signal is converted in ADC channel
+        fMapA2->AddSignal(k,(Int_t)strip,dXCharge1);
+        tav->Add(k,(Int_t)strip);
+        if(((Int_t) strip) > 0) {
+            // strip doesn't have to be the first
+            // otherwise part of the charge is lost
+            fMapA2->AddSignal(k,((Int_t)strip-1),dXCharge2);
+            tav->Add(k,((Int_t)(strip-1)));
+        } // end if
+    } // end if
 }
 //______________________________________________________________________
 Int_t AliITSsimulationSSD::NumOfSteps(Double_t x, Double_t y, Double_t z,
-                                      Double_t & dex,Double_t & dey,Double_t & dez){
-  // number of steps
-  // it also returns steps for each coord
-  //AliITSsegmentationSSD *seg = new AliITSsegmentationSSD();
-
-  Double_t step = 25E-4;
-  //step = (Double_t) seg->GetStepSize();  // step size (cm)
-  Int_t numOfSteps = (Int_t) (TMath::Sqrt(x*x+y*y+z*z)/step); 
-
-  if (numOfSteps < 1) numOfSteps = 1;       // one step, at least
-
-  // we could condition the stepping depending on the incident angle
-  // of the track
-  dex = x/numOfSteps;
-  dey = y/numOfSteps;
-  dez = z/numOfSteps;
-
-  return numOfSteps;
+                                      Double_t &dex,Double_t &dey,
+                                      Double_t &dez){
+    // number of steps
+    // it also returns steps for each coord
+    //AliITSsegmentationSSD *seg = new AliITSsegmentationSSD();
+
+    Double_t step = 25E-4;
+    //step = (Double_t) seg->GetStepSize();  // step size (cm)
+    Int_t numOfSteps = (Int_t) (TMath::Sqrt(x*x+y*y+z*z)/step); 
+
+    if (numOfSteps < 1) numOfSteps = 1;       // one step, at least
+
+    // we could condition the stepping depending on the incident angle
+    // of the track
+    dex = x/numOfSteps;
+    dey = y/numOfSteps;
+    dez = z/numOfSteps;
+    
+    return numOfSteps;
 }
 //----------------------------------------------------------------------
 void AliITSsimulationSSD::GetList(Int_t label,Int_t hit,Int_t mod,
                                   AliITSpList *pList,AliITSTableSSD *tav) {
-  // loop over nonzero digits
-  Int_t ix,i;
-  Double_t signal=0.;
-
-  for(Int_t k=0; k<2; k++) {
-    ix=tav->Use(k);
-    while(ix>-1){
-      signal = fMapA2->GetSignal(k,ix);
-      if(signal==0.0) {
+    // loop over nonzero digits
+    Int_t ix,i;
+    Double_t signal=0.;
+
+    for(Int_t k=0; k<2; k++) {
         ix=tav->Use(k);
-        continue;
-      } // end if signal==0.0
-      // check the signal magnitude
-      for(i=0;iGetNSignals(k,ix);i++){
-        signal -= pList->GetTSignal(k,ix,i);
-      } // end for i
-      //  compare the new signal with already existing list
-      if(signal>0)pList->AddSignal(k,ix,label,hit,mod,signal);
-      ix=tav->Use(k);
-    } // end of loop on strips
-  } // end of loop on P/N side
-  tav->Clear();
+        while(ix>-1){
+            signal = fMapA2->GetSignal(k,ix);
+            if(signal==0.0) {
+                ix=tav->Use(k);
+                continue;
+            } // end if signal==0.0
+            // check the signal magnitude
+            for(i=0;iGetNSignals(k,ix);i++){
+                signal -= pList->GetTSignal(k,ix,i);
+            } // end for i
+            //  compare the new signal with already existing list
+            if(signal>0)pList->AddSignal(k,ix,label,hit,mod,signal);
+            ix=tav->Use(k);
+        } // end of loop on strips
+    } // end of loop on P/N side
+    tav->Clear();
 }
 //----------------------------------------------------------------------
 void AliITSsimulationSSD::ChargeToSignal(AliITSpList *pList) {
-  // charge to signal
-  static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
-  Float_t threshold = 0.;
-  Int_t size = AliITSdigitSSD::GetNTracks();
-  Int_t * digits = new Int_t[size];
-  Int_t * tracks = new Int_t[size];
-  Int_t * hits = new Int_t[size];
-  Int_t j1;
-  Float_t charges[3] = {0.0,0.0,0.0};
-  Float_t signal;
-  Float_t noise[2] = {0.,0.};
-
-  ((AliITSresponseSSD*)fResponse)->GetNoiseParam(noise[0],noise[1]);
-
-  for(Int_t k=0;k<2;k++){         // both sides (0=Pside, 1=Nside)
-	// Threshold for zero-suppression
-	// It can be defined in AliITSresponseSSD
-	//             threshold = (Float_t)fResponse->MinVal(k);
-	// I prefer to think adjusting the threshold "manually", looking
-	// at the scope, and considering noise standard deviation
-	threshold = 4.0*noise[k]; // 4 times noise is a choice
-	for(Int_t ix=0;ixGetSignal(k,ix) <= threshold)continue;
-	    // convert to ADC signal
-	    signal = ((AliITSresponseSSD*)fResponse)->DEvToADC(
-                                                      fMapA2->GetSignal(k,ix));
-	    if(signal>1024.) signal = 1024.;//if exceeding, accumulate last one
-	    digits[0] = k;
-	    digits[1] = ix;
-	    digits[2] = (Int_t) signal;
-	    for(j1=0;j1GetNEnteries()){
-		// only three in digit.
-		tracks[j1]  = pList->GetTrack(k,ix,j1);
-		hits[j1]    = pList->GetHit(k,ix,j1);
-	    }else{
-		tracks[j1]  = -3;
-		hits[j1]    = -1;
-	    } // end for j1
-	    // finally add digit
-	    aliITS->AddSimDigit(2,0,digits,tracks,hits,charges);
-	} // end for ix
-  } // end for k
-  delete [] digits;
-  delete [] tracks;
-  delete [] hits;
+    // charge to signal
+    static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+    Float_t threshold = 0.;
+    Int_t size = AliITSdigitSSD::GetNTracks();
+    Int_t * digits = new Int_t[size];
+    Int_t * tracks = new Int_t[size];
+    Int_t * hits = new Int_t[size];
+    Int_t j1;
+    Float_t charges[3] = {0.0,0.0,0.0};
+    Float_t signal;
+    Double_t noise[2] = {0.,0.};
+
+    GetResp()->GetNoiseParam(noise[0],noise[1]);
+
+    for(Int_t k=0;k<2;k++){         // both sides (0=Pside, 1=Nside)
+        // Threshold for zero-suppression
+        // It can be defined in AliITSresponseSSD
+        //             threshold = (Float_t)GetResp()->MinVal(k);
+        // I prefer to think adjusting the threshold "manually", looking
+        // at the scope, and considering noise standard deviation
+        threshold = 4.0*noise[k]; // 4 times noise is a choice
+        for(Int_t ix=0;ixGetSignal(k,ix) <= threshold)continue;
+            // convert to ADC signal
+            signal = GetResp()->DEvToADC(
+                fMapA2->GetSignal(k,ix));
+            if(signal>1024.) signal = 1024.;//if exceeding, accumulate last one
+            digits[0] = k;
+            digits[1] = ix;
+            digits[2] = (Int_t) signal;
+            for(j1=0;j1GetNEnteries()){
+                // only three in digit.
+                tracks[j1]  = pList->GetTrack(k,ix,j1);
+                hits[j1]    = pList->GetHit(k,ix,j1);
+            }else{
+                tracks[j1]  = -3;
+                hits[j1]    = -1;
+            } // end for j1
+            // finally add digit
+            aliITS->AddSimDigit(2,0,digits,tracks,hits,charges);
+        } // end for ix
+    } // end for k
+    delete [] digits;
+    delete [] tracks;
+    delete [] hits;
 }
 //______________________________________________________________________
 void AliITSsimulationSSD::WriteSDigits(AliITSpList *pList){
-  // Fills the Summable digits Tree
-  Int_t i,ni,j,nj;
-  static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
-
-  pList->GetMaxMapIndex(ni,nj);
-  for(i=0;iGetSignalOnly(i,j)>0.0){
-	  aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
-//	    cout << "pListSSD: " << *(pList->GetpListItem(i,j)) << endl;
-      } // end if
-  } // end for i,j
+    // Fills the Summable digits Tree
+    Int_t i,ni,j,nj;
+    static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+
+    pList->GetMaxMapIndex(ni,nj);
+    for(i=0;iGetSignalOnly(i,j)>0.0){
+            aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
+            if(GetDebug(4)) cout << "pListSSD: "<<*(pList->GetpListItem(i,j))
+                                << endl;
+        } // end if
+    } // end for i,j
   return;
 }
 //______________________________________________________________________
 void AliITSsimulationSSD::FillMapFrompList(AliITSpList *pList){
-  // Fills fMap2A from the pList of Summable digits
-  Int_t k,ix;
+    // Fills fMap2A from the pList of Summable digits
+    Int_t k,ix;
 
-  for(k=0;k<2;k++)for(ix=0;ixAddSignal(k,ix,pList->GetSignal(k,ix));
-  return;
+    for(k=0;k<2;k++)for(ix=0;ixAddSignal(k,ix,pList->GetSignal(k,ix));
+    return;
 }
 //______________________________________________________________________
 void AliITSsimulationSSD::Print(ostream *os){
-  //Standard output format for this class
-
-  //AliITSsimulation::Print(os);
-  *os << fIonE <<",";
-  *os << fDifConst[0] <<","<< fDifConst[1] <<",";
-  *os << fDriftVel[0] <<","<< fDriftVel[1];
-  //*os <<","; fDCS->Print(os);
-  //*os <<","; fMapA2->Print(os);
+    //Standard output format for this class
+
+    //AliITSsimulation::Print(os);
+    *os << fIonE <<",";
+    *os << fDifConst[0] <<","<< fDifConst[1] <<",";
+    *os << fDriftVel[0] <<","<< fDriftVel[1];
+    //*os <<","; fDCS->Print(os);
+    //*os <<","; fMapA2->Print(os);
 }
 //______________________________________________________________________
 void AliITSsimulationSSD::Read(istream *is){
-  // Standard output streaming function.
-
-  //AliITSsimulation::Read(is);
-  *is >> fIonE;
-  *is >> fDifConst[0] >> fDifConst[1];
-  *is >> fDriftVel[0] >> fDriftVel[1];
-  //fDCS->Read(is);
-  //fMapA2->Read(is);
+    // Standard output streaming function.
+
+    //AliITSsimulation::Read(is);
+    *is >> fIonE;
+    *is >> fDifConst[0] >> fDifConst[1];
+    *is >> fDriftVel[0] >> fDriftVel[1];
+    //fDCS->Read(is);
+    //fMapA2->Read(is);
 }
 //______________________________________________________________________
 ostream &operator<<(ostream &os,AliITSsimulationSSD &source){
-  // Standard output streaming function.
+    // Standard output streaming function.
 
-  source.Print(&os);
-  return os;
+    source.Print(&os);
+    return os;
 }
 //______________________________________________________________________
 istream &operator>>(istream &os,AliITSsimulationSSD &source){
-  // Standard output streaming function.
+    // Standard output streaming function.
 
-  source.Read(&os);
-  return os;
+    source.Read(&os);
+    return os;
 }
 //______________________________________________________________________
 
diff --git a/ITS/AliITSsimulationSSD.h b/ITS/AliITSsimulationSSD.h
index 98656f1993c..74c9ac237e2 100644
--- a/ITS/AliITSsimulationSSD.h
+++ b/ITS/AliITSsimulationSSD.h
@@ -27,7 +27,9 @@ class AliITSsimulationSSD: public AliITSsimulation {
     //Destructor
     virtual ~AliITSsimulationSSD();
     // Initilize variables for this simulation
-    void Init(AliITSsegmentationSSD *seg,AliITSresponseSSD *resp);
+    void Init();
+    // Initilize variables for this simulation
+    //void Init(AliITSsegmentationSSD *seg,AliITSresponseSSD *resp);
     // Create maps to build the lists of tracks for each summable digit
     void InitSimulationModule(Int_t module,Int_t events);
     // Digitize module from the sum of summable digits.
@@ -65,6 +67,11 @@ class AliITSsimulationSSD: public AliITSsimulation {
     void Read(istream *is);
 
  private:
+    // Return the Response class
+    AliITSresponseSSD* GetResp(){return (AliITSresponseSSD*)fResponse;}
+    // Return the Segmentation class
+    AliITSsegmentationSSD* GetSeg(){
+        return (AliITSsegmentationSSD*)fSegmentation;}
     // returns the number of steps needed to proplerly distribute the charge
     // in a step
     Int_t NumOfSteps(Double_t x,Double_t y,Double_t z,
@@ -104,9 +111,6 @@ class AliITSsimulationSSD: public AliITSsimulation {
     Double_t    fIonE;        // ionization energy of Si in GeV
     Double_t    fDifConst[2]; // Diffusion constants [h,e] in cm**2/sec
     Double_t    fDriftVel[2]; // Drift velocities [P,N sides] cm/sec
-//    Int_t       fModule;      //! Current module number
-//    Int_t       fEvent;       //! Current Event number
-//    AliITSpList *fpList;      //! Array of s digits.
 
     ClassDef(AliITSsimulationSSD,2) // SSD signal simulation class
 
diff --git a/ITS/AliITSvSDD03.cxx b/ITS/AliITSvSDD03.cxx
index 83a5b8760a1..d84e54c6775 100644
--- a/ITS/AliITSvSDD03.cxx
+++ b/ITS/AliITSvSDD03.cxx
@@ -18,28 +18,16 @@
 */
 
 #include 
-//#include 
-//#include 
 #include 
 #include 
 #include 
 #include 
-//#include 
-//#include 
-//#include 
-//#include     // only required for Tracking function?
-//#include 
-//#include 
 #include 
-//#include 
-//#include 
-//#include 
 #include 
 
 #include "AliMC.h"
 #include "AliRun.h"
 #include "AliMagF.h"
-//#include "AliConst.h"
 #include "AliITSGeant3Geometry.h"
 #include "AliTrackReference.h"
 #include "AliITShit.h"
@@ -56,31 +44,28 @@
 #include "AliITSsegmentationSPD.h"
 #include "AliITSsegmentationSDD.h"
 #include "AliITSsegmentationSSD.h"
-#include "AliITSsimulationSPD.h"
+#include "AliITSsimulationSPDdubna.h"
 #include "AliITSsimulationSDD.h"
 #include "AliITSsimulationSSD.h"
-//#include "AliITSClusterFinderSPD.h"
-//#include "AliITSClusterFinderSDD.h"
-//#include "AliITSClusterFinderSSD.h"
 
 ClassImp(AliITSvSDD03)
 
 //______________________________________________________________________
 AliITSvSDD03::AliITSvSDD03() :
-    AliITS(),
-    fGeomDetOut(kFALSE),
-    fGeomDetIn(kFALSE),
-    fMajorVersion(11),
-    fMinorVersion(-1),
-    fEuclidGeomDet(),
-    fRead(),
-    fWrite(),
-    fDet1(0.0),
-    fDet2(0.0),
-    fChip1(0.0),
-    fChip2(0.0),
-    fIDMother(0),
-    fYear(2003){
+AliITS(),
+fGeomDetOut(kFALSE),
+fGeomDetIn(kFALSE),
+fMajorVersion(1),
+fMinorVersion(2),
+fEuclidGeomDet(),
+fRead(),
+fWrite(),
+fDet1(300.0),
+fDet2(300.0),
+fChip1(300.0),
+fChip2(300.0),
+fIDMother(0),
+fYear(2003){
     ////////////////////////////////////////////////////////////////////////
     // Standard default constructor for the ITS SDD test beam 2002 version 1.
     // Inputs:
@@ -96,30 +81,26 @@ AliITSvSDD03::AliITSvSDD03() :
     fIdName       = 0;
     fIdSens       = 0;
     fEuclidOut    = kFALSE; // Don't write Euclide file
-    fGeomDetOut   = kFALSE; // Don't write .det file
-    fGeomDetIn    = kFALSE; // Don't Read .det file
-    fMajorVersion = IsVersion();
-    fMinorVersion = -1;
     for(i=0;i<60;i++) fRead[i] = '\0';
     for(i=0;i<60;i++) fWrite[i] = '\0';
     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
 }
 //______________________________________________________________________
 AliITSvSDD03::AliITSvSDD03(const char *title,Int_t year):
-    AliITS("ITS", title),
-    fGeomDetOut(kFALSE),
-    fGeomDetIn(kFALSE),
-    fMajorVersion(11),
-    fMinorVersion(-1),
-    fEuclidGeomDet(),
-    fRead(),
-    fWrite(),
-    fDet1(0.0),
-    fDet2(0.0),
-    fChip1(0.0),
-    fChip2(0.0),
-    fIDMother(0),
-    fYear(2003){
+AliITS("ITS", title),
+fGeomDetOut(kFALSE),
+fGeomDetIn(kFALSE),
+fMajorVersion(1),
+fMinorVersion(2),
+fEuclidGeomDet(),
+fRead(),
+fWrite(),
+fDet1(300.0),
+fDet2(300.0),
+fChip1(300.0),
+fChip2(300.0),
+fIDMother(0),
+fYear(2003){
     ////////////////////////////////////////////////////////////////////////
     //    Standard constructor for the ITS SDD testbeam 2002 version 1.
     // Inputs:
@@ -138,11 +119,7 @@ AliITSvSDD03::AliITSvSDD03(const char *title,Int_t year):
     fIdName[2] = "ISNT";
     fIdSens    = new Int_t[fIdN];
     for(i=0;iWriteNewFile(fWrite);
     AliITS::Init();
     fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
-//
+
     for(i=0;i<72;i++) cout << "*";
     cout << endl;
 }
@@ -797,47 +760,46 @@ void AliITSvSDD03::SetDefaultSimulation(){
 
     AliITSDetType *iDetType;
     AliITSsimulation *sim;
+    AliITSsegmentation *seg;
+    AliITSresponse *res;
     iDetType = DetType(kSPD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg0=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        if(seg0==0) seg0 = new AliITSsegmentationSPD();
-        AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
-        if(res0==0) res0 = new AliITSresponseSPD();
-        AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
-        SetSimulationModel(kSPD,sim0);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSPD*)sim)->Init(
-            (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSPD*) iDetType->GetResponseModel());
-    } // end if
+    if(iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
+            if(seg==0) seg = new AliITSsegmentationSPD();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            if(res==0) res = new AliITSresponseSPD();
+            sim = new AliITSsimulationSPDdubna(seg,res,0);
+            SetSimulationModel(kSPD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            sim->Init();
+        } // end if
+    } // end if iDetType
     iDetType = DetType(kSDD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg1=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
-        SetSimulationModel(kSDD,sim1);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSDD*)sim)->Init(
-            (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSDD*) iDetType->GetResponseModel());
-    } //end if
+    if(iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSDD(seg,res);
+            SetSimulationModel(kSDD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            sim->Init();
+        } //end if
+    } // end if iDetType
     iDetType = DetType(kSSD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg2=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
-        SetSimulationModel(kSSD,sim2);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSSD*)sim)->Init(
-            (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSSD*) iDetType->GetResponseModel());
-    } // end if
+    if(iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSSD(seg,res);
+            SetSimulationModel(kSSD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            sim->Init();
+        } // end if
+    } // end if iDetType
 }
 //______________________________________________________________________
 void AliITSvSDD03::DrawModule() const{
diff --git a/ITS/AliITSvSPD02.cxx b/ITS/AliITSvSPD02.cxx
index 00c77b38ee6..d285ff502fe 100644
--- a/ITS/AliITSvSPD02.cxx
+++ b/ITS/AliITSvSPD02.cxx
@@ -40,7 +40,7 @@
 #include "AliITSsegmentationSPD.h"
 #include "AliITSsegmentationSDD.h"
 #include "AliITSsegmentationSSD.h"
-#include "AliITSsimulationSPD.h"
+#include "AliITSsimulationSPDdubna.h"
 #include "AliITSsimulationSDD.h"
 #include "AliITSsimulationSSD.h"
 #include "AliMC.h"
@@ -56,7 +56,20 @@
 ClassImp(AliITSvSPD02)
 
 //______________________________________________________________________
-AliITSvSPD02::AliITSvSPD02() {
+AliITSvSPD02::AliITSvSPD02():
+AliITS(),
+fGeomDetOut(kFALSE),
+fGeomDetIn(kFALSE),
+fMajorVersion(1),
+fMinorVersion(2),
+fGeomNumber(2002),
+fEuclidGeomDet(),
+fRead(),
+fWrite(),
+fDet1(300.0),
+fDet2(300.0),
+fChip1(300.0),
+fChip2(300.0){
     ////////////////////////////////////////////////////////////////////////
     // Standard default constructor for the ITS SPD test beam 2002 version 1.
     // Inputs:
@@ -68,21 +81,24 @@ AliITSvSPD02::AliITSvSPD02() {
     ////////////////////////////////////////////////////////////////////////
     Int_t i;
 
-    fIdN          = 0;
-    fIdName       = 0;
-    fIdSens       = 0;
-    fEuclidOut    = kFALSE; // Don't write Euclide file
-    fGeomDetOut   = kFALSE; // Don't write .det file
-    fGeomDetIn    = kFALSE; // Don't Read .det file
-    fMajorVersion = IsVersion();
-    fMinorVersion = -1;
-    fGeomNumber   = 2002; // default value
     for(i=0;i<60;i++) fRead[i] = '\0';
     for(i=0;i<60;i++) fWrite[i] = '\0';
     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
 }
 //______________________________________________________________________
-AliITSvSPD02::AliITSvSPD02(const char *title,Int_t gn) : AliITS("ITS", title){
+AliITSvSPD02::AliITSvSPD02(const char *title,Int_t gn) : AliITS("ITS", title),
+fGeomDetOut(kFALSE),
+fGeomDetIn(kFALSE),
+fMajorVersion(1),
+fMinorVersion(2),
+fGeomNumber(2002),
+fEuclidGeomDet(),
+fRead(),
+fWrite(),
+fDet1(300.0),
+fDet2(300.0),
+fChip1(300.0),
+fChip2(300.0){
     ////////////////////////////////////////////////////////////////////////
     //    Standard constructor for the ITS SPD testbeam 2002 version 1.
     // Inputs:
@@ -102,11 +118,6 @@ AliITSvSPD02::AliITSvSPD02(const char *title,Int_t gn) : AliITS("ITS", title){
     fIdName[1] = "ITST";
     fIdSens    = new Int_t[fIdN];
     for(i=0;icd(); // set ourselve into ITSV subvolume of aALIC
 
     // SPD part of telescope (MiniBuS)
@@ -297,36 +308,36 @@ void AliITSvSPD02::BuildGeometry2002(){
 			    0.0,iIDETshape->GetDy()-spdY,0.0,0,0);
     TNode *iIPC0[5];
     for(i=0;i<5;i++) { //place readout chips on the back of SPD chip under test
-	sprintf(name,"IPC0%d",i);
-	sprintf(title,"Readout chip #%d",i+1);
-	j = i-2;
-	iIPC0[i] = new TNode(name,title,iIPC0shape,
-			    0.0,spdchipY-iIDETshape->GetDy(),
-			    j*2.0*spdchipZ+j*0.25*(spdZ-5.*spdchipZ),0,0);
+        sprintf(name,"IPC0%d",i);
+        sprintf(title,"Readout chip #%d",i+1);
+        j = i-2;
+        iIPC0[i] = new TNode(name,title,iIPC0shape,
+                             0.0,spdchipY-iIDETshape->GetDy(),
+                             j*2.0*spdchipZ+j*0.25*(spdZ-5.*spdchipZ),0,0);
     } // end for i
     iITS0->cd();
     TNode *iITST = new TNode("ITST","SPD sensitive volume",iITSTshape,
-			    0.0,0.0,0.0,0,0);
+                             0.0,0.0,0.0,0,0);
     for(Int_t i=0;i<4;i++){
-	iITSV->cd();
-	sprintf(name,"ITEL%d",i);
-	sprintf(title,"Test beam telescope element #%d",i+1);
-	iITEL[i] = new TNode(name,title,iITELshape,px,py,pz[i],r0,0);
-	iITEL[i]->cd();
-	iICMB[i] = new TNode("ICMB","Chip MiniBus",iICMBshape,
-			    0.0,-iITELshape->GetDy()+detMiniBusY,0.0,0,0);
-	iIMB0[i] = new TNode("IMB0","Chip MiniBus",iIMB0shape,
-			    0.0, iITELshape->GetDy()-detMiniBusY,0.0,0,0);
-	iIMB0[i]->cd();
-	iIMBS[i] = new TNode("IMBS","IMBS",iIMBSshape,0.0,0.0,0.0,0,0);
-	// place IMBS inside IMB0 with no translation and unit rotation matrix.
+        iITSV->cd();
+        sprintf(name,"ITEL%d",i);
+        sprintf(title,"Test beam telescope element #%d",i+1);
+        iITEL[i] = new TNode(name,title,iITELshape,px,py,pz[i],r0,0);
+        iITEL[i]->cd();
+        iICMB[i] = new TNode("ICMB","Chip MiniBus",iICMBshape,
+                             0.0,-iITELshape->GetDy()+detMiniBusY,0.0,0,0);
+        iIMB0[i] = new TNode("IMB0","Chip MiniBus",iIMB0shape,
+                             0.0, iITELshape->GetDy()-detMiniBusY,0.0,0,0);
+        iIMB0[i]->cd();
+        iIMBS[i] = new TNode("IMBS","IMBS",iIMBSshape,0.0,0.0,0.0,0,0);
+        // place IMBS inside IMB0 with no translation and unit rotation matrix.
     } // end for i
     aALIC->cd();
     iITST->SetLineColor(kYellow);
     fNodes->Add(iITST);
     for(i=0;i<4;i++){
-	iIMBS[i]->SetLineColor(kGreen);
-	fNodes->Add(iIMBS[i]);
+        iIMBS[i]->SetLineColor(kGreen);
+        fNodes->Add(iIMBS[i]);
     } // end for i
 }
 //______________________________________________________________________
@@ -540,14 +551,14 @@ void AliITSvSPD02::CreateMaterials2002(){
     Float_t fieldm = gAlice->Field()->Max();
 
     AliMaterial(1,"AIR$",0.14610E+02,0.73000E+01,0.12050E-02,
-		0.30423E+05,0.99900E+03);
+                0.30423E+05,0.99900E+03);
     AliMedium(1,"AIR$",1,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,
-	      epsilAir,stminAir);
+              epsilAir,stminAir);
 
     AliMaterial(2,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,
-		0.93600E+01,0.99900E+03);
+                0.93600E+01,0.99900E+03);
     AliMedium(2,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
-	      epsilSi,stminSi);
+              epsilSi,stminSi);
 }
 //______________________________________________________________________
 void AliITSvSPD02::InitAliITSgeom(){
@@ -596,22 +607,22 @@ void AliITSvSPD02::InitAliITSgeom(){
         return;
     } // end if gMC==0
     if(strcmp(gMC->GetName(),"TGeant3")) {
-	Error("InitAliITSgeom",
-		"Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
-	return;
+        Error("InitAliITSgeom",
+              "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
+        return;
     } // end if
     cout << "Reading Geometry transformation directly from Geant 3." << endl;
     ig = new AliITSGeant3Geometry();
     Char_t names[kltypess][kndeep][4];
     Int_t itsGeomTreeCopys[kltypess][kndeep];
     const char *namesA[kltypess][kndeep] = {
-     {"ALIC","ITSV","ITEL","IMB0","IMBS"}, // lay=1
-     {"ALIC","ITSV","IDET","ITS0","ITST"}};// Test SPD
+        {"ALIC","ITSV","ITEL","IMB0","IMBS"}, // lay=1
+        {"ALIC","ITSV","IDET","ITS0","ITST"}};// Test SPD
     Int_t itsGeomTreeCopysA[kltypess][kndeep]= {{1,1,4,1,1},// lay=1
-					      {1,1,1,1,1}};//lay=2 TestSPD
+                                                {1,1,1,1,1}};//lay=2 TestSPD
     for(i=0;i2 && typ==1) lay = cpy +1;
-	    if(typ==2) lay = 3;
-	    mod = lay-1;
-	    ig->GetGeometry(kndeep,lnam,lnum,t,r,idshape,npar,natt,par,att,
-			    imat,imed);
-	    fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
-	    if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
-		fITSgeom->ReSetShape(kSPD,
-				     new AliITSgeomSPD425Short(npar,par));
-	} // end for cpy
+        for(j=0;j2 && typ==1) lay = cpy +1;
+            if(typ==2) lay = 3;
+            mod = lay-1;
+            ig->GetGeometry(kndeep,lnam,lnum,t,r,idshape,npar,natt,par,att,
+                            imat,imed);
+            fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+            if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+                fITSgeom->ReSetShape(kSPD,
+                                     new AliITSgeomSPD425Short(npar,par));
+        } // end for cpy
     } // end for typ
     return;
 }
@@ -664,7 +675,7 @@ void AliITSvSPD02::Init(){
     for(i=0;i<26;i++) cout << "*";
     cout << " ITSvSPD02" << fMinorVersion << "_Init ";
     for(i=0;i<25;i++) cout << "*";cout << endl;
-//
+
     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
     if(fITSgeom!=0) delete fITSgeom;
@@ -673,7 +684,7 @@ void AliITSvSPD02::Init(){
     if(!fGeomDetIn) this->InitAliITSgeom();
     if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
     AliITS::Init();
-//
+
     for(i=0;i<72;i++) cout << "*";
     cout << endl;
     if(gMC) fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
@@ -725,7 +736,7 @@ void AliITSvSPD02::SetDefaults(){
     if (strstr(kData0,"real")) iDetType->ClassNames("AliITSdigit",
 						    "AliITSRawClusterSPD");
     else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
-//    SetSimulationModel(kSPD,new AliITSsimulationSPD(seg0,resp0));
+//    SetSimulationModel(kSPD,new AliITSsimulationSPDdubna(seg0,resp0));
 //    iDetType->ReconstructionModel(new AliITSClusterFinderSPD());
 
     SetResponseModel(kSDD,new AliITSresponseSDD());
@@ -754,57 +765,56 @@ void AliITSvSPD02::SetDefaultSimulation(){
 
     AliITSDetType *iDetType;
     AliITSsimulation *sim;
+    AliITSsegmentation *seg;
+    AliITSresponse *res;
     iDetType=DetType(kSPD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg0=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
-        SetSimulationModel(kSPD,sim0);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSPD*)sim)->Init(
-            (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSPD*) iDetType->GetResponseModel());
-//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
-//            (AliITSresponse*)iDetType->GetResponseModel());
-//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
-//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
-    } // end if
+    if(iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSPDdubna(seg,res,0);
+            SetSimulationModel(kSPD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            if(sim->GetResponseModel()==0) sim->SetResponseModel(
+                (AliITSresponse*)iDetType->GetResponseModel());
+            if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+                (AliITSsegmentation*)iDetType->GetSegmentationModel());
+            sim->Init();
+        } // end if
+    } // end if iDetType
     iDetType=DetType(kSDD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg1=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
-        SetSimulationModel(kSDD,sim1);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSDD*)sim)->Init(
-            (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSDD*) iDetType->GetResponseModel());
-//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
-//            (AliITSresponse*)iDetType->GetResponseModel());
-//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
-//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
-    } //end if
+    if(iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSDD(seg,res);
+            SetSimulationModel(kSDD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            if(sim->GetResponseModel()==0) sim->SetResponseModel(
+                (AliITSresponse*)iDetType->GetResponseModel());
+            if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+                (AliITSsegmentation*)iDetType->GetSegmentationModel());
+            sim->Init();
+        } //end if
+    } // end if iDetType
     iDetType=DetType(kSSD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg2=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
-        SetSimulationModel(kSDD,sim2);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSSD*)sim)->Init(
-            (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSSD*) iDetType->GetResponseModel());
-//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
-//            (AliITSresponse*)iDetType->GetResponseModel());
-//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
-//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
-    } // end if
+    if(iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSSD(seg,res);
+            SetSimulationModel(kSSD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            if(sim->GetResponseModel()==0) sim->SetResponseModel(
+                (AliITSresponse*)iDetType->GetResponseModel());
+            if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+                (AliITSsegmentation*)iDetType->GetSegmentationModel());
+            sim->Init();
+        } // end if
+    } // end if iDetType
 }
 //______________________________________________________________________
 void AliITSvSPD02::DrawModule() const {
@@ -860,13 +870,14 @@ void AliITSvSPD02::StepManager(){
     static Int_t stat0=0;
     if((id=gMC->CurrentVolID(copy) == fIDMother)&&
        (gMC->IsTrackEntering()||gMC->IsTrackExiting())){
-	copy = fTrackReferences->GetEntriesFast();
-	TClonesArray &lTR = *fTrackReferences;
-	// Fill TrackReference structure with this new TrackReference.
-	new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+        copy = fTrackReferences->GetEntriesFast();
+        TClonesArray &lTR = *fTrackReferences;
+        // Fill TrackReference structure with this new TrackReference.
+        new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->
+                                         GetCurrentTrackNumber());
     } // if Outer ITS mother Volume
     if(!(this->IsActive())){
-	return;
+        return;
     } // end if !Active volume.
     Int_t   vol[5];
     TClonesArray &lhits = *fHits;
@@ -886,31 +897,32 @@ void AliITSvSPD02::StepManager(){
     if(!(gMC->TrackCharge())) return;
     id = gMC->CurrentVolID(copy);
     if(id==fIdSens[0]){  // Volume name "IMBS"
-	vol[2] = vol[1] = 1; // Det, ladder
-	id = gMC->CurrentVolOffID(2,copy);
-	//detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
-	vol[0] = copy; // Lay
-	if(copy>2) vol[0]++;
+        vol[2] = vol[1] = 1; // Det, ladder
+        id = gMC->CurrentVolOffID(2,copy);
+        //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
+        vol[0] = copy; // Lay
+        if(copy>2) vol[0]++;
     } else if(id == fIdSens[1]){ // Volume name "ITST"
-	vol[0] = 3; // layer
-	vol[1] = 1; // ladder
-	id = gMC->CurrentVolOffID(2,copy);
-	//detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
-	vol[2] = 1;  // detector
+        vol[0] = 3; // layer
+        vol[1] = 1; // ladder
+        id = gMC->CurrentVolOffID(2,copy);
+        //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
+        vol[2] = 1;  // detector
     } else return; // end if
     //
     gMC->TrackPosition(position);
     gMC->TrackMomentum(momentum);
     vol[4] = stat0;
     if(gMC->IsTrackEntering()){
-	position0 = position;
-	stat0 = vol[3];
-	return;
+        position0 = position;
+        stat0 = vol[3];
+        return;
     } // end if IsEntering
     // Fill hit structure with this new hit only for non-entrerance hits.
-    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
-					gMC->Edep(),gMC->TrackTime(),position,
-					position0,momentum);
+    else new(lhits[fNhits++]) AliITShit(fIshunt,
+                                  gAlice->GetMCApp()->GetCurrentTrackNumber(),
+                                        vol,gMC->Edep(),gMC->TrackTime(),
+                                        position,position0,momentum);
     //
     position0 = position;
     stat0 = vol[3];
diff --git a/ITS/AliITSvSSD03.cxx b/ITS/AliITSvSSD03.cxx
index 06c7435db1a..729708edbc3 100644
--- a/ITS/AliITSvSSD03.cxx
+++ b/ITS/AliITSvSSD03.cxx
@@ -40,7 +40,7 @@
 #include "AliITSsegmentationSPD.h"
 #include "AliITSsegmentationSDD.h"
 #include "AliITSsegmentationSSD.h"
-#include "AliITSsimulationSPD.h"
+#include "AliITSsimulationSPDdubna.h"
 #include "AliITSsimulationSDD.h"
 #include "AliITSsimulationSSD.h"
 #include "AliMC.h"
@@ -695,60 +695,59 @@ void AliITSvSSD03::SetDefaultSimulation(){
 
     AliITSDetType *iDetType;
     AliITSsimulation *sim;
+    AliITSsegmentation *seg;
+    AliITSresponse *res;
 
     iDetType=DetType(kSPD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg0=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
-        SetSimulationModel(kSPD,sim0);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSPD*)sim)->Init(
-            (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSPD*) iDetType->GetResponseModel());
+    if(!iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSPDdubna(seg,res,1);
+            SetSimulationModel(kSPD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            ((AliITSsimulation*)sim)->Init();
 //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
 //            (AliITSresponse*)iDetType->GetResponseModel());
 //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
 //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
-    } // end if
+        } // end if
+    } // end if !iDetType
 
     iDetType=DetType(kSDD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg1=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
-        SetSimulationModel(kSDD,sim1);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSDD*)sim)->Init(
-            (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSDD*) iDetType->GetResponseModel());
+    if(!iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSDD(seg,res);
+            SetSimulationModel(kSDD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            ((AliITSsimulation*)sim)->Init();
 //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
 //            (AliITSresponse*)iDetType->GetResponseModel());
 //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
 //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
     } //end if
+    } // end if !iDetType
 
     iDetType=DetType(kSSD);
-    sim = iDetType->GetSimulationModel();
-    if (!sim) {
-        AliITSsegmentation *seg2=
-            (AliITSsegmentation*)iDetType->GetSegmentationModel();
-        AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
-        AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
-        SetSimulationModel(kSSD,sim2);
-    }else{ // simulation exists, make sure it is set up properly.
-        ((AliITSsimulationSSD*)sim)->Init(
-            (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
-            (AliITSresponseSSD*) iDetType->GetResponseModel());
+    if(!iDetType){
+        sim = iDetType->GetSimulationModel();
+        if (!sim) {
+            seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
+            res = (AliITSresponse*)iDetType->GetResponseModel();
+            sim = new AliITSsimulationSSD(seg,res);
+            SetSimulationModel(kSSD,sim);
+        }else{ // simulation exists, make sure it is set up properly.
+            ((AliITSsimulation*)sim)->Init();
 //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
 //            (AliITSresponse*)iDetType->GetResponseModel());
 //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
 //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
-    } // end if
+        } // end if
+    } // end if !iDetType
 }
 
 //______________________________________________________________________
diff --git a/ITS/ITSLinkDef.h b/ITS/ITSLinkDef.h
index 1ae1bc30145..7d7f4c173bc 100644
--- a/ITS/ITSLinkDef.h
+++ b/ITS/ITSLinkDef.h
@@ -70,7 +70,7 @@
 #pragma link C++ class  AliITSsegmentationSSD+;
 #pragma link C++ class  AliITSresponse+;
 #pragma link C++ class  AliITSresponseSPD+;
-#pragma link C++ class  AliITSresponseSPDdubna+;
+//#pragma link C++ class  AliITSresponseSPDdubna+;
 #pragma link C++ class  AliITSresponseSDD+;
 #pragma link C++ class  AliITSresponseSSD+;
 #pragma link C++ class  AliITSsimulation+;
@@ -85,7 +85,7 @@
 #pragma link C++ class  AliITSsimulationFastPointsV0+;
 #pragma link C++ class  AliITSClusterFinder+;
 #pragma link C++ class  AliITSClusterFinderSPD+;
-#pragma link C++ class  AliITSClusterFinderSPDdubna+;
+//#pragma link C++ class  AliITSClusterFinderSPDdubna+;
 #pragma link C++ class  AliITSClusterFinderSDD+;
 #pragma link C++ class  AliITSClusterFinderSSD+;
 #pragma link C++ class  AliITSDetType+;
diff --git a/ITS/libITS.pkg b/ITS/libITS.pkg
index fcaa6fbec0f..e5f8866c702 100644
--- a/ITS/libITS.pkg
+++ b/ITS/libITS.pkg
@@ -41,12 +41,10 @@ SRCS = 	AliITS.cxx \
 		AliITSsegmentationSSD.cxx \
 		AliITSresponse.cxx \
 		AliITSresponseSPD.cxx \
-		AliITSresponseSPDdubna.cxx \
 		AliITSresponseSDD.cxx \
 		AliITSresponseSSD.cxx \
 		AliITSClusterFinder.cxx \
 		AliITSClusterFinderSPD.cxx \
-		AliITSClusterFinderSPDdubna.cxx \
 		AliITSClusterFinderSDD.cxx \
 		AliITSClusterFinderSSD.cxx \
 		AliITSRawData.cxx \
@@ -105,6 +103,8 @@ SRCS = 	AliITS.cxx \
 #		AliITSBaseGeometry.cxx \
 # 		AliITSAlignmentTrack.cxx AliITSAlignmentModule.cxx \
 # 		AliACORDEFunctions.cxx \
+#		AliITSresponseSPDdubna.cxx \
+#		AliITSClusterFinderSPDdubna.cxx \
 
 HDRS:=  $(SRCS:.cxx=.h)
 
-- 
2.39.3