--- /dev/null
+/**************************************************************************
+ * 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 "AliITSClusterFinder.h"
+#include "TTree.h"
+#include "AliRun.h"
+#include <TCanvas.h>
+#include <TH1.h>
+#include <TPad.h>
+#include <TGraph.h>
+#include <TPostScript.h>
+#include <TMinuit.h>
+
+class AliITSRecPointNew;
+
+//----------------------------------------------------------
+
+//----------------------------------------------------------
+
+ClassImp(AliITSClusterFinder)
+
+AliITSClusterFinder::AliITSClusterFinder
+(AliITSsegmentation *seg, AliITSresponse *response, TClonesArray *digits)
+{
+ // cluster finder
+ fSegmentation=seg;
+ fResponse=response;
+ fMap = 0;
+
+ fDigits=digits;
+ fNdigits = fDigits->GetEntriesFast();
+
+ fNRawClusters=0;
+
+ SetNperMax();
+ SetClusterSize();
+ SetDeclusterFlag();
+
+ fNPeaks=-1;
+}
+
+//----------------------------------------------------------
+AliITSClusterFinder::AliITSClusterFinder()
+{
+ // constructor
+ fResponse=0;
+
+ fDigits=0;
+ fNdigits = 0;
+
+ fNRawClusters=0;
+ fMap = 0;
+
+
+ SetNperMax();
+ SetClusterSize();
+ SetDeclusterFlag();
+
+ fNPeaks=-1;
+}
+
+//__________________________________________________________________________
+AliITSClusterFinder::AliITSClusterFinder(const AliITSClusterFinder &source){
+ // Copy Constructor
+ 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;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSClusterFinder&
+ AliITSClusterFinder::operator=(const AliITSClusterFinder &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ 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;
+ return *this;
+}
+
+//----------------------------------------------------------
+void AliITSClusterFinder::AddCluster(Int_t branch, AliITSRawCluster *c)
+{
+ //
+ // Add a raw cluster copy to the list
+ //
+ AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
+ iTS->AddCluster(branch,c);
+ fNRawClusters++;
+}
+
+
+
+
+
--- /dev/null
+#ifndef ALIITSCLUSTERFINDER_H
+#define ALIITSCLUSTERFINDER_H
+
+
+////////////////////////////////////////////////
+// ITS Cluster Finder Class //
+////////////////////////////////////////////////
+
+#include "AliITSMap.h"
+
+//---------------------------------------------------------------
+class AliITSClusterFinder :public TObject
+{
+public:
+ TClonesArray *fDigits; // digits
+ Int_t fNdigits; // num of digits
+
+ AliITSClusterFinder(AliITSsegmentation *seg, AliITSresponse *resp, TClonesArray *digits);
+ AliITSClusterFinder();
+ virtual ~AliITSClusterFinder(){
+ // destructor
+ }
+ AliITSClusterFinder(const AliITSClusterFinder &source); // copy constructor
+ AliITSClusterFinder& operator=(const AliITSClusterFinder &source); // assignment operator
+
+ 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 Int_t NDigits() {
+ // Get Number of Digits
+ return fNdigits;
+ }
+
+ virtual void SetMap() {
+ // set map
+ }
+ AliITSMap *Map() {
+ // map
+ return fMap;
+ }
+ //
+ virtual void AddCluster(Int_t branch, AliITSRawCluster *c);
+
+ virtual void FindRawClusters() {
+ // Search for raw clusters
+ }
+ virtual void FindCluster(Int_t i, Int_t j, AliITSRawCluster *c) {
+ // find cluster
+ }
+
+ virtual void Decluster(AliITSRawCluster *cluster) {
+ // 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 *cluster) {
+ // cluster
+ return kTRUE;
+ }
+ virtual void SplitByLocalMaxima(AliITSRawCluster *cluster) {
+ // split by local maxima
+ }
+ virtual void FillCluster(AliITSRawCluster *cluster, Int_t) {
+ // fiil cluster
+ }
+ virtual void FillCluster(AliITSRawCluster *cluster) {
+ // fill cluster
+ FillCluster(cluster,1);
+ }
+
+ // set the fitting methods in the derived classes
+
+protected:
+ AliITSresponse *fResponse; // response
+ AliITSsegmentation *fSegmentation; //segmentation
+
+ Int_t fNRawClusters; // in case we split the cluster
+ // and want to keep track of
+ // the cluster which was splitted
+ AliITSMap *fMap; // map
+
+ Int_t fNperMax; // NperMax
+ Int_t fDeclusterFlag; // DeclusterFlag
+ Int_t fClusterSize; // ClusterSize
+ Int_t fNPeaks; // NPeaks
+
+
+ ClassDef(AliITSClusterFinder,1) //Class for clustering and reconstruction of space points
+ };
+#endif
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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 "AliITSClusterFinderSDD.h"
+#include "AliRun.h"
+
+
+
+ClassImp(AliITSClusterFinderSDD)
+
+//----------------------------------------------------------
+AliITSClusterFinderSDD::AliITSClusterFinderSDD
+(AliITSsegmentation *seg, AliITSresponse *response, TClonesArray *digits, TClonesArray *recp)
+{
+ // constructor
+ fSegmentation=seg;
+ fResponse=response;
+ fDigits=digits;
+ fClusters=recp;
+ fNclusters= fClusters->GetEntriesFast();
+ printf("SDD: fNclusters %d\n",fNclusters);
+ SetCutAmplitude();
+ SetDAnode();
+ SetDTime();
+ SetMap();
+ SetMinPeak();
+ SetNCells();
+}
+
+//_____________________________________________________________________________
+AliITSClusterFinderSDD::AliITSClusterFinderSDD()
+{
+ // constructor
+ fSegmentation=0;
+ fResponse=0;
+ fDigits=0;
+ fClusters=0;
+ fNclusters=0;
+ SetCutAmplitude();
+ SetDAnode();
+ SetDTime();
+ SetMap();
+ SetMinPeak();
+ SetNCells();
+
+}
+
+//__________________________________________________________________________
+AliITSClusterFinderSDD::AliITSClusterFinderSDD(const AliITSClusterFinderSDD &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fClusters = source.fClusters ;
+ this->fNclusters = source.fNclusters ;
+ this->fMap = source.fMap ;
+ this->fCutAmplitude = source.fCutAmplitude ;
+ this->fDAnode = source.fDAnode ;
+ this->fDTime = source.fDTime ;
+ this->fMinPeak = source.fMinPeak ;
+ this->fMinNCells = source.fMinNCells ;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSClusterFinderSDD&
+ AliITSClusterFinderSDD::operator=(const AliITSClusterFinderSDD &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fClusters = source.fClusters ;
+ this->fNclusters = source.fNclusters ;
+ this->fMap = source.fMap ;
+ this->fCutAmplitude = source.fCutAmplitude ;
+ this->fDAnode = source.fDAnode ;
+ this->fDTime = source.fDTime ;
+ this->fMinPeak = source.fMinPeak ;
+ this->fMinNCells = source.fMinNCells ;
+ return *this;
+}
+
+//_____________________________________________________________________________
+void AliITSClusterFinderSDD::SetMap()
+{
+ // set map
+ if(!fMap) fMap=new AliITSMapA2(fSegmentation);
+
+}
+//_____________________________________________________________________________
+void AliITSClusterFinderSDD::FillMap()
+{
+ // fCoord1 = anode #
+ // fCoord2 = time sample
+
+ if (!fDigits) return;
+
+ Int_t ndigits = fDigits->GetEntriesFast();
+ //printf("FillMap: ndigits %d\n",ndigits);
+ if (!ndigits) return;
+
+ AliITSdigitSDD *dig;
+ Int_t ndig;
+ for(ndig=0; ndig<ndigits; ndig++) {
+ dig = (AliITSdigitSDD*)fDigits->UncheckedAt(ndig);
+ Double_t signal=dig->fSignal;
+ //printf("FillMap: ndig fCoord1 fCoord2 signal %d %d %d %f\n",ndig,dig->fCoord1,dig->fCoord2,signal);
+ fMap->SetHit(dig->fCoord1,dig->fCoord2,signal);
+ }
+
+
+}
+//_____________________________________________________________________________
+
+void AliITSClusterFinderSDD::Find1DClusters()
+{
+ // find 1D clusters
+
+ AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
+
+ // retrieve the parameters
+ Int_t fNofMaps = fSegmentation->Npz();
+ Int_t fMaxNofSamples = fSegmentation->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);
+ // map the signal
+ FillMap();
+
+ // Piergiorgio's code - do not subtract baseline since we start
+ // from digits and do not duplicate arrays, i.e. use fMap instead
+ // of Float_t fadc[2*fNofAnodes][fMaxNofSamples];
+
+
+ Int_t nofFoundClusters = 0;
+ Float_t dfadc[fNofMaps][fMaxNofSamples];
+ Float_t fadc, fadc1, fadc2;
+ Int_t j,k,idx,l,m;
+ for(j=0;j<2;j++) {
+ for(k=0;k<fNofAnodes;k++) {
+ idx = j*fNofAnodes+k;
+ // signal (fadc) & derivative (dfadc)
+ for(l=0; l<fMaxNofSamples; l++) {
+ fadc2=(Float_t)fMap->GetSignal(idx,l);
+ fadc1=(Float_t)fMap->GetSignal(idx,l-1);
+ if(l>0) dfadc[k][l-1] = fadc2-fadc1;
+ } // samples
+ } // anodes
+
+ for(k=0;k<fNofAnodes;k++) {
+ idx = j*fNofAnodes+k;
+
+ Int_t imax = 0;
+ Int_t imaxd = 0;
+ Int_t it=0;
+ while(it <= fMaxNofSamples-3) {
+ // cout << "sample: " << it << endl;
+
+ imax = it;
+ imaxd = it;
+ // maximum of signal
+
+ Float_t fadcmax = 0.;
+ Float_t dfadcmax = 0.;
+ Int_t lthrmina = 1;
+ // if(it >= 60) lthrmina = 2;
+ // if(it >= 100) lthrmina = 3;
+ Int_t lthrmint = 2;
+ //if(it >= 60) lthrmint = 3;
+ //if(it >= 100) lthrmint = 4;
+
+ Int_t lthra = 0;
+ Int_t lthrt = 0;
+ for(m=0;m<10;m++) {
+ Int_t id = it+m;
+ if(id>=fMaxNofSamples) break;
+ fadc=fMap->GetSignal(idx,id);
+ if(fadc > fadcmax) {
+ fadcmax = fadc;
+ if(fadc > fCutAmplitude) { lthra++; lthrt++; }
+ imax = id;
+ }
+ if(dfadc[k][id] > dfadcmax) {
+ dfadcmax = dfadc[k][id];
+ imaxd = id;
+ }
+ }
+ it = imaxd;
+ // skip if no signal over threshold
+ if(fMap->GetSignal(idx,imax) < fCutAmplitude) {it++; continue;}
+
+ if(k>0) {
+ if(fMap->GetSignal(idx-1,imax) > fCutAmplitude) lthra++;
+ }
+ if(k<fNofAnodes-1)
+ if(fMap->GetSignal(idx+1,imax) > fCutAmplitude) lthra++;
+
+ if(imax>0) {
+ if(fMap->GetSignal(idx,imax-1) > fCutAmplitude) lthrt++;
+ }
+ if(imax<fMaxNofSamples)
+ if(fMap->GetSignal(idx,imax+1) > fCutAmplitude) lthrt++;
+
+ // cluster charge
+ Int_t tstart = it-1;
+
+ Bool_t ilcl = 0;
+ if(lthrt >= lthrmint && lthra >= lthrmina) ilcl = 1;
+
+ if(ilcl) {
+ nofFoundClusters++;
+ Int_t tstop = tstart;
+ Float_t dfadcmin = 10000.;
+ Int_t ij;
+ for(ij=0; ij<10; ij++) {
+ if(dfadc[k][it+ij] < dfadcmin) {
+ tstop = it+ij+1;
+ dfadcmin = dfadc[k][it+ij];
+ }
+ }
+
+ Float_t clusterCharge = 0.;
+ Float_t clusterAnode = k+0.5;
+ Float_t clusterTime = 0.;
+ Float_t clusterMult = 0.;
+ Float_t clusterPeakAmplitude = 0.;
+ Int_t its;
+ for(its=tstart; its<=tstop; its++) {
+ fadc=fMap->GetSignal(idx,its);
+ clusterCharge += fadc;
+ if(fadc > clusterPeakAmplitude) clusterPeakAmplitude = fadc;
+ clusterTime += fadc*its;
+ clusterMult++;
+ if(its == tstop) {
+ clusterTime /= (clusterCharge/fTimeStep); // ns
+ clusterCharge *= (fTimeStep/160.); // keV
+ if(clusterTime > 58.2) clusterTime -= 58.2; // ns
+ /*
+ else {
+ cout << "Warning: cluster with negative time " << clusterTime << ", peak ampl.: " << clusterPeakAmplitude << ", mult: " << clusterMult << ", charge: " << clusterCharge << endl;
+ cout << "Anode: " << k << ", tstart: " << tstart << ", tstop: " << tstop << ", Charge: " << clusterCharge << endl;
+ }
+ */
+ }
+ }
+ // cout << "Anode: " << k << ", tstart: " << tstart << ", tstop: " << tstop << ", Charge: " << clusterCharge << endl;
+
+ Float_t clusteranodePath = (0.06 + clusterAnode - fNofAnodes/2)*anodePitch;
+ Float_t clusterDriftPath = clusterTime*fDriftSpeed;
+ clusterDriftPath = fSddLength-clusterDriftPath;
+
+ if(clusterCharge < 0.) break;
+
+ //printf("wing clusterMult clusterAnode clusterTime %d %f %f %f \n",j+1,clusterMult, clusterAnode, clusterTime);
+
+ AliITSRawClusterSDD *clust = new AliITSRawClusterSDD(j+1,clusterAnode,clusterTime,clusterCharge,clusterPeakAmplitude,0.,0.,clusterDriftPath,clusteranodePath,clusterMult);
+ //fClusters->Add(point);
+ iTS->AddCluster(1,clust);
+ it = tstop;
+ } // ilcl
+
+ it++;
+
+ } // while (samples)
+ } // anodes
+ } // detectors (2)
+
+ Int_t nofClusters = fClusters->GetEntriesFast();
+ nofClusters -= fNclusters;
+
+ //printf("SDD- Find1Dclust: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
+
+ fMap->ClearMap();
+
+ return;
+
+}
+
+//_____________________________________________________________________________
+void AliITSClusterFinderSDD::GroupClusters()
+{
+ // group clusters
+ Int_t dummy=0;
+ Float_t fTimeStep = fSegmentation->Dpx(dummy);
+
+
+ // get number of clusters for this module
+ Int_t nofClusters = fClusters->GetEntriesFast();
+ nofClusters -= fNclusters;
+
+ //printf("SDD- GroupClusters: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
+
+ AliITSRawClusterSDD *clusterI;
+ AliITSRawClusterSDD *clusterJ;
+
+ Int_t label[nofClusters];
+ Int_t i,j;
+ for(i=0; i<nofClusters; i++) label[i] = 0;
+ for(i=0; i<nofClusters; i++) {
+ if(label[i] != 0) continue;
+ for(j=i+1; j<nofClusters; j++) {
+ if(label[j] != 0) continue;
+ clusterI = (AliITSRawClusterSDD*) fClusters->At(i);
+ clusterJ = (AliITSRawClusterSDD*) fClusters->At(j);
+ // 1.3 good
+ if(clusterI->T() < fTimeStep*60) fDAnode = 3.2;
+ if(clusterI->T() < fTimeStep*10) fDAnode = 1.2;
+ Bool_t pair = clusterI->Brother(clusterJ,fDAnode,fDTime);
+ if(!pair) continue;
+ // clusterI->Print();
+ // clusterJ->Print();
+ clusterI->Add(clusterJ);
+ label[j] = 1;
+ fClusters->RemoveAt(j);
+ } // J clusters
+ label[i] = 1;
+ } // I clusters
+ fClusters->Compress();
+ return;
+
+}
+
+//_____________________________________________________________________________
+
+void AliITSClusterFinderSDD::SelectClusters()
+{
+ // get number of clusters for this module
+ Int_t nofClusters = fClusters->GetEntriesFast();
+ nofClusters -= fNclusters;
+
+ //printf("SDD- SelectClusters: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
+
+ Int_t i;
+ for(i=0; i<nofClusters; i++) {
+ AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*) fClusters->At(i);
+ Int_t rmflg = 0;
+ Float_t wy = 0.;
+ if(clusterI->Anodes() != 0.) {
+ wy = ((Float_t) clusterI->Samples())/clusterI->Anodes();
+ }
+ Float_t amp = clusterI->PeakAmpl();
+ if(amp < fMinPeak) rmflg = 1;
+ if(wy < fMinNCells) rmflg = 1;
+ if(rmflg) fClusters->RemoveAt(i);
+ } // I clusters
+ fClusters->Compress();
+ return;
+
+}
+
+//_____________________________________________________________________________
+
+void AliITSClusterFinderSDD::GetRecPoints()
+{
+ // get rec points
+ //static Int_t counter=0;
+
+ AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
+
+ // get number of clusters for this module
+ Int_t nofClusters = fClusters->GetEntriesFast();
+ nofClusters -= fNclusters;
+
+ //printf("SDD- GetRecPoints: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
+
+// const Float_t kdEdXtoQ = 2.778e+2; // KeV -> number of e-hole pairs in Si
+ 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
+
+ Int_t i;
+ for(i=0; i<nofClusters; i++) {
+ AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*) fClusters->At(i);
+ AliITSRecPoint rnew;
+ rnew.SetX(clusterI->X());
+ rnew.SetZ(clusterI->Z());
+ rnew.SetQ(clusterI->Q()); // in KeV - should be ADC
+ //rnew.SetdEdX((clusterI->Q())/kdEdXtoQ);
+ rnew.SetdEdX(kconvGeV*clusterI->Q());
+ rnew.SetSigmaX2(kRMSx*kRMSx);
+ rnew.SetSigmaZ2(kRMSz*kRMSz);
+ rnew.SetProbability(1.);
+ iTS->AddRecPoint(rnew);
+ //counter++;
+ } // I clusters
+ //printf("counter %d\n",counter);
+
+}
+
+//_____________________________________________________________________________
+
+void AliITSClusterFinderSDD::FindRawClusters()
+{
+ // find raw clusters
+ Find1DClusters();
+ GroupClusters();
+ SelectClusters();
+ GetRecPoints();
+}
+
+
+
+
--- /dev/null
+#ifndef ALIITSCLUSTERFINDERSDD_H
+#define ALIITSCLUSTERFINDERSDD_H
+
+////////////////////////////////////////////////
+// ITS Cluster Finder Class //
+////////////////////////////////////////////////
+
+#include "AliITSClusterFinder.h"
+
+class AliITSClusterFinderSDD :
+ public AliITSClusterFinder
+
+{
+public:
+ AliITSClusterFinderSDD
+ (AliITSsegmentation *seg,
+ AliITSresponse *response, TClonesArray *digits,TClonesArray *recpoints);
+ AliITSClusterFinderSDD();
+ virtual ~AliITSClusterFinderSDD(){
+ // destructor
+ }
+ AliITSClusterFinderSDD(const AliITSClusterFinderSDD &source); // copy constructor
+ AliITSClusterFinderSDD& operator=(const AliITSClusterFinderSDD &source); // assignment operator
+
+ virtual void SetMap();
+ virtual void SetCutAmplitude(Float_t thres=1.2) {
+ // set cut amplitude
+ fCutAmplitude=thres;
+ }
+ virtual void SetDAnode(Float_t danode=4.2) {
+ // setDAnode
+ fDAnode=danode;
+ }
+ virtual void SetDTime(Float_t dtime=75) {
+ // SetDTime
+ fDTime=dtime;
+ }
+ virtual void SetMinPeak(Int_t minpeak=7) {
+ // SetMinPeak
+ fMinPeak=minpeak;
+ }
+ virtual void SetNCells(Int_t minc=4) {
+ // setNCells
+ fMinNCells=minc;
+ }
+
+ void FillMap();
+
+ // Search for clusters
+ virtual void FindRawClusters();
+ void Find1DClusters();
+ void GroupClusters();
+ void SelectClusters();
+ void GetRecPoints();
+
+private:
+
+ TClonesArray *fClusters; // clusters
+ Int_t fNclusters; // num of clusters
+ AliITSMapA2 *fMap; // map
+ Float_t fCutAmplitude; // cut amplitude
+ Float_t fDAnode; // fDanode
+ Float_t fDTime; // fDtime
+
+ Int_t fMinPeak; // min peak
+ Int_t fMinNCells; // min num of cells
+
+
+ ClassDef(AliITSClusterFinderSDD,1) // SDD clustering - Piergiorgio C. algo
+ };
+#endif
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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 "AliITSClusterFinderSPD.h"
+#include "AliRun.h"
+
+
+
+ClassImp(AliITSClusterFinderSPD)
+
+//----------------------------------------------------------
+AliITSClusterFinderSPD::AliITSClusterFinderSPD
+(AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
+{
+ // constructor
+ fSegmentation=seg;
+ fDigits=digits;
+ fClusters=recp;
+ fNclusters= fClusters->GetEntriesFast();
+ SetDx();
+ SetDz();
+ SetMap();
+ SetNCells();
+}
+
+//_____________________________________________________________________________
+AliITSClusterFinderSPD::AliITSClusterFinderSPD()
+{
+ // constructor
+ fSegmentation=0;
+ fDigits=0;
+ fClusters=0;
+ fNclusters=0;
+ SetDx();
+ SetDz();
+ SetMap();
+ SetNCells();
+
+}
+
+//__________________________________________________________________________
+AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fClusters = source.fClusters ;
+ this->fNclusters = source.fNclusters ;
+ this->fMap = source.fMap ;
+ this->fDz = source.fDz ;
+ this->fDx = source.fDx ;
+ this->fMinNCells = source.fMinNCells ;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSClusterFinderSPD&
+ AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fClusters = source.fClusters ;
+ this->fNclusters = source.fNclusters ;
+ this->fMap = source.fMap ;
+ this->fDz = source.fDz ;
+ this->fDx = source.fDx ;
+ this->fMinNCells = source.fMinNCells ;
+ return *this;
+}
+
+//_____________________________________________________________________________
+void AliITSClusterFinderSPD::SetMap()
+{
+ // set map
+ if(!fMap) fMap=new AliITSMapA1(fSegmentation,fDigits);
+
+}
+
+//_____________________________________________________________________________
+
+void AliITSClusterFinderSPD::Find1DClusters()
+{
+ // Find one dimensional clusters, i.e.
+ // in r*phi(x) direction for each colunm in z direction
+
+ 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<fNofPixels;k++) {
+
+ Int_t mmax = 10; // a size of the window for the cluster finding
+
+ for(it=0;it<fMaxNofSamples;it++) {
+
+ Int_t lclx = 0;
+ Int_t xstart = 0;
+ Int_t xstop = 0;
+ Int_t id = 0;
+ Int_t ilcl =0;
+
+ for(m=0;m<mmax;m++) { // find the cluster inside the window
+ id = it+m;
+ if(id >= fMaxNofSamples) break; // ! no possible for the fadc
+
+ if(fMap->GetHitIndex(k,id)) { // start of the cluster
+ lclx += 1;
+ if(lclx == 1) xstart = id;
+
+ }
+
+ if(lclx > 0 && !fMap->GetHitIndex(k,id)) {
+ // end of cluster if a gap exists
+ xstop = id-1;
+ ilcl = 1;
+ break;
+ }
+
+ } // 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;
+ }
+
+ if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
+ xstop = fMaxNofSamples - 1; // the end cluster exists
+ ilcl = 1;
+ }
+
+ // --- Calculate z and x coordinates for one dimensional clusters
+
+ if(ilcl == 1) { // new cluster exists
+ it = id;
+ mmax = 10;
+ nofFoundClusters++;
+ Float_t clusterCharge = 0.;
+ // get this from segmentation when this will be implemented
+ Float_t zpitch = fSegmentation->Dpz(k+1);
+ Float_t clusterZ, dummyX;
+ Int_t dummy=0;
+ fSegmentation->GetCellCxz(dummy,k,dummyX,clusterZ);
+ Float_t zstart = clusterZ - 0.5*zpitch;
+ Float_t zstop = clusterZ + 0.5*zpitch;
+ Float_t clusterX = 0.;
+ Int_t xstartfull = xstart;
+ Int_t xstopfull = xstop;
+ 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)) firedpixel=1;
+ clusterCharge += firedpixel;
+ clusterX +=its + 0.5;
+ }
+ Float_t fRphiPitch = fSegmentation->Dpx(dummy);
+ clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
+
+
+ //printf("ClusterZ ClusterX %f %f \n",clusterZ, clusterX);
+
+ // Int_t nclusters = fClusters->GetEntriesFast();
+ // cout << nclusters << " clusters" << endl;
+ // cout<< "Create point"<<endl;
+
+ // Write the points (coordinates and some cluster information) to the
+ // AliITSRawClusterSPD object
+
+ AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(clusterZ,clusterX,clusterCharge,clusterSizeZ,clusterSizeX,xstart,xstop,xstartfull,xstopfull,zstart,zstop,k);
+ // fClusters->Add(point);
+ iTS->AddCluster(0,clust);
+ // cout << "Cluster at Ladder: " << fLadder << ", Detector: " <<fDetector<<endl;
+
+ // cout<<" end of cluster finding for Z pixel "<<endl;
+
+ } // new cluster (ilcl=1)
+ } // X direction loop (it)
+ } // Z direction loop (k)
+ return;
+
+}
+
+//_____________________________________________________________________________
+void AliITSClusterFinderSPD::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;
+ //printf("Group: fNclusters nofClusters %d %d\n",fNclusters, nofClusters);
+
+ AliITSRawClusterSPD *clusterI;
+ AliITSRawClusterSPD *clusterJ;
+
+ //Int_t *label=new Int_t[nofClusters]; // activate this for DEC machines
+ Int_t label[nofClusters];
+ Int_t i,j;
+ for(i=0; i<nofClusters; i++) label[i] = 0;
+ for(i=0; i<nofClusters; i++) {
+ if(label[i] != 0) continue;
+ for(j=i+1; j<nofClusters; j++) {
+ if(label[j] != 0) continue;
+ clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
+ clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
+ Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
+ if(pair) {
+
+ // if((clusterI->XStop() == clusterJ->XStart()-1)||(clusterI->XStart()==clusterJ->XStop()+1)) cout<<"!! Diagonal cluster"<<endl;
+ /*
+ cout << "clusters " << i << "," << j << " before grouping" << endl;
+ clusterI->Print();
+ clusterJ->Print();
+ */
+ clusterI->Add(clusterJ);
+ // cout << "remove cluster " << j << endl;
+ label[j] = 1;
+ fClusters->RemoveAt(j);
+ /*
+ cout << "cluster " << i << " after grouping" << endl;
+ clusterI->Print();
+ */
+ } // pair
+ } // J clusters
+ label[i] = 1;
+ } // I clusters
+ fClusters->Compress();
+ //Int_t totalNofClusters = fClusters->GetEntriesFast();
+ //cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
+
+ return;
+
+
+}
+//_____________________________________________________________________________
+
+void AliITSClusterFinderSPD::GetRecPoints()
+{
+ // get rec points
+ AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
+
+ // get number of clusters for this module
+ Int_t nofClusters = fClusters->GetEntriesFast();
+ nofClusters -= fNclusters;
+ //printf("GetRecP: fNclusters nofClusters %d %d\n",fNclusters, nofClusters);
+
+ 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
+
+ Int_t i;
+ for(i=0; i<nofClusters; i++) {
+ AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
+ AliITSRecPoint rnew;
+ rnew.SetX(clusterI->X()*kconv);
+ rnew.SetZ(clusterI->Z()*kconv);
+ rnew.SetQ(1.);
+ rnew.SetdEdX(0.);
+ rnew.SetSigmaX2(kRMSx*kRMSx);
+ rnew.SetSigmaZ2(kRMSz*kRMSz);
+ rnew.SetProbability(1.);
+ iTS->AddRecPoint(rnew);
+ } // I clusters
+
+}
+//_____________________________________________________________________________
+
+void AliITSClusterFinderSPD::FindRawClusters()
+{
+ // find raw clusters
+ Find1DClusters();
+ GroupClusters();
+ GetRecPoints();
+}
+
--- /dev/null
+#ifndef ALIITSCLUSTERFINDERSPD_H
+#define ALIITSCLUSTERFINDERSPD_H
+
+////////////////////////////////////////////////
+// ITS Cluster Finder Class //
+////////////////////////////////////////////////
+
+#include "AliITSClusterFinder.h"
+
+class AliITSClusterFinderSPD :
+ public AliITSClusterFinder
+
+{
+public:
+ AliITSClusterFinderSPD
+ (AliITSsegmentation *segmentation,
+ TClonesArray *digits, TClonesArray *recpoints);
+ AliITSClusterFinderSPD();
+ virtual ~AliITSClusterFinderSPD(){
+ // destructor
+ }
+ AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source); // copy constructor
+ AliITSClusterFinderSPD& operator=(const AliITSClusterFinderSPD &source); // assignment operator
+
+ virtual void SetMap();
+ virtual void SetDx(Float_t dx=1.) {
+ // set dx
+ fDx=dx;
+ }
+ virtual void SetDz(Float_t dz=0.) {
+ // set dz
+ fDz=dz;
+ }
+ virtual void SetNCells(Int_t minc=0) {
+ // set ncells
+ fMinNCells=minc;
+ }
+
+ // Search for clusters
+ virtual void FindRawClusters();
+ void Find1DClusters();
+ void GroupClusters();
+ void SelectClusters() {
+ // selects clusters
+ }
+ void GetRecPoints();
+
+private:
+
+ TClonesArray *fClusters; // clusters
+ Int_t fNclusters; // num of clusters
+ AliITSMapA1 *fMap; // map
+ Float_t fDz; // dz
+ Float_t fDx; // dx
+
+ Int_t fMinNCells; // min num of cells
+
+ ClassDef(AliITSClusterFinderSPD,1) // SPD clustering - Boris B. algo based
+ // on Piergiorgio's algo
+ };
+#endif
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+/*
+
+Adding rekonstruction facilities
+Piotr Krzysztof Skowronski
+December 1999.
+*/
+
+/*
+15 -18 V 2000
+Eroor counting routines
+Automatic combination routines improved (traps)
+
+*/
+
+#include "AliRun.h"
+#include "AliITSClusterFinderSSD.h"
+
+
+const Int_t debug=0;
+
+ClassImp(AliITSClusterFinderSSD)
+
+//____________________________________________________________________
+//
+// Constructor
+//____________________________________________________________________
+//
+
+
+AliITSClusterFinderSSD::AliITSClusterFinderSSD(AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
+{
+
+ fSegmentation=seg;
+ fDigits=digits;
+ fRecPoints=recp;
+
+ fITS=(AliITS*)gAlice->GetModule("ITS");
+
+ fClusterP = new TClonesArray ("AliITSclusterSSD",200);
+ fNClusterP =0;
+
+ fClusterN= new TClonesArray ("AliITSclusterSSD",200);
+ fNClusterN =0;
+
+ fPackages = new TClonesArray ("AliITSpackageSSD",200); //packages
+ fNPackages = 0;
+
+
+ fDigitsIndexP = new TArrayI(300);
+ fNDigitsP = 0;
+
+ fDigitsIndexN = new TArrayI(300);
+ fNDigitsN = 0;
+
+ SetAlpha1(1000);
+ SetAlpha2(1000);
+ SetAlpha3(1000);
+
+
+ fPitch = fSegmentation->Dpx(0);
+ Float_t StereoP,StereoN;
+ fSegmentation->Angles(StereoP,StereoN);
+ fTanP=TMath::Tan(StereoP);
+ fTanN=TMath::Tan(StereoN);
+
+}
+
+//-------------------------------------------------------
+AliITSClusterFinderSSD::~AliITSClusterFinderSSD() {
+
+ delete fClusterP;
+ delete fClusterN;
+ delete fPackages;
+ delete fDigitsIndexP;
+ delete fDigitsIndexN;
+}
+
+//-------------------------------------------------------
+void AliITSClusterFinderSSD::InitReconstruction()
+{
+
+ register Int_t i; //iterator
+
+ for(i=0;i<fNClusterP;i++)
+ {
+ fClusterP->RemoveAt(i);
+ }
+ fNClusterP =0;
+ for(i=0;i<fNClusterN;i++)
+ {
+ fClusterN->RemoveAt(i);
+ }
+ fNClusterN=0;
+
+ for(i=0;i<fNPackages;i++)
+ {
+ fPackages->RemoveAt(i);
+ }
+
+ fNPackages = 0;
+ fNDigitsP=0;
+ fNDigitsN=0;
+
+ Float_t StereoP,StereoN;
+ fSegmentation->Angles(StereoP,StereoN);
+
+ CalcStepFactor (StereoP,StereoN);
+
+ if (debug) cout<<"fSFF = "<<fSFF<<" fSFB = "<<fSFB<<"\n";
+}
+
+
+//---------------------------------------------
+void AliITSClusterFinderSSD::FindRawClusters()
+{
+
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+// This function findes out all clusters belonging to one module
+// 1. Zeroes all space after previous module reconstruction
+// 2. Finds all neighbouring digits
+// 3. If necesery, resolves for each group of neighbouring digits
+// how many clusters creates it.
+// 4. Creates packages
+// 5. Creates clusters
+
+ InitReconstruction(); //ad. 1
+ FillDigitsIndex();
+ SortDigits();
+ FindNeighbouringDigits(); //ad. 2
+ SeparateOverlappedClusters(); //ad. 3
+ ClustersToPackages(); //ad. 4
+ ConsumeClusters();
+ PackagesToPoints(); //ad. 5
+ ReconstructNotConsumedClusters();
+
+}
+
+
+//-------------------------------------------------
+void AliITSClusterFinderSSD::FindNeighbouringDigits()
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ register Int_t i;
+
+ //If there are any digits on this side, create 1st Cluster,
+ // add to it this digit, and increment number of clusters
+
+ if ((fNDigitsP>0 ) && (fNDigitsN > 0 )) {
+
+ Int_t currentstripNo;
+ Int_t *dbuffer = new Int_t [300]; //buffer for strip numbers
+ Int_t dnumber; //curent number of digits in buffer
+ TArrayI &lDigitsIndexP = *fDigitsIndexP;
+ TArrayI &lDigitsIndexN = *fDigitsIndexN;
+ TObjArray &lDigits=*fDigits;
+ TClonesArray &lClusterP = *fClusterP;
+ TClonesArray &lClusterN = *fClusterN;
+
+ //process P side
+ dnumber = 1;
+ dbuffer[0]=lDigitsIndexP[0];
+ //If next digit is a neighbour of previous, adds to last cluster this digit
+ for(i=1; i<fNDigitsP; i++) {
+ //reads new digit
+ currentstripNo = ((AliITSdigitSSD*)lDigits[lDigitsIndexP[i]])->
+ GetStripNumber();
+ //check if it is a neighbour of a previous one
+ if ( (((AliITSdigitSSD*)lDigits[lDigitsIndexP[i-1]])->GetStripNumber())
+ == (currentstripNo-1) ) dbuffer[dnumber++]=lDigitsIndexP[i];
+ else {
+ //create a new one side cluster
+ new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEP);
+ dbuffer[0]=lDigitsIndexP[i];
+ dnumber = 1;
+ }
+ } // end loop over fNDigitsP
+ new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEP);
+
+
+ //process N side
+ //for comments, see above
+ dnumber = 1;
+ dbuffer[0]=lDigitsIndexN[0];
+ //If next digit is a neighbour of previous, adds to last cluster this digit
+ for(i=1; i<fNDigitsN; i++) {
+ currentstripNo = ((AliITSdigitSSD*)(lDigits[lDigitsIndexN[i]]))->
+ GetStripNumber();
+ if ( (((AliITSdigitSSD*)lDigits[lDigitsIndexN[i-1]])->GetStripNumber())
+ == (currentstripNo-1) ) dbuffer[dnumber++]=lDigitsIndexN[i];
+ else {
+ new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEN);
+ dbuffer[0]=lDigitsIndexN[i];
+ dnumber = 1;
+ }
+ } // end loop over fNDigitsN
+ new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,fDigits,SIDEN);
+ delete [] dbuffer;
+
+ } // end condition on NDigits
+
+ if (debug) cout<<"\n Found clusters: fNClusterP = "<<fNClusterP<<" fNClusterN ="<<fNClusterN<<"\n";
+
+}
+/**********************************************************************/
+
+
+void AliITSClusterFinderSSD::SeparateOverlappedClusters()
+{
+//************************************************
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ register Int_t i,j; //iterator
+
+ Float_t factor=0.75; // How many percent must be lower signal
+ // on the middle one digit
+ // from its neighbours
+ Int_t signal0; //signal on the strip before the current one
+ Int_t signal1; //signal on the current one signal
+ Int_t signal2; //signal on the strip after the current one
+ TArrayI *splitlist; // List of splits
+ Int_t numerofsplits=0; // number of splits
+ Int_t initPsize = fNClusterP; //initial size of the arrays
+ Int_t initNsize = fNClusterN; //we have to keep it because it will grow
+ // in this function and it doasn't make
+ // sense to pass through it again
+
+ splitlist = new TArrayI(300);
+
+ for(i=0;i<initPsize;i++)
+ {
+ if (( ((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits())==1) continue;
+ if (( ((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits())==2) continue;
+ Int_t nj=(((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits()-1);
+ for(j=1; j<nj; j++)
+ {
+ signal1=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j);
+ signal0=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j-1);
+ signal2=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j+1);
+ //if signal is less then factor*signal of its neighbours
+ if ( (signal1<(factor*signal0)) && (signal1<(factor*signal2)) )
+ {
+ (*splitlist)[numerofsplits++]=j;
+ }
+ } // end loop over number of digits
+ //split this cluster if necessary
+ if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,SIDEP);
+ numerofsplits=0;
+
+ //in signed places (splitlist)
+ } // end loop over clusters on Pside
+
+ for(i=0;i<initNsize;i++) {
+ if (( ((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits())==1) continue;
+ if (( ((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits())==2) continue;
+ Int_t nj=(((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits()-1);
+ for(j=1; j<nj; j++)
+ {
+ signal1=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j);
+ signal0=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j-1);
+ signal2=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j+1);
+ //if signal is less then factor*signal of its neighbours
+ if ( (signal1<(factor*signal0)) && (signal1<(factor*signal2)) )
+ (*splitlist)[numerofsplits++]=j;
+ } // end loop over number of digits
+ //split this cluster into more clusters
+ if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,SIDEN);
+ numerofsplits=0; //in signed places (splitlist)
+ } // end loop over clusters on Nside
+
+ delete splitlist;
+}
+
+//-------------------------------------------------------
+void AliITSClusterFinderSSD::SplitCluster(TArrayI *list, Int_t nsplits, Int_t index, Bool_t side)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ //This function splits one side cluster into more clusters
+ //number of splits is defined by "nsplits"
+ //Place of splits are defined in the TArray "list"
+
+ // For further optimisation: Replace this function by two
+ // specialised ones (each for one side)
+ // save one "if"
+
+ //For comlete comments see AliITSclusterSSD::SplitCluster
+
+
+ register Int_t i; //iterator
+
+ AliITSclusterSSD* curentcluster;
+ Int_t *tmpdigits = new Int_t[100];
+ Int_t NN;
+ // side true means P side
+ if (side) {
+ curentcluster =((AliITSclusterSSD*)((*fClusterP)[index])) ;
+ for(i = nsplits; i>0 ;i--) {
+ NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits);
+ new ((*fClusterP)[fNClusterP]) AliITSclusterSSD(NN,tmpdigits,fDigits,side);
+ ( (AliITSclusterSSD*)((*fClusterP)[fNClusterP]) )->
+ SetLeftNeighbour(kTRUE);
+ //if left cluster had neighbour on the right before split
+ //new should have it too
+ if ( curentcluster->GetRightNeighbour() )
+ ( (AliITSclusterSSD*)((*fClusterP)[fNClusterP]) )->
+ SetRightNeighbour(kTRUE);
+ else curentcluster->SetRightNeighbour(kTRUE);
+ fNClusterP++;
+ } // end loop over nplits
+ } else {
+ curentcluster =((AliITSclusterSSD*)((*fClusterN)[index]));
+ for(i = nsplits; i>0 ;i--) {
+ NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits);
+ new ((*fClusterN)[fNClusterN]) AliITSclusterSSD(NN,tmpdigits,fDigits,side);
+ ((AliITSclusterSSD*)((*fClusterN)[fNClusterN]))->
+ SetRightNeighbour(kTRUE);
+ if (curentcluster->GetRightNeighbour())
+ ( (AliITSclusterSSD*)( (*fClusterN)[fNClusterN]) )->
+ SetRightNeighbour(kTRUE);
+ else curentcluster->SetRightNeighbour(kTRUE);
+ fNClusterN++;
+ } // end loop over nplits
+ } // end if side
+ delete []tmpdigits;
+
+}
+
+
+//-------------------------------------------------
+Int_t AliITSClusterFinderSSD::SortDigitsP(Int_t start, Int_t end)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ Int_t right;
+ Int_t left;
+ if (start != (end - 1) )
+ {
+ left=this->SortDigitsP(start,(start+end)/2);
+ right=this->SortDigitsP((start+end)/2,end);
+ return (left || right);
+ }
+ else
+ {
+ left = ((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndexP)[start]]))->GetStripNumber();
+ right= ((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndexP)[end]]))->GetStripNumber();
+ if( left > right )
+ {
+ Int_t tmp = (*fDigitsIndexP)[start];
+ (*fDigitsIndexP)[start]=(*fDigitsIndexP)[end];
+ (*fDigitsIndexP)[end]=tmp;
+ return 1;
+ }
+ else return 0;
+ }
+}
+
+
+//--------------------------------------------------
+
+Int_t AliITSClusterFinderSSD::SortDigitsN(Int_t start, Int_t end)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ Int_t right;
+ Int_t left;
+ if (start != (end - 1))
+ {
+ left=this->SortDigitsN(start,(start+end)/2);
+ right=this->SortDigitsN((start+end)/2,end);
+ return (left || right);
+ }
+ else
+ {
+ left =((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndexN)[start]]))->GetStripNumber();
+ right=((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndexN)[end]]))->GetStripNumber();
+ if ( left > right )
+ {
+ Int_t tmp = (*fDigitsIndexN)[start];
+ (*fDigitsIndexN)[start]=(*fDigitsIndexN)[end];
+ (*fDigitsIndexN)[end]=tmp;
+ return 1;
+ }else return 0;
+ }
+}
+
+
+//------------------------------------------------
+void AliITSClusterFinderSSD::FillDigitsIndex()
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ //Fill the indexes of the clusters belonging to a given ITS module
+ //Created by Piotr K. Skowronski, August 7 1999
+
+ Int_t PNs=0, NNs=0;
+ Int_t tmp,bit,k;
+ Int_t N;
+ Int_t i;
+
+ N = fDigits->GetEntriesFast();
+
+ Int_t* PSidx = new Int_t [N*sizeof(Int_t)];
+ Int_t* NSidx = new Int_t [N*sizeof(Int_t)];
+ if (fDigitsIndexP==NULL) fDigitsIndexP = new TArrayI(N);
+ if (fDigitsIndexN==NULL) fDigitsIndexN = new TArrayI(N);
+
+ AliITSdigitSSD *dig;
+
+ for(i = 0 ; i< N; i++ ) {
+ dig=(AliITSdigitSSD*)fDigits->UncheckedAt(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;k<PNs;k++)
+ {
+ if (tmp==PSidx[k])
+ {
+ if (debug) cout<<"Such a digit exists \n";
+ bit=0;
+ }
+ }
+ // end comment
+ if(bit) {
+ fDigitsIndexP->AddAt(i,fNDigitsP++);
+ PSidx[PNs++]=tmp;
+ }
+ } else {
+ bit=1;
+ tmp=dig->GetStripNumber();
+ // same as above
+ for(k=0;k<NNs;k++)
+ {
+ if (tmp==NSidx[k])
+ {
+ if (debug) cout<<"Such a digit exists \n";
+ bit=0;
+ }
+ }
+ // end comment
+ if (bit) {
+ fDigitsIndexN->AddAt(i,fNDigitsN++);
+ NSidx[NNs++] =tmp;
+ }
+ }
+ }
+
+
+ if (debug) cout<<"Digits : P = "<<fNDigitsP<<" N = "<<fNDigitsN<<endl;
+
+}
+
+
+//-------------------------------------------
+
+void AliITSClusterFinderSSD::SortDigits()
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+
+
+ Int_t i;
+ if(fNDigitsP>1)
+ for(i=0;i<fNDigitsP-1;i++)
+ if (SortDigitsP(0,(fNDigitsP-1-i))==0) break;
+
+ if(fNDigitsN>1)
+ for(i=0;i<fNDigitsN-1;i++)
+ if(SortDigitsN(0,(fNDigitsN-1-i))==0) break;
+}
+
+
+
+//----------------------------------------------
+void AliITSClusterFinderSSD::FillClIndexArrays(Int_t* arrayP, Int_t *arrayN)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+
+ register Int_t i;
+ for(i=0; i<fNClusterP;i++)
+ {
+ arrayP[i]=i;
+ }
+ for(i=0; i<fNClusterN;i++)
+ {
+ arrayN[i]=i;
+ }
+}
+
+
+//------------------------------------------------------
+void AliITSClusterFinderSSD::SortClusters(Int_t* arrayP, Int_t *arrayN)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+
+ Int_t i;
+ if(fNClusterP>1)
+ for(i=0;i<fNClusterP-1;i++)
+ if (SortClustersP(0,(fNClusterP-1),arrayP)==0) break;
+
+
+ if(fNClusterN>1)
+ for(i=0;i<fNClusterN-1;i++)
+ if (SortClustersN(0,(fNClusterN-1),arrayN)==0) break;
+
+}
+
+
+
+//---------------------------------------------------
+Int_t AliITSClusterFinderSSD::SortClustersP(Int_t start, Int_t end, Int_t *array)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+
+
+ Int_t right;
+ Int_t left;
+ if (start != (end - 1) ) {
+ left=this->SortClustersP(start,(start+end)/2,array);
+ right=this->SortClustersP((start+end)/2,end,array);
+ return (left || right);
+ } else {
+ left =((AliITSclusterSSD*)((*fClusterP)[array[start]]))->
+ GetDigitStripNo(0);
+ right=((AliITSclusterSSD*)((*fClusterP)[array[ end ]]))->
+ GetDigitStripNo(0);
+ if(left>right) {
+ Int_t tmp = array[start];
+ array[start]=array[end];
+ array[end]=tmp;
+ return 1;
+ } else return 0;
+ }
+
+
+}
+
+
+
+//-------------------------------------------------------
+Int_t AliITSClusterFinderSSD::SortClustersN(Int_t start, Int_t end, Int_t *array)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ Int_t right;
+ Int_t left;
+
+ if (start != (end - 1) ) {
+ left=this->SortClustersN(start,(start+end)/2,array);
+ right=this->SortClustersN((start+end)/2,end,array);
+ return (left || right);
+ } else {
+ left =((AliITSclusterSSD*)((*fClusterN)[array[start]]))->
+ GetDigitStripNo(0);
+ right=((AliITSclusterSSD*)((*fClusterN)[array[ end ]]))->
+ GetDigitStripNo(0);
+ if( left > right) {
+ Int_t tmp = array[start];
+ array[start]=array[end];
+ array[end]=tmp;
+ return 1;
+ } else return 0;
+ }
+
+}
+
+
+
+//-------------------------------------------------------
+void AliITSClusterFinderSSD::ClustersToPackages()
+{
+
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+
+ Int_t *oneSclP = new Int_t[fNClusterP]; //I want to have sorted 1 S clusters
+ Int_t *oneSclN = new Int_t[fNClusterN]; //I can not sort it in TClonesArray
+ //so, I create table of indexes and
+ //sort it
+ //I do not use TArrayI on purpose
+ // MB: well, that's not true that one
+ //cannot sort objects in TClonesArray
+
+ Int_t i,k; //iterator
+ AliITSpackageSSD *currentpkg;
+ AliITSclusterSSD *currentP;
+ AliITSclusterSSD *currentN;
+ AliITSclusterSSD *fcurrN;
+
+ Int_t lastNclIndex=0; //index of last N sidecluster
+ Int_t Nclpack=0; //number of P clusters in current package
+ Int_t Pclpack=0; //number of N clusters in current package
+ Int_t firstStripP;
+ Int_t lastStripP;
+ Int_t firstStripN;
+ Int_t lastStripN;
+ Int_t tmplastNclIndex;
+
+//Fills in One Side Clusters Index Array
+ FillClIndexArrays(oneSclP,oneSclN);
+//Sorts filled Arrays
+ SortClusters(oneSclP,oneSclN);
+
+
+ fNPackages=1;
+ new ((*fPackages)[0]) AliITSpackageSSD(fClusterP,fClusterN);
+ currentpkg = (AliITSpackageSSD*)((*fPackages)[0]);
+
+ //main loop on sorted P side clusters
+ for(i=0;i<fNClusterP;i++) {
+ //Take new P side cluster
+ currentP = GetPSideCluster(oneSclP[i]);
+ currentN = GetNSideCluster(oneSclN[lastNclIndex]);
+ // take a new P cluster or not ?
+ if(IsCrossing(currentP,currentN)) {
+ // don't take a new P cluster
+ Pclpack++;
+ currentP->AddCross(oneSclN[lastNclIndex]);
+ currentN->AddCross(oneSclP[i]);
+ currentpkg->AddPSideCluster(oneSclP[i]);
+ if (Nclpack==0) {
+ currentpkg->AddNSideCluster(oneSclN[lastNclIndex]);
+ Nclpack++;
+ }
+ //check if previous N side clusters crosses with it too
+ for(k=1;k<fSFB+1;k++) {
+ //check if we are not out of array
+ if ((lastNclIndex-k)>-1) {
+ fcurrN = GetNSideCluster( oneSclN[lastNclIndex-k] );
+ if( IsCrossing(currentP,fcurrN) ) {
+ currentP->AddCross(oneSclN[lastNclIndex-k]);
+ fcurrN->AddCross(oneSclP[i]);
+ } else break; //There is no sense to check rest of clusters
+ } else break;
+ }
+ tmplastNclIndex=lastNclIndex;
+ //Check if next N side clusters crosses with it too
+ for(k=1;k<fSFF+1;k++) {
+ //check if we are not out of array
+ if ((tmplastNclIndex+k)<fNClusterN) {
+ fcurrN = GetNSideCluster( oneSclN[tmplastNclIndex+k] );
+ if(IsCrossing(currentP,fcurrN) ) {
+ lastNclIndex++;
+ fcurrN->AddCross(oneSclP[i]);
+ currentP->AddCross(oneSclN[tmplastNclIndex+k]);
+ currentpkg->AddNSideCluster(oneSclN[lastNclIndex]);
+ Nclpack++;
+ }else break;
+ } else break;
+ }
+
+ // end of package
+ //if( IsCrossing )
+ } else {
+ lastStripP = currentP->GetLastDigitStripNo();
+ lastStripN = currentN->GetLastDigitStripNo();
+
+ if((lastStripN-fSFF) < lastStripP ) {
+ //Take new PCluster
+ if((Nclpack>0)&& (Pclpack>0)) {
+ new ((*fPackages)[fNPackages]) AliITSpackageSSD(fClusterP,fClusterN);
+ currentpkg = (AliITSpackageSSD*)((*fPackages)[fNPackages++]);
+ }
+
+ //so we have to take another cluster on side N and check it
+ //we have to check until taken cluster's last strip will
+ //be > last of this cluster(P)
+ //so it means that there is no corresponding cluster on side N
+ //to this cluster (P)
+ //so we have to continue main loop with new "lastNclIndex"
+
+ Nclpack=0;
+ Pclpack=0;
+ //We are not sure that next N cluter will cross with this P cluster
+ //There might one, or more, clusters that do not have any
+ //corresponding cluster on the other side
+ for(;;) {
+ lastNclIndex++;
+ //Check if we are not out of array
+ if (lastNclIndex<fNClusterN) {
+ currentN = GetNSideCluster(oneSclN[lastNclIndex]);
+ if ( IsCrossing(currentP, currentN) ){
+ Nclpack++;
+ Pclpack++;
+ currentP->AddCross(oneSclN[lastNclIndex]);
+ currentN->AddCross(oneSclP[i]);
+ currentpkg->AddNSideCluster(oneSclN[lastNclIndex]);
+ currentpkg->AddPSideCluster(oneSclP[i]);
+ //Check, if next N side clusters crosses with it too
+ tmplastNclIndex=lastNclIndex;
+ for(k=1;k<fSFF+1;k++) {
+ //Check if we are not out of array
+ if ((tmplastNclIndex+k)<fNClusterN) {
+ fcurrN = GetNSideCluster(oneSclN[tmplastNclIndex+k]);
+ if( IsCrossing(currentP, fcurrN) ) {
+ Nclpack++;
+ lastNclIndex++;
+ currentP->AddCross(oneSclN[tmplastNclIndex+k]);
+ fcurrN->AddCross(oneSclP[i]);
+ currentpkg->AddNSideCluster(oneSclN[tmplastNclIndex+k]);
+ }else break;
+ } else break; //we are out of array
+ } // end loop
+ break;
+ } else {
+ firstStripP = currentP->GetFirstDigitStripNo();
+ firstStripN = currentN->GetFirstDigitStripNo();
+ if((firstStripN+fSFB)>=firstStripP) break;
+ else continue;
+ }
+ } else goto EndOfFunction;
+ } // end for(;;)
+ } else //EndOfPackage
+ {
+ continue;
+ } //else EndOfPackage
+
+ }//else IsCrossing
+
+ }//main for
+
+ EndOfFunction:
+ if ((Nclpack<1) || (Pclpack<1)) fNPackages--;
+
+ delete oneSclP;
+ delete oneSclN;
+
+}
+
+
+
+//-----------------------------------------------
+void AliITSClusterFinderSSD::PackagesToPoints()
+{
+
+ register Int_t i;
+ AliITSpackageSSD *currentpkg;
+ Int_t NumNcl;
+ Int_t NumPcl;
+ Int_t clusterIndex;
+ Bool_t clusterSide;
+
+ for(i=0;i<fNPackages;i++) {
+ //get pointer to next package
+ currentpkg = (AliITSpackageSSD*)((*fPackages)[i]);
+ NumNcl = currentpkg->GetNumOfClustersN();
+ NumPcl = currentpkg->GetNumOfClustersP();
+ if(debug) cout<<"New Package\nNumPcl ="<<NumPcl<<" NumNcl ="<<NumNcl<<"\n";
+
+ while(((NumPcl>=2)&&(NumNcl>2))||((NumPcl>2)&&(NumNcl>=2))) {
+ //This is case of "big" pacakage
+ //conditions see 3 lines above
+ //if in the big package exists cluster with one cross
+ //we can reconstruct this point without any geometrical ambiguities
+ if(currentpkg->GetClusterWithOneCross(clusterIndex, clusterSide) )
+ {
+ ResolveClusterWithOneCross(currentpkg, clusterIndex, clusterSide);
+ } else if (clusterIndex == -2) {
+ NumPcl = 0;
+ NumNcl = 0;
+ break;
+ } else {
+ if ( (NumNcl==NumPcl) && (NumPcl<10)) {
+ //if there is no cluster with one cross
+ //we can resolve whole package at once
+ //by finding best combination
+ //we can make combinations when NumNcl==NumPcl
+ if (ResolvePackageBestCombin(currentpkg)) {
+ //sometimes creating combinations fail,
+ //but it happens very rarely
+ NumPcl = 0;
+ NumNcl = 0;
+ break;
+ } else ResolveOneBestMatchingPoint(currentpkg);
+ } else {
+ ResolveOneBestMatchingPoint(currentpkg);
+ }
+ }
+ NumNcl = currentpkg->GetNumOfClustersN();
+ NumPcl = currentpkg->GetNumOfClustersP();
+ } // end while
+ if ((NumPcl==1)&&(NumNcl==1)) {
+ ResolveSimplePackage(currentpkg);
+ continue;
+ }
+ if (NumPcl==1) {
+ ResolvePackageWithOnePSideCluster(currentpkg);
+ continue;
+ }
+ if (NumNcl==1) {
+ ResolvePackageWithOneNSideCluster(currentpkg);
+ continue;
+ }
+ if ((NumPcl==2)&&(NumNcl==2)) {
+ ResolveTwoForTwoPackage(currentpkg);
+ continue;
+ }
+ if ((NumPcl==0)&&(NumNcl>0)) { }
+ if ((NumNcl==0)&&(NumPcl>0)) { }
+
+ } // end loop over fNPackages
+
+
+}
+
+
+//----------------------------------------------------------
+
+void AliITSClusterFinderSSD::
+ResolveClusterWithOneCross(AliITSpackageSSD *currentpkg, Int_t clusterIndex, Bool_t clSide)
+{
+
+ if (clSide == SIDEP) ResolvePClusterWithOneCross(currentpkg,clusterIndex);
+ else ResolveNClusterWithOneCross(currentpkg,clusterIndex);
+
+}
+
+
+//---------------------------------------------------------
+void AliITSClusterFinderSSD::
+ResolvePClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex)
+{
+
+/*
+There is cluster (side P) which crosses with only one cluster on the other
+side (N)
+
+ie:
+ \ / \/ /
+ \ / /\ /
+ \/ / \/
+ /\ / /\
+ / \/ / \ .....
+ / /\ / \
+ / / \/ \
+ / / /\ \
+ / / / \ \
+*/
+
+
+ AliITSclusterSSD * clusterP;
+ AliITSclusterSSD * clusterN;
+
+ Float_t posClusterP; //Cluster P position in strip coordinates
+ Float_t posClusterN; //Cluster N position in strip coordinates
+
+ Float_t posErrorClusterP;
+ Float_t posErrorClusterN;
+
+ Float_t sigClusterP;
+ Float_t sigClusterN;
+
+ Float_t sigErrorClusterP;
+ Float_t sigErrorClusterN;
+
+ Float_t ps;
+ Float_t ns;
+
+ Float_t Chicomb;
+ Int_t clusterIdx;
+
+ if (debug) cout<<"ResolvePClusterWithOneCross\n";
+
+ clusterP=pkg->GetPSideCluster(clusterIndex);
+ posClusterP = GetClusterZ(clusterP);
+ posErrorClusterP = clusterP->GetPositionError();
+ sigClusterP = ps = clusterP->GetTotalSignal();
+ sigErrorClusterP = clusterP->GetTotalSignalError();
+ //carefully, it returns index in TClonesArray
+
+ clusterIdx = clusterP->GetCross(0);
+ clusterN=this->GetNSideCluster(clusterIdx);
+ ns = clusterN->GetTotalSignal();
+ posClusterN = GetClusterZ(clusterN);
+ posErrorClusterN = clusterN->GetPositionError();
+ pkg->DelCluster(clusterIndex,SIDEP);
+ sigClusterN = ps/PNsignalRatio;
+ // there is no sonse to check how signal ratio is far from perfect
+ // matching line if the if below it is true
+ if (ns < sigClusterN) {
+ sigClusterN=ns;
+ if (debug) cout<<"n1 < p1/PNsignalRatio";
+ if (debug) cout<<"Attempting to del cluster N "<<clusterIdx<<" ... \n";
+ pkg->DelClusterOI(clusterIdx,SIDEN);
+ } else {
+ //Let's see how signal ratio is far from perfect matching line
+ Chicomb = DistToPML(ps,ns);
+ if (debug) cout<<"Chic "<<Chicomb<<"\n";
+ if (Chicomb > falpha2) {
+ //it is near, so we can risk throwing this cluster away too
+ if (debug) cout<<"Attempting to del cluster N "<<clusterIdx<<"...\n";
+ pkg->DelClusterOI(clusterIdx,SIDEN);
+ } else {
+ clusterN->CutTotalSignal(sigClusterN);
+ if (debug) cout <<"Signal cut |||||||||||||\n";
+ }
+ }
+ sigErrorClusterN= clusterN->GetTotalSignalError();
+ CreateNewRecPoint(posClusterP,posErrorClusterP,posClusterN,posErrorClusterN,
+ sigClusterP+sigClusterN, sigErrorClusterN+sigErrorClusterP,
+ clusterP, clusterN, 0.75);
+
+}
+
+
+//------------------------------------------------------
+void AliITSClusterFinderSSD::
+ResolveNClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex)
+{
+
+ AliITSclusterSSD * clusterP;
+ AliITSclusterSSD * clusterN;
+
+ Float_t posClusterP; //Cluster P position in strip coordinates
+ Float_t posClusterN; //Cluster N position in strip coordinates
+
+ Float_t posErrorClusterP;
+ Float_t posErrorClusterN;
+
+ Float_t sigClusterP;
+ Float_t sigClusterN;
+
+ Float_t sigErrorClusterP;
+ Float_t sigErrorClusterN;
+
+ Float_t ps;
+ Float_t ns;
+
+ Float_t Chicomb;
+ Int_t clusterIdx;
+
+ if (debug) cout<<"ResolveNClusterWithOneCross\n";
+
+ clusterN=pkg->GetNSideCluster(clusterIndex);
+ posClusterN = GetClusterZ(clusterN);
+ posErrorClusterN = clusterN->GetPositionError();
+ sigClusterN = ns = clusterN->GetTotalSignal();
+ sigErrorClusterN = clusterN->GetTotalSignalError();
+ //carefully, it returns index in TClonesArray
+ clusterIdx = clusterN->GetCross(0);
+ clusterP=this->GetPSideCluster(clusterIdx);
+ ps = clusterP->GetTotalSignal();
+ posClusterP = GetClusterZ(clusterP);
+ posErrorClusterP = clusterP->GetPositionError();
+ pkg->DelCluster(clusterIndex,SIDEN);
+ sigClusterP=ns*PNsignalRatio;
+ // there is no sonse to check how signal ratio is far from perfect
+ // matching line if the if below it is true
+ if (ps < sigClusterP) {
+ sigClusterP = ps;
+ if (debug) cout<<"ps < ns*PNsignalRatio";
+ if (debug) cout<<"Attempting to del cluster P "<<clusterIdx<<" ... \n";
+ pkg->DelClusterOI(clusterIdx,SIDEP);
+ } else {
+ //Let's see how signal ratio is far from perfect matching line
+ Chicomb = DistToPML(ps,ns);
+ if (debug) cout<<"Chic "<<Chicomb<<"\n";
+ if (Chicomb > falpha2) {
+ //it is near, so we can risk frowing this cluster away too
+ if (debug) cout<<"Attempting to del cluster P "<<clusterIdx<<"...\n";
+ pkg->DelClusterOI(clusterIdx,SIDEP);
+ } else {
+ clusterN->CutTotalSignal(sigClusterP);
+ if (debug) cout <<"Signal cut ------------\n";
+ }
+ }
+ sigErrorClusterP= clusterP->GetTotalSignalError();
+ CreateNewRecPoint( posClusterP,posErrorClusterP,posClusterN,posErrorClusterN,
+ sigClusterP+sigClusterN,sigErrorClusterN+sigErrorClusterP,
+ clusterP, clusterN, 0.75);
+
+
+}
+
+
+
+//-------------------------------------------------------
+
+Bool_t AliITSClusterFinderSSD::
+ResolvePackageBestCombin(AliITSpackageSSD *pkg)
+{
+ if (debug) cout<<"NumNcl==NumPcl ("<<pkg->GetNumOfClustersN()
+ <<"=="<<pkg->GetNumOfClustersP()<<"); Generating combinations ... \n";
+
+
+ AliITSclusterSSD * clusterP;
+ AliITSclusterSSD * clusterN;
+
+ Int_t Ncombin; //Number of combinations
+ Int_t itera; //iterator
+ Int_t sizet=1; //size of array to allocate
+
+ Int_t NP = pkg->GetNumOfClustersP();
+ for(itera =2; itera <= NP ;itera ++) {
+ sizet=sizet*itera;
+ if (sizet > 10000) {
+ sizet=10000;
+ break;
+ }
+ }
+
+ Int_t** combin = new (Int_t*)[sizet]; //2D array to keep combinations in
+
+ for(itera =0; itera <sizet;itera++) {
+ combin[itera] = new Int_t[NP+1];
+ }
+
+ pkg->GetAllCombinations(combin,Ncombin,sizet);
+
+ if (Ncombin==0) {
+ if (debug) cout<<"No combin Error";
+ return kFALSE;
+ }
+//calculate which combination fits the best to perfect matching line
+ Int_t bc = GetBestComb(combin,Ncombin,NP,pkg);
+ if (debug) cout<<" bc "<<bc <<"\n";
+
+ for(itera =0; itera < NP; itera ++) {
+ clusterP = pkg->GetPSideCluster(itera);
+ //carefully here
+ //becase AliITSclusterSSD::GetCross returns index in
+ //AliITSmoduleSSD.fClusterP, which is put to "combin"
+ clusterN = GetNSideCluster(combin[bc][itera]);
+ CreateNewRecPoint(clusterP, clusterN, 0.75);
+ }
+
+ for(itera =0; itera <sizet;itera++) {
+ delete [](combin[itera]);
+ }
+ delete [] combin;
+ return kTRUE;
+
+}
+
+
+//----------------------------------------------------
+void AliITSClusterFinderSSD::
+ResolveOneBestMatchingPoint(AliITSpackageSSD *pkg)
+{
+
+ Int_t ni, pi;
+
+ Int_t prvP, prvN;
+ Int_t nextP, nextN=0;
+
+
+ AliITSclusterSSD * clusterP;
+ AliITSclusterSSD * clusterN;
+
+ Bool_t split = kFALSE;
+
+ if (debug) cout<<"ResolveOneBestMatchingPoint \n";
+
+ GetBestMatchingPoint(pi, ni, pkg);
+
+ clusterP = GetPSideCluster(pi);
+ clusterN = GetNSideCluster(ni);
+
+ CreateNewRecPoint(clusterP, clusterN, 0.75);
+
+ if ((nextP=pkg->GetNextPIdx(pi))!=-1)
+ if ((nextN=pkg->GetNextNIdx(ni))!=-1)
+ if ((prvP=pkg->GetPrvPIdx(pi))!=-1)
+ if ((prvN=pkg->GetPrvNIdx(ni))!=-1)
+ if( !(GetPSideCluster(prvP)->IsCrossingWith(nextN)))
+ if( !(GetPSideCluster(nextP)->IsCrossingWith(prvN)))
+ {
+ split = kTRUE;
+ }
+
+
+ pkg->DelClusterOI(pi, SIDEP);
+ pkg->DelClusterOI(ni, SIDEN);
+
+ if (split) {
+ if (debug) cout<<"spltting package ...\n";
+ new ((*fPackages)[fNPackages]) AliITSpackageSSD(fClusterP,fClusterN);
+ pkg->
+ SplitPackage(nextP,nextN,(AliITSpackageSSD*)((*fPackages)[fNPackages++]));
+ }
+
+}
+
+
+//--------------------------------------------------
+void AliITSClusterFinderSSD::ResolveSimplePackage(AliITSpackageSSD *pkg)
+{
+
+ AliITSclusterSSD * clusterP;
+ AliITSclusterSSD * clusterN;
+
+ clusterP = pkg->GetPSideCluster(0);
+
+ clusterN = pkg->GetNSideCluster(0);
+
+ CreateNewRecPoint(clusterP, clusterN, 1.0);
+
+
+}
+
+
+//--------------------------------------------------
+void AliITSClusterFinderSSD:: ResolvePackageWithOnePSideCluster(AliITSpackageSSD *pkg) {
+
+
+/*
+ \ \ \ /
+ \ \ \/
+ \ \ /\
+ \ \/ \
+ \ /\ \
+ \/ \ \
+ /\ \ \
+ / \ \ \
+
+*/
+
+
+/************************/
+/**************************/
+/*XP SP itg jest tylko jeden nie musi byc tablica i w peetli nie trzeba po niej iterowcac*/
+/***************************/
+
+
+ Int_t k;
+ AliITSclusterSSD * clusterP;
+ AliITSclusterSSD * clusterN;
+
+ Int_t NN=pkg->GetNumOfClustersN();
+ Float_t sumsig = 0;
+
+ Float_t XP;
+ Float_t XPerr;
+
+ Float_t * XN = new Float_t[NN];
+ Float_t * XNerr = new Float_t[NN];
+
+ Float_t * SP = new Float_t[NN];
+ Float_t * SN = new Float_t[NN];
+
+ Float_t * SPerr = new Float_t[NN];
+ Float_t * SNerr = new Float_t[NN];
+
+ Float_t p1;
+ Float_t p1err;
+
+ clusterP = pkg->GetPSideCluster(0);
+ p1 = clusterP->GetTotalSignal();
+
+ XP = GetClusterZ(clusterP);
+ XPerr = clusterP->GetPositionError();
+ p1err = clusterP->GetTotalSignalError();
+
+ for(k=0;k<NN;k++) {
+ SN[k] = pkg->GetNSideCluster(k)->GetTotalSignal();
+ SNerr[k] = pkg->GetNSideCluster(k)->GetTotalSignalError();
+ sumsig += SN[k];
+ }
+ for(k=0;k<NN;k++) {
+ clusterN = pkg->GetNSideCluster(k);
+ SP[k]= p1*SN[k]/sumsig;
+ SPerr[k] = p1err*SN[k]/sumsig;
+ XN[k]=GetClusterZ(clusterN);
+ XNerr[k]= clusterN->GetPositionError();
+ CreateNewRecPoint(XP,XPerr, XN[k],XNerr[k], SP[k]+SN[k], SPerr[k]+SNerr[k], clusterP, clusterN, 1.0);
+
+ }
+
+}
+
+
+//---------------------------------------------------------
+void AliITSClusterFinderSSD::ResolvePackageWithOneNSideCluster(AliITSpackageSSD *pkg) {
+
+
+/*
+ \ / / /
+ \ / / /
+ \/ / /
+ /\ / /
+ / \/ /
+ / /\ /
+ / / \/
+ / / /\
+ / / / \
+*/
+
+
+ Int_t k;
+ AliITSclusterSSD * clusterP;
+ AliITSclusterSSD * clusterN;
+
+ Int_t NP=pkg->GetNumOfClustersP();
+ Float_t sumsig = 0;
+
+ Float_t * XP = new Float_t[NP];
+ Float_t * XPerr = new Float_t[NP];
+
+ Float_t XN;
+ Float_t XNerr;
+
+ Float_t * SP = new Float_t[NP];
+ Float_t * SN = new Float_t[NP];
+
+ Float_t * SPerr = new Float_t[NP];
+ Float_t * SNerr = new Float_t[NP];
+
+ Float_t n1;
+ Float_t n1err;
+
+ clusterN = pkg->GetNSideCluster(0);
+ n1 = clusterN->GetTotalSignal();
+
+ XN = GetClusterZ(clusterN);
+ XNerr = clusterN->GetPositionError();
+
+ n1err=clusterN->GetTotalSignalError();
+
+ for(k=0;k<NP;k++) {
+ SP[k] = pkg->GetPSideCluster(k)->GetTotalSignal();
+ sumsig += SP[k];
+ SPerr[k] = pkg->GetPSideCluster(k)->GetTotalSignalError();
+ }
+
+ for(k=0;k<NP;k++) {
+ clusterP = pkg->GetPSideCluster(k);
+ SN[k]= n1*SP[k]/sumsig;
+ XP[k]=GetClusterZ(clusterP);
+ XPerr[k]= clusterP->GetPositionError();
+ SNerr[k] = n1err*SP[k]/sumsig;
+ CreateNewRecPoint(XP[k],XPerr[k], XN,XNerr, SP[k]+SN[k], SPerr[k]+SNerr[k],clusterP, clusterN, 1.0);
+ }
+
+
+}
+
+/**********************************************************************/
+/********* 2 X 2 *********************************************/
+/**********************************************************************/
+
+void AliITSClusterFinderSSD::
+ResolveTwoForTwoPackage(AliITSpackageSSD *pkg)
+{
+
+ AliITSclusterSSD *clusterP1 = pkg->GetPSideCluster(0);
+ AliITSclusterSSD *clusterP2 = pkg->GetPSideCluster(1);
+ AliITSclusterSSD *clusterN1 = pkg->GetNSideCluster(0);
+ AliITSclusterSSD *clusterN2 = pkg->GetNSideCluster(1);
+
+ AliITSclusterSSD *tmp;
+
+ Float_t p1sig;
+ Float_t p2sig;
+ Float_t n1sig;
+ Float_t n2sig;
+
+ Float_t p1sigErr;
+ Float_t p2sigErr;
+ Float_t n1sigErr;
+ Float_t n2sigErr;
+
+ Float_t ZposP1;
+ Float_t ZposP2;
+ Float_t ZposN1;
+ Float_t ZposN2;
+
+ Float_t ZposErrP1;
+ Float_t ZposErrP2;
+ Float_t ZposErrN1;
+ Float_t ZposErrN2;
+
+ Float_t D12;
+
+ Float_t Chicomb1;
+ Float_t Chicomb2;
+
+ if(clusterP1->GetDigitStripNo(0) > clusterP2->GetDigitStripNo(0)) {
+ if (debug) cout<<"P strips flip\n";
+ tmp = clusterP1;
+ clusterP1 = clusterP2;
+ clusterP2 = tmp;
+ }
+ if(clusterN1->GetDigitStripNo(0) > clusterN2->GetDigitStripNo(0)) {
+ if (debug) cout<<"N strips flip\n";
+ tmp = clusterN1;
+ clusterN1 = clusterN2;
+ clusterN2 = tmp;
+ }
+ p1sig = clusterP1->GetTotalSignal();
+ p2sig = clusterP2->GetTotalSignal();
+ n1sig = clusterN1->GetTotalSignal();
+ n2sig = clusterN2->GetTotalSignal();
+
+
+ p1sigErr = clusterP1->GetTotalSignalError();
+ n1sigErr = clusterN1->GetTotalSignalError();
+ p2sigErr = clusterP2->GetTotalSignalError();
+ n2sigErr = clusterN2->GetTotalSignalError();
+
+ ZposP1 = clusterP1->GetPosition();
+ ZposN1 = clusterN1->GetPosition();
+ ZposP2 = clusterP2->GetPosition();
+ ZposN2 = clusterN2->GetPosition();
+
+ ZposErrP1 = clusterP1->GetPositionError();
+ ZposErrN1 = clusterN1->GetPositionError();
+ ZposErrP2 = clusterP2->GetPositionError();
+ ZposErrN2 = clusterN2->GetPositionError();
+
+ //in this may be two types:
+ // 1.When each cluster crosses with 2 clusters on the other side
+ // gives 2 ghosts and 2 real points
+ //
+ // 2.When two clusters (one an each side) crosses with only one on
+ // the other side and two crosses (one on the each side) with
+ // two on the other gives 2 or 3 points,
+
+ if (debug) cout<<"2 for 2 ambiguity ...";
+ /***************************/
+ /*First sort of combination*/
+ /***************************/
+
+ if((clusterP1->GetCrossNo()==2) && (clusterN1->GetCrossNo()==2)) {
+ if (debug) cout<<"All clusters has 2 crosses\n";
+ D12 = TMath::Sqrt((Float_t)((p1sig -p2sig)*(p1sig -p2sig) + (n1sig -n2sig)*(n1sig -n2sig)));
+
+ if(debug) cout<<"Distance between points in P(N) plane D12 = "<<D12<<"\n";
+
+ /*********************************************/
+ /*resolving ambiguities: */
+ /*we count Chicomb's and we take combination */
+ /*giving lower Chicomb as a real points */
+ /*Keep only better combinantion */
+ /*********************************************/
+
+ if (D12 > (falpha3*17.8768)) {
+ if (debug) cout<<"decided to take only one pair \n";
+ Chicomb1 = DistToPML(p1sig,n1sig) + DistToPML(p2sig,n2sig);
+ Chicomb2 = DistToPML(p2sig,n1sig) + DistToPML(p1sig,n2sig);
+ if (debug) {
+ cout<<" 00 11 combination : "<<Chicomb1<<" 01 10 combination : "<<Chicomb2<<" \n";
+ cout<<"p1 = "<<p1sig<<" n1 = "<<n1sig<<" p2 = "<<p2sig<<" n2 = "<<n2sig<<"\n";
+ }
+ if (Chicomb1 < Chicomb2) {
+ if (debug) cout<<"00 11";
+ CreateNewRecPoint(ZposP1,ZposErrP1, ZposN1,ZposErrN1, p1sig+n1sig, p1sigErr+n1sigErr, clusterP1, clusterN1, 0.75);
+ CreateNewRecPoint(ZposP2,ZposErrP2, ZposN2,ZposErrN2, p2sig+n2sig, p2sigErr+n2sigErr, clusterP2, clusterN2, 0.75);
+
+
+ //second cominantion
+ } else {
+ if (debug) cout<<"01 10";
+ CreateNewRecPoint(ZposP1,0, ZposN2,0, p1sig+n2sig, p1sigErr+n2sigErr, clusterP1, clusterN2, 0.75);
+ CreateNewRecPoint(ZposP2,0, ZposN1,0, p2sig+n1sig, p2sigErr+n1sigErr, clusterP2, clusterN1, 0.75);
+ } //end second combinantion
+ //if (D12 > falpha3*17.8768)
+ //keep all combinations
+ } else {
+ if (debug) cout<<"We decide to take all points\n";
+ CreateNewRecPoint(ZposP1,ZposErrP1, ZposN1,ZposErrN1, p1sig+n1sig, p1sigErr+n1sigErr, clusterP1, clusterN1, 0.5);
+ CreateNewRecPoint(ZposP2,ZposErrP2, ZposN2,ZposErrN2, p2sig+n2sig, p2sigErr+n2sigErr, clusterP2, clusterN2, 0.5);
+ CreateNewRecPoint(ZposP1,ZposErrP1, ZposN2,ZposErrN2, p1sig+n2sig, p1sigErr+n2sigErr, clusterP1, clusterN2, 0.5);
+ CreateNewRecPoint(ZposP2,ZposErrP2, ZposN1,ZposErrN1, p2sig+n1sig, p2sigErr+n1sigErr, clusterP2, clusterN1, 0.5);
+ }
+ }
+ // ad.2 Second type of combination
+ else {
+ Chicomb1 = DistToPML(p1sig,n1sig) + DistToPML(p2sig,n2sig);
+ if (debug) cout<<"\nhere can be reconstructed 3 points: chicomb = "<<Chicomb1<<"\n";
+
+ if (Chicomb1<falpha1) {
+ if (debug) cout<<"\nWe decided to take 3rd point";
+ if (clusterP1->GetCrossNo()==1) {
+ if (debug) cout<<"... P1 has one cross\n";
+ n1sig = p1sig/PNsignalRatio;
+ p2sig = n2sig*PNsignalRatio;
+
+ clusterN1->CutTotalSignal(n1sig);
+ clusterP2->CutTotalSignal(p2sig);
+
+ CreateNewRecPoint(ZposP2,ZposErrP2, ZposN1,ZposErrN1, p2sig+n1sig, p2sigErr+n1sigErr, clusterP2, clusterN1, 0.5);
+
+ n1sig = clusterN1->GetTotalSignal();
+ p2sig = clusterP2->GetTotalSignal();
+
+ } else {
+ if (debug) cout<<"... N1 has one cross\n";
+
+ n2sig=p2sig/PNsignalRatio;
+ p1sig=n1sig*PNsignalRatio;
+
+ clusterN2->CutTotalSignal(n2sig);
+ clusterP1->CutTotalSignal(p1sig);
+
+ CreateNewRecPoint(ZposP1,ZposErrP1, ZposN2,ZposErrN2, p1sig+n2sig, p1sigErr+n2sigErr, clusterP1, clusterN2, 0.5);
+
+ n2sig=clusterN2->GetTotalSignal();
+ p1sig=clusterP1->GetTotalSignal();
+ }
+ } else {
+ if (debug) cout<<"\nWe decided NOT to take 3rd point\n";
+ }
+
+ CreateNewRecPoint(ZposP1,ZposErrP1, ZposN1,ZposErrN1, p1sig+n1sig, p1sigErr+n1sigErr, clusterP1, clusterN1, 1.0);
+ CreateNewRecPoint(ZposP2,ZposErrP2, ZposN2,ZposErrN2, p2sig+n2sig, p2sigErr+n2sigErr, clusterP2, clusterN2, 1.0);
+
+ }
+
+}
+
+
+
+//------------------------------------------------------
+Bool_t AliITSClusterFinderSSD::
+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)
+{
+
+ const Float_t kdEdXtoQ = 2.778e+8;
+ const Float_t kconv = 1.0e-4;
+ const Float_t kRMSx = 20.0*kconv; // microns->cm ITS TDR Table 1.3
+ const Float_t kRMSz = 830.0*kconv; // microns->cm ITS TDR Table 1.3
+
+
+ Float_t p=P;
+ Float_t n=N;
+ if (GetCrossing(P,N)) {
+ GetCrossingError(dP,dN);
+ AliITSRawClusterSSD cnew;
+ Int_t nstripsP=clusterP->GetNumOfDigits();
+ Int_t nstripsN=clusterN->GetNumOfDigits();
+ cnew.fMultiplicity=nstripsP;
+ cnew.fMultiplicityN=nstripsN;
+ /*
+ if (nstripsP > 100) {
+ printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsP);
+ nstripsP=100;
+ }
+ Int_t i;
+ for(i=0;i<nstripsP;i++) {
+ // check if 'clusterP->GetDigitStripNo(i)' returns the digit index
+ cnew.fIndexMap[i] = clusterP->GetDigitStripNo(i);
+ }
+ if (nstripsN > 100) {
+ printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsN);
+ nstripsN=100;
+ }
+ for(i=0;i<nstripsN;i++) {
+ // check if 'clusterN->GetDigitStripNo(i)' returns the digit index
+ cnew.fIndexMapN[i] = clusterN->GetDigitStripNo(i);
+ }
+ */
+ cnew.fQErr=dSig;
+ //cnew.fProbability=(float)prob;
+ fITS->AddCluster(2,&cnew);
+ // add the rec point info
+ AliITSRecPoint rnew;
+ rnew.SetX(P*kconv);
+ rnew.SetZ(N*kconv);
+ rnew.SetQ(Sig);
+ rnew.SetdEdX(Sig/kdEdXtoQ);
+ rnew.SetSigmaX2( kRMSx* kRMSx);
+ rnew.SetSigmaZ2( kRMSz* kRMSz);
+ rnew.SetProbability((float)prob);
+ fITS->AddRecPoint(rnew);
+ /*
+ // it was
+ fPointsM->AddLast( (TObject*)
+ new AliITSRecPointSSD(P,dP,0,0,N,dN,Sig,dSig,fLayer,fLad,fDet,clusterP,clusterN,prob) );
+ */
+
+ if(debug) cout<<"\n"<<": ImpactPoint Created: X = "<<P<<" Z = "<<N<<"; P = "<<p<<" N = "<<n<<"\n";
+ return kTRUE;
+ } else {
+ if (debug) {
+ cout<<"\n"<<": ATENTION : stupid ImpactPoit Point X = "<<P<<" Z = "<<N<<"; P = "<<p<<" N = "<<n<<"\n";
+ }
+ return kFALSE;
+ }
+}
+
+
+
+/**********************************************************************/
+Bool_t AliITSClusterFinderSSD::
+CreateNewRecPoint(AliITSclusterSSD *clusterP, AliITSclusterSSD *clusterN, Stat_t prob)
+{
+ Float_t posClusterP; //Cluster P position in strip coordinates
+ Float_t posClusterN; //Cluster N position in strip coordinates
+
+ Float_t posErrorClusterP;
+ Float_t posErrorClusterN;
+
+ Float_t sigClusterP;
+ Float_t sigClusterN;
+
+ Float_t sigErrorClusterP;
+ Float_t sigErrorClusterN;
+
+ posClusterP = clusterP->GetPosition();
+ posErrorClusterP = clusterP->GetPositionError();
+ sigClusterP = clusterP->GetTotalSignal();
+ sigErrorClusterP = clusterP->GetTotalSignalError();
+
+ posClusterN = clusterN->GetPosition();
+ posErrorClusterN = clusterN->GetPositionError();
+ sigClusterN = clusterN->GetTotalSignal();
+ sigErrorClusterN = clusterN->GetTotalSignalError();
+
+ return CreateNewRecPoint( posClusterP,posErrorClusterP, posClusterN,posErrorClusterN,
+ sigClusterP+sigClusterN, sigErrorClusterN+sigErrorClusterP,
+ clusterP, clusterN, prob);
+
+}
+
+//--------------------------------------------------
+Bool_t AliITSClusterFinderSSD::IsCrossing(AliITSclusterSSD* p, AliITSclusterSSD* n)
+{
+ Float_t x = p->GetPosition();
+ Float_t y = n->GetPosition();
+ return GetCrossing(x,y);
+}
+
+
+//----------------------------------------------
+Bool_t AliITSClusterFinderSSD::Strip2Local( Float_t stripP, Float_t stripN, Float_t &Z,Float_t &X)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+/*
+ Z = (stripN-stripP)*fFactorOne;
+ X = (stripN + stripP - fStripZeroOffset)*fFactorTwo;
+*/
+
+ Float_t P =stripP;
+ Float_t N =stripN;
+
+ GetCrossing(P,N);
+ X=P;
+ Z=N;
+ if (debug) cout<<"P="<<stripP<<" N="<<stripN<<" X = "<<X<<" Z = "<<Z<<"\n";
+ if ((Z<2.1)&&(Z>-2.1)&&(X<3.65)&&(X>-3.65)) return true;
+ else return false;
+
+}
+
+
+//-----------------------------------------------------------
+Float_t AliITSClusterFinderSSD::GetClusterZ(AliITSclusterSSD* clust)
+{
+
+ return clust->GetPosition();
+
+}
+
+//-------------------------------------------------------------
+Int_t AliITSClusterFinderSSD::GetBestComb
+(Int_t** comb,Int_t Ncomb, Int_t Ncl, AliITSpackageSSD * pkg)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+//returns index of best combination in "comb"
+//comb : sets of combinations
+// in given combination on place "n" is index of
+// Nside cluster coresponding to "n" P side cluster
+//
+//Ncomb : number of combinations == number of rows in "comb"
+//
+//Ncl : number of clusters in each row == number of columns in "comb"
+//
+//pkg : package
+
+
+ Float_t currbval=-1; //current best value,
+ //starting value is set to number negative,
+ //to be changed in first loop turn automatically
+
+ Int_t curridx=0; //index of combination giving currently the best chi^2
+ Float_t chi;
+ Float_t ps, ns; //signal of P cluster and N cluster
+
+ Int_t i,j;
+ for(i=0;i<Ncomb;i++)
+ {
+ chi=0;
+
+ for(j=0;j<Ncl;j++)
+ {
+ ps = pkg->GetPSideCluster(j)->GetTotalSignal(); //carrefully here, different functions
+ ns = GetNSideCluster(comb[i][j])->GetTotalSignal();
+ chi+=DistToPML(ps,ns);
+ }
+
+ if (currbval==-1) currbval = chi;
+ if (chi<currbval)
+ {
+ curridx = i;
+ currbval =chi;
+ }
+ }
+
+
+ return curridx;
+
+}
+
+//--------------------------------------------------
+void AliITSClusterFinderSSD::GetBestMatchingPoint
+(Int_t & ip, Int_t & in, AliITSpackageSSD* pkg )
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ if (debug) pkg->PrintClusters();
+
+ Float_t ps, ns; //signals on side p & n
+
+ Int_t nc; // number of crosses in given p side cluster
+ Int_t n,p;
+ AliITSclusterSSD *curPcl, *curNcl; //current p side cluster
+ Float_t bestchi, chi;
+ ip=p=pkg->GetPSideClusterIdx(0);
+ in=n=pkg->GetNSideClusterIdx(0);
+
+ bestchi=DistToPML( pkg->GetPSideCluster(0)->GetTotalSignal(),
+ pkg->GetNSideCluster(0)->GetTotalSignal() );
+ Int_t i,j;
+ for(i = 0; i< pkg->GetNumOfClustersP(); i++)
+ {
+
+ p = pkg->GetPSideClusterIdx(i);
+ curPcl= GetPSideCluster(p);
+ nc=curPcl->GetCrossNo();
+ ps=curPcl->GetTotalSignal();
+
+ for(j = 0; j< nc; j++)
+ {
+ n=curPcl->GetCross(j);
+ curNcl= GetNSideCluster(n);
+ ns=curNcl->GetTotalSignal();
+ chi = DistToPML(ps, ns);
+
+ if (chi <= bestchi)
+ {
+ bestchi = chi;
+ in = n;
+ ip = p;
+ }
+ }
+ }
+
+}
+
+
+//------------------------------------------------------
+void AliITSClusterFinderSSD::CalcStepFactor(Float_t Psteo, Float_t Nsteo )
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+
+ // 95 is the pitch, 4000 - dimension along z ?
+ /*
+ fSFF = ( (Int_t) (Psteo*40000/95 ) );// +1;
+ fSFB = ( (Int_t) (Nsteo*40000/95 ) );// +1;
+ */
+
+
+ Float_t dz=fSegmentation->Dz();
+
+ fSFF = ( (Int_t) (Psteo*dz/fPitch ) );// +1;
+ fSFB = ( (Int_t) (Nsteo*dz/fPitch ) );// +1;
+
+}
+
+
+//-----------------------------------------------------------
+AliITSclusterSSD* AliITSClusterFinderSSD::GetPSideCluster(Int_t idx)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+
+
+ if((idx<0)||(idx>=fNClusterP))
+ {
+ printf("AliITSClusterFinderSSD::GetPSideCluster : index out of range\n");
+ return 0;
+ }
+ else
+ {
+ return (AliITSclusterSSD*)((*fClusterP)[idx]);
+ }
+}
+
+//-------------------------------------------------------
+AliITSclusterSSD* AliITSClusterFinderSSD::GetNSideCluster(Int_t idx)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ if((idx<0)||(idx>=fNClusterN))
+ {
+ printf("AliITSClusterFinderSSD::GetNSideCluster : index out of range\n");
+ return 0;
+ }
+ else
+ {
+ return (AliITSclusterSSD*)((*fClusterN)[idx]);
+ }
+}
+
+//--------------------------------------------------------
+AliITSclusterSSD* AliITSClusterFinderSSD::GetCluster(Int_t idx, Bool_t side)
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+
+ return (side) ? GetPSideCluster(idx) : GetNSideCluster(idx);
+}
+
+
+//--------------------------------------------------------
+void AliITSClusterFinderSSD::ConsumeClusters()
+{
+
+ Int_t i;
+ for(i=0;i<fNPackages;i++)
+ {
+ ((AliITSpackageSSD*)((*fPackages)[i]))->ConsumeClusters();
+ }
+
+}
+
+
+//--------------------------------------------------------
+void AliITSClusterFinderSSD::ReconstructNotConsumedClusters()
+{
+ Int_t i;
+ AliITSclusterSSD *cluster;
+ Float_t pos;
+ Float_t sig;
+ Float_t sigerr;
+ Float_t x1,x2,z1,z2;
+
+ Float_t Dx = fSegmentation->Dx();
+ Float_t Dz = fSegmentation->Dz();
+
+ const Float_t kdEdXtoQ = 2.778e+8; // GeV -> number of e-hole pairs
+ const Float_t kconv = 1.0e-4;
+ const Float_t kRMSx = 20.0*kconv; // microns->cm ITS TDR Table 1.3
+ const Float_t kRMSz = 830.0*kconv; // microns->cm ITS TDR Table 1.3
+
+ for(i=0;i<fNClusterP;i++)
+ {
+ //printf("P side cluster: cluster number %d\n",i);
+ cluster = GetPSideCluster(i);
+ if (!cluster->IsConsumed())
+ {
+ if( (pos = cluster->GetPosition()) < fSFB)
+ {
+ sig = cluster->GetTotalSignal();
+
+ sig += sig/PNsignalRatio;
+
+ sigerr = cluster->GetTotalSignalError();
+ x1 = -Dx/2 + pos *fPitch;
+ z1 = -Dz/2;
+
+ x2 = pos;
+ z2 = 1;
+ GetCrossing (x2,z2);
+ AliITSRawClusterSSD cnew;
+ Int_t nstripsP=cluster->GetNumOfDigits();
+ cnew.fMultiplicity=nstripsP;
+ cnew.fMultiplicityN=0;
+ /*
+ if (nstripsP > 100) {
+ printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsP);
+ nstripsP=100;
+ }
+ Int_t k;
+ for(k=0;k<nstripsP;k++) {
+ // check if 'clusterP->GetDigitStripNo(i)' returns
+ // the digit index and not smth else
+ cnew.fIndexMap[k] = cluster->GetDigitStripNo(k);
+ }
+ */
+ cnew.fQErr=sigerr;
+ //cnew.fProbability=0.75;
+ fITS->AddCluster(2,&cnew);
+ // add the rec point info
+ AliITSRecPoint rnew;
+ rnew.SetX(kconv*(x1+x2)/2);
+ rnew.SetZ(kconv*(z1+z2)/2);
+ rnew.SetQ(sig);
+ rnew.SetdEdX(sig/kdEdXtoQ);
+ rnew.SetSigmaX2( kRMSx* kRMSx);
+ rnew.SetSigmaZ2( kRMSz* kRMSz);
+ rnew.SetProbability(0.75);
+ fITS->AddRecPoint(rnew);
+ /*
+ fPointsM->AddLast( (TObject*)
+ new AliITSRecPointSSD((x1+x2)/2 ,0,0,0,(z1+z2)/2,0,sig,sigerr,fLayer,fLad,fDet,cluster, 0.75) );
+ */
+
+ if(debug) cout<<"\n"<<": SINGLE SIDE ImpactPoint Created: X = "
+ <<(x1+x2)/2<<" Z = "<<(z1+z2)/2<<"; Pos = "<<pos;
+ }
+ }
+ }
+
+ for(i=0;i<fNClusterN;i++)
+ {
+ // printf("N side cluster: cluster number %d\n",i);
+ cluster = GetNSideCluster(i);
+ if (!cluster->IsConsumed())
+ {
+ if( (pos = cluster->GetPosition()) < fSFF)
+ {
+ sig = cluster->GetTotalSignal();
+
+ sig += sig*PNsignalRatio;
+
+ sigerr = cluster->GetTotalSignalError();
+
+ x1 = -Dx/2 + pos *fPitch;
+ z1 = Dz/2;
+
+ x2 = 1;
+ z2 = pos;
+
+ GetCrossing (x2,z2);
+ AliITSRawClusterSSD cnew;
+ Int_t nstripsN=cluster->GetNumOfDigits();
+ cnew.fMultiplicity=0;
+ cnew.fMultiplicityN=nstripsN;
+ /*
+ if (nstripsN > 100) {
+ printf("multiplicity > 100 - increase the dimension of the arrays %d\n",nstripsN);
+ nstripsN=100;
+ }
+ Int_t k;
+ for(k=0;k<nstripsN;k++) {
+ // check if 'clusterP->GetDigitStripNo(i)' returns
+ // the digit index and not smth else
+ cnew.fIndexMapN[k] = cluster->GetDigitStripNo(k);
+ }
+ */
+ cnew.fQErr=sigerr;
+ //cnew.fProbability=0.75;
+ fITS->AddCluster(2,&cnew);
+ // add the rec point info
+ AliITSRecPoint rnew;
+ rnew.SetX(kconv*(x1+x2)/2);
+ rnew.SetZ(kconv*(z1+z2)/2);
+ rnew.SetQ(sig);
+ rnew.SetdEdX(sig/kdEdXtoQ);
+ rnew.SetSigmaX2( kRMSx* kRMSx);
+ rnew.SetSigmaZ2( kRMSz* kRMSz);
+ rnew.SetProbability(0.75);
+ fITS->AddRecPoint(rnew);
+ /*
+ fPointsM->AddLast( (TObject*)
+ new AliITSRecPointSSD((x1+x2)/2 ,0,0,0,(z1+z2)/2,0,sig,sigerr,fLayer,fLad,fDet,cluster, 0.75) );
+ */
+
+ if(debug) cout<<"\n"<<": SINGLE SIDE ImpactPoint Created: X = "
+ <<(x1+x2)/2<<" Z = "<<(z1+z2)/2<<"; Pos = "<<pos;
+
+ }
+ }
+ }
+
+
+}
+
+//_______________________________________________________________________
+
+Bool_t AliITSClusterFinderSSD::GetCrossing (Float_t &P, Float_t &N)
+{
+
+ Float_t Dx = fSegmentation->Dx();
+ Float_t Dz = fSegmentation->Dz();
+
+ //P==X
+ //N==Z
+
+ Float_t dx = 0.1;
+ P *= fPitch;
+ N *= fPitch;
+
+ //P = (kZ * fTan + N + P)/2.0; // x coordinate
+ //N = kZ - (P-N)/fTan; // z coordinate
+
+ if(fTanP + fTanN == 0) return kFALSE;
+
+ N = (N - P + fTanN * Dz) / (fTanP + fTanN); // X coordinate
+ P = P + fTanP * N; // Y coordinate
+
+ P -= Dx/2;
+ N -= Dz/2;
+
+ // N = -(N - P + kZ/2*(fTanP + fTanN))/(fTanP + fTanN);
+ // P = (fTanP*(N-kX/2-kZ*fTanN/2) + fTanN*(P-kX/2-kZ*fTanP/2) )/(fTanP + fTanN);
+
+ if ( ( N < -(Dz/2+dx) ) || ( N > (Dz/2+dx) ) ) return kFALSE;
+ if ( ( P < -(Dx/2+dx) ) || ( P > (Dx/2+dx) ) ) return kFALSE;
+
+ return kTRUE;
+}
+
+
+//_________________________________________________________________________
+
+void AliITSClusterFinderSSD::GetCrossingError(Float_t& dP, Float_t& dN)
+{
+ Float_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) ));
+
+ dN = dz;
+ dP = dx;
+}
+
+
--- /dev/null
+#ifndef ALIITSCLUSTERFINDERSSD_H
+#define ALIITSCLUSTERFINDERSSD_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+
+#include <TObject.h>
+#include <TArrayS.h>
+#include <TClonesArray.h>
+#include <TRandom.h>
+#include <TMath.h>
+
+#include "AliITS.h"
+#include "AliITSclusterSSD.h"
+#include "AliITSpackageSSD.h"
+#include "AliITSClusterFinder.h"
+
+
+class AliITSClusterFinderSSD: public AliITSClusterFinder
+{
+
+public:
+
+ AliITSClusterFinderSSD(AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp);
+
+ virtual ~AliITSClusterFinderSSD();
+
+
+ void FindRawClusters();
+
+
+ void SetAlpha1(Float_t a) {falpha1 =a;}
+ void SetAlpha2(Float_t a) {falpha2 =a;}
+ void SetAlpha3(Float_t a) {falpha3 =a;}
+
+
+
+ protected:
+
+ 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(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 index, 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);
+ 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 ConsumeClusters();
+ void ClustersToPackages();
+ void PackagesToPoints();
+ void ReconstructNotConsumedClusters();
+ Bool_t Strip2Local( Float_t stripP, Float_t stripN, Float_t &Z,Float_t &X);
+ Float_t GetClusterZ(AliITSclusterSSD* clust);
+ Bool_t IsCrossing(AliITSclusterSSD* p, AliITSclusterSSD* n);
+ //returns index of best combination in "comb"
+ Int_t GetBestComb(Int_t** comb,Int_t Ncomb, Int_t Ncl, AliITSpackageSSD * pkg);
+
+ //get point that have best signal ratio
+ void GetBestMatchingPoint(Int_t & ip, Int_t & in, AliITSpackageSSD* pkg );
+
+ //calculates Distance To Perfect Matching Line
+ Float_t DistToPML(Float_t psig, Float_t nsig){ return (TMath::Abs( (7.0*nsig - 8.0*psig )/10.630146) );}
+
+
+ Int_t GetDiff(Float_t *retx, Float_t *rety) {return 0;}
+
+ void CalcStepFactor(Float_t Psteo, Float_t Nsteo );
+
+/*************************************************/
+/** methods for resolving packages ****/
+/*************************************************/
+//names may not be meaningful for all, see implementations for descriptions
+
+ void ResolveSimplePackage(AliITSpackageSSD *pkg);
+ void ResolvePackageWithOnePSideCluster(AliITSpackageSSD *pkg);
+ void ResolvePackageWithOneNSideCluster(AliITSpackageSSD *pkg);
+ void ResolveTwoForTwoPackage(AliITSpackageSSD *pkg);
+
+ void ResolveClusterWithOneCross(AliITSpackageSSD *pkg,
+ Int_t clusterIndex, Bool_t clusterSide);
+
+ void ResolvePClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex);
+ void ResolveNClusterWithOneCross(AliITSpackageSSD *pkg, Int_t clusterIndex);
+ Bool_t ResolvePackageBestCombin(AliITSpackageSSD *pkg);
+ void ResolveOneBestMatchingPoint(AliITSpackageSSD *pkg);
+
+ Bool_t GetCrossing(Float_t &x, Float_t &z); //x, y of strips crossing
+ void GetCrossingError(Float_t&, Float_t&); //x, y of strips crossing errors
+
+ // Data memebers
+
+ AliITS *fITS; //Pointer to AliITS object
+ TClonesArray *fDigits; //Pointer to TClonesArray of digits
+
+ TClonesArray *fRecPoints; //Pointer to TClonesArray of rec points
+
+
+ TClonesArray *fClusterP; //
+ Int_t fNClusterP; //Number of P side clusters in the array
+
+ TClonesArray *fClusterN; //Number of N side clusters in the array
+ Int_t fNClusterN;
+
+ TClonesArray *fPackages; //packages
+ Int_t fNPackages;
+
+ TArrayI *fDigitsIndexP; //Digits on P side
+ Int_t fNDigitsP; //Number of Digits on P side
+
+ 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
+
+/*************************************************/
+/** parameters for reconstruction ****/
+/** to be tune when slow simulation raliable ****/
+/*************************************************/
+
+ Float_t falpha1;
+ Float_t falpha2;
+ Float_t falpha3;
+
+
+ static const Bool_t SIDEP=kTRUE;
+ static const Bool_t SIDEN=kFALSE;
+ static const Float_t PNsignalRatio = 7./8.;
+ Int_t fSFF; //forward stepping factor
+ Int_t fSFB; //backward stepping factor
+
+public:
+ ClassDef(AliITSClusterFinderSSD, 1) //Class for clustering and reconstruction of space points in SSDs
+
+};
+
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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 "AliITSDetType.h"
+
+ClassImp(AliITSDetType)
+
+AliITSDetType::AliITSDetType()
+{
+ // constructor
+ fSegmentation=0;
+ fResponse=0;
+ fSimulation=0;
+ fReconst=0;
+}
+
+//__________________________________________________________________________
+AliITSDetType::AliITSDetType(const AliITSDetType &source){
+ // Copy Constructor
+ 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;
+}
+
+//_________________________________________________________________________
+AliITSDetType& AliITSDetType::operator=(const AliITSDetType &source){
+ // Assignment operator
+ 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;
+
+}
--- /dev/null
+#ifndef ALIITSDETTYPE_H
+#define ALIITSDETTYPE_H
+
+
+#include <TString.h>
+#include <TObject.h>
+
+#include "AliITSsegmentation.h"
+#include "AliITSresponse.h"
+
+class AliITSClusterFinder;
+class AliITSsimulation;
+
+class AliITSDetType:public TObject
+{
+
+ public:
+ AliITSDetType();
+ ~AliITSDetType(){
+ //destructor
+ }
+ AliITSDetType(const AliITSDetType &source); // copy constructor
+ AliITSDetType& operator=(const AliITSDetType &source); // assign. operator
+
+// Set the defaults
+ void Init() {}
+
+//
+ void SegmentationModel(AliITSsegmentation* thisSegmentation){
+ // Configure segmentation model
+ if(fSegmentation) delete fSegmentation;
+ fSegmentation=thisSegmentation;
+ }
+ //
+ void ResponseModel(AliITSresponse* thisResponse) {
+ // Configure response model
+ if(fResponse) delete fResponse;
+ fResponse=thisResponse;
+ }
+ //
+ void SimulationModel(AliITSsimulation *thisSimulation) {
+ // Configure simulation model
+ fSimulation = thisSimulation;
+ }
+ //
+ void ReconstructionModel(AliITSClusterFinder *thisReconstruction) {
+// Configure reconstruction model
+ fReconst = thisReconstruction;
+ }
+ void ClassNames(TString digit, TString cluster) {
+ // Set class names for digits and clusters
+ fDigClassName=digit; fClustClassName=cluster;
+ }
+
+ AliITSsegmentation* &GetSegmentationModel(){
+ // Get reference to segmentation model
+ return fSegmentation;
+ }
+ AliITSresponse* &GetResponseModel(){
+ // Get reference to response model
+ return fResponse;
+ }
+ AliITSsimulation* &GetSimulationModel(){
+ // Get reference to simulation model
+ return fSimulation;
+ }
+ AliITSClusterFinder* &GetReconstructionModel(){
+ // Get reference to hit reconstruction model
+ return fReconst;
+ }
+ //
+
+ void GetClassNames(const char *&digit, const char *&cluster)
+ {
+ // Get class names for digits and rec points
+ digit=fDigClassName; cluster=fClustClassName;
+ }
+
+protected:
+
+ AliITSClusterFinder *fReconst; // cluster finder
+ AliITSsimulation *fSimulation; // simulation
+ AliITSresponse *fResponse; // response
+ AliITSsegmentation *fSegmentation; // segmentation
+
+ TString fDigClassName; // string
+ TString fClustClassName; // string
+
+ ClassDef(AliITSDetType,1)
+
+ };
+
+#endif
--- /dev/null
+////////////////////////////////////////////////
+// RawData classes for set:ITS //
+////////////////////////////////////////////////
+
+#include <TMath.h>
+
+#include <iostream.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "AliITSHuffman.h"
+#include "AliITSRawData.h"
+
+ClassImp(AliITSHNode)
+
+//_____________________________________________________________________________
+
+AliITSHNode::AliITSHNode()
+{
+ // constructor
+ fLeft=0;
+ fRight=0;
+ fFather=0;
+}
+//_____________________________________________________________________________
+
+AliITSHNode::AliITSHNode(UChar_t sym, ULong_t freq)
+{
+ // constructor
+ fSymbol=sym;
+ fFrequency=freq;
+ fLeft=0;
+ fRight=0;
+ fFather=0;
+}
+
+//__________________________________________________________________________
+AliITSHNode::AliITSHNode(const AliITSHNode &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fSymbol = source.fSymbol;
+ this->fFrequency = source.fFrequency;
+ this->fLeft = source.fLeft;
+ this->fRight = source.fRight;
+ this->fFather = source.fFather;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSHNode&
+ AliITSHNode::operator=(const AliITSHNode &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fSymbol = source.fSymbol;
+ this->fFrequency = source.fFrequency;
+ this->fLeft = source.fLeft;
+ this->fRight = source.fRight;
+ this->fFather = source.fFather;
+ return *this;
+}
+
+//____________________________________________
+Int_t AliITSHNode::Compare(TObject *obj)
+{
+ // function called by Sort method of TObjArray
+
+ AliITSHNode *node=(AliITSHNode *)obj;
+ ULong_t f=fFrequency;
+ ULong_t fo=node->fFrequency;
+ if (f>fo) return 1;
+ else if (f<fo) return -1;
+ else return 0;
+}
+//_____________________________________________________________________________
+
+
+ClassImp(AliITSHTable)
+
+//_____________________________________________________________________________
+
+AliITSHTable::AliITSHTable()
+{
+ // constructor
+ fCodeLen=0;
+ fCode=0;
+ fHNodes=0;
+ fNnodes=0;
+
+}
+//_____________________________________________________________________________
+
+AliITSHTable::AliITSHTable(Int_t size)
+{
+ //
+ // Creates the look-up table for the 1D compression
+ //
+
+ //initialise
+
+ fSize=size;
+ fCodeLen = new UChar_t[fSize];
+ fCode = new ULong_t[fSize];
+ fHNodes = new TObjArray;
+ fNnodes=0;
+ fSym= new Short_t[fSize];
+ for(Short_t i=0;i<fSize;i++) {
+ fSym[i]=i;
+ }
+ Clear();
+
+}
+
+//__________________________________________________________________________
+AliITSHTable::AliITSHTable(const AliITSHTable &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fSize = source.fSize;
+ this->fCodeLen = source.fCodeLen;
+ this->fCode = source.fCode;
+ this->fSym = source.fSym;
+ this->fHNodes = source.fHNodes;
+ this->fNnodes = source.fNnodes;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSHTable&
+ AliITSHTable::operator=(const AliITSHTable &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fSize = source.fSize;
+ this->fCodeLen = source.fCodeLen;
+ this->fCode = source.fCode;
+ this->fSym = source.fSym;
+ this->fHNodes = source.fHNodes;
+ this->fNnodes = source.fNnodes;
+ return *this;
+}
+
+//_____________________________________________________________________________
+void AliITSHTable::GetFrequencies(Int_t len, UChar_t *stream)
+{
+ // get frequencies
+ printf("Get Frequencies: sym %p \n",fSym);
+
+ // use temporarily the fCode array to store the frequencies
+ Int_t i;
+ for(i=0; i< len; i++) {
+ Int_t idx=TMath::BinarySearch(fSize,fSym,(Short_t)stream[i]);
+ if (idx == (Int_t)stream[i]) fCode[idx]++;
+ // test
+ if(idx==134) cout<< "idx fCode[idx] "<<idx<<" "<<fCode[idx]<<endl;
+ //printf("idx,fCode[i] %d %d\n",idx,(Int_t)fCode[idx]);
+ }
+
+
+}
+
+
+//_____________________________________________________________________________
+void AliITSHTable::BuildHTable()
+{
+ // build Htable
+
+ Int_t i;
+ for(i=0; i< fSize; i++) {
+ //printf("i,fCode[i] %d %d\n",i,(Int_t)fCode[i]);
+ if (fCode[i] > 0) {
+ fNnodes++;
+ cout<< "i fCode[i] fNnodes "<<i<<" "<<fCode[i]<<" "<<fNnodes<<endl;
+ //printf("i, fCode[i] fNnodes %d %d %d\n",i,fCode[i],fNnodes);
+ fHNodes->Add(new AliITSHNode((UChar_t)i,fCode[i]));
+ }
+ }
+
+ Int_t nentries=fHNodes->GetEntriesFast();
+ Int_t nindex=nentries-1;
+ printf("nentries fNnodes nindex %d %d %d\n",nentries,fNnodes,nindex);
+
+ while (nindex > 0)
+ {
+
+ fHNodes->Sort(nindex);
+ AliITSHNode *aux = new AliITSHNode(0,0);
+ AliITSHNode *node= (AliITSHNode*)fHNodes->UncheckedAt(nindex-1);
+ AliITSHNode *node1= (AliITSHNode*)fHNodes->UncheckedAt(nindex);
+ aux->fLeft = node;
+ aux->fRight = node1;
+ aux->fFrequency = node->fFrequency + node1->fFrequency;
+ printf("symbol symbol1 freq freq1 %d %d %d %d\n",(int)node->fSymbol,(int)node1->fSymbol,(int)node->fFrequency,(int)node1->fFrequency);
+ cout << "aux - frequency "<< (Int_t)(aux->fFrequency) <<endl;
+ fHNodes->RemoveAt(nindex-1);
+ fHNodes->AddAt(aux,nindex-1);
+ nindex--;
+ printf("nindex, obj at nindex %d %p \n",nindex,(AliITSHNode*)fHNodes->UncheckedAt(nindex));
+
+ }
+
+ Clear();
+
+ AliITSHNode *start= (AliITSHNode*)fHNodes->UncheckedAt(0);
+ SpanTree(start,0,0);
+
+ // check the Huffman table
+
+ cout << "...Done, Huffman Table is: \n";
+ Int_t c;
+ for(c=0; c <= 255; c++) {
+ if (fCodeLen[c] > 0) cout << "Symbol " << c << " Coded as " << fCode[c] << " and long " << (int) fCodeLen[c] << " bits.\n";
+ }
+
+}
+
+//_____________________________________________________________________________
+AliITSHTable::~AliITSHTable()
+{
+ // HTable
+ printf("HTable destructor !\n");
+ if (fCodeLen) delete[] fCodeLen;
+ if (fCode) delete [] fCode;
+ delete fHNodes;
+}
+
+
+//____________________________________________
+Bool_t AliITSHTable::SpanTree(AliITSHNode *start, ULong_t code, UChar_t len)
+{
+ // span tree
+ AliITSHNode * visited;
+ visited = start;
+
+ printf("outside: code, len %d %d\n",(int)code,(int)len);
+
+ Int_t idx=(Int_t)visited->fSymbol;
+ if (!visited->fLeft) {
+ fCode[idx] = code;
+ fCodeLen[idx] = len;
+ printf("idx, fCode[idx], fCodeLen[idx] %d %d %d\n",idx,(int)fCode[idx],
+ (int)fCodeLen[idx]);
+ return kTRUE;
+ }
+
+// reccursive stuff
+
+ if (SpanTree(visited->fLeft, code << 1, len + 1)) {
+ printf("code, len %d %d\n",(int)code,(int)len);
+ if (visited->fRight)
+ SpanTree(visited->fRight, code << 1 | 0x01, len + 1);
+ }
+ return kTRUE;
+}
+
+//____________________________________________
+void AliITSHTable::ResetHNodes()
+{
+ //
+ // Reset number of HNodes and the HNodes array
+ //
+ if (fHNodes) fHNodes->Clear();
+ if (fNnodes) fNnodes=0;
+
+}
+
+//_____________________________________________________________________________
+void AliITSHTable::Clear()
+{
+ // clear
+ memset(fCodeLen,0,sizeof(UChar_t)*fSize);
+ memset(fCode,0,sizeof(ULong_t)*fSize);
+}
+
+//___________________________________________________________________________
+void AliITSHTable::Streamer(TBuffer &R__b)
+{
+ // Stream an object of class AliITSHTable.
+
+ if (R__b.IsReading()) {
+ Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+ TObject::Streamer(R__b);
+ R__b >> fSize;
+ R__b.ReadArray(fCodeLen);
+ R__b.ReadArray(fCode);
+ R__b.ReadArray(fSym);
+ R__b >> fHNodes;
+ R__b >> fNnodes;
+ } else {
+ R__b.WriteVersion(AliITSHTable::IsA());
+ TObject::Streamer(R__b);
+ R__b << fSize;
+ R__b.WriteArray(fCodeLen, fSize);
+ R__b.WriteArray(fCode, fSize);
+ R__b.WriteArray(fSym, fSize);
+ R__b << fHNodes;
+ R__b << fNnodes;
+ }
+}
+
--- /dev/null
+#ifndef AliITSHUFFMAN_H
+#define AliITSHUFFMAN_H
+
+///////////////////////////////////////////////////
+// Huffman Table associated classes for set:ITS //
+///////////////////////////////////////////////////
+
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// Attention! Two classes in this file.
+// They have to stay in the same file.
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+#include <TObject.h>
+#include <TObjArray.h>
+
+class AliITSInStream;
+
+class AliITSHNode: public TObject {
+
+ public:
+
+ UChar_t fSymbol; // comment to be written
+ ULong_t fFrequency; // comment to be written
+ AliITSHNode *fLeft; // comment to be written
+ AliITSHNode *fRight; // comment to be written
+ AliITSHNode *fFather; // not used
+
+ public:
+ AliITSHNode();
+ AliITSHNode(UChar_t symbol, ULong_t freq);
+ virtual ~AliITSHNode() {
+ // destructor
+ }
+ AliITSHNode(const AliITSHNode &source); // copy constructor
+ AliITSHNode& operator=(const AliITSHNode &source); // ass. op.
+
+ Bool_t IsSortable() const {
+ // is sortable
+ return kTRUE;
+ }
+ Int_t Compare(TObject *obj);
+
+ ClassDef(AliITSHNode,1) //HuffT node object for set:ITS
+ };
+
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// Attention! Next class has kept deliberaty in
+// the same file as the previous one
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+//___________________________________________
+class AliITSHTable: public TObject{
+
+public:
+ AliITSHTable();
+ AliITSHTable(Int_t size);
+ virtual ~AliITSHTable();
+ AliITSHTable(const AliITSHTable &source); // copy constructor
+ AliITSHTable& operator=(const AliITSHTable &source); // ass. op.
+
+ Int_t Size() {
+ // size
+ return fSize;
+ }
+ UChar_t *CodeLen() {
+ // code len
+ return fCodeLen;
+ }
+ ULong_t *Code() {
+ // code
+ return fCode;
+ }
+ TObjArray *HNodes() {
+ // HNodes
+ return fHNodes;
+ }
+
+
+ void GetFrequencies(Int_t len, UChar_t *stream);
+ void BuildHTable();
+ Bool_t SpanTree(AliITSHNode*start, ULong_t code, UChar_t len);
+ void ResetHNodes();
+ void Clear();
+
+ protected:
+
+ Int_t fSize; // size of the arrays
+ UChar_t *fCodeLen; //[fSize] number of bits array
+ ULong_t *fCode; //[fSize] coded symbols array
+
+ Short_t *fSym; //[fSize] array of input symbols
+ TObjArray *fHNodes; // array of nodes
+ Int_t fNnodes; // number of nodes
+
+ ClassDef(AliITSHTable,1) //Huffman Table object for set:ITS
+ };
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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 <TH1.h>
+#include "AliITSMap.h"
+
+ClassImp(AliITSMap)
+
+ClassImp(AliITSMapA1)
+
+AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg)
+{
+ //constructor
+ fSegmentation = seg;
+ fNpz=fSegmentation->Npz();
+ fNpx=fSegmentation->Npx();
+ fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
+
+ fHitMap = new Int_t[fMaxIndex];
+ fObjects = 0;
+ ClearMap();
+}
+
+AliITSMapA1::AliITSMapA1(AliITSsegmentation *seg, TObjArray *obj)
+{
+ //constructor
+ fSegmentation = seg;
+ fNpz=fSegmentation->Npz();
+ fNpx=fSegmentation->Npx();
+ fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
+
+ fHitMap = new Int_t[fMaxIndex];
+ fObjects = obj;
+ if (fObjects) fNobjects = fObjects->GetEntriesFast();
+ ClearMap();
+}
+
+
+AliITSMapA1::~AliITSMapA1()
+{
+ //destructor
+ if (fHitMap) delete[] fHitMap;
+}
+
+//__________________________________________________________________________
+AliITSMapA1::AliITSMapA1(const AliITSMapA1 &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fNpx = source.fNpx;
+ this->fNpz = source.fNpz;
+ this->fObjects = source.fObjects;
+ this->fNobjects = source.fNobjects;
+ this->fMaxIndex = source.fMaxIndex;
+ this->fHitMap = source.fHitMap;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSMapA1&
+ AliITSMapA1::operator=(const AliITSMapA1 &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fNpx = source.fNpx;
+ this->fNpz = source.fNpz;
+ this->fObjects = source.fObjects;
+ this->fNobjects = source.fNobjects;
+ this->fMaxIndex = source.fMaxIndex;
+ this->fHitMap = source.fHitMap;
+ return *this;
+}
+
+void AliITSMapA1::ClearMap()
+{
+ //clear array
+ memset(fHitMap,0,sizeof(int)*fMaxIndex);
+}
+
+void AliITSMapA1::SetArray(TObjArray *obj)
+{
+ // set array of objects
+ fObjects = obj;
+ if (fObjects) fNobjects = fObjects->GetEntriesFast();
+}
+
+
+Int_t AliITSMapA1::CheckedIndex(Int_t iz, Int_t ix)
+{
+ //check boundaries and return an index in array
+ Int_t index=fNpx*iz+ix;
+ if (index > fMaxIndex) {
+ printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",iz,ix, fMaxIndex, index, fNpz, fNpx);
+ // force crash
+ return -1;
+ } else {
+ return index;
+ }
+}
+
+
+void AliITSMapA1::FillMap()
+{
+ // fill array with digits indices
+ Int_t ndigits = fObjects->GetEntriesFast();
+ //printf("MapA1: ndigits fNobjects %d %d \n",ndigits,fNobjects);
+ if (!ndigits) return;
+
+ AliITSdigit *dig;
+ Int_t ndig;
+ for(ndig=0; ndig<ndigits; ndig++) {
+ dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
+ //printf("MapA1: ndig fCoord1 fCoord2 %d %d %d \n",dig->fCoord1,dig->fCoord2,ndig);
+ SetHit(dig->fCoord1,dig->fCoord2,ndig);
+ }
+
+}
+
+void AliITSMapA1::SetHit(Int_t iz, Int_t ix, Int_t idigit)
+{
+ // set the digit index at a certain position in array
+ fHitMap[CheckedIndex(iz, ix)]=idigit+1;
+}
+
+void AliITSMapA1::DeleteHit(Int_t iz, Int_t ix)
+{
+ // delete an entry in array
+ fHitMap[CheckedIndex(iz, ix)]=0;
+}
+
+void AliITSMapA1::FlagHit(Int_t iz, Int_t ix)
+{
+ // flag an entry in array
+ fHitMap[CheckedIndex(iz, ix)]=
+ -TMath::Abs(fHitMap[CheckedIndex(iz, ix)]);
+}
+
+Int_t AliITSMapA1::GetHitIndex(Int_t iz, Int_t ix)
+{
+ // return the digit index from a specific entry in array
+ return TMath::Abs(fHitMap[CheckedIndex(iz, ix)])-1;
+}
+
+TObject* AliITSMapA1::GetHit(Int_t iz, Int_t ix)
+{
+ // return the pointer to the digit
+ Int_t index=GetHitIndex(iz,ix);
+ // Force crash if index does not exist !
+ return (index <0) ? 0 : fObjects->UncheckedAt(GetHitIndex(iz,ix));
+}
+
+
+Flag_t AliITSMapA1::TestHit(Int_t iz, Int_t ix)
+{
+ // check whether the digit has already been flagged
+ Int_t inf=fHitMap[CheckedIndex(iz, ix)];
+ if (inf < 0) {
+ return kUsed;
+ } else if (inf == 0) {
+ return kEmpty;
+ } else {
+ return kUnused;
+ }
+}
+//_______________________________________________________________________
+void AliITSMapA1::Streamer(TBuffer &R__b)
+{
+ // Stream an object of class AliITSMapA1.
+
+ if (R__b.IsReading()) {
+ Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+ AliITSMap::Streamer(R__b);
+ R__b >> fSegmentation;
+ R__b >> fNpx;
+ R__b >> fNpz;
+ R__b >> fObjects;
+ R__b >> fNobjects;
+ R__b >> fMaxIndex;
+ R__b.ReadArray(fHitMap);
+ } else {
+ R__b.WriteVersion(AliITSMapA1::IsA());
+ AliITSMap::Streamer(R__b);
+ R__b << fSegmentation;
+ R__b << fNpx;
+ R__b << fNpz;
+ R__b << fObjects;
+ R__b << fNobjects;
+ R__b << fMaxIndex;
+ R__b.WriteArray(fHitMap,fMaxIndex);
+ }
+}
+
+//========================================================================
+ClassImp(AliITSMapA2)
+
+ AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg)
+{
+ //constructor
+ fSegmentation = seg;
+ fNpz=fSegmentation->Npz();
+ fNpx=fSegmentation->Npx();
+ fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
+
+ fHitMap = new Double_t[fMaxIndex];
+ fMapThreshold=0.;
+ ClearMap();
+}
+
+//--------------------------------------
+AliITSMapA2::AliITSMapA2(AliITSsegmentation *seg, TObjArray *hist, Double_t thresh)
+{
+ //constructor
+ fSegmentation = seg;
+ fNpz=fSegmentation->Npz();
+ fNpx=fSegmentation->Npx();
+ fMaxIndex=fNpz*fNpx+fNpx; // 2 halves of detector
+
+ fHitMap = new Double_t[fMaxIndex];
+ fObjects = hist;
+ if (fObjects) fNobjects = fObjects->GetEntriesFast();
+ fMapThreshold = thresh;
+ ClearMap();
+}
+//--------------------------------------
+
+
+AliITSMapA2::~AliITSMapA2()
+{
+ //destructor
+ if (fHitMap) delete[] fHitMap;
+}
+//--------------------------------------
+
+//__________________________________________________________________________
+AliITSMapA2::AliITSMapA2(const AliITSMapA2 &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fMapThreshold = source.fMapThreshold;
+ this->fHitMap = source.fHitMap;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSMapA2&
+ AliITSMapA2::operator=(const AliITSMapA2 &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fMapThreshold = source.fMapThreshold;
+ this->fHitMap = source.fHitMap;
+ return *this;
+}
+
+void AliITSMapA2::ClearMap()
+{
+ //clear array
+ memset(fHitMap,0,sizeof(Double_t)*fMaxIndex);
+}
+
+//--------------------------------------
+void AliITSMapA2::FillMap()
+{
+
+ // fills signal map from digits - apply a threshold for signal
+
+ if (!fObjects) return;
+
+ Int_t ndigits = fObjects->GetEntriesFast();
+ printf("MapA2: ndigits fNobjects %d %d \n",ndigits,fNobjects);
+ if (!ndigits) return;
+
+ AliITSdigit *dig;
+ Int_t ndig;
+ for(ndig=0; ndig<ndigits; ndig++) {
+ dig = (AliITSdigit*)fObjects->UncheckedAt(ndig);
+ Double_t signal = (Double_t)(dig->fSignal);
+ if (signal >= fMapThreshold) SetHit(dig->fCoord1,dig->fCoord2,signal);
+ }
+}
+
+//--------------------------------------
+void AliITSMapA2::SetHit(Int_t iz, Int_t ix, Double_t signal)
+{
+ // set signal at a certain position in array
+ fHitMap[CheckedIndex(iz, ix)]=signal;
+
+}
+
+//--------------------------------------
+void AliITSMapA2::DeleteHit(Int_t iz, Int_t ix)
+{
+ //set the entry value to zero
+ fHitMap[CheckedIndex(iz, ix)]=0;
+}
+
+//--------------------------------------
+void AliITSMapA2::FlagHit(Int_t iz, Int_t ix)
+{
+ //flag an entry
+ fHitMap[CheckedIndex(iz, ix)]=
+ -1000.*TMath::Abs((Int_t)(fHitMap[CheckedIndex(iz, ix)])+1.);
+
+}
+
+//--------------------------------------
+Int_t AliITSMapA2::GetHitIndex(Int_t iz, Int_t ix)
+{
+ //return the index of an entry in array
+ return CheckedIndex(iz, ix);
+}
+
+//--------------------------------------
+TObject* AliITSMapA2::GetHit(Int_t i, Int_t dummy)
+{
+
+ //return a pointer to the 1D histogram
+ if (fObjects) {
+
+ return fObjects->UncheckedAt(i);
+
+ } else return NULL;
+
+}
+
+//--------------------------------------
+Double_t AliITSMapA2::GetSignal(Int_t iz, Int_t ix)
+{
+ //get signal in a cell
+ Int_t index=GetHitIndex(iz,ix);
+ return (index <0) ? 0. : fHitMap[CheckedIndex(iz, ix)];
+}
+
+//--------------------------------------
+Double_t AliITSMapA2::GetSignal(Int_t index)
+{
+ //get signal in a cell
+ if (index<fMaxIndex) return (index <0) ? 0. : fHitMap[index];
+ else return 0.;
+}
+//--------------------------------------
+Flag_t AliITSMapA2::TestHit(Int_t iz, Int_t ix)
+{
+ // check if the entry has already been flagged
+ Int_t inf=(Int_t)fHitMap[CheckedIndex(iz, ix)];
+
+ if (inf <= -1000) {
+ return kUsed;
+ } else if (inf == 0) {
+ return kEmpty;
+ } else {
+ return kUnused;
+ }
+}
+
+//--------------------------------------
+void AliITSMapA2::FillMapFromHist()
+{
+
+ // fills map from 1D histograms
+
+ if (!fObjects) return;
+
+ // an example
+ Int_t i,j;
+ for(i=0; i<fNobjects; i++) {
+ TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
+ Int_t nsamples = hist->GetNbinsX();
+ for(j=0; j<nsamples; j++) {
+ Double_t signal = (Double_t)(hist->GetBinContent(j+1));
+ if (signal >= fMapThreshold) SetHit(i,j,signal);
+ }
+ }
+
+}
+//--------------------------------------
+void AliITSMapA2::FillHist()
+{
+
+ // fill 1D histograms from map
+ if (!fObjects) return;
+
+ // an example
+ Int_t i,j;
+ for(i=0; i<fNobjects; i++) {
+ TH1F *hist =(TH1F *)fObjects->UncheckedAt(i);
+ for(j=0; j<fNpx; j++) {
+ Double_t signal=GetSignal(i,j);
+ if (signal >= fMapThreshold) hist->Fill((Float_t)j,signal);
+ }
+ }
+
+}
+//--------------------------------------
+void AliITSMapA2::ResetHist()
+{
+ //
+ // Reset histograms
+ //
+
+ if (!fObjects) return;
+
+ Int_t i;
+ for(i=0; i<fNobjects; i++) {
+ if ((*fObjects)[i]) ((TH1F*)(*fObjects)[i])->Reset();
+ }
+
+}
+//______________________________________________________________________________
+void AliITSMapA2::Streamer(TBuffer &R__b)
+{
+ // Stream an object of class AliITSMapA2.
+
+ if (R__b.IsReading()) {
+ Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+ AliITSMapA1::Streamer(R__b);
+ R__b.ReadArray(fHitMap);
+ R__b >> fMapThreshold;
+ } else {
+ R__b.WriteVersion(AliITSMapA2::IsA());
+ AliITSMapA1::Streamer(R__b);
+ R__b.WriteArray(fHitMap, fMaxIndex); // fMaxIndex is from AliITSMapA1.
+ R__b << fMapThreshold;
+ }
+}
--- /dev/null
+#ifndef ALIITSMAP_H
+#define ALIITSMAP_H
+
+
+#include "AliITS.h"
+
+typedef enum {kEmpty, kUsed, kUnused} Flag_t;
+
+//___________________________________________________________________________
+
+class AliITSMap :
+ public TObject {
+
+public:
+ virtual ~AliITSMap() {}
+ virtual void FillMap() =0;
+ virtual void ClearMap() =0;
+ virtual void SetHit(Int_t iz, Int_t ix, Int_t idigit) =0;
+ virtual void DeleteHit(Int_t iz, Int_t ix) =0;
+ virtual void FlagHit(Int_t iz, Int_t ix) =0;
+ virtual Int_t GetHitIndex(Int_t iz, Int_t ix) =0;
+ virtual TObject * GetHit(Int_t iz, Int_t ix) =0;
+ virtual Flag_t TestHit(Int_t iz, Int_t ix) =0;
+ virtual Double_t GetSignal(Int_t iz, Int_t ix) =0;
+
+ ClassDef(AliITSMap,1) //virtual base class for ITS Hit/Digit Map
+
+ };
+
+
+class AliITSMapA1 :
+ public AliITSMap
+{
+
+public:
+ AliITSMapA1() {
+ // constructor
+ }
+ AliITSMapA1(AliITSsegmentation *seg);
+ AliITSMapA1(AliITSsegmentation *seg, TObjArray *dig);
+ AliITSMapA1(const AliITSMapA1 &source); // copy constructor
+ AliITSMapA1& operator=(const AliITSMapA1 &source); // assignment operator
+
+ virtual ~AliITSMapA1();
+ virtual void FillMap();
+ virtual void ClearMap();
+ virtual Double_t GetSignal(Int_t iz, Int_t ix) {
+ // get signal
+ return 0.;
+ }
+ virtual void SetHit(Int_t iz, Int_t ix, Int_t idigit);
+ virtual void DeleteHit(Int_t iz, Int_t ix);
+ virtual Int_t GetHitIndex(Int_t iz, Int_t ix);
+ virtual TObject* GetHit(Int_t iz, Int_t ix);
+ virtual void FlagHit(Int_t iz, Int_t ix);
+ virtual Flag_t TestHit(Int_t iz, Int_t ix);
+ Int_t CheckedIndex(Int_t iz, Int_t ix);
+ Int_t MaxIndex() {
+ // max index
+ return fMaxIndex;
+ }
+ void SetArray(TObjArray *obj);
+
+protected:
+ AliITSsegmentation *fSegmentation; // segmentation class
+ Int_t fNpx; // fNpx
+ Int_t fNpz; // fNpz
+ TObjArray *fObjects; // object
+ Int_t fNobjects; // nu of object
+ Int_t fMaxIndex; // max index
+
+private:
+ Int_t *fHitMap; // hit map
+
+ ClassDef(AliITSMapA1,1) // Implements Hit/Digit Map for SDD - read tree
+ };
+
+
+class AliITSMapA2 :
+public AliITSMapA1
+{
+
+public:
+ AliITSMapA2(AliITSsegmentation *seg);
+ AliITSMapA2(AliITSsegmentation *seg, TObjArray *hist,Double_t thresh);
+ virtual ~AliITSMapA2();
+ AliITSMapA2(const AliITSMapA2 &source); // copy constructor
+ AliITSMapA2& operator=(const AliITSMapA2 &source); // assignment operator
+ virtual void FillMap();
+ virtual void ClearMap();
+ virtual void SetHit(Int_t iz, Int_t ix, Int_t signal){
+ // set hit
+ }
+ virtual void FlagHit(Int_t iz, Int_t ix);
+ virtual void DeleteHit(Int_t iz, Int_t ix);
+ virtual Int_t GetHitIndex(Int_t iz, Int_t ix);
+ virtual TObject * GetHit(Int_t iz, Int_t dummy);
+ virtual Flag_t TestHit(Int_t iz, Int_t ix);
+ virtual Double_t GetSignal(Int_t iz, Int_t ix);
+ void SetHit(Int_t iz, Int_t ix, Double_t signal);
+ Double_t GetSignal(Int_t index);
+
+private:
+ Double_t *fHitMap; // fHitMap
+ Double_t fMapThreshold; // fMapThreshold
+
+ void FillMapFromHist();
+ void FillHist();
+ void ResetHist();
+
+ ClassDef(AliITSMapA2,1) // Implements Signal Map for SDD -fill or read hist
+ };
+
+
+#endif
+
+
+
+
--- /dev/null
+#include <iostream.h>
+#include <TMath.h>
+
+#include "AliITSRawCluster.h"
+
+ClassImp(AliITSRawCluster)
+
+ClassImp(AliITSRawClusterSDD)
+//--------------------------------------
+AliITSRawClusterSDD::AliITSRawClusterSDD(Int_t wing, Float_t Anode,Float_t Time,Float_t Charge,Float_t PeakAmplitude,Float_t Asigma, Float_t Tsigma,Float_t DriftPath,Float_t AnodeOffset,Int_t Samples) {
+ // constructor
+ fWing = wing;
+ fAnode = Anode;
+ fTime = Time;
+ fQ = Charge;
+ fPeakAmplitude = PeakAmplitude;
+ fNanodes = 1;
+ fNsamples = Samples;
+ Int_t sign = 1;
+ Int_t i;
+ for(i=0;i<fWing; i++) sign*=(-1);
+ fX = DriftPath*sign/10000.;
+ fZ = AnodeOffset/10000.;
+}
+
+//----------------------------------------
+void AliITSRawClusterSDD::Add(AliITSRawClusterSDD* clJ) {
+ // add
+ fAnode = (fAnode*fQ + clJ->A()*clJ->Q())/(fQ+clJ->Q());
+ fTime = (fTime*fQ + clJ->T()*clJ->Q())/(fQ+clJ->Q());
+ fX = (fX*fQ + clJ->X()*clJ->Q())/(fQ+clJ->Q());
+ fZ = (fZ*fQ + clJ->Z()*clJ->Q())/(fQ+clJ->Q());
+ fQ += clJ->Q();
+ fNsamples += (Int_t) (clJ->Samples());
+ (fNanodes)++;
+ if(clJ->PeakAmpl() > fPeakAmplitude) fPeakAmplitude = clJ->PeakAmpl();
+
+ return;
+}
+//--------------------------------------
+Bool_t AliITSRawClusterSDD::Brother(AliITSRawClusterSDD* cluster,Float_t danode,Float_t dtime) {
+ // brother
+ Bool_t brother = kTRUE;
+ if(fWing != cluster->W()) return brother = kFALSE;
+ if(TMath::Abs(fTime-cluster->T()) > dtime) return brother = kFALSE;
+ if(TMath::Abs(fAnode-cluster->A()) > danode) return brother = kFALSE;
+ return brother;
+}
+
+//--------------------------------------
+void AliITSRawClusterSDD::Print() {
+ // print
+ cout << ", Anode " << fAnode << ", Time: " << fTime << ", Charge: " << fQ;
+ cout << ", Samples: " << fNsamples;
+ cout << ", X: " << fX << ", Z: " << fZ << endl;
+}
+//--------------------------------------
+
+
+ClassImp(AliITSRawClusterSPD)
+ //--------------------------------------
+
+ AliITSRawClusterSPD::AliITSRawClusterSPD(Float_t clz,Float_t clx,Float_t Charge,Int_t ClusterSizeZ,Int_t ClusterSizeX,Int_t xstart,Int_t xstop,Int_t xstartf,Int_t xstopf,Float_t zstart,Float_t zstop,Int_t zend) {
+ // constructor
+
+ fZ = clz;
+ fX = clx;
+ fQ = Charge;
+ fNClZ = ClusterSizeZ;
+ fNClX = ClusterSizeX;
+ fXStart = xstart;
+ fXStop = xstop;
+ fXStartf = xstartf;
+ fXStopf = xstopf;
+ fZStart = zstart;
+ fZStop = zstop;
+ fZend = zend;
+}
+
+//--------------------------------------
+void AliITSRawClusterSPD::Add(AliITSRawClusterSPD* clJ) {
+ // Recolculate the new center of gravity coordinate and cluster sizes
+ // in both directions after grouping of clusters
+
+ if(this->fZStop < clJ->ZStop()) this->fZStop = clJ->ZStop();
+
+ this->fZ = (this->fZ + clJ->Z())/2.;
+ this->fX = (this->fX + clJ->X())/2.;
+ this->fQ = this->fQ + clJ->Q();
+
+ this->fXStart = clJ->XStart(); // for a comparison with the next
+ this->fXStop = clJ->XStop(); // z column
+
+ if(this->fXStartf > clJ->XStartf()) this->fXStartf = clJ->XStartf();
+ if(this->fXStopf < clJ->XStopf()) this->fXStopf = clJ->XStopf();
+ if(this->fZend < clJ->Zend()) this->fZend = clJ->Zend();
+ this->fNClX = this->fXStopf - this->fXStartf + 1;
+ (this->fNClZ)++;
+
+ return;
+}
+
+//--------------------------------------
+Bool_t AliITSRawClusterSPD::Brother(AliITSRawClusterSPD* cluster,Float_t dz,Float_t dx) {
+ // fXStart, fXstop and fZend information is used now instead of dz and dx
+ // to check an absent (or a present) of the gap between two pixels in
+ // both x and z directions. The increasing order of fZend is used.
+
+ Bool_t brother = kFALSE;
+ Bool_t test2 = kFALSE;
+ Bool_t test3 = kFALSE;
+
+ // Diagonal clusters are included:
+ if(fXStop >= (cluster->XStart() -1) && fXStart <= (cluster->XStop()+1)) test2 = kTRUE;
+
+ // Diagonal clusters are excluded:
+ // if(fXStop >= cluster->XStart() && fXStart <= cluster->XStop()) test2 = kTRUE;
+ if(cluster->Zend() == (fZend + 1)) test3 = kTRUE;
+ if(test2 && test3) {
+ // cout<<"test 2,3 0k, brother = true "<<endl;
+ return brother = kTRUE;
+ }
+ return brother;
+}
+
+//--------------------------------------
+void AliITSRawClusterSPD::Print()
+{
+ // print
+ cout << ", Z: " << fZ << ", X: " << fX << ", Charge: " << fQ<<endl;
+ cout << " Z cluster size: " << fNClZ <<", X cluster size "<< fNClX <<endl;
+ cout <<" XStart, XStop, XStartf,XStopf,Zend ="<<fXStart<<","<<fXStop<<","<<fXStartf<<","<<fXStopf<<","<<fZend<<endl;
+
+}
+
+
+ClassImp(AliITSRawClusterSSD)
+ //--------------------------------------
+ AliITSRawClusterSSD::AliITSRawClusterSSD(Float_t Prob,Int_t Sp,Int_t Sn) {
+ // constructor
+ //fProbability = Prob;
+ fMultiplicity = Sp;
+ fMultiplicityN = Sn;
+
+}
--- /dev/null
+#ifndef ALIITSRAWCLUSTER_H
+#define ALIITSRAWCLUSTER_H
+
+
+////////////////////////////////////////////////////
+// Cluster classes for set:ITS //
+////////////////////////////////////////////////////
+
+#include <TObject.h>
+
+
+class AliITSRawCluster : public TObject {
+
+ // this class is subject to changes ! - info used for declustering
+ // and eventual debugging
+
+public:
+
+ AliITSRawCluster() {
+ /*
+ for (int k=0;k<100;k++) {
+ fIndexMap[k]=-1;
+ }
+ fNcluster[0]=fNcluster[1]=-1;
+ fChi2=-1;
+ */
+ fMultiplicity=0;
+ }
+
+ virtual ~AliITSRawCluster() {
+ // destructor
+ }
+ virtual Bool_t IsSortable() const {
+ // is sortable
+ return kTRUE;
+ }
+
+public:
+
+ Int_t fMultiplicity; // cluster multiplicity
+ //Int_t fIndexMap[100]; // indices of digits
+ //Int_t fNcluster[2];
+ //Float_t fChi2;
+
+ ClassDef(AliITSRawCluster,1) // AliITSRawCluster class
+ };
+
+//---------------------------------------------
+class AliITSRawClusterSPD : public AliITSRawCluster {
+
+ // these classes are subject to changes - keep them temporarily for
+ // compatibility !!!
+
+public:
+
+ AliITSRawClusterSPD() {
+ // constructor
+ fX=fZ=fQ;
+ fZStart=fZStop;
+ fNClZ=fNClX=fXStart=fXStop=fXStartf=fXStopf=fZend;
+ }
+
+ AliITSRawClusterSPD(Float_t clz,Float_t clx,Float_t Charge,
+ Int_t ClusterSizeZ,Int_t ClusterSizeX,Int_t xstart,Int_t xstop,
+ Int_t xstartf,Int_t xstopf,Float_t zstart,Float_t zstop,Int_t zend);
+ virtual ~AliITSRawClusterSPD() {
+ // destructor
+ }
+
+ void Add(AliITSRawClusterSPD* clJ);
+ Bool_t Brother(AliITSRawClusterSPD* cluster,Float_t dz,Float_t dx);
+ void Print();
+ // Getters
+ Float_t Q() const {
+ // Q
+ return fQ ;
+ }
+ Float_t Z() const {
+ // Z
+ return fZ ;
+ }
+ Float_t X() const {
+ // X
+ return fX ;
+ }
+ Float_t NclZ() const {
+ // NclZ
+ return fNClZ ;
+ }
+ Float_t NclX() const {
+ // NclX
+ return fNClX ;
+ }
+ Int_t XStart() const {
+ //XStart
+ return fXStart;
+ }
+ Int_t XStop() const {
+ //XStop
+ return fXStop;
+ }
+ Int_t XStartf() const {
+ //XStartf
+ return fXStartf;
+ }
+ Int_t XStopf() const {
+ //XStopf
+ return fXStopf;
+ }
+ Float_t ZStart() const {
+ //ZStart
+ return fZStart;
+ }
+ Float_t ZStop() const {
+ //ZStop
+ return fZStop;
+ }
+ Int_t Zend() const {
+ //Zend
+ return fZend;
+ }
+
+protected:
+
+ Float_t fX; // X of cluster
+ Float_t fZ; // Z of cluster
+ Float_t fQ; // Q of cluster
+ Int_t fNClZ; // Cluster size in Z direction
+ Int_t fNClX; // Cluster size in X direction
+ Int_t fXStart; // number of first pixel in cluster
+ Int_t fXStop; // number of last pixel in cluster
+ Int_t fXStartf; // number of first pixel in full cluster
+ Int_t fXStopf; // number of last pixel in full cluster
+ Float_t fZStart; // number of first pixel in cluster
+ Float_t fZStop; // number of last pixel in cluster
+ Int_t fZend; // Zend
+
+ ClassDef(AliITSRawClusterSPD,1) // AliITSRawCluster class for SPD
+
+ };
+
+//---------------------------------------------
+class AliITSRawClusterSDD : public AliITSRawCluster {
+
+public:
+
+ AliITSRawClusterSDD() {
+ // constructor
+ fX=fZ=fQ;
+ fWing=fNsamples=0;
+ fNanodes=1;
+ fAnode=fTime=fPeakAmplitude=0;
+ }
+
+ AliITSRawClusterSDD(Int_t wing, Float_t Anode,Float_t Time,Float_t Charge,
+ Float_t PeakAmplitude,Float_t Asigma, Float_t Tsigma,Float_t DriftPath, Float_t AnodeOffset,Int_t Samples);
+ virtual ~AliITSRawClusterSDD() {
+ // destructor
+ }
+
+ void Add(AliITSRawClusterSDD* clJ);
+ Bool_t Brother(AliITSRawClusterSDD* cluster,Float_t dz,Float_t dx);
+ void Print();
+ // Getters
+ Float_t X() const {
+ //X
+ return fX ;
+ }
+ Float_t Z() const {
+ //Z
+ return fZ ;
+ }
+ Float_t Q() const {
+ //Q
+ return fQ ;
+ }
+ Float_t A() const {
+ //A
+ return fAnode ;
+ }
+ Float_t T() const {
+ //T
+ return fTime ;
+ }
+ Float_t W() const {
+ //W
+ return fWing ;
+ }
+ Int_t Anodes() const {
+ //Anodes
+ return fNanodes ;
+ }
+ Int_t Samples() const {
+ //Samples
+ return fNsamples ;
+ }
+ Float_t PeakAmpl() const {
+ //PeakAmpl
+ return fPeakAmplitude ;
+ }
+
+protected:
+
+ Float_t fX; // X of cluster
+ Float_t fZ; // Z of cluster
+ Float_t fQ; // Q of cluster
+ Int_t fWing; // Wing number
+ Float_t fAnode; // Anode number
+ Float_t fTime; // Drift Time
+ Float_t fPeakAmplitude; // Peak Amplitude
+ Int_t fNanodes; // N of anodes used for the cluster
+ Int_t fNsamples; // N of samples used for the cluster
+
+ ClassDef(AliITSRawClusterSDD,1) // AliITSRawCluster class for SDD
+ };
+
+//-----------------------------------------
+class AliITSRawClusterSSD : public AliITSRawCluster {
+
+public:
+
+ AliITSRawClusterSSD() {
+ /*
+ for (int k=0;k<100;k++) {
+ fIndexMapN[k]=-1;
+ }
+ */
+ fMultiplicityN=0;
+ // fProbability=0;
+ fQErr=0;
+ //fChi2N=-1;
+ fStatus=-1;
+ }
+ AliITSRawClusterSSD(Float_t Prob,Int_t Sp,Int_t Sn);
+ virtual ~AliITSRawClusterSSD() {
+ // destructor
+ }
+
+ Int_t GetStatus() const {
+ // get status
+ return fStatus;
+ }
+ void SetStatus(Int_t status) {
+ // set status
+ fStatus=status;
+ }
+
+
+public:
+ // Float_t fProbability; // The probability that this is a "real" point
+ //Int_t fIndexMapN[100]; // indices of digits for Nside - the corresponding
+ // info for P side is carried in the base class
+ //Float_t fChi2N;
+
+ Int_t fMultiplicityN; // The number of N side strips involved
+ // in this point calculations
+ Int_t fStatus; // Flag status : 0 - real point
+ // 1 - ghost
+ // 2 - EIC ?
+ // 3 - single side
+
+ Float_t fQErr; // Total charge error
+
+ ClassDef(AliITSRawClusterSSD,1) // AliITSRawCluster class for SSD
+
+};
+
+
+#endif
--- /dev/null
+////////////////////////////////////////////////
+// RawData classes for set:ITS //
+////////////////////////////////////////////////
+
+
+#include "AliITSRawData.h"
+
+ClassImp(AliITSRawData)
+
+ClassImp(AliITSInStream)
+
+//_____________________________________________________________________________
+
+AliITSInStream::AliITSInStream()
+{
+ //default constructor
+ fStreamLen=0;
+ fInStream=0;
+}
+//_____________________________________________________________________________
+
+AliITSInStream::AliITSInStream(ULong_t length)
+{
+ //
+ // Creates a stream of unsigned chars
+ //
+
+ fStreamLen = length;
+ fInStream = new UChar_t[length];
+
+ ClearStream();
+
+}
+
+//_____________________________________________________________________________
+AliITSInStream::~AliITSInStream()
+{
+ //destructor
+ if (fInStream) delete[] fInStream;
+}
+
+//__________________________________________________________________________
+AliITSInStream::AliITSInStream(const AliITSInStream &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fStreamLen = source.fStreamLen;
+ this->fInStream = source.fInStream;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSInStream&
+ AliITSInStream::operator=(const AliITSInStream &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fStreamLen = source.fStreamLen;
+ this->fInStream = source.fInStream;
+ return *this;
+}
+
+//_____________________________________________________________________________
+void AliITSInStream::ClearStream()
+{
+ //clear the array
+ memset(fInStream,0,sizeof(UChar_t)*fStreamLen);
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliITSInStream::CheckCount(ULong_t count) {
+ //check boundaries
+ if (count <= (ULong_t)fStreamLen) return kTRUE;
+ else {
+ Error("CheckCount", "actual size is %d, the necessary size is %d",fStreamLen,count);
+ return kFALSE;
+ }
+}
+
+//____________________________________________________________________________
+void AliITSInStream::Streamer(TBuffer &R__b){
+ // Stream an object of class AliITSInStream.
+
+ static unsigned char *array;
+ static Bool_t make=kTRUE;
+
+ if (R__b.IsReading()) {
+ R__b >> fStreamLen;
+ //printf("Streamer: fStreamLen %d\n",fStreamLen);
+ if (make) array=new unsigned char[fStreamLen];
+ make=kFALSE;
+ memset(array,0,sizeof(UChar_t)*fStreamLen);
+ fInStream=array;
+ R__b.ReadFastArray(fInStream,fStreamLen);
+
+ } else {
+ R__b << fStreamLen;
+ R__b.WriteFastArray(fInStream,fStreamLen);
+ }
+}
+
+
+
+ClassImp(AliITSOutStream)
+
+ //_______________________________________________________________________
+
+ AliITSOutStream::AliITSOutStream() {
+ //default constructor
+ fStreamLen=0;
+ fOutStream=0;
+}
+
+//__________________________________________________________________________
+
+AliITSOutStream::AliITSOutStream(ULong_t length) {
+ //
+ // Creates a stream of unsigned chars
+ //
+
+ fStreamLen = length;
+ fOutStream = new ULong_t[length];
+ ClearStream();
+
+}
+
+//_____________________________________________________________________________
+AliITSOutStream::~AliITSOutStream()
+{
+ //destructor
+ if (fOutStream) delete[] fOutStream;
+}
+
+//__________________________________________________________________________
+AliITSOutStream::AliITSOutStream(const AliITSOutStream &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fStreamLen = source.fStreamLen;
+ this->fOutStream = source.fOutStream;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSOutStream&
+ AliITSOutStream::operator=(const AliITSOutStream &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fStreamLen = source.fStreamLen;
+ this->fOutStream = source.fOutStream;
+ return *this;
+}
+
+//_____________________________________________________________________________
+void AliITSOutStream::ClearStream()
+{
+ // clear stream
+ memset(fOutStream,0,sizeof(ULong_t)*fStreamLen);
+}
+
+//_____________________________________________________________________________
+Bool_t AliITSOutStream::CheckCount(ULong_t count)
+{
+ //check boundaries
+ if (count < fStreamLen) return kTRUE;
+ else {
+ Error("CheckCount", "actual size is %d, the necessary size is %d",fStreamLen,count);
+ return kFALSE;
+ }
+}
+
+//____________________________________________________________________________
+void AliITSOutStream::Streamer(TBuffer &R__b){
+
+ // Stream an object of class AliITSOutStream.
+
+ static unsigned long *array;
+ static Bool_t make=kTRUE;
+
+ if (R__b.IsReading()) {
+ R__b >> fStreamLen;
+ //printf("Streamer: fStreamLen %d\n",fStreamLen);
+ if (make) array=new unsigned long[fStreamLen];
+ make=kFALSE;
+ memset(array,0,sizeof(ULong_t)*fStreamLen);
+ fOutStream=array;
+ R__b.ReadFastArray(fOutStream,fStreamLen);
+
+ } else {
+ R__b << fStreamLen;
+ R__b.WriteFastArray(fOutStream,fStreamLen);
+ }
+}
+
--- /dev/null
+#ifndef ALIITSRAWDATA_H
+#define ALIITSRAWDATA_H
+
+////////////////////////////////////////////////
+// RawData classes for set:ITS //
+////////////////////////////////////////////////
+
+#include <TObject.h>
+
+
+
+class AliITSRawData: public TObject {
+
+ // most probably it should have a class AliITSHeaderEvent as data member
+
+ public:
+ AliITSRawData() {
+ // constructor
+ }
+ virtual ~AliITSRawData() {
+ // destructor
+ }
+
+ ClassDef(AliITSRawData,1) //RawData object for set:ITS
+
+};
+
+//___________________________________________
+class AliITSInStream: public TObject{
+
+ public:
+ AliITSInStream();
+ AliITSInStream(ULong_t length);
+ virtual ~AliITSInStream();
+ AliITSInStream(const AliITSInStream &source); // copy constructor
+ AliITSInStream& operator=(const AliITSInStream &source); // ass. operator
+
+ void ClearStream();
+ Bool_t CheckCount(ULong_t count);
+ ULong_t StreamLength() {
+ // stream length
+ return fStreamLen;
+ }
+ UChar_t *Stream() {
+ // stream
+ return fInStream;
+ }
+
+protected:
+
+ // input stream of unsigned chars
+
+ ULong_t fStreamLen; // Length of the array
+ UChar_t *fInStream; // Pointer to an array of input unsigned chararacters
+
+
+
+ ClassDef(AliITSInStream,1) //Input Stream object for set:ITS
+ };
+
+//___________________________________________
+class AliITSOutStream: public TObject{
+
+public:
+ AliITSOutStream();
+
+ AliITSOutStream(ULong_t length);
+ virtual ~AliITSOutStream();
+ AliITSOutStream(const AliITSOutStream &source); // copy constructor
+ AliITSOutStream& operator=(const AliITSOutStream &source); // assignment operator
+
+ void ClearStream();
+ Bool_t CheckCount(ULong_t count);
+ ULong_t StreamLength() {
+ // stream length
+ return fStreamLen;
+ }
+ ULong_t *Stream() {
+ // stream
+ return fOutStream;
+ }
+
+protected:
+
+ // output stream of unsigned chars
+
+ ULong_t fStreamLen; // Length of the array
+ ULong_t *fOutStream; // Pointer to an array of unsigned long
+
+
+
+ ClassDef(AliITSOutStream,1) //Output Stream object for set:ITS
+};
+
+
+
+#endif
--- /dev/null
+#ifndef ALIITSRECPOINT_H
+#define ALIITSRECPOINT_H
+
+////////////////////////////////////////////////////
+// Reconstructed space point class for set:ITS //
+////////////////////////////////////////////////////
+
+#include <TObject.h>
+
+
+class AliITSRecPoint : public TObject {
+
+
+ public:
+
+ AliITSRecPoint() {
+ // default creator
+ fTracks[0]=fTracks[1]=fTracks[2]=-3;
+ fX=fZ=fQ=fdEdX=0.;
+ fSigmaX2=fSigmaZ2=0.;
+ fProbability=0;
+ }
+
+ virtual ~AliITSRecPoint() {}; // distructor
+ Bool_t IsSortable() const {return kTRUE;} // allows for sorting
+ Int_t * GetTracks() {return fTracks;} // returns pointer to tracks
+ Float_t GetX(){return fX;} // gets fX
+ Float_t GetZ(){return fZ;} // gets fZ
+ Float_t GetQ(){return fQ;} // gets fQ
+ Float_t GetdEdX(){return fdEdX;} // gets fdEdX
+ Float_t GetSigmaX2(){return fSigmaX2;} // gets fSigmaX2
+ Float_t GetSigmaZ2(){return fSigmaZ2;} // gets fSigmaZ2
+ Float_t GetProbability(){return fProbability;} // gets fProbability
+ void SetX(Float_t x){fX=x;} // sets fX
+ void SetZ(Float_t z){fZ=z;} // sets fZ
+ void SetQ(Float_t q){fQ=q;} // sets fQ
+ void SetdEdX(Float_t dedx){fdEdX=dedx;} // sets fdEdX
+ void SetSigmaX2(Float_t sx2){fSigmaX2=sx2;} // sets fSigmaX2
+ void SetSigmaZ2(Float_t sz2){fSigmaZ2=sz2;} // sets fSigmaZ2
+ void SetProbability(Float_t p){fProbability = p;} // sets fProbability
+ void Use() {
+ //if fQ<0 cluster is already associated with a track
+ fQ=-fQ;
+ }
+ Int_t IsUsed() const {return (fQ<0) ? 1 : 0;} // checks Use condision
+ Int_t Compare(TObject *o) {
+ //to be defined
+ return 0;
+ }
+
+ public:
+ Int_t fTracks[3]; //labels of overlapped tracks
+ Float_t fX ; //X of cluster
+ Float_t fZ ; //Z of cluster
+ Float_t fQ ; //Q of cluster (in ADC counts)
+ Float_t fdEdX; //dE/dX inside this cluster
+ Float_t fSigmaX2; //Sigma X square of cluster
+ Float_t fSigmaZ2; //Sigma Z square of cluster
+
+ Float_t fProbability; // only temporary solution! - The probability
+ // that this is a "real" point in SSD
+
+ ClassDef(AliITSRecPoint,1) // AliITSRecPoint class
+};
+
+#endif
+
+
+
--- /dev/null
+#include <iostream.h>
+
+#include "AliITSclusterSSD.h"
+
+ClassImp(AliITSclusterSSD)
+
+AliITSclusterSSD::AliITSclusterSSD()
+{
+ // default constructor
+ fSide = true;
+ fDigits = 0;
+ fNDigits = 0;
+ fDigitsIndex = 0;
+ fNCrosses = 0;
+ fTotalSignal = -1;
+ fNTrack = -1;
+ fLeftNeighbour = kFALSE;
+ fRightNeighbour = kFALSE;
+ fCrossedClusterIndexes = new TArrayI(300);
+ fConsumed=kFALSE;
+
+}
+/*************************************************************************/
+
+AliITSclusterSSD::AliITSclusterSSD
+ (Int_t ndigits, Int_t *DigitIndexes,
+ TObjArray *Digits, Bool_t side)
+{
+ // comment to be written
+ fNDigits = ndigits;
+ fDigits = Digits;
+ fSide = side;
+ fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
+ fNCrosses = 0;
+ fCrossedClusterIndexes = new TArrayI(300);
+ fLeftNeighbour = kFALSE;
+ fRightNeighbour = kFALSE;
+ fTotalSignal =-1;
+ fNTrack = -1;
+ fConsumed=kFALSE;
+}
+/*************************************************************************/
+AliITSclusterSSD::~AliITSclusterSSD()
+{
+ // destructor
+ delete fDigitsIndex;
+ delete fCrossedClusterIndexes;
+}
+
+/*************************************************************************/
+AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster)
+{
+ // copy constructor
+ if (this == &OneSCluster) return;
+ fNDigits = OneSCluster.fNDigits;
+ fSide=OneSCluster.fSide;
+ fDigits=OneSCluster.fDigits;
+ fDigitsIndex = new TArrayI(fNDigits);
+ fLeftNeighbour = OneSCluster.fLeftNeighbour;
+ fRightNeighbour = OneSCluster.fRightNeighbour;
+ fTotalSignal =-1;
+ fNTrack = -1;
+ fNCrosses = OneSCluster.fNCrosses;
+ fConsumed = OneSCluster.fConsumed;
+ Int_t i;
+ for(i = 0; i< fNCrosses ; i++)
+ {
+ fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
+ }
+ for(i = 0; i< fNDigits ; i++)
+ {
+ fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
+ }
+ return;
+}
+
+/*************************************************************************/
+AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD & OneSCluster)
+{
+ // assignment operator
+ if (this == &OneSCluster) return *this;
+ fNDigits = OneSCluster.fNDigits;
+ fSide=OneSCluster.fSide;
+ fDigits=OneSCluster.fDigits;
+ fDigitsIndex = new TArrayI(fNDigits);
+ fLeftNeighbour = OneSCluster.fLeftNeighbour;
+ fRightNeighbour = OneSCluster.fRightNeighbour;
+ fTotalSignal =-1;
+ fNTrack = -1;
+ fNCrosses = OneSCluster.fNCrosses;
+ fConsumed = OneSCluster.fConsumed;
+ Int_t i;
+ for(i = 0; i< fNCrosses ; i++)
+ {
+ fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
+ }
+ for(i = 0; i< fNDigits ; i++)
+ {
+ fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
+ }
+ return *this;
+}
+
+/*************************************************************************/
+Int_t AliITSclusterSSD::SplitCluster(Int_t where, Int_t *outdigits)
+{
+//This methods generate data necessery to make new object of this class
+//I choosen this way, because methods TClonesArray::Add* dont work
+//so I have to use constraction: new (a[i]) Creator(params...);
+//where 'a' is a TClonesArray
+//This method generate params - see AliITSmoduleSSD::SplitCluster;
+
+
+ Int_t tmp = fNDigits;
+ Int_t ind = 0;
+ outdigits[ind++]=(*fDigitsIndex)[where];
+ //coping border strip (it is shared by this two clusters)
+ Int_t i;
+ for(i = (where+1); i < tmp; i++)
+ {
+ outdigits[ind++]=(*fDigitsIndex)[i]; //"moving" strips from this to the new one
+ (*fDigitsIndex)[i]=-1;
+ fNDigits--; //deleting strips from this cluster
+ }
+ return ind;
+}
+
+/*******************************************************************/
+Int_t AliITSclusterSSD::GetDigitStripNo(Int_t digit)
+{
+ // comment to be written
+ if (digit<0) return -1;
+ return (digit>(fNDigits-1))?-1 :
+ ((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndex)[digit]]))->GetStripNumber();
+}
+/************************************************************/
+Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit)
+{
+ Int_t index,signal;
+ // returns digit signal
+ if (digit<0||digit>=fNDigits) return -1;
+ index = (*fDigitsIndex)[digit];
+ signal = ((AliITSdigitSSD*)((*fDigits)[index]))->GetSignal();
+ /*
+ if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
+ digit,index, signal);
+ */
+ return signal;
+}
+
+/***********************************************************/
+void AliITSclusterSSD::AddCross(Int_t clIndex)
+{
+ // comment to be written
+ (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
+}
+/***********************************************************/
+
+Int_t AliITSclusterSSD::GetCross(Int_t crIndex)
+{
+ // comment to be written
+ return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
+}
+/***********************************************************/
+Double_t AliITSclusterSSD::CentrOfGravity()
+{
+ // comment to be written
+ Float_t ret=0;
+
+ if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0));
+ else ret+=(GetDigitStripNo(0)*GetDigitSignal(0));
+
+ if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1));
+ else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1));
+ Int_t i;
+ for(i=1;i<fNDigits-1;i++)
+ {
+ ret +=GetDigitStripNo(i)*GetDigitSignal(i);
+ }
+
+ if (fTotalSignal<0) GetTotalSignal();
+
+ return (ret/fTotalSignal);
+}
+
+/***********************************************************/
+Float_t AliITSclusterSSD::GetTotalSignal()
+{
+ // comment to be written
+ if(fTotalSignal <0)
+ {
+ fTotalSignal=0;
+ if (fNDigits ==1) {
+ fTotalSignal = (Float_t)GetDigitSignal(0);
+ //printf("1 digit: signal %d \n",GetDigitSignal(0));
+ return fTotalSignal;
+ }
+
+ if (fLeftNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(0));
+ else fTotalSignal += (Float_t) GetDigitSignal(0);
+ //printf("GetTotalSignal :i DigitSignal %d %d \n",0,GetDigitSignal(0));
+
+ if (fRightNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(fNDigits -1));
+ else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
+ //printf("GetTotalSignal :i DigitSignal %d %d \n",fNDigits -1,GetDigitSignal(fNDigits -1));
+ Int_t i;
+ for(i = 1;i<fNDigits -1;i++)
+ {
+ fTotalSignal += (Float_t)GetDigitSignal(i);
+ //printf("GetTotalSignal :i DigitSignal %d %d \n",i,GetDigitSignal(i));
+ }
+ //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
+ }
+ return fTotalSignal;
+}
+/***********************************************************/
+
+Float_t AliITSclusterSSD::GetTotalSignalError()
+{
+ // comment to be written
+ Float_t err =0;
+ Int_t i;
+ for(i =1; i<fNDigits -1; i++)
+ {
+ err+=0.1*GetDigitSignal(i);
+ }
+ if (GetLeftNeighbour())
+ {
+ err+=GetDigitSignal(0);
+ }
+ else
+ {
+ err+=0.1*GetDigitSignal(0);
+ }
+ if (GetRightNeighbour())
+ {
+ err+=GetDigitSignal(fNDigits -1);
+ }
+ else
+ {
+ err+=0.1*GetDigitSignal(fNDigits -1);
+ }
+ return err;
+
+}
+
+/***********************************************************/
+
+void AliITSclusterSSD::DelCross(Int_t index)
+{
+ // comment to be written
+Int_t i,j; //iterators
+
+for(i =0;i<fNCrosses;i++)
+ {
+ if ((*fCrossedClusterIndexes)[i] == index)
+ {
+ for(j=i;j<fNCrosses-1;j++)
+ {
+ (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1];
+ }
+ fNCrosses--;
+ return;
+ }
+ }
+
+}
+/***********************************************************/
+
+Int_t *AliITSclusterSSD::GetTracks(Int_t &nt)
+{
+ // comment to be written
+ Int_t *tidx=0;
+ Int_t i, bit;
+ nt=0;
+
+
+
+ fNTrack =0;
+ for(i=0;i<10;i++)
+ {
+ fTrack[i] = 0;
+ }
+
+ tidx=GetDigit(0)->GetTracks();
+
+ for(i = 0; i<3;i++)
+ {
+ fTrack[i]=tidx[i];
+ if (fTrack[i] != 0) fNTrack++;
+ }
+ for(i = 1; i<fNDigits; i++)
+ {
+ tidx=GetDigit(i)->GetTracks();
+ Int_t j;
+ for(j = 0; j<3;j++)
+ {
+ bit = 1;
+ if (tidx[j]==0) break;
+ Int_t k;
+ for(k = 0; k < fNTrack;k++)
+ {
+ if (tidx[j]==fTrack[k]) bit =0;
+ }
+ if (bit) fTrack[fNTrack++]=tidx[j];
+ }
+ }
+
+
+ if (fNTrack > 10)
+ {
+ cout<<"\n\n Error AliITSclusterSSD::GetTracks OUT "<<fNDigits<<" "<<fNTrack<<"\n\n\n\n\n";
+
+ }
+
+
+ nt = fNTrack;
+ if(!nt) return 0;
+ return &(fTrack[0]);
+}
+/***********************************************************/
+
+Double_t AliITSclusterSSD::GetPosition()
+{
+ // comment to be written
+ Float_t ret;
+ switch(fNDigits)
+ {
+ case 1:
+ ret = GetDigitStripNo(0);
+ break;
+ case 2:
+ ret = EtaAlgorithm();
+ break;
+ default:
+ ret = CentrOfGravity();
+ }
+ return ret;
+}
+
+/***********************************************************/
+
+Double_t AliITSclusterSSD::EtaAlgorithm()
+{
+ // comment to be written
+ if (fNDigits != 2) return -1;
+
+ Int_t strip1 = GetDigit(0)->GetStripNumber();
+ Int_t strip2 = GetDigit(1)->GetStripNumber();
+ Int_t signal1 = GetDigit(0)->GetSignal();
+ Int_t signal2 = GetDigit(1)->GetSignal();
+
+ Double_t eta;
+
+
+ if (strip1<strip2)
+ {
+ eta = ((Double_t)signal2)/((Double_t)(signal1+signal2));
+ if (eta<0.04) return strip1;
+ if (eta>0.96) return strip2;
+ return (strip1 + 0.43478261*eta + 0.2826087);
+ }
+ else
+ {
+ eta = ((Double_t)signal1)/((Double_t)(signal1+signal2));
+ if (eta<0.04) return strip2;
+ if (eta>0.96) return strip1;
+ return (strip2 + 0.43478261*eta + 0.2826087);
+ }
+
+
+}
+
+Double_t AliITSclusterSSD::GetPositionError()
+{
+ // comment to be written
+ return (GetNumOfDigits()+1)/2;
+}
+
+Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx)
+{
+ // comment to be written
+ Int_t i;
+ for(i =0; i< fNCrosses;i++)
+ {
+ if (GetCross(i) == idx) return kTRUE;
+ }
+ return kFALSE;
+}
--- /dev/null
+#ifndef ALIITSCLUSTERSSD_H
+#define ALIITSCLUSTERSSD_H
+
+#include "TObject.h"
+#include "TArrayI.h"
+#include "AliITSdigit.h"
+#include "TClonesArray.h"
+
+
+class AliITSclusterSSD : public TObject
+{
+
+
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+//
+// Describes set of neighbouring digits on one side of detector,
+// that are supposed to be generated by one particle.
+// includes information about clusters on other side that it crosses with
+
+public:
+
+ AliITSclusterSSD(); //Default Constructor
+ ~AliITSclusterSSD();
+ AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes, TObjArray *Digits, Bool_t side);
+ AliITSclusterSSD(const AliITSclusterSSD &source);
+ AliITSclusterSSD& operator=( const AliITSclusterSSD & source);
+
+ void AddDigit(Int_t index){
+ // //adds on digit
+ (*fDigitsIndex)[fNDigits++]=index;
+ }
+ TObjArray* GetPointer2Digits(){
+ // comment to be written
+ return fDigits;
+ }
+
+// TArrayI* GetDigitsIndexes(Int_t &ndigits);
+// void SetDigitIndex(Int_t index);
+
+ void SetPointer2Digits(TObjArray *digits){
+ // comment to be written
+ fDigits = digits;
+ }
+ Int_t GetNumOfDigits(){
+ //Returns number of digits that creates this cluster
+ return fNDigits;
+ }
+ Int_t GetDigitSignal(Int_t digit);
+
+
+ AliITSdigitSSD *GetDigit(Int_t idx) {
+ // comment to be written
+ return (AliITSdigitSSD *)((*fDigits)[GetDigitIndex(idx)]);
+ }
+ Int_t GetDigitIndex (Int_t digit) {
+ // comment to be written
+ return (*fDigitsIndex)[digit];
+ }
+ Int_t GetDigitStripNo(Int_t digit);
+ Int_t GetFirstDigitStripNo(){
+ // comment to be written
+ return GetDigitStripNo(0);
+ }
+ Int_t GetLastDigitStripNo(){
+ // comment to be written
+ return GetDigitStripNo(fNDigits-1);
+ }
+ Int_t SplitCluster(Int_t where,Int_t *outdigits); //splits this one side cluster for two
+ void AddCross(Int_t clIndex); //Add index of cluster that it crosses with
+ Int_t GetCross(Int_t crIndex); //return index of cluster that it crosses with
+ Int_t GetCrossNo() {
+ // Returns number of crosses
+ return fNCrosses;
+ }
+ void DelCross(Int_t index);
+
+ Double_t GetPosition();
+ Double_t GetPositionError();
+ Float_t GetTotalSignal();
+ Float_t GetTotalSignalError();
+ void CutTotalSignal(Float_t sx) {
+ // comment to be written
+ if (fTotalSignal>sx) fTotalSignal-=sx;
+ }
+
+ Bool_t GetRightNeighbour() const {
+ // comment to be written
+ return fRightNeighbour;
+ }
+ Bool_t GetLeftNeighbour() const {
+ // comment to be written
+ return fLeftNeighbour;
+ }
+ void SetRightNeighbour(Bool_t nei) {
+ // comment to be written
+ fRightNeighbour=nei;
+ }
+ void SetLeftNeighbour(Bool_t nei) {
+ // comment to be written
+ fLeftNeighbour=nei;
+ }
+ Bool_t GetSide(){
+ // comment to be written
+ return fSide;
+ }
+ Int_t CheckSatus(Int_t *tracks){
+ //check if digits comes from the same track
+ return 0;
+ }
+ Int_t *GetTracks(Int_t &nt);
+ void Consume(){
+ // comment
+ fConsumed = kTRUE;
+ }
+ Bool_t IsConsumed() const{
+ // comment
+ return fConsumed;
+ }
+ Bool_t IsCrossingWith(Int_t idx);
+
+protected:
+
+ Bool_t fSide; //True if P
+ TObjArray *fDigits; //Pointer to List of Digitsbelonging to AliITS
+
+ Int_t fNDigits; //Number of digits that make up that cluster
+ TArrayI *fDigitsIndex; // Digit indexes in fDigits array
+
+ Int_t fNCrosses; //Number of crossed one side clusters on the other siede
+ // (max 8 : it is not aribtrary)
+ TArrayI *fCrossedClusterIndexes; //Array of inedexes of crossed clusters (in TClonesArray)
+ // not in TArrayI in package
+
+ Bool_t fLeftNeighbour; // comment to be written
+ Bool_t fRightNeighbour; // comment to be written
+ Bool_t fConsumed; // comment to be written
+
+ Float_t fTotalSignal; // comment to be written
+ Int_t fTrack[10]; // comment to be written
+ Int_t fNTrack; // comment to be written
+
+ Double_t CentrOfGravity();
+ Double_t EtaAlgorithm();
+
+private:
+
+/*************************************/
+/*************************************/
+ ClassDef(AliITSclusterSSD,1)
+};
+
+#endif
--- /dev/null
+
+#include "AliITSdcsSSD.h"
+#include "AliITSresponseSSD.h"
+#include "AliITSsegmentationSSD.h"
+
+ClassImp(AliITSdcsSSD)
+
+
+//_____________________________________________________________________
+//
+// Constructor and Destructor
+//_____________________________________________________________________
+
+
+AliITSdcsSSD::AliITSdcsSSD(AliITSsegmentation *seg, AliITSresponse *resp)
+{
+ // constructor
+
+ fRandom = new TRandom();
+
+ fNstrips = seg->Npx();
+
+ fInvalidP = new TArrayS();
+ fInvalidN = new TArrayS();
+
+ Int_t npar=resp->NDetParam();
+ if (npar < 6) {
+ Warning("AliITSdcsSSD","I need 6 parameters ");
+ npar=6;
+ }
+
+ Float_t detpar[npar];
+ resp->GetDetParam(detpar);
+
+ fNInvalid = detpar[0];
+ fISigma = detpar[1];
+
+ fCouplingPR = detpar[2];
+ fCouplingPL = detpar[3];
+ fCouplingNR = detpar[4];
+ fCouplingNL = detpar[5];
+
+
+ Option_t *opt,*dummy;
+ resp->ParamOptions(opt,dummy);
+ if (strstr(opt,"SetInvalid")) SetInvalidMC(fNInvalid,fISigma);
+
+}
+
+//_____________________________________________________________________
+
+
+AliITSdcsSSD::~AliITSdcsSSD() {
+ // destructor
+ delete fInvalidP;
+ delete fInvalidN;
+}
+
+//__________________________________________________________________________
+AliITSdcsSSD::AliITSdcsSSD(const AliITSdcsSSD &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fCouplingPR = source.fCouplingPR;
+ this->fCouplingPL = source.fCouplingPL;
+ this->fCouplingNR = source.fCouplingNR;
+ this->fCouplingNL = source.fCouplingNL;
+ this->fNstrips = source.fNstrips;
+ this->fNInvalid = source.fNInvalid;
+ this->fISigma = source.fISigma;
+ this->fInvalidP = source.fInvalidP;
+ this->fInvalidN = source.fInvalidN;
+ this->fRandom = source.fRandom;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSdcsSSD&
+ AliITSdcsSSD::operator=(const AliITSdcsSSD &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fCouplingPR = source.fCouplingPR;
+ this->fCouplingPL = source.fCouplingPL;
+ this->fCouplingNR = source.fCouplingNR;
+ this->fCouplingNL = source.fCouplingNL;
+ this->fNstrips = source.fNstrips;
+ this->fNInvalid = source.fNInvalid;
+ this->fISigma = source.fISigma;
+ this->fInvalidP = source.fInvalidP;
+ this->fInvalidN = source.fInvalidN;
+ this->fRandom = source.fRandom;
+ return *this;
+}
+
+//_____________________________________________________________________
+//
+// Methods for creating invalid strips
+//_____________________________________________________________________
+//
+
+
+void AliITSdcsSSD::SetInvalidMC(Float_t mean, Float_t sigma) {
+ // set invalid MC
+ SetInvalidParam(mean, sigma);
+ SetInvalidMC();
+}
+
+//_____________________________________________________________________
+
+void AliITSdcsSSD::SetInvalidMC() {
+ // set invalid MC
+ Int_t pside;
+ Int_t nside;
+ Int_t i;
+ Int_t strip;
+
+ pside = (Int_t)fRandom->Gaus(fNInvalid, fISigma);
+ nside = (Int_t)fRandom->Gaus(fNInvalid, fISigma);
+
+ fInvalidP->Set(pside);
+ fInvalidN->Set(nside);
+
+ for(i=0 ;i<pside; i++) {
+ strip = (Int_t)(fRandom->Rndm() * fNstrips);
+ fInvalidP->AddAt(strip, i);
+ }
+
+ for(i=0 ;i<nside; i++) {
+ strip = (Int_t)(fRandom->Rndm() * fNstrips);
+ fInvalidN->AddAt(strip, i);
+ }
+}
+
+//_____________________________________________________________________
+
+
+void AliITSdcsSSD::SetInvalidParam(Float_t mean, Float_t sigma) {
+ // set invalid param
+ fNInvalid = mean;
+ fISigma = sigma;
+
+ fNInvalid = (fNInvalid<0)? 0 : fNInvalid;
+ fNInvalid = (fNInvalid>fNstrips)? fNstrips: fNInvalid;
+
+ fISigma = (fISigma < 0)? 0 : fISigma;
+ fISigma = (fISigma > fNstrips/10) ? fNstrips/10 : fISigma;
+}
+
+
+//_____________________________________________________________________
+
+
+void AliITSdcsSSD::GetInvalidParam(Float_t &mean, Float_t &sigma) {
+ // get invalid param
+ mean = fNInvalid;
+ sigma = fISigma;
+
+}
+
+
+//_____________________________________________________________________
+//
+// Methods for accessing to invalid strips
+//_____________________________________________________________________
+//
+
+
+Bool_t AliITSdcsSSD::IsValidP(Int_t strip) {
+ // isvalidP
+ Int_t nElem = fInvalidP->GetSize();
+ Int_t i;
+ for(i = 0; i<nElem; i++)
+ if(fInvalidP->At(i) == strip) return kFALSE;
+ return kTRUE;
+}
+
+//_____________________________________________________________________
+
+Bool_t AliITSdcsSSD::IsValidN(Int_t strip) {
+ // is valid N
+ Int_t nElem = fInvalidN->GetSize();
+ Int_t i;
+ for(i = 0; i<nElem; i++)
+ if(fInvalidN->At(i) == strip) return kFALSE;
+ return kTRUE;
+}
+
+//_____________________________________________________________________
+
+
+TArrayS* AliITSdcsSSD::GetInvalidP() {
+ // get invalid P
+ return fInvalidP;
+}
+
+TArrayS* AliITSdcsSSD::GetInvalidN() {
+ // get invalid N
+ return fInvalidN;
+}
+
+Int_t AliITSdcsSSD::GetNInvalidP(){
+ // get numeber of invalid P
+ return fInvalidP->GetSize();
+}
+
+Int_t AliITSdcsSSD::GetNInvalidN() {
+ // // get number of invalid N
+ return fInvalidN->GetSize();
+}
+
+//_____________________________________________________________________
+
+
+
+
+
+
+
--- /dev/null
+#ifndef ALIITSDCSSSD_H
+#define ALIITSDCSSSD_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+#include <TObject.h>
+#include <TArrayS.h>
+#include <TRandom.h>
+
+//____________________________________________________________________
+//
+// Class AliITSdcsSSD
+// describes Detector Control System parameters for one SSD module.
+//
+// This class stores parametrers such as gain, threshold
+// capacitive coupling.
+//
+// Class takes care of invalid strip menagement during
+// simulation and runtime
+//
+//
+// created at: Warsaw University of Technology
+// ver. 1.0 WARSAW, 23.12.1999
+//
+//___________________________________________________________________
+//
+
+
+class AliITSsegmentation;
+class AliITSresponse;
+
+
+class AliITSdcsSSD: public TObject {
+
+public:
+
+ //________________________________________________________________
+ //
+ // Constructors and deconstructor
+ //________________________________________________________________
+ //
+
+ AliITSdcsSSD(AliITSsegmentation *s, AliITSresponse *r);
+ ~AliITSdcsSSD();
+ AliITSdcsSSD(const AliITSdcsSSD &source); // copy constructor
+ AliITSdcsSSD& operator=(const AliITSdcsSSD &source); // assignment operator
+
+ //________________________________________________________________
+ //
+ // Invalid strips management methods
+ //________________________________________________________________
+ //
+
+ // Parameters for invalid strips MonteCarlo
+
+ void SetInvalidParam(Float_t mean, Float_t sigma);
+ void GetInvalidParam(Float_t &mean, Float_t &sigma);
+
+
+ // Methods for creating invalid strips
+
+ void SetInvalidMC(Float_t mean, Float_t sigma);
+ void SetInvalidMC();
+
+
+ // Testing if strip is valid
+
+ Bool_t IsValidN(Int_t strip); //True if strip works properly
+ Bool_t IsValidP(Int_t strip); //True if strip works properly
+
+
+ // Access to invalid strips
+
+ TArrayS *GetInvalidP(); //Array of invalid P strips
+ TArrayS *GetInvalidN(); //Array of invalid N strips
+ Int_t GetNInvalidP(); //Number of invalid P strips
+ Int_t GetNInvalidN(); //Number of invalid N strips
+
+
+ // Creating invalid strips
+
+ void SetInvalidP(Int_t strip, Bool_t side){
+ //Set invalid if true
+ }
+
+ void SetInvalidN(Int_t strip, Bool_t side){
+ //Set invalid if true
+ }
+
+ Float_t GetCouplingPR() {
+ // couplings
+ return fCouplingPR;
+ }
+
+ Float_t GetCouplingPL() {
+ // couplings
+ return fCouplingPL;
+ }
+
+ Float_t GetCouplingNR() {
+ // couplings
+ return fCouplingNR;
+ }
+
+ Float_t GetCouplingNL() {
+ // couplings
+ return fCouplingNL;
+ }
+
+ protected:
+
+ //_____________________________________________
+ //
+ // Parameters for invalid strips simulatation
+ //_____________________________________________
+
+ Float_t fCouplingPR; // couplings
+ Float_t fCouplingPL; // couplings
+ Float_t fCouplingNR; // couplings
+ Float_t fCouplingNL; // couplings
+
+ Float_t fNstrips ; //Number of strips
+ Float_t fNInvalid; //Mean number of invalid strips (for simulation)
+ Float_t fISigma; //RMS of invalid strips (Gaussian)
+
+ TArrayS *fInvalidP; //Array of invalid strips on P-side
+ TArrayS *fInvalidN; //Array of invalid strips on N-side
+
+ TRandom *fRandom; //!Random numbers generator
+
+ ClassDef(AliITSdcsSSD, 1) // ITS SSD DCS specific class
+
+};
+
+
+#endif
--- /dev/null
+
+#include <stdio.h>
+#include <TObjArray.h>
+
+#include "AliITSsegmentationSSD.h"
+#include "AliITSresponseSSD.h"
+#include "AliITSsimulationSSD.h"
+#include "AliITSdictSSD.h"
+#include "AliITSdcsSSD.h"
+#include "AliITS.h"
+#include "AliRun.h"
+
+
+void AliITSdictSSD::AddTrack(Int_t track) {
+ // add track
+ if (fTracks > 9) return;
+ Int_t exist = 0,i;
+
+ for(i=0; i<10; i++)
+ {
+ if(track == fTrack[i])
+ {
+ exist = 1;
+ }
+
+ }
+ if (!exist)
+ {
+ fTrack[fTracks++] = track;
+ }
+
+}
+
+
+Int_t AliITSdictSSD::GetTrack(Int_t index) {
+ // get track
+ if(index > fTracks) return 0;
+ else return fTrack[index];
+}
+
+
+//****************************************************************************
--- /dev/null
+#ifndef ALIITSDICTSSD_H
+#define ALIITSDICTSSD_H
+
+#include <TArrayF.h>
+
+#include "AliITSdcsSSD.h"
+
+class AliITSdcsSSD;
+
+class AliITSdictSSD {
+
+public:
+
+ AliITSdictSSD() {
+ // constructor
+ fTracks = 0;
+ }
+ ~AliITSdictSSD() {
+ // destructor
+ };
+
+ void AddTrack(Int_t track);
+ Int_t GetTrack(Int_t index);
+ Int_t GetNTracks() {
+ // get num of tracks
+ return fTracks;
+ }
+ void ZeroTracks() {
+ // zero tracks
+ for (Int_t i =0;i<10;i++) fTrack[i]=0; fTracks = 0;
+ }
+
+private:
+ Int_t fTrack[10]; // Track array
+ Int_t fTracks; // Tracks
+};
+
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+/*
+$Log$
+Revision 1.1.2.2 2000/06/12 18:09:36 barbera
+fixed posible compilation errors on HP unix
+
+Revision 1.1.2.1 2000/01/12 20:21:30 nilsen
+missed AliITSetfSDD files ealier
+
+$Name$
+$Author$
+$Id$
+*/
+
+#include <iostream.h>
+#include <TMath.h>
+#include "AliITSetfSDD.h"
+
+////////////////////////////////////////////////////////////////////////
+// Version: 0
+// Written by Piergiorgio Cerello
+// November 23 1999
+//
+// AliITSmapSDD is the map of SDDs.
+//
+//Begin_Html
+/*
+<img src="picts/ITS/AliITShit_Class_Diagram.gif">
+</pre>
+<br clear=left>
+<font size=+2 color=red>
+<p>This show the relasionships between the ITS hit class and the rest of Aliroot.
+</font>
+<pre>
+*/
+//End_Htm
+//extern Int_t power(Int_t b, Int_t e);
+
+//_____________________________________________________________________________
+ClassImp(AliITSetfSDD)
+
+Int_t ppower(Int_t b, Int_t e) {
+ Int_t power = 1,i;
+ for(i=0; i<e; i++) power *= b;
+ return power;
+}
+
+AliITSetfSDD::AliITSetfSDD(Double_t timeclock)
+{
+ // sampling time in ns
+ fSamplingTime = 1000./timeclock;
+ fT0 = 0.;
+ fDf = ppower(10,9)/(fMaxNofSamples*fSamplingTime);
+ fA0 = 9000.;
+
+ Int_t i,j,k;
+ for(i=0; i<fMaxNofPoles; i++) {
+ fZero_M[i] = 0.;
+ fZero_R[i] = 0.;
+ fZero_I[i] = 0.;
+ fPole_M[i] = 0.;
+ fPole_R[i] = 0.;
+ fPole_I[i] = 0.;
+ }
+ fPole_M[0] = 1.;
+ fPole_R[0] = -2100000.;
+ fPole_I[0] = fPole_R[0];
+ fPole_M[1] = 1.;
+ fPole_R[1] = -2100000.;
+ fPole_I[1] = -fPole_R[1];
+
+ // Compute Transfer Function
+
+ Double_t PI = acos(-1.);
+ for(i=0; i<=fMaxNofSamples/2; i++) {
+ Double_t frequency = fDf*i;
+ Double_t VM = fA0;
+ Double_t VA = 0.;
+ for(k=0; k<fMaxNofPoles; k++) {
+ if(fZero_M[k]) {
+ Double_t VZR = -fZero_R[k];
+ Double_t VZI = frequency - fZero_I[k];
+ Double_t VZM = TMath::Sqrt(VZR*VZR+VZI*VZI);
+ Double_t VZA = TMath::ATan2(VZI,VZR);
+ // cout << "VZM: " << VZM << ", VZA: " << VZA << endl;
+ // cout << "VZR: " << VZR << ", VZI: " << VZI << endl;
+ for(j=1; j<= (Int_t) fZero_M[k]; j++) {
+ VM *= VZM;
+ VA += VZA;
+ if(VA >= PI) VA -= (2.*PI);
+ if(VA <= -PI) VA += (2.*PI);
+ //cout << "VM: " << VM << ", VA: " << VA << endl;
+ }
+ }
+
+ if(fPole_M[k]) {
+ Double_t VPR = -fPole_R[k];
+ Double_t VPI = frequency - fPole_I[k];
+ Double_t VPM = TMath::Sqrt(VPR*VPR+VPI*VPI);
+ Double_t VPA = TMath::ATan2(VPI,VPR);
+ //cout << "VPM: " << VPM << ", VPA: " << VPA << endl;
+ //cout << "VPR: " << VPR << ", VPI: " << VPI << endl;
+ for(j=1; j<= (Int_t) fPole_M[k]; j++) {
+ VM /= VPM;
+ VA -= VPA;
+ if(VA >= PI) VA -= (2.*PI);
+ if(VA <= -PI) VA += (2.*PI);
+ //cout << "VM: " << VM << ", VA: " << VA << endl;
+ }
+ }
+ Double_t VR = VM*cos(VA);
+ Double_t VI = VM*sin(VA);
+ //cout << "VM: " << VM << ", VA: " << VA << endl;
+ //cout << "VR: " << VR << ", VI: " << VI << endl;
+ fTf_R[i] = VR*ppower(10,9);
+ fTf_I[i] = VI*ppower(10,9);
+ //cout << "fTf_R[" << i << "] = " << fTf_R[i] << endl;
+ //cout << "fTf_I[" << i << "] = " << fTf_I[i] << endl;
+ if(i) {
+ fTf_R[fMaxNofSamples-i] = fTf_R[i];
+ fTf_I[fMaxNofSamples-i] = -fTf_I[i];
+ }
+ }
+ }
+
+ // Compute Fourier Weights
+
+ for(i=0; i<=fMaxNofSamples/2; i++) {
+ fW_R[i] = cos(-2.*PI*i/fMaxNofSamples);
+ fW_I[i] = sin(-2.*PI*i/fMaxNofSamples);
+ if(i) {
+ fW_R[fMaxNofSamples-i] = fW_R[i];
+ fW_I[fMaxNofSamples-i] = -fW_I[i];
+ }
+ }
+
+}
+
+void AliITSetfSDD::Print()
+{
+ Int_t i;
+ cout << "Sampling Time " << fSamplingTime << endl;
+ cout << "Number of Time Samples " << fMaxNofSamples << endl;
+ cout << "fT0 " << fT0 << endl;
+ cout << "fDf " << fDf << endl;
+ cout << "fA0 " << fA0 << endl;
+
+ cout << "Zero's and Pole's" << endl;
+ cout << "fZero_M " << endl;
+ for(i=0; i<fMaxNofPoles; i++) cout << fZero_M[i] << endl;
+ cout << "fZero_R " << endl;
+ for(i=0; i<fMaxNofPoles; i++) cout << fZero_R[i] << endl;
+ cout << "fZero_I " << endl;
+ for(i=0; i<fMaxNofPoles; i++) cout << fZero_I[i] << endl;
+ cout << "fPole_M " << endl;
+ for(i=0; i<fMaxNofPoles; i++) cout << fPole_M[i] << endl;
+ cout << "fPole_R " << endl;
+ for(i=0; i<fMaxNofPoles; i++) cout << fPole_R[i] << endl;
+ cout << "fPole_I " << endl;
+ for(i=0; i<fMaxNofPoles; i++) cout << fPole_I[i] << endl;
+
+ cout << "Transfer function" << endl;
+ cout << "Real Part" << endl;
+ for(i=0; i<fMaxNofSamples; i++) cout << fTf_R[i] << endl;
+ cout << "Imaginary Part " << endl;
+ for(i=0; i<fMaxNofSamples; i++) cout << fTf_I[i] << endl;
+
+ cout << "Fourier Weights" << endl;
+ cout << "Real Part" << endl;
+ for(i=0; i<fMaxNofSamples; i++) cout << fW_R[i] << endl;
+ cout << "Imaginary Part " << endl;
+ for(i=0; i<fMaxNofSamples; i++) cout << fW_I[i] << endl;
+}
+
+
+
+
+
+
+
+
--- /dev/null
+#ifndef ITSETFSDD_H
+#define ITSETFSDD_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+#include <TObject.h>
+
+class AliITSetfSDD : public TObject {
+
+////////////////////////////////////////////////////////////////////////
+// Version: 0
+// Written by Piergiorgio Cerello
+// November 24 1999
+//
+// AliITSetfSDD is the class describing the electronics for the ITS SDDs.
+//
+// Data members:
+//
+////////////////////////////////////////////////////////////////////////
+
+ private:
+
+ Double_t fSamplingTime; //
+ Double_t fT0; //
+ Double_t fDf; //
+ Double_t fA0; //
+ static const Int_t fMaxNofPoles = 5;
+ Double_t fZero_M[fMaxNofPoles]; //
+ Double_t fZero_R[fMaxNofPoles]; //
+ Double_t fZero_I[fMaxNofPoles]; //
+ Double_t fPole_M[fMaxNofPoles]; //
+ Double_t fPole_R[fMaxNofPoles]; //
+ Double_t fPole_I[fMaxNofPoles]; //
+ static const Int_t fMaxNofSamples = 256;
+ Double_t fTf_R[fMaxNofSamples]; // Transfer function (real part)
+ Double_t fTf_I[fMaxNofSamples]; // Transfer function (imaginary part)
+ Double_t fW_R[fMaxNofSamples]; // Fourier Weights (real part)
+ Double_t fW_I[fMaxNofSamples]; // Fourier Weights (imaginary part)
+
+ public:
+
+ AliITSetfSDD() {}; // default constructor
+ AliITSetfSDD(Double_t);
+ ~AliITSetfSDD() {;}
+ Double_t GetWeightReal(Int_t n) { return fW_R[n]; }
+ Double_t GetWeightImag(Int_t n) { return fW_I[n]; }
+ Double_t GetTraFunReal(Int_t n) { return fTf_R[n]; }
+ Double_t GetTraFunImag(Int_t n) { return fTf_I[n]; }
+ Int_t GetSamples() { return fMaxNofSamples; }
+ void Print(); // Print Electronics parameters
+
+ friend class AliITSmapSDD;
+ ClassDef(AliITSetfSDD,1) // Class for SDD electornics
+ };
+
+#endif
+
+
--- /dev/null
+#include "AliITSpackageSSD.h"
+//************************************************
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+//
+
+const Int_t debug=0;
+
+ClassImp(AliITSpackageSSD)
+
+AliITSpackageSSD::AliITSpackageSSD()
+{
+ fNclustersN=0;
+ fClusterNIndexes = new TArrayI(300);
+
+ fNclustersP=0;
+ fClusterPIndexes = new TArrayI(300);
+ if (debug) cout<<"Default Ctor was used\n>>>>>>>>>>>>>><<<<<<<<<<<<<";
+}
+
+
+/*******************************************************/
+
+AliITSpackageSSD::AliITSpackageSSD
+ (TClonesArray *clustersP, TClonesArray *clustersN)
+{
+ fClustersP=clustersP;
+ fClustersN=clustersN;
+
+ fNclustersN=0;
+ fClusterNIndexes = new TArrayI(300);
+
+ fNclustersP=0;
+ fClusterPIndexes = new TArrayI(300);
+}
+
+/*******************************************************/
+
+
+AliITSpackageSSD::AliITSpackageSSD
+ ( Int_t len, TClonesArray *clustersP, TClonesArray *clustersN)
+
+{
+ fClustersP=clustersP;
+ fClustersN=clustersN;
+
+ fNclustersN=0;
+ fClusterNIndexes = new TArrayI(len);
+
+ fNclustersP=0;
+ fClusterPIndexes = new TArrayI(len);
+}
+
+
+/*******************************************************/
+
+AliITSpackageSSD::~AliITSpackageSSD()
+{
+ // destructor
+ delete fClusterNIndexes;
+ delete fClusterPIndexes;
+}
+/*******************************************************/
+
+AliITSpackageSSD::AliITSpackageSSD(const AliITSpackageSSD &package)
+{
+ // copy constractor
+ Int_t i; //iterator
+
+ if (this == &package) return;
+ fClustersN = package.fClustersN;
+ fClustersP = package.fClustersP;
+
+ fNclustersN= package.fNclustersN;
+ fNclustersP= package.fNclustersP;
+
+ for(i =0; i<fNclustersN;i++)
+ {
+ fClusterNIndexes[i]= package.fClusterNIndexes[i];
+ }
+
+ for(i =0; i<fNclustersP;i++)
+ {
+ fClusterPIndexes[i]= package.fClusterPIndexes[i];
+ }
+
+ if (debug) cout << "Copying function was used\n<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>";
+
+ return;
+
+}
+/*******************************************************/
+
+AliITSpackageSSD&
+AliITSpackageSSD::operator=( const AliITSpackageSSD & package)
+{
+
+Int_t i; //iterator
+
+if (this == &package) return *this;
+fClustersN = package.fClustersN;
+fClustersP = package.fClustersP;
+
+fNclustersN= package.fNclustersN;
+fNclustersP= package.fNclustersP;
+
+for(i =0; i<fNclustersN;i++)
+ {
+ fClusterNIndexes[i]= package.fClusterNIndexes[i];
+ }
+
+for(i =0; i<fNclustersP;i++)
+ {
+ fClusterPIndexes[i]= package.fClusterPIndexes[i];
+ }
+
+if (debug) cout << "Copying function was used\n<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>";
+
+return *this;
+
+}
+
+
+/*******************************************************/
+
+Int_t
+AliITSpackageSSD::GetNSideClusterIdx(Int_t index)
+
+{
+ if ((index>-1)&&(index<fNclustersN))
+ return (*fClusterNIndexes)[index];
+ else
+ {
+ cout << "AliITSpackageSSD::GetNSideClusterIdx : Out of Range\n";
+ return -1;
+ }
+}
+/*******************************************************/
+
+
+Int_t AliITSpackageSSD::GetPSideClusterIdx(Int_t index)
+{
+ if ((index>-1)&&(index<fNclustersP))
+ return (*fClusterPIndexes)[index];
+ else
+ {
+ cout << "AliITSpackageSSD::GetPSideClusterIdx : Out of Range\n";
+ return -1;
+ }
+}
+/*******************************************************/
+AliITSclusterSSD*
+AliITSpackageSSD::GetPSideCluster(Int_t index)
+{
+
+return (AliITSclusterSSD*)((*fClustersP)[GetPSideClusterIdx(index)]);
+}
+
+/*******************************************************/
+
+AliITSclusterSSD*
+AliITSpackageSSD::GetNSideCluster(Int_t index)
+{
+return (AliITSclusterSSD*)((*fClustersN)[GetNSideClusterIdx(index)]);
+}
+
+
+/*******************************************************/
+
+
+
+Bool_t
+AliITSpackageSSD::GetClusterWithOneCross
+ (Int_t & index, Bool_t& side)
+{
+
+
+ if((fNclustersP==0)||(fNclustersN==0) )
+ {
+ printf("Empty package ((fNclustersP==0)||(fNclustersN==0))\n");
+ index = -2;
+ return kFALSE;
+ }
+ Int_t ind;
+
+ ind =(*fClusterPIndexes)[fNclustersP-1];
+ if ( ( ((AliITSclusterSSD*)(*fClustersP)[ind] )->GetCrossNo() ) ==1 )
+ {
+ //index=ind;
+ index =fNclustersP-1;
+ side=SIDEP;
+ return kTRUE;
+ }
+
+ ind =(*fClusterNIndexes)[fNclustersN-1];
+ if ( ( ((AliITSclusterSSD*)(*fClustersN)[ind] )->GetCrossNo() ) ==1 )
+ {
+ //index=ind;
+ index = fNclustersN-1;
+ side=SIDEN;
+ return kTRUE;
+ }
+
+
+ ind =(*fClusterPIndexes)[0];
+ if ( ( ((AliITSclusterSSD*)(*fClustersP)[ind] )->GetCrossNo() ) ==1 )
+ {
+ //index=ind;
+ index = 0;
+ side=SIDEP;
+ return kTRUE;
+ }
+
+
+ ind =(*fClusterNIndexes)[0];
+ if ( ( ((AliITSclusterSSD*)(*fClustersN)[ind] )->GetCrossNo() ) ==1 )
+ {
+// index=ind;
+ index = 0;
+ side=SIDEN;
+ return kTRUE;
+ }
+
+
+ //Add for to be shure
+ index = -1;
+ return kFALSE;
+
+}
+/*******************************************************/
+
+void AliITSpackageSSD::DelCluster(Int_t index, Bool_t side)
+{
+ if(side==SIDEP) DelPCluster(index); else DelNCluster(index);
+}
+/*******************************************************/
+void AliITSpackageSSD::DelPCluster(Int_t index)
+{
+
+//it not deletes delete given cluster physically,
+//but only complytely erase it from package
+//all clusters are deleted automatically when TClonesArray is deleted
+
+ Int_t i;
+ Int_t idx;
+ Int_t clToDelIdx = GetPSideClusterIdx(index); //Index of cluster in TClonesArray
+ AliITSclusterSSD *clToDel = GetPSideCluster(index); //cluster to be deleted
+ Int_t ncr = clToDel->GetCrossNo();
+
+ for(i =0;i<ncr;i++)
+ {
+ idx = clToDel->GetCross(i);
+ ((AliITSclusterSSD *)((*fClustersN)[idx]) )->DelCross(clToDelIdx);
+ }
+
+
+ for(i=index;i<fNclustersP-1;i++)
+ {
+ (*fClusterPIndexes)[i]=(*fClusterPIndexes)[i+1];
+ }
+ fNclustersP--;
+ if (debug) cout<<"Cluster P ("<<index<<") deleted\n";
+
+
+ for(i=0;i<fNclustersN;i++)
+ {
+ if ( (GetNSideCluster(i)->GetCrossNo())==0) DelNCluster(i);
+ }
+}
+
+
+
+/*******************************************************/
+void AliITSpackageSSD::DelNCluster(Int_t index)
+{
+
+//it not deletes delete given cluster physically,
+//but only complytely erase it from package
+//all clusters are deleted automatically when TClonesArray is deleted
+
+ Int_t i;
+ Int_t idx;
+ Int_t clToDelIdx = GetNSideClusterIdx(index); //Index of cluster in TClonesArray
+ AliITSclusterSSD *clToDel = GetNSideCluster(index); //cluster to be deleted
+ Int_t ncr = clToDel->GetCrossNo();
+
+ for(i =0;i<ncr;i++)
+ {
+ idx = clToDel->GetCross(i);
+ ((AliITSclusterSSD *)((*fClustersP)[idx]) )->DelCross(clToDelIdx);
+ }
+
+
+ for(i=index;i<fNclustersN-1;i++)
+ {
+ (*fClusterNIndexes)[i]=(*fClusterNIndexes)[i+1];
+ }
+ fNclustersN--;
+ if (debug) cout<<"Cluster N ("<<index<<") deleted\n";
+
+ for(i=0;i<fNclustersP;i++)
+ {
+ if ( (GetPSideCluster(i)->GetCrossNo())==0) DelPCluster(i);
+ }
+
+}
+
+
+/*******************************************************/
+
+void AliITSpackageSSD::DelPClusterOI(Int_t index)
+{
+//This function looks like this,
+//because probably cut cluster is
+//on the beginning or on the end of package
+ Int_t i;
+ if( ((*fClusterPIndexes)[0]) == index)
+ {
+ DelPCluster(0);
+ return;
+ }
+ else
+ {
+ if( ((*fClusterPIndexes)[fNclustersP-1]) ==index)
+ {
+ DelPCluster(fNclustersP-1);
+ return;
+ }
+ else
+ {
+ for(i=1;i<fNclustersP-1;i++)
+ {
+ if( ((*fClusterPIndexes)[i])==index)
+ {
+ DelPCluster(i);
+ return;
+ }
+ }
+ }
+ }
+
+ cout<<"AliITSpackageSSD - DelPClusterOI: index "<<index<<" not found\n";
+
+}
+
+
+/*******************************************************/
+
+void AliITSpackageSSD::DelNClusterOI(Int_t index)
+{
+//This function looks like this,
+//because probably cluster to cut is
+//on the beginning or on the end of package
+
+ Int_t i;
+ if( ((*fClusterNIndexes)[0])==index)
+ {
+ DelNCluster(0);
+ return;
+ }
+ else
+ {
+ if( ((*fClusterNIndexes)[fNclustersN-1])==index)
+ {
+ DelNCluster(fNclustersN-1);
+ return;
+ }
+ else
+ {
+ for(i=1;i<fNclustersN-1;i++)
+ {
+ if( ((*fClusterNIndexes)[i])==index)
+ {
+ DelNCluster(i);
+ return;
+ }
+ }
+ }
+ }
+ cout<<"AliITSpackageSSD - DelNClusterOI: index "<<index<<" not found\n";
+}
+
+
+/*******************************************************/
+
+
+void AliITSpackageSSD::DelClusterOI(Int_t index, Bool_t side)
+{
+ if (side == SIDEP)
+ {
+ DelPClusterOI(index);
+ }
+ else
+ {
+ DelNClusterOI(index);
+ }
+
+}
+
+
+/**********************************************/
+
+
+void AliITSpackageSSD::GetAllCombinations(Int_t**array,Int_t &num,Int_t sizet)
+{
+
+ Int_t *takenNcl = new Int_t[fNclustersN];
+
+ num=0;
+
+ if (debug) PrintClusters();
+
+ Int_t i;
+ for(i=0;i<fNclustersP;i++)
+ {
+ takenNcl[i]=-1;
+ }
+ //see comment on the beginning of MakeCombin
+ if (debug) cout<<"GetAllCombinations entered";
+ MakeCombin (array,num,0,takenNcl,sizet);
+
+ delete []takenNcl;
+}
+/**********************************************/
+
+
+void AliITSpackageSSD::MakeCombin
+ (Int_t**arr,Int_t& nu, Int_t np, Int_t *occup, Int_t sizet)
+
+{
+
+//ATTENTION: anybody watching this function
+//AliITSclusterSSD::GetCrossNo() returns index of cluster in main array belonging to AliITSmodulesSSD
+//however, we have pointer to that array (TClonesArray)
+//we can not use
+//Get?SideCluster because it takes index from local look_up_table
+
+ Int_t i,j;
+
+ //this cluster
+ AliITSclusterSSD *cl=GetPSideCluster(np);
+
+ //printf("np %d cl %p\n",np,cl);
+
+
+ Int_t NC = cl->GetCrossNo(); //number of crosses for this cluster
+ Int_t indcro; //index of given cluster on side N that
+ // this cluster crosses with
+
+ // printf("NC %d \n",NC);
+
+
+ if (np == fNclustersP-1) {
+ //printf("if \n");
+ for(i=0;i<NC;i++) {
+ indcro=cl->GetCross(i);
+ //printf("if: i indcro %d %d\n",i, indcro);
+ if(IsFree(indcro,np,occup)) {
+ occup[np]=indcro;
+ //printf("if- isFree: i np occup[np] %d %d %d\n",i,np,occup[np]);
+ for(j=0;j<fNclustersP;j++)
+ {
+ //printf("if- for: j nu occup[j] %d %d %d\n",j, nu, occup[j]);
+ if (nu<sizet) arr[nu][j]=occup[j];
+ else {
+ //printf("MakeComb - exceeding array size! i j %d %d\n",i,j);
+ continue;}
+ //printf("if- for: j nu arr[nu][j] %d %d %d\n",j, nu, arr[nu][j]);
+
+ }
+
+ occup[np]=-1;
+ if (nu<sizet-1) nu++;
+ //printf("i j nu %d %d %d \n",i,j,nu);
+ }
+ }
+ } else {
+ // printf("else \n");
+
+ for(i=0;i<NC;i++) {
+ indcro=cl->GetCross(i);
+ //printf("else: i indcro %d %d\n",i, indcro);
+ if(IsFree(indcro,np,occup)) {
+ occup[np]=indcro;
+ //printf("else:recursive call - i np occup %d %d %d\n",i,np,occup[np]);
+ if (nu<sizet) MakeCombin(arr,nu,(np+1),occup,sizet);
+ //else printf("MakeComb - exceeding array size!\n");
+ }
+ }
+ occup[np]=-1;
+ }
+
+}
+
+/**********************************************/
+Bool_t AliITSpackageSSD::IsFree(Int_t idx, Int_t nn, Int_t *lis)
+{
+
+ Int_t i;
+ for(i=0;i<nn;i++)
+ {
+ if (lis[i]==idx) return kFALSE;
+ }
+ return kTRUE;
+}
+
+/**********************************************/
+void AliITSpackageSSD::PrintClusters()
+{
+
+Int_t i,j;
+cout<<"SIDE P\n";
+for(i=0;i<fNclustersP;i++)
+ {
+ cout<<i<<". IO="<<GetPSideClusterIdx(i)<<" NC="<<GetPSideCluster(i)->GetCrossNo()<<" C. IDXs : ";
+ for(j=0;j<GetPSideCluster(i)->GetCrossNo();j++)
+ {
+ cout<<GetPSideCluster(i)->GetCross(j)<<" ";
+ }
+ // if (GetPSideCluster(i)->GetSide()) cout<<" P\n";
+ // else cout<<"BAD SIDE ==N\n";
+ cout<<"\n";
+
+ }
+
+cout <<"SIDE N\n";
+for(i=0;i<fNclustersN;i++)
+ {
+ cout<<i<<". IO="<<GetNSideClusterIdx(i)<<" NC="<<GetNSideCluster(i)->GetCrossNo()<<" C. IDXs : ";
+ for(j=0;j<GetNSideCluster(i)->GetCrossNo();j++)
+ {
+ cout<<GetNSideCluster(i)->GetCross(j)<<" ";
+ }
+ // if (GetNSideCluster(i)->GetSide()) cout<<" N\n";
+ // else cout<<"BAD SIDE ==P\n";
+ cout<<"\n";
+ }
+
+
+
+}
+/**********************************************/
+void AliITSpackageSSD::ConsumeClusters()
+{
+register Int_t i;
+
+for(i=0;i<fNclustersP;i++)
+ {
+ GetPSideCluster(i)->Consume();
+ }
+
+for(i=0;i<fNclustersN;i++)
+ {
+ GetNSideCluster(i)->Consume();
+ }
+
+}
+
+/**********************************************/
+
+Int_t AliITSpackageSSD::GetNextPIdx(Int_t OI)
+{
+ //Returns index of next P cluster OI in package; OI == Original Inedx (in TClonesArray)
+ //if not egsist return -1;
+ Int_t i;
+ for(i =0; i<fNclustersP-1;i++)
+ {
+ if(GetPSideClusterIdx(i) == OI)
+ return GetPSideClusterIdx(i+1);
+ }
+ return -1;
+}
+/**********************************************/
+Int_t AliITSpackageSSD::GetPrvPIdx(Int_t OI)
+{
+ //Returns index of previous P cluster OI in package; OI == Original Inedx (in TClonesArray)
+ //if not egsist return -1;
+
+ Int_t i;
+ for(i =1; i<fNclustersP;i++)
+ {
+ if(GetPSideClusterIdx(i) == OI)
+ return GetPSideClusterIdx(i-1);
+ }
+ return -1;
+}
+/**********************************************/
+Int_t AliITSpackageSSD::GetNextNIdx(Int_t OI)
+{
+//Returns index of next N cluster OI in package; OI == Original Inedx (in TClonesArray)
+ //if not egsist return -1;
+ Int_t i;
+ for(i =0; i<fNclustersN-1;i++)
+ {
+ if(GetNSideClusterIdx(i) == OI)
+ return GetNSideClusterIdx(i+1);
+ }
+ return -1;
+
+}
+/**********************************************/
+Int_t AliITSpackageSSD::GetPrvNIdx(Int_t OI)
+{
+ //Returns index of previous N cluster OI in package; OI == Original Inedx (in TClonesArray)
+ //if not egsist return -1;
+
+ Int_t i;
+ for(i =1; i<fNclustersN;i++)
+ {
+ if(GetNSideClusterIdx(i) == OI)
+ return GetNSideClusterIdx(i-1);
+ }
+ return -1;
+
+}
+
+void AliITSpackageSSD::SplitPackage(Int_t pi, Int_t ni, AliITSpackageSSD* pkg)
+{
+ // split package of clusters
+ Int_t p=-1, n=-1;
+ Int_t i;
+ for(i=0;i<fNclustersN;i++)
+ {
+ if((*fClusterNIndexes)[i]==ni)
+ {
+ n = i;
+ break;
+ }
+ }
+
+ for(i=0;i<fNclustersP;i++)
+ {
+ if((*fClusterPIndexes)[i]==pi)
+ {
+ p = i;
+ break;
+ }
+ }
+ if (debug) cout<<" p = "<<p<<" n = "<<n;
+ if ((p==-1)||(n==-1)) return;
+
+ for(i=p;i<fNclustersP;i++)
+ {
+ pkg->AddPSideCluster(GetPSideClusterIdx(i));
+ }
+ fNclustersP = p;
+
+ for(i=n;i<fNclustersN;i++)
+ {
+ pkg->AddNSideCluster(GetNSideClusterIdx(i));
+ }
+ fNclustersN = n;
+
+ cout<<" After split: fNclustersP = "<< fNclustersP<< "fNclustersN = "<< fNclustersN<<"\n";
+}
--- /dev/null
+#ifndef ALIITSPACKAGESSD_H
+#define ALIITSPACKAGESSD_H
+//Class describing set of AliITSoneSideClusterSSDs, which contact each other.
+//Piotr Krzysztof Skowronski
+//Warsaw University of Technology
+//skowron@if.pw.edu.pl
+//
+#include "TObject.h"
+#include "TArrayI.h"
+#include "TClonesArray.h"
+#include "AliITS.h"
+
+#include "AliITSclusterSSD.h"
+
+
+class AliITSpackageSSD : public TObject
+{
+ public:
+ AliITSpackageSSD();
+
+ AliITSpackageSSD(Int_t len, TClonesArray *clustersP, TClonesArray *clustersP);
+ AliITSpackageSSD(TClonesArray *clustersP, TClonesArray *clustersP);
+
+ ~AliITSpackageSSD();
+
+ AliITSpackageSSD(const AliITSpackageSSD &package);
+ AliITSpackageSSD& operator=( const AliITSpackageSSD & package);
+ //Add cluster in side N, clindex is an index of this cluster in TClonesArray
+
+ void AddNSideCluster(Int_t clindex) {(*fClusterNIndexes)[fNclustersN++]=clindex;}
+ void AddPSideCluster(Int_t clindex) {(*fClusterPIndexes)[fNclustersP++]=clindex;}
+
+ void AddCluster(Int_t clindex, Bool_t side){
+ (side)?(*fClusterNIndexes)[fNclustersN++]=
+ clindex:(*fClusterPIndexes)[fNclustersP++]=clindex;}
+
+//Returns index of one side cluster in TClonesArray, NOT AliITSclusterSSD
+ Int_t GetNSideClusterIdx(Int_t index); //input index is number of cluster in this package
+ Int_t GetPSideClusterIdx(Int_t index); //returns index in TClonesArray
+ Int_t GetClusterIdx(Int_t index,Bool_t side)
+ {return (side)?GetPSideClusterIdx(index):GetNSideClusterIdx(index);}
+
+ AliITSclusterSSD* GetNSideCluster(Int_t index);
+ AliITSclusterSSD* GetPSideCluster(Int_t index); //index is
+ AliITSclusterSSD* GetCluster(Int_t index, Bool_t side)
+ {return (side)?GetPSideCluster(index):GetNSideCluster(index);}
+
+ Int_t GetNextPIdx(Int_t OI); //Returns index of next P cluster in package; OI == Original Inedx (in TClonesArray)
+ Int_t GetPrvPIdx(Int_t OI); //Returns index of previous P cluster in package; OI == Original Inedx (in TClonesArray)
+ Int_t GetNextNIdx(Int_t OI); //Returns index of next N cluster in package; OI == Original Inedx (in TClonesArray)
+ Int_t GetPrvNIdx(Int_t OI); //Returns index of previous N cluster in package; OI == Original Inedx (in TClonesArray)
+
+ Int_t GetNumOfClustersN (){return fNclustersN;}
+ Int_t GetNumOfClustersP(){return fNclustersP;}
+ Int_t GetNumOfClusters() {return fNclustersP+fNclustersN;}
+ Int_t GetNumOfClusters(Bool_t side) {return (side)?fNclustersP:fNclustersN;}
+
+ //returns number of clusters belonging to package,
+ //that crosses with only one cluster on the other side
+ //There might be only 2 such a clusters:
+ //on the begining and on the end of the package
+ //
+ Bool_t GetClusterWithOneCross(Int_t & index, Bool_t& side );
+ void DelCluster(Int_t index, Bool_t side);
+ void DelPCluster(Int_t index);
+ void DelNCluster(Int_t index);
+ void DelClusterOI(Int_t index, Bool_t side); //OI indicates that it is Original Index
+ void DelPClusterOI(Int_t index); //it means value in look up table
+ void DelNClusterOI(Int_t index);
+
+ void SplitPackage(Int_t pi, Int_t ni, AliITSpackageSSD* pkg);
+ void GetAllCombinations(Int_t**array,Int_t &num,Int_t size);
+
+ void ConsumeClusters();
+ void PrintClusters();
+
+protected:
+
+ TClonesArray *fClustersN; //Pointer to array of clusters - only to have direct acces to
+ TClonesArray *fClustersP; //clusters
+ Int_t fNclustersN;
+ Int_t fNclustersP;
+ TArrayI *fClusterNIndexes;
+ TArrayI *fClusterPIndexes;
+ static const Bool_t SIDEP=kTRUE;
+ static const Bool_t SIDEN=kFALSE;
+
+
+/***************/
+/* Methods */
+/***************/
+
+
+ void MakeCombin(Int_t**arr, Int_t& nu, Int_t np, Int_t *occup,Int_t size);
+ Bool_t IsFree(Int_t idx, Int_t nn, Int_t *lis);
+
+
+
+private:
+
+//-------------------------------------------------------
+ ClassDef(AliITSpackageSSD,1)
+};
+
+#endif
+
+
+
+
+
+
+
--- /dev/null
+#ifndef ALIITSRESPONSE_H
+#define ALIITSRESPONSE_H
+
+
+#include <TObject.h>
+#include <TF1.h>
+#include "AliITSsegmentation.h"
+
+class AliITSgeom;
+
+//----------------------------------------------
+//
+// ITS response virtual base class
+//
+class AliITSresponse :
+public TObject {
+ public:
+ //
+ // Configuration methods
+ //
+
+ // Set maximum Adc-count value
+ virtual void SetMaxAdc(Float_t p1) {}
+ // Get maximum Adc-count value
+ virtual Float_t MaxAdc() {return 0.;}
+
+ // Set maximum Adc-magic value
+ virtual void SetMagicValue(Float_t p1) {}
+ // Get maximum Adc-magic value
+ virtual Float_t MagicValue() {return 0.0;}
+
+ // Diffusion coefficient
+ virtual void SetDiffCoeff(Float_t) =0;
+ // Get diffusion coefficient
+ virtual Float_t DiffCoeff() =0;
+ virtual Float_t Qref() {return 0.;}
+
+ // Temperature
+ virtual void SetTemperature(Float_t) {}
+ // Get temperature
+ virtual Float_t Temperature() {return 0.;}
+ // Type of data - real or simulated
+ virtual void SetDataType(char *data) =0;
+ // Get data type
+ virtual const char *DataType() =0;
+
+
+
+ // parameters: "same" or read from "file" or "SetInvalid" or ...
+ virtual void SetParamOptions(Option_t *opt1, Option_t *opt2) {}
+ virtual void SetNoiseParam(Float_t, Float_t) {}
+ // gain, coupling ...
+ // Number of parameters to be set
+ virtual void SetNDetParam(Int_t) {}
+ virtual void SetDetParam(Float_t *) {}
+
+ // Parameters options
+ virtual void ParamOptions(Option_t *&, Option_t *&) {}
+ virtual Int_t NDetParam() {return 0;}
+ virtual void GetDetParam(Float_t *) {}
+ virtual void GetNoiseParam(Float_t&, Float_t&) {}
+
+ // Zero-suppression option - could be 1D, 2D or non-ZS
+ virtual void SetZeroSupp(Option_t *opt) {}
+ // Get zero-suppression option
+ virtual Option_t *ZeroSuppOption() {return "";}
+ // Set thresholds
+ virtual void SetThresholds(Float_t, Float_t) {}
+ virtual void Thresholds(Float_t &, Float_t &) {}
+ // Set min val
+ virtual void SetMinVal(Int_t) {};
+ virtual Int_t MinVal() {return 0;};
+
+ // Set filenames
+ virtual void SetFilenames(char *,char *,char *) {}
+ // Filenames
+ virtual void Filenames(const char*&,const char*&,const char*&) {}
+
+
+ virtual Float_t DriftSpeed() {return 0.;}
+ virtual Bool_t OutputOption() {return kFALSE;}
+ virtual void GiveCompressParam(Int_t *x) {}
+
+ //
+ // Detector type response methods
+ // Set number of sigmas over which cluster disintegration is performed
+ virtual void SetNSigmaIntegration(Float_t p1) {}
+ // Get number of sigmas over which cluster disintegration is performed
+ virtual Float_t NSigmaIntegration() {return 0.;}
+ // Set sigmas of the charge spread function
+ virtual void SetSigmaSpread(Float_t p1, Float_t p2) {}
+ // Get sigmas for the charge spread
+ virtual void SigmaSpread(Float_t &s1, Float_t &s2) {}
+
+
+ // Pulse height from scored quantity (eloss)
+ virtual Float_t IntPH(Float_t eloss) {return 0.;}
+ // Charge disintegration
+ virtual Float_t IntXZ(AliITSsegmentation *) {return 0.;}
+
+ ClassDef(AliITSresponse,1) // Detector type response virtual base class
+};
+#endif
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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 <TMath.h>
+
+#include "AliITSgeom.h"
+#include "AliITSresponseSDD.h"
+#include "AliITS.h"
+#include "AliRun.h"
+
+class AliITS;
+
+//___________________________________________
+ClassImp(AliITSresponseSDD)
+
+AliITSresponseSDD::AliITSresponseSDD()
+{
+ // constructor
+ SetMaxAdc();
+ SetDiffCoeff();
+ SetQref();
+ SetDriftSpeed();
+ // SetClock();
+ SetNoiseParam();
+ SetMagicValue();
+ SetMinVal();
+ SetParamOptions();
+ SetZeroSupp();
+ SetDataType();
+ SetFilenames();
+ SetOutputOption();
+
+}
+
+//__________________________________________________________________________
+AliITSresponseSDD::AliITSresponseSDD(const AliITSresponseSDD &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fCPar = source.fCPar;
+ this->fNoise = source.fNoise;
+ this->fBaseline = source.fBaseline;
+ this->fTopValue = source.fTopValue;
+ this->fTemperature = source.fTemperature;
+ this->fDriftSpeed = source.fDriftSpeed;
+ this->fMaxAdc = source.fMaxAdc;
+ this->fDiffCoeff = source.fDiffCoeff;
+ this->fQref = source.fQref;
+ this->fZeroSuppFlag = source.fZeroSuppFlag;
+ this->fMinVal = source.fMinVal;
+ this->fWrite = source.fWrite;
+ this->fOption = source.fOption;
+ this->fParam1 = source.fParam1;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSresponseSDD&
+ AliITSresponseSDD::operator=(const AliITSresponseSDD &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fCPar = source.fCPar;
+ this->fNoise = source.fNoise;
+ this->fBaseline = source.fBaseline;
+ this->fTopValue = source.fTopValue;
+ this->fTemperature = source.fTemperature;
+ this->fDriftSpeed = source.fDriftSpeed;
+ this->fMaxAdc = source.fMaxAdc;
+ this->fDiffCoeff = source.fDiffCoeff;
+ this->fQref = source.fQref;
+ this->fZeroSuppFlag = source.fZeroSuppFlag;
+ this->fMinVal = source.fMinVal;
+ this->fWrite = source.fWrite;
+ this->fOption = source.fOption;
+ this->fParam1 = source.fParam1;
+ return *this;
+}
+
+void AliITSresponseSDD::SetCompressParam(Int_t cp[8])
+{
+ // set compression param
+ Int_t i;
+ for(i=0; i<8; i++) {
+ fCPar[i]=cp[i];
+ //printf("\n CompressPar %d %d \n",i,fCPar[i]);
+
+ }
+}
+void AliITSresponseSDD::GiveCompressParam(Int_t cp[8])
+{
+ // give compression param
+ Int_t i;
+ for(i=0; i<8; i++) {
+ cp[i]=fCPar[i];
+ }
+}
+//______________________________________________________________________________
+void AliITSresponseSDD::Streamer(TBuffer &R__b)
+{
+ // Stream an object of class AliITSresponseSDD.
+
+ if (R__b.IsReading()) {
+ Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+ AliITSresponse::Streamer(R__b);
+ R__b.ReadStaticArray(fCPar);
+ R__b >> fNoise;
+ R__b >> fBaseline;
+ R__b >> fTopValue;
+ R__b >> fTemperature;
+ R__b >> fDriftSpeed;
+ R__b >> fMaxAdc;
+ R__b >> fDiffCoeff;
+ R__b >> fQref;
+ R__b >> fZeroSuppFlag;
+ R__b >> fMinVal;
+ R__b >> fWrite;
+ //R__b.ReadArray(fOption); // Not to be printed out?
+ //R__b.ReadArray(fParam1); // Not to be printed out?
+ //R__b.ReadArray(fParam2); // Not to be printed out?
+ fDataType.Streamer(R__b);
+ fFileName1.Streamer(R__b);
+ fFileName2.Streamer(R__b);
+ fFileName3.Streamer(R__b);
+ } else {
+ R__b.WriteVersion(AliITSresponseSDD::IsA());
+ AliITSresponse::Streamer(R__b);
+ R__b.WriteArray(fCPar, 8);
+ R__b << fNoise;
+ R__b << fBaseline;
+ R__b << fTopValue;
+ R__b << fTemperature;
+ R__b << fDriftSpeed;
+ R__b << fMaxAdc;
+ R__b << fDiffCoeff;
+ R__b << fQref;
+ R__b << fZeroSuppFlag;
+ R__b << fMinVal;
+ R__b << fWrite;
+ //R__b.WriteArray(fOption, __COUNTER__); // Not to be printed out?
+ //R__b.WriteArray(fParam1, __COUNTER__); // Not to be printed out?
+ //R__b.WriteArray(fParam2, __COUNTER__); // Not to be printed out?
+ fDataType.Streamer(R__b);
+ fFileName1.Streamer(R__b);
+ fFileName2.Streamer(R__b);
+ fFileName3.Streamer(R__b);
+ }
+}
--- /dev/null
+#ifndef ALIITSRESPONSESDD_H
+#define ALIITSRESPONSESDD_H
+
+#include "AliITSresponse.h"
+
+// response for SDD
+
+class AliITSresponseSDD :
+ public AliITSresponse {
+public:
+ //
+ // Configuration methods
+ //
+
+ AliITSresponseSDD();
+ virtual ~AliITSresponseSDD() {
+ // destructor
+ }
+ AliITSresponseSDD(const AliITSresponseSDD &source); // copy constructor
+ AliITSresponseSDD& operator=(const AliITSresponseSDD &source); // ass. op.
+
+ virtual void SetMaxAdc(Float_t p1=1023) {
+ // Adc-count saturation value
+ fMaxAdc=p1;
+ }
+ virtual Float_t MaxAdc() {
+ // Get maximum Adc-count value
+ return fMaxAdc;
+ }
+
+ virtual void SetMagicValue(Float_t p1=450.) {
+ // Set maximum Adc-magic value
+ fTopValue=p1;
+ }
+ virtual Float_t MagicValue() {
+ // Get maximum Adc-magic value
+ return fTopValue;
+ }
+
+ virtual void SetDiffCoeff(Float_t p1=5.) {
+ // Diffusion coefficient
+ fDiffCoeff=p1;
+ }
+ virtual Float_t DiffCoeff() {
+ // Get diffusion coefficient
+ return fDiffCoeff;
+ }
+
+ virtual void SetQref(Float_t p1=120.) {
+ // Coulomb repulsion
+ fQref=p1;
+ }
+ virtual Float_t Qref() {
+ // qref
+ return fQref;
+ }
+
+ virtual void SetDriftSpeed(Float_t p1=7.5) {
+ // Drift velocity
+ fDriftSpeed=p1;
+ }
+ virtual Float_t DriftSpeed() {
+ // drift speed
+ return fDriftSpeed;
+ }
+
+ virtual void SetTemperature(Float_t p1=23.) {
+ // Temperature
+ fTemperature=p1;
+ }
+ virtual Float_t Temperature() {
+ // Get temperature
+ return fTemperature;
+ }
+
+ virtual void SetDataType(char *data="simulated") {
+ // Type of data - real or simulated
+ fDataType=data;
+ }
+ virtual const char *DataType() {
+ // Get data type
+ return fDataType.Data();
+ }
+
+ virtual void SetParamOptions(Option_t *opt1="same",Option_t *opt2="same"){
+ // Parameters: "same" or read from "file"
+ fParam1=opt1; fParam2=opt2;
+ }
+ virtual void ParamOptions(Option_t *&opt1,Option_t *&opt2) {
+ // options
+ opt1=fParam1; opt2=fParam2;
+ }
+
+ virtual void SetNoiseParam(Float_t n=3., Float_t b=20.){
+ // Noise and baseline
+ fNoise=n; fBaseline=b;
+ }
+ virtual void GetNoiseParam(Float_t &n, Float_t &b) {
+ // get noise param
+ n=fNoise; b=fBaseline;
+ }
+
+ virtual void SetZeroSupp(Option_t *opt="2D") {
+ // Zero-suppression option - could be 1D, 2D or non-ZS
+ fOption=opt;
+ }
+ virtual Option_t *ZeroSuppOption() {
+ // Get zero-suppression option
+ return fOption;
+ }
+ virtual void SetMinVal(Int_t mv=4) {
+ // Min value used in 2D - could be used as a threshold setting
+ fMinVal = mv;
+ }
+ virtual Int_t MinVal() {
+ // min val
+ return fMinVal;
+ }
+
+ virtual void SetFilenames(char *f1=0,char *f2=0, char *f3=0) {
+ // Set filenames - input, output, parameters ....
+ fFileName1=f1; fFileName2=f2; fFileName3=f3;
+ }
+ virtual void Filenames(const char*&input,const char*&baseline,const char*¶m) {
+ // Filenames
+ input=fFileName1; baseline=fFileName2; param=fFileName3;
+ }
+
+
+ virtual void SetOutputOption(Bool_t write=kFALSE) {
+ // set output option
+ fWrite = write;
+ }
+ Bool_t OutputOption() {
+ // output option
+ return fWrite;
+ }
+ //
+ // Compression parameters
+ virtual void SetCompressParam(Int_t cp[8]);
+ void GiveCompressParam(Int_t *x);
+
+ //
+ // Detector type response methods
+ virtual void SetNSigmaIntegration(Float_t p1) {
+ // Set number of sigmas over which cluster disintegration is performed
+ }
+ virtual Float_t NSigmaIntegration() {
+ // Get number of sigmas over which cluster disintegration is performed
+ return 0.;
+ }
+ virtual void SetSigmaSpread(Float_t p1, Float_t p2) {
+ // Set sigmas of the charge spread function
+ }
+ virtual void SigmaSpread(Float_t &s1, Float_t &s2) {
+ // Get sigmas for the charge spread
+ }
+
+ virtual Float_t IntPH(Float_t eloss) {
+ // Pulse height from scored quantity (eloss)
+ return 0.;
+ }
+ virtual Float_t IntXZ(AliITSsegmentation *) {
+ // Charge disintegration
+ return 0.;
+ }
+
+
+protected:
+
+ Int_t fCPar[8]; // Hardware compression parameters
+ //Int_t fNDetPar; // Number of detector param
+ //Float_t fDetPar[fNDetPar];
+
+ Float_t fNoise; // Noise
+ Float_t fBaseline; // Baseline
+ Float_t fTopValue; // still unclear to me
+ Float_t fTemperature; // Temperature
+ Float_t fDriftSpeed; // Drift velocity
+
+ Float_t fMaxAdc; // Adc saturation value
+ Float_t fDiffCoeff; // Diffusion Coefficient
+ Float_t fQref; // Coulomb repulsion
+
+ Int_t fZeroSuppFlag; // Zero-suppression flag
+ Int_t fMinVal; // Min value used in 2D zero-suppression algo
+
+ Bool_t fWrite; // Write option for the compression algorithms
+ Option_t *fOption; // Zero-suppresion option (1D, 2D or none)
+ Option_t *fParam1; // Read baselines from file option
+ Option_t *fParam2; // Read compression algo thresholds from file
+
+ TString fDataType; // input keys : run, module #
+ TString fFileName1; // input keys : run, module #
+ TString fFileName2; // baseline & noise val or output coded // signal or monitored bgr.
+ TString fFileName3; // param values or output coded signal
+
+ ClassDef(AliITSresponseSDD,1) // SDD response
+
+ };
+#endif
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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 <TMath.h>
+
+#include "AliITSresponseSPD.h"
+
+//___________________________________________
+ClassImp(AliITSresponseSPD)
+
+AliITSresponseSPD::AliITSresponseSPD()
+{
+ // constructor
+ SetDiffCoeff();
+ SetNoiseParam();
+ SetDataType();
+ SetMinVal();
+
+}
+
--- /dev/null
+#ifndef ALIITSRESPONSESPD_H
+#define ALIITSRESPONSESPD_H
+
+#include "AliITSsegmentation.h"
+#include "AliITSresponse.h"
+//----------------------------------------------
+//
+// ITS response class for SPD
+//
+class AliITSresponseSPD :
+ public AliITSresponse {
+public:
+
+ AliITSresponseSPD();
+ virtual ~AliITSresponseSPD() {
+ // destructror
+ }
+ //
+ // Configuration methods
+ //
+ virtual void SetDiffCoeff(Float_t p1=0.00433) {
+ // Diffusion coefficient
+ fDiffCoeff=p1;
+ }
+ virtual Float_t DiffCoeff() {
+ // Get diffusion coefficient
+ return fDiffCoeff;
+ }
+ virtual void SetNoiseParam(Float_t n=0., Float_t b=0.) {
+ // set noise
+ fNoise=n; fBaseline=b;
+ }
+ virtual void GetNoiseParam(Float_t &n, Float_t &b) {
+ // get noise
+ n=fNoise; b=fBaseline;
+ }
+ virtual void SetMinVal(Int_t p1=0) {
+ // Zero-suppression option threshold
+ fThreshold=p1;
+ }
+ virtual Int_t MinVal() {
+ // Get zero-suppression threshold
+ return fThreshold;
+ }
+ virtual void SetDataType(char *data="simulated") {
+ // Type of data - real or simulated
+ fDataType=data;
+ }
+ virtual const char *DataType() {
+ // Get data typer
+ return fDataType.Data();
+ }
+
+ ClassDef(AliITSresponseSPD,1) // SPD response
+
+ protected:
+
+ Float_t fDiffCoeff; // Diffusion Coefficient
+ Float_t fNoise; // Noise value
+ Float_t fBaseline; // Baseline value
+ Int_t fThreshold; // Zero-Suppression threshold
+
+ TString fDataType; // Type of data - real or simulated
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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 <TMath.h>
+
+#include "AliITSresponseSSD.h"
+#include "AliITSgeom.h"
+
+ClassImp(AliITSresponseSSD)
+//----------------------------------------------------------
+AliITSresponseSSD::AliITSresponseSSD()
+{
+ // constructor
+ SetDiffCoeff();
+ SetNoiseParam();
+ SetDataType();
+ SetSigmaSpread();
+ SetParamOptions();
+ SetNDetParam();
+ fDetPar = new Float_t[fNPar];
+ if (fNPar==6) {
+ fDetPar[0]=10.;
+ fDetPar[1]=5.;
+ fDetPar[2]=0.02;
+ fDetPar[3]=0.02;
+ fDetPar[4]=0.02;
+ fDetPar[5]=0.03;
+ }
+
+
+}
+
+//----------------------------------------------------------
+AliITSresponseSSD::~AliITSresponseSSD()
+{
+ // destructor
+ delete [] fDetPar;
+ delete fDetPar;
+
+}
+
+//__________________________________________________________________________
+AliITSresponseSSD::AliITSresponseSSD(const AliITSresponseSSD &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fNPar = source.fNPar;
+ this->fDetPar = source.fDetPar;
+ this->fNoiseP = source.fNoiseP;
+ this->fNoiseN = source.fNoiseN;
+ this->fSigmaP = source.fSigmaP;
+ this->fSigmaN = source.fSigmaN;
+ this->fDiffCoeff = source.fDiffCoeff;
+ this->fOption1 = source.fOption1;
+ this->fOption2 = source.fOption2;
+ this->fDataType = source.fDataType;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSresponseSSD&
+ AliITSresponseSSD::operator=(const AliITSresponseSSD &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fNPar = source.fNPar;
+ this->fDetPar = source.fDetPar;
+ this->fNoiseP = source.fNoiseP;
+ this->fNoiseN = source.fNoiseN;
+ this->fSigmaP = source.fSigmaP;
+ this->fSigmaN = source.fSigmaN;
+ this->fDiffCoeff = source.fDiffCoeff;
+ this->fOption1 = source.fOption1;
+ this->fOption2 = source.fOption2;
+ this->fDataType = source.fDataType;
+ return *this;
+}
+
+//----------------------------------------------------------
+void AliITSresponseSSD::SetDetParam(Float_t *par)
+{
+ // set det param
+ Int_t i;
+ for(i=0; i<fNPar; i++) {
+ fDetPar[i]=par[i];
+ //printf("\n CompressPar %d %d \n",i,fCPar[i]);
+
+ }
+}
+void AliITSresponseSSD::GetDetParam(Float_t *par)
+{
+ // get det param
+ Int_t i;
+ for(i=0; i<fNPar; i++) {
+ par[i]=fDetPar[i];
+ }
+}
+
+//______________________________________________________________________________
+void AliITSresponseSSD::Streamer(TBuffer &R__b)
+{
+ // Stream an object of class AliITSresponseSSD.
+
+ if (R__b.IsReading()) {
+ Version_t R__v = R__b.ReadVersion(); if (R__v) { }
+ AliITSresponse::Streamer(R__b);
+ R__b >> fNPar;
+ //R__b.ReadArray(fDetPar); // Not to be printed out?
+ R__b >> fNoiseP;
+ R__b >> fNoiseN;
+ R__b >> fSigmaP;
+ R__b >> fSigmaN;
+ R__b >> fDiffCoeff;
+ //R__b.ReadArray(fOption1); // Not to be printed out?
+ //R__b.ReadArray(fOption2); // Not to be printed out?
+ fDataType.Streamer(R__b);
+ } else {
+ R__b.WriteVersion(AliITSresponseSSD::IsA());
+ AliITSresponse::Streamer(R__b);
+ R__b << fNPar;
+ //R__b.WriteArray(fDetPar, __COUNTER__); // Not to be printed out?
+ R__b << fNoiseP;
+ R__b << fNoiseN;
+ R__b << fSigmaP;
+ R__b << fSigmaN;
+ R__b << fDiffCoeff;
+ //R__b.WriteArray(fOption1, __COUNTER__); // Not to be printed out?
+ //R__b.WriteArray(fOption2, __COUNTER__); // Not to be printed out?
+ fDataType.Streamer(R__b);
+ }
+}
--- /dev/null
+#ifndef ALIITSRESPONSESSD_H
+#define ALIITSRESPONSESSD_H
+
+#include "AliITSresponse.h"
+
+// response for SSD
+
+//-----------------------------
+class AliITSresponseSSD :
+public AliITSresponse {
+
+public:
+
+ AliITSresponseSSD();
+ virtual ~AliITSresponseSSD();
+ AliITSresponseSSD(const AliITSresponseSSD &source); // copy constructor
+ AliITSresponseSSD& operator=(const AliITSresponseSSD &source); // ass. op.
+
+ virtual void SetDiffCoeff(Float_t p1=0.) {
+ // Diffusion coefficient
+ fDiffCoeff=p1;
+ }
+ virtual Float_t DiffCoeff() {
+ // Get diffusion coefficient
+ return fDiffCoeff;
+ }
+
+ virtual void SetNoiseParam(Float_t np=420., Float_t nn=625.) {
+ // set noise par
+ fNoiseP=np; fNoiseN=nn;
+ }
+ virtual void GetNoiseParam(Float_t &np, Float_t &nn) {
+ // get noise par
+ np=fNoiseP; nn=fNoiseN;
+ }
+
+ virtual void SetParamOptions(Option_t *opt1="", Option_t *opt2="") {
+ // parameters: "SetInvalid" to simulate the invalid strips
+ fOption1=opt1; fOption2=opt2;
+ }
+ virtual void ParamOptions(Option_t *&opt1,Option_t *&opt2) {
+ // options
+ opt1=fOption1; opt2=fOption2;
+ }
+
+ // Number of parameters to be set
+ // 4 couplings, mean number of invalid strips, RMS of invalid strips
+ virtual void SetNDetParam(Int_t npar=6) {
+ // set number of param
+ fNPar=npar;
+ }
+
+ virtual void SetDetParam(Float_t *par);
+
+ // Parameters options
+ virtual Int_t NDetParam() {
+ // number of param
+ return fNPar;
+ }
+ virtual void GetDetParam(Float_t *dpar);
+
+ virtual void SetDataType(char *data="simulated") {
+ // Type of data - real or simulated
+ fDataType=data;
+ }
+ virtual const char *DataType() {
+ // Get data type
+ return fDataType.Data();
+ }
+
+ virtual void SetSigmaSpread(Float_t p1=3., Float_t p2=2.) {
+ // 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) {
+ // Get sigmas for the charge spread
+ sP=fSigmaP; sN=fSigmaN;
+ }
+
+protected:
+ Int_t fNPar; // Number of detector param
+ Float_t *fDetPar ; // Array of parameters
+
+ Float_t fNoiseP; // Noise on Pside
+ Float_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
+
+ Option_t *fOption1; // Simulate invalid strips option
+ Option_t *fOption2; // Not used for the moment
+
+ TString fDataType; // Type of data - real or simulated
+
+ ClassDef(AliITSresponseSSD,1) //Response class for SSD
+
+ };
+
+
+
+#endif
+
+
+
+
+
+
+
--- /dev/null
+#ifndef ALIITSSEGMENTATION_H
+#define ALIITSSEGMENTATION_H
+
+
+#include <TObject.h>
+#include <TF1.h>
+
+class AliITSgeom;
+
+//----------------------------------------------
+//
+// ITS segmentation virtual base class
+//
+class AliITSsegmentation :
+public TObject {
+ public:
+ // Set Detector Segmentation Parameters
+ //
+ // Detector size
+ virtual void SetDetSize(Float_t Dx, Float_t Dz, Float_t Dy) {}
+
+ // Cell size
+ virtual void SetCellSize(Float_t p1, Float_t p2) {}
+
+ // Maximum number of cells along the two coordinates
+ virtual void SetNCells(Int_t p1, Int_t p2) {}
+
+ // Set angles - find a generic name fit for other detectors as well
+ // might be useful for beam test setups (3 angles ?)
+ virtual void SetAngles(Float_t p1, Float_t p2) {}
+
+ // Transform from real to cell coordinates
+ virtual void GetCellIxz(Float_t &x ,Float_t &z ,Int_t &ix,Int_t &iz)=0;
+ // Transform from cell to real coordinates
+ virtual void GetCellCxz(Int_t ix, Int_t iz, Float_t &x ,Float_t &z )=0;
+ // Transform from real global to local coordinates
+ virtual void GetLocal(Int_t module,Float_t *g ,Float_t *l) =0;
+ // Transform from real local to global coordinates
+ virtual void GetGlobal(Int_t module,Float_t *l ,Float_t *g) =0;
+ //
+ // Initialisation
+ virtual void Init() {}
+ //
+ // Get member data
+ //
+ // Detector type geometry
+ virtual AliITSgeom* Geometry() {return 0;}
+ // Detector length
+ virtual Float_t Dx() =0;
+ // Detector width
+ virtual Float_t Dz() =0;
+ // Detector thickness
+ virtual Float_t Dy() =0;
+ // Cell size in x
+ virtual Float_t Dpx(Int_t) =0;
+ // Cell size in z
+ virtual Float_t Dpz(Int_t) =0;
+
+ // Maximum number of Cells in x
+ virtual Int_t Npx() =0;
+ // Maximum number of Cells in z
+ virtual Int_t Npz() =0;
+
+ // Angles
+ virtual void Angles(Float_t &, Float_t&) {}
+
+ // Set cell position
+ virtual void SetPad(Int_t, Int_t) {}
+ // Set hit position
+ virtual void SetHit(Float_t, Float_t) {}
+
+ //
+ // Iterate over cells
+ // Initialiser
+ virtual void FirstCell
+ (Float_t xhit, Float_t zhit, Float_t dx, Float_t dz) {}
+ // Stepper
+ virtual void NextCell() {}
+ // Condition
+ virtual Int_t MoreCells() {return 0;}
+ //
+ // Get next neighbours
+ virtual void Neighbours
+ (Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[10], Int_t Zlist[10]) {}
+ //
+ // Current cell cursor during disintegration
+ // x-coordinate
+ virtual Int_t Ix() {return 0;}
+ // z-coordinate
+ virtual Int_t Iz() {return 0;}
+ //
+ // Signal Generation Condition during Stepping
+ virtual Int_t SigGenCond(Float_t x, Float_t y, Float_t z) {return 0;}
+ // Initialise signal generation at coord (x,y,z)
+ virtual void SigGenInit(Float_t x, Float_t y, Float_t z) {}
+ // Current integration limits
+ virtual void IntegrationLimits
+ (Float_t& x1, Float_t& x2, Float_t& z1, Float_t& z2) {}
+ // Test points for auto calibration
+ virtual void GiveTestPoints(Int_t &n, Float_t *x, Float_t *z) {}
+ // Function for systematic corrections
+ // Set the correction function
+ virtual void SetCorrFunc(Int_t, TF1*) {}
+ // Get the correction Function
+ virtual TF1* CorrFunc(Int_t) {return 0;}
+
+ ClassDef(AliITSsegmentation,1) //Segmentation virtual base class
+};
+
+#endif
+
+
+
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * 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 <TMath.h>
+
+#include "AliITSgeom.h"
+#include "AliITSsegmentationSDD.h"
+#include "AliITS.h"
+#include "AliRun.h"
+
+class AliITS;
+
+ClassImp(AliITSsegmentationSDD)
+//------------------------------
+AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSgeom* geom, AliITSresponse *resp){
+ // constructor
+ fGeom=geom;
+ fResponse=resp;
+ fCorr=0;
+ SetDetSize();
+ SetCellSize();
+ SetNCells();
+
+}
+//_____________________________________________________________________________
+AliITSsegmentationSDD::AliITSsegmentationSDD(){
+ fGeom=0;
+ fResponse=0;
+ fCorr=0;
+ SetDetSize();
+ SetCellSize();
+ SetNCells();
+
+}
+//_____________________________________________________________________________
+AliITSsegmentationSDD& AliITSsegmentationSDD::operator=(AliITSsegmentationSDD &source){
+ // Operator =
+ if(this==&source) return *this;
+ this->fNsamples = source.fNsamples;
+ this->fNanodes = source.fNanodes;
+ this->fPitch = source.fPitch;
+ this->fTimeStep = source.fTimeStep;
+ this->fDx = source.fDx;
+ this->fDz = source.fDz;
+ this->fDy = source.fDy;
+ this->fCorr = new TF1(*(source.fCorr));
+ this->fGeom = source.fGeom; // Just copy the pointer
+ this->fResponse = source.fResponse; //Just copy the pointer
+ return *this;
+}
+//___________________________________________________________________________
+AliITSsegmentationSDD::AliITSsegmentationSDD(AliITSsegmentationSDD &source){
+ // Copy constructor
+ *this = source;
+}
+//------------------------------
+void AliITSsegmentationSDD::Init(){
+ // Standard initilisation routine
+
+ AliITSgeomSDD *gsdd = (AliITSgeomSDD *) (fGeom->GetShape(3,1,1));
+
+ const Float_t kconv=10000.;
+ fDz = 2.*kconv*gsdd->GetDz();
+ fDx = kconv*gsdd->GetDx();
+ fDy = 2.*kconv*gsdd->GetDy();
+}
+
+//------------------------------
+void AliITSsegmentationSDD::
+Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[4], Int_t Zlist[4]){
+ // returns neighbers for use in Cluster Finder routines and the like
+
+ *Nlist=4;
+ Xlist[0]=Xlist[1]=iX;
+ if(iX) Xlist[2]=iX-1;
+ else Xlist[2]=iX;
+ if (iX < fNanodes) Xlist[3]=iX+1;
+ else Xlist[3]=iX;
+ if(iZ) Zlist[0]=iZ-1;
+ else Zlist[0]=iZ;
+ if (iZ < fNsamples) Zlist[1]=iZ+1;
+ else Zlist[1]=iZ;
+ Zlist[2]=Zlist[3]=iZ;
+
+}
+//------------------------------
+void AliITSsegmentationSDD::GetCellIxz(Float_t &x,Float_t &z,Int_t &timebin,Int_t &anode){
+// Returns cell coordinates (time sample,anode) for given real local coordinates (x,z)
+
+ // expects x, z in cm
+
+ const Float_t kconv=10000; // cm->um
+
+ Float_t speed=fResponse->DriftSpeed();
+ Int_t na = fNanodes/2;
+ Float_t driftpath=fDx-TMath::Abs(kconv*x);
+ timebin=(Int_t)(driftpath/speed/fTimeStep);
+ anode=(Int_t)(kconv*z/fPitch + na/2);
+ if (x > 0) anode += na;
+
+ timebin+=1;
+ anode+=1;
+
+}
+
+//------------------------------
+void AliITSsegmentationSDD::GetCellCxz(Int_t timebin,Int_t anode,Float_t &x ,Float_t &z){
+ // Transform from cell to real local coordinates
+
+ // returns x, z in cm
+
+ const Float_t kconv=10000; // um->cm
+
+ Float_t speed=fResponse->DriftSpeed();
+ Int_t na = fNanodes/2;
+ Float_t driftpath=(timebin+1)*fTimeStep*speed;
+ if (anode >= na) x=(fDx-driftpath)/kconv;
+ else x = -(fDx-driftpath)/kconv;
+ if (anode >= na) anode-=na;
+ z=((anode+1)*fPitch-fDz/2)/kconv;
+
+}
+
+//------------------------------
+void AliITSsegmentationSDD::GetLocal(Int_t module,Float_t *g ,Float_t *l){
+ // returns local coordinates from global
+ if(!fGeom) {
+ fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
+ }
+ fGeom->GtoL(module,g,l);
+}
+//------------------------------
+void AliITSsegmentationSDD::GetGlobal(Int_t module,Float_t *l ,Float_t *g){
+ // return global coordinates from local
+ if(!fGeom) {
+ fGeom = ((AliITS*)gAlice->GetModule("ITS"))->GetITSgeom();
+ }
+
+ fGeom->LtoG(module,l,g);
+
+}
--- /dev/null
+#ifndef ALIITSSEGMENTATIONSDD_H
+#define ALIITSSEGMENTATIONSDD_H
+
+
+#include "AliITSsegmentation.h"
+#include "AliITSresponse.h"
+
+// segmentation for SDD
+
+class AliITSsegmentationSDD :
+public AliITSsegmentation {
+ public:
+
+
+ AliITSsegmentationSDD();
+ AliITSsegmentationSDD(AliITSgeom *gm, AliITSresponse *resp);
+ AliITSsegmentationSDD(AliITSsegmentationSDD &source);
+ virtual ~AliITSsegmentationSDD(){}
+ AliITSsegmentationSDD& operator=(AliITSsegmentationSDD &source);
+
+ // Set Detector Segmentation Parameters
+ //
+ // Detector size : x,z,y
+ virtual void SetDetSize
+ (Float_t p1=35000., Float_t p2=76800., Float_t p3= 300.)
+ {fDx=p1; fDz=p2; fDy=p3;}
+
+ // Cell size dz*dx
+ virtual void SetCellSize(Float_t pitch=200., Float_t clock=40.)
+ {fPitch=pitch;fTimeStep=1000./clock;}
+
+ // Maximum number of cells along the two coordinates z,x (anodes,samples)
+ virtual void SetNCells(Int_t p1=384, Int_t p2=256)
+ {fNanodes=2*p1;fNsamples=p2;}
+
+ // Transform from real local to cell coordinates
+ virtual void GetCellIxz(Float_t &x ,Float_t &z ,Int_t &ix,Int_t &iz);
+ // Transform from cell to real local coordinates
+ virtual void GetCellCxz(Int_t ix,Int_t iz,Float_t &x ,Float_t &z );
+ // Transform from real global to local coordinates
+ virtual void GetLocal(Int_t module,Float_t *g ,Float_t *l);
+ // Transform from real local to global coordinates
+ virtual void GetGlobal(Int_t module,Float_t *l ,Float_t *g);
+ //
+ // Initialisation
+ virtual void Init();
+ //
+ // Get member data
+ //
+ // Detector type geometry
+ virtual AliITSgeom* Geometry() {return fGeom;}
+ // Detector length
+ virtual Float_t Dx() {return fDx;}
+ // Detector width
+ virtual Float_t Dz() {return fDz;}
+ // Detector thickness
+ virtual Float_t Dy() {return fDy;}
+ // Cell size in x
+ virtual Float_t Dpx(Int_t dummy) {return fTimeStep;}
+ // Cell size in z
+ virtual Float_t Dpz(Int_t dummy) {return fPitch;}
+
+ // Maximum number of samples in x
+ virtual Int_t Npx() {return fNsamples;}
+ // Maximum number of anodes in z
+ virtual Int_t Npz() {return fNanodes;}
+
+ //
+ // Get next neighbours
+ virtual void Neighbours
+ (Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[10], Int_t Zlist[10]);
+
+ // Set cell position
+ virtual void SetPad(Int_t, Int_t) {}
+ // Set hit position
+ virtual void SetHit(Float_t, Float_t) {}
+
+ //
+ // Iterate over cells
+ // Initialiser
+ virtual void FirstCell
+ (Float_t xhit, Float_t zhit, Float_t dx, Float_t dz) {}
+ // Stepper
+ virtual void NextCell() {}
+ // Condition
+ virtual Int_t MoreCells() {return 0;}
+ //
+ // Current cell cursor during disintegration
+ // x-coordinate
+ virtual Int_t Ix() {return 0;}
+ // z-coordinate
+ virtual Int_t Iz() {return 0;}
+ //
+ // Signal Generation Condition during Stepping
+ virtual Int_t SigGenCond(Float_t x, Float_t y, Float_t z) {return 0;}
+ // Initialise signal generation at coord (x,y,z)
+ virtual void SigGenInit(Float_t x, Float_t y, Float_t z) {}
+ // Current integration limits
+ virtual void IntegrationLimits
+ (Float_t& x1, Float_t& x2, Float_t& z1, Float_t& z2) {}
+ // Test points for auto calibration
+ virtual void GiveTestPoints(Int_t &n, Float_t *x, Float_t *z) {}
+ // Function for systematic corrections
+ // Set the correction function
+ virtual void SetCorrFunc(Int_t, TF1*) {}
+ // Get the correction Function
+ virtual TF1* CorrFunc(Int_t) {return 0;}
+
+ protected:
+
+ Int_t fNsamples; // Number of time samples in x
+ Int_t fNanodes; // Summed # of anodes in the two det halves (z)
+ Float_t fPitch; // Anode pitch - microns
+ Float_t fTimeStep; // Sampling time - ns
+ Float_t fDx ; // Full width of the detector (x axis) - microns
+ Float_t fDz ; // Length of half-detector (z axis) - microns
+ Float_t fDy; // Full thickness of the detector (y axis)
+
+ AliITSgeom *fGeom; // pointer to the geometry class
+ AliITSresponse *fResponse; // pointer to the response class
+
+ TF1* fCorr; // correction function
+
+ ClassDef(AliITSsegmentationSDD,1) // SDD segmentation
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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 <TMath.h>
+
+#include "AliITSsegmentationSPD.h"
+
+ClassImp(AliITSsegmentationSPD)
+
+
+Float_t ColFromZ300(Float_t z) {
+// Get column number for each z-coordinate taking into account the
+// extra pixels in z direction assuming 300 micron sized pixels.
+ Float_t col = 0.0;
+ Float_t pitchz = 300.0;
+ col = Float_t (z/pitchz);
+ return col;
+}
+//_____________________________________________________________________________
+Float_t ZFromCol300(Int_t col) {
+// same comments as above
+// Get z-coordinate for each colunm number
+ Float_t pitchz = 300.0;
+ Float_t z = 0.0;
+ z = (col+0.5)*pitchz;
+ return z;
+}
+//_____________________________________________________________________________
+Float_t ZpitchFromCol300(Int_t col) {
+ // returns Z pixel pitch for 300 micron pixels.
+ return 300.0;
+}
+//_____________________________________________________________________________
+Float_t ColFromZ(Float_t z) {
+// hard-wired - keep it like this till we can parametrise
+// and get rid of AliITSgeomSPD425
+// Get column number for each z-coordinate taking into account the
+// extra pixels in z direction
+
+ Float_t col = 0;
+ Float_t pitchz = 425;
+ if( z < 13175) {
+ col = Float_t(z/pitchz);
+ } else if( z < 14425) {
+ pitchz = 625;
+ col = 31 + (z - 13175)/pitchz;
+ } else if( z < 27175) {
+ col = 33 + (z - 14425)/pitchz;
+ } else if( z < 28425) {
+ pitchz = 625;
+ col = 63 + (z - 27175)/pitchz;
+ } else if( z < 41175) {
+ col = 65 + (z - 28425)/pitchz;
+ } else if( z < 42425) {
+ pitchz = 625;
+ col = 95 + (z - 41175)/pitchz;
+ } else if( z < 55175) {
+ col = 97 + (z - 42425)/pitchz;
+ } else if( z < 56425) {
+ pitchz = 625;
+ col = 127 + (z - 55175)/pitchz;
+ } else if( z < 69175) {
+ col = 129 + (z - 56425)/pitchz;
+ } else if( z < 70425) {
+ pitchz = 625;
+ col = 159 + (z - 69175)/pitchz;
+ } else if( z < 83600) {
+ col = 161 + (z - 70425)/pitchz;
+ }
+ return col;
+}
+
+//_____________________________________________________________________________
+Float_t ZFromCol(Int_t col) {
+// same comments as above
+// Get z-coordinate for each colunm number
+
+ Float_t pitchz = 425;
+ Float_t z = 0;
+ if( col >=0 && col <= 30 ) {
+ z = (col + 0.5)*pitchz;
+ } else if( col >= 31 && col <= 32) {
+ pitchz = 625;
+ z = 13175 + (col -31 + 0.5)*pitchz;
+ } else if( col >= 33 && col <= 62) {
+ z = 14425 + (col -33 + 0.5)*pitchz;
+ } else if( col >= 63 && col <= 64) {
+ pitchz = 625;
+ z = 27175 + (col -63 + 0.5)*pitchz;
+ } else if( col >= 65 && col <= 94) {
+ z = 28425 + (col -65 + 0.5)*pitchz;
+ } else if( col >= 95 && col <= 96) {
+ pitchz = 625;
+ z = 41175 + (col -95 + 0.5)*pitchz;
+ } else if( col >= 97 && col <= 126) {
+ z = 42425 + (col -97 + 0.5)*pitchz;
+ } else if( col >= 127 && col <= 128) {
+ pitchz = 625;
+ z = 55175 + (col -127 + 0.5)*pitchz;
+ } else if( col >= 129 && col <= 158) {
+ z = 56425 + (col -129 + 0.5)*pitchz;
+ } else if( col >= 159 && col <= 160) {
+ pitchz = 625;
+ z = 69175 + (col -159 + 0.5)*pitchz;
+ } else if( col >= 161 && col <= 191) {
+ z = 70425 + (col -161 + 0.5)*pitchz;
+ }
+
+ return z;
+}
+
+Float_t ZpitchFromCol(Int_t col) {
+// Get pitch size in z direction for each colunm
+
+ Float_t pitchz = 425;
+ if( col >=32 && col <= 33 ) {
+ pitchz = 625;
+ } else if( col >= 64 && col <= 65) {
+ pitchz = 625;
+ } else if( col >= 96 && col <= 97) {
+ pitchz = 625;
+ } else if( col >= 128 && col <= 129) {
+ pitchz = 625;
+ } else if( col >= 160 && col <= 161) {
+ pitchz = 625;
+ }
+ return pitchz;
+}
+
+AliITSsegmentationSPD::AliITSsegmentationSPD(){
+ // Default constructor
+ fNpx = 0;
+ fNpz = 0;
+ fCorr=0;
+ fGeom = 0;
+
+}
+//____________________________________________________________________________
+AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm){
+ // Constructor
+ fCorr=0;
+ fNpx = 0;
+ fNpz = 0;
+ Init();
+ fGeom = gm;
+
+}
+//____________________________________________________________________________
+AliITSsegmentationSPD& AliITSsegmentationSPD::operator=(AliITSsegmentationSPD &source){
+ // = operator
+ Int_t i;
+ if(this==&source) return *this;
+ this->fNpx = source.fNpx;
+ this->fNpz = source.fNpz;
+ this->fDx = source.fDx;
+ this->fDy = source.fDy;
+ for(i=0;i<256;i++) this->fCellSizeX[i] = source.fCellSizeX[i];
+ for(i=0;i<280;i++) this->fCellSizeZ[i] = source.fCellSizeZ[i];
+ this->fCorr = new TF1(*(source.fCorr));// make a proper copy of the function
+ this->fGeom = source.fGeom; // copy only the pointers.
+ return *this;
+}
+//____________________________________________________________________________
+AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSsegmentationSPD &source){
+ // copy constructor
+ *this = source;
+}
+//------------------------------
+void AliITSsegmentationSPD::Init300(){
+// Initialize infromation for 6 read out chip 300X50 micron pixel SPD
+// detectors. This chip is 150 microns thick by 1.28 cm in x by 8.37 cm
+// long. It has 256 50 micron pixels in x and 279 300 micron size
+// pixels in z.
+
+ Int_t i;
+ //const Float_t kconv=10000.;
+ fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
+ fNpz = 279; // The number of Z pixel Cell same as in fCellSizeZ array size
+ for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
+ for(i=0;i<fNpz;i++) fCellSizeZ[i] = ZpitchFromCol300(i); // microns
+ for(i=fNpz;i<280;i++) fCellSizeZ[i] = 0.0; // zero out rest of array
+ fDx = 0;
+ for(i=0;i<fNpx;i++) fDx += fCellSizeX[i];
+ fDz = 0;
+ for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
+ fDy = 300.0; //microns SPD sensitive layer thickness
+}
+
+//------------------------------
+void AliITSsegmentationSPD::Init(){
+// Initialize infromation for 6 read out chip 425X50 micron pixel SPD
+// detectors. This chip is 150 microns thick by 1.28 cm in x by 8.375 cm
+// long. It has 256 50 micron pixels in x and 197 mostly 425 micron size
+// pixels in z. The two pixels between each readout chip are 625 microns long.
+
+ Int_t i;
+ //const Float_t kconv=10000.;
+ fNpx = 256; // The number of X pixel Cell same as in fCellSizeX array size
+ fNpz = 192; // The number of Z pixel Cell same as in fCellSizeZ array size
+ for(i=0;i<fNpx;i++) fCellSizeX[i] = 50.0; // microns all the same
+ for(i=0;i<fNpz;i++) fCellSizeZ[i] = ZpitchFromCol(i); // microns
+ for(i=fNpz;i<280;i++) fCellSizeZ[i] = 0.0; // zero out rest of array
+ fDx = 0;
+ for(i=0;i<fNpx;i++) fDx += fCellSizeX[i];
+ fDz = 0;
+ for(i=0;i<fNpz;i++) fDz += fCellSizeZ[i];
+ fDy = 300.0; //microns SPD sensitive layer thickness
+ printf(" AliITSsegmentationSPD - Init: fNpx fNpz fDx fDz %d %d %f %f\n",fNpx, fNpz, fDx, fDz);
+
+}
+//------------------------------
+void AliITSsegmentationSPD::SetNCells(Int_t p1, Int_t p2){
+ // for SPD this function should be used ONLY when a beam test setup
+ // configuration is studied
+
+ fNpx=p1;
+ fNpz=p2;
+
+}
+//------------------------------
+void AliITSsegmentationSPD::SetDetSize(Float_t p1, Float_t p2, Float_t p3){
+ // for SPD this function should be used ONLY when a beam test setup
+ // configuration is studied
+
+ fDx=p1;
+ fDz=p2;
+ fDy=p3;
+
+}
+//------------------------------
+Float_t AliITSsegmentationSPD::Dpx(Int_t i){
+ //returs x pixel pitch for a give pixel
+ return fCellSizeX[i];
+}
+//------------------------------
+Float_t AliITSsegmentationSPD::Dpz(Int_t i){
+ // returns z pixel pitch for a give pixel
+ return ZpitchFromCol(i);
+}
+//------------------------------
+void AliITSsegmentationSPD::GetCellIxz(Float_t &x,Float_t &z,Int_t &ix,Int_t &iz){
+// Returns pixel coordinates (ix,iz) for given real local coordinates (x,z)
+//
+
+ // expects x, z in microns
+
+ // same segmentation on x
+ Float_t dpx=Dpx(0);
+ ix = (Int_t)(x/dpx + 1);
+ // different segmentation on z
+ iz = (Int_t)(ColFromZ(z) + 1);
+
+ x /= dpx;
+ z = ColFromZ(z);
+
+ if (iz > fNpz) iz= fNpz;
+ if (ix > fNpx) ix= fNpx;
+
+ /*
+ if (iz < -fNpz) iz= -fNpz;
+ if (ix < -fNpx) ix=-fNpx;
+ */
+}
+
+//------------------------------
+void AliITSsegmentationSPD::GetCellCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z){
+ // Transform from pixel to real local coordinates
+
+ // returns x, z in microns
+
+ Float_t dpx=Dpx(0);
+
+ x = (ix>0) ? Float_t(ix*dpx)-dpx/2. : Float_t(ix*dpx)+dpx/2.;
+ z = ZFromCol(iz);
+
+
+}
+//------------------------------
+void AliITSsegmentationSPD::
+Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
+ // returns the neighbouring pixels for use in Cluster Finders and the like.
+ /*
+ *Nlist=4;Xlist[0]=Xlist[1]=iX;Xlist[2]=iX-1;Xlist[3]=iX+1;
+ Zlist[0]=iZ-1;Zlist[1]=iZ+1;Zlist[2]=Zlist[3]=iZ;
+ */
+
+
+ *Nlist=8;
+ Xlist[0]=Xlist[1]=iX;
+ Xlist[2]=iX-1;
+ Xlist[3]=iX+1;
+ Zlist[0]=iZ-1;
+ Zlist[1]=iZ+1;
+ Zlist[2]=Zlist[3]=iZ;
+
+ // Diagonal elements
+ Xlist[4]=iX+1;
+ Zlist[4]=iZ+1;
+
+ Xlist[5]=iX-1;
+ Zlist[5]=iZ-1;
+
+ Xlist[6]=iX-1;
+ Zlist[6]=iZ+1;
+
+ Xlist[7]=iX+1;
+ Zlist[7]=iZ-1;
+}
--- /dev/null
+#ifndef ALIITSSEGMENTATIONSPD_H
+#define ALIITSSEGMENTATIONSPD_H
+
+#include "AliITSsegmentation.h"
+
+// segmentation and response for SPD
+
+class AliITSsegmentationSPD :
+public AliITSsegmentation {
+ public:
+
+ AliITSsegmentationSPD();
+ AliITSsegmentationSPD(AliITSgeom *gm);
+ AliITSsegmentationSPD(AliITSsegmentationSPD &source);
+ virtual ~AliITSsegmentationSPD(){}
+ AliITSsegmentationSPD& operator=(AliITSsegmentationSPD &source);
+
+ // Set Detector Segmentation Parameters
+ //
+ // Detector size along x,z,y coordinates
+ virtual void SetDetSize(Float_t Dx, Float_t Dz, Float_t Dy);
+
+ // Maximum number of pixels along the two coordinates
+ virtual void SetNCells(Int_t p1, Int_t p2);
+
+ // Transform from real to pixel coordinates
+ virtual void GetCellIxz
+ (Float_t &x,Float_t &z,Int_t &ix,Int_t &iz);
+ // Transform from pixel to real coordinates
+ virtual void GetCellCxz
+ (Int_t ix,Int_t iz,Float_t &x,Float_t &z);
+ // Transform from real global to local coordinates
+ virtual void GetLocal(Int_t module,Float_t *g ,Float_t *l) {}
+ // Transform from real local to global coordinates
+ virtual void GetGlobal(Int_t module,Float_t *l ,Float_t *g) {}
+ //
+ // Initialisation
+ virtual void Init();
+ virtual void Init300();
+ //
+ // Get member data
+ //
+ // Detector Type geometry
+ virtual AliITSgeom* Geometry() {return fGeom;}
+ // Detector length
+ virtual Float_t Dx() {return fDx;}
+ // Detector width
+ virtual Float_t Dz() {return fDz;}
+ // Detector thickness
+ virtual Float_t Dy() {return fDy;}
+ // Pixel size in x
+ virtual Float_t Dpx(Int_t ix);
+ // Pixel size in z
+ virtual Float_t Dpz(Int_t iz);
+
+ // Maximum number of Pixels in x
+ virtual Int_t Npx() {return fNpx;}
+ // Maximum number of Pixels in z
+ virtual Int_t Npz(){return fNpz;}
+ //
+ // Get next neighbours
+ virtual void Neighbours
+ (Int_t iX,Int_t iZ,Int_t* Nlist,Int_t Xlist[10],Int_t Zlist[10]);
+
+ protected:
+
+ Int_t fNpx; // Number of pixels in x
+ Int_t fNpz; // Number of pixels in z
+ Float_t fDx; // Full width of the detector (x axis)- microns
+ Float_t fDz; // Full length of the detector (z axis)- microns
+ Float_t fDy; // Full thickness of the detector (y axis) -um
+ Float_t fCellSizeX[256];// Size for each pixel in x -microns
+ Float_t fCellSizeZ[280];// Size for each pixel in z -microns
+ TF1* fCorr; // correction function
+ AliITSgeom *fGeom; // local pointer to AliITSgeom.
+
+ ClassDef(AliITSsegmentationSPD,1) //Segmentation class for SPD
+
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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 <TMath.h>
+
+#include "AliITSsegmentationSSD.h"
+#include "AliITSgeom.h"
+
+
+ClassImp(AliITSsegmentationSSD)
+AliITSsegmentationSSD::AliITSsegmentationSSD(){
+ // default constructor
+ fGeom=0;
+ fCorr=0;
+ SetDetSize();
+ SetCellSize();
+ SetNCells();
+ SetAngles();
+}
+//------------------------------
+AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
+ // constuctor
+ fGeom=geom;
+ fCorr=0;
+ SetDetSize();
+ SetCellSize();
+ SetNCells();
+ SetAngles();
+ //Init();
+}
+//____________________________________________________________________________
+AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(AliITSsegmentationSSD &source){
+// Operator =
+ if(this==&source) return *this;
+ this->fNstrips = source.fNstrips;
+ this->fStereoP = source.fStereoP;
+ this->fStereoN = source.fStereoN;
+ this->fPitch = source.fPitch;
+ this->fDz = source.fDz;
+ this->fDx = source.fDx;
+ this->fDy = source.fDy;
+ this->fGeom = source.fGeom; // copy only the pointer
+ this->fCorr = new TF1(*(source.fCorr)); // make a proper copy
+ return *this;
+
+}
+//____________________________________________________________________________
+AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSsegmentationSSD &source){
+ // copy constructor
+ *this = source;
+}
+//------------------------------
+void AliITSsegmentationSSD::Init(){
+ // standard initalizer
+
+ AliITSgeomSSD *gssd = (AliITSgeomSSD *) (fGeom->GetShape(5,1,1));
+ const Float_t kconv=10000.;
+ fDx = 2.*kconv*gssd->GetDx();
+ fDz = 2.*kconv*gssd->GetDz();
+ fDy = 2.*kconv*gssd->GetDy();
+ SetCellSize();
+ SetNCells();
+ SetAngles();
+
+}
+//-------------------------------------------------------
+void AliITSsegmentationSSD::GetCellIxz(Float_t &x,Float_t &z,Int_t &iP,Int_t &iN)
+{
+ // returns P and N sided strip numbers for a given location.
+
+ // expects x, z in microns
+
+ Float_t tanP=TMath::Tan(fStereoP);
+ Float_t tanN=TMath::Tan(fStereoN);
+
+ Float_t x1=x,z1=z;
+ x1 += fDx/2;
+ z1 += fDz/2;
+
+ Float_t ldX = x1 - z1*tanP; // distance from left-down edge
+ iP = (Int_t)(ldX/fPitch);
+ iP = (iP<0)? -1: iP;
+ iP = (iP>fNstrips)? -1: iP;
+
+
+ ldX = x1 - tanN*(fDz - z1);
+ iN = (Int_t)(ldX/fPitch);
+ iN = (iN<0)? -1: iN;
+ iN = (iN>fNstrips)? -1: iN;
+
+}
+//-------------------------------------------------------
+void AliITSsegmentationSSD::GetCellCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z)
+{
+ // actually this is the GetCrossing(Float_t &,Float_t &)
+
+ // returns x, z in microns !
+
+ Float_t flag=2*fDx;
+
+ Float_t tanP=TMath::Tan(fStereoP);
+ Float_t tanN=TMath::Tan(fStereoN);
+
+ Float_t dx = 0.1;
+ x = iP*fPitch;
+ z = iN*fPitch;
+
+ if(tanP + tanN == 0) {x=z=flag; return ;}
+
+ z = (z - x + tanN * fDz) / (tanP + tanN);
+ x = x + tanP * z;
+
+ x -= fDx/2;
+ z -= fDz/2;
+
+ if ( ( z < -(fDz/2+dx) ) || ( z > (fDz/2+dx) ) ) {x=z=flag; return ;}
+ if ( ( x < -(fDx/2+dx) ) || ( x > (fDx/2+dx) ) ) {x=z=flag; return ;}
+
+ return;
+}
--- /dev/null
+#ifndef ALIITSSEGMENTATIONSSD_H
+#define ALIITSSEGMENTATIONSSD_H
+
+#include "AliITSsegmentation.h"
+
+// segmentation for SSD
+
+class AliITSsegmentationSSD :
+public AliITSsegmentation {
+ public:
+
+ AliITSsegmentationSSD();
+ AliITSsegmentationSSD(AliITSgeom *gm);
+ AliITSsegmentationSSD(AliITSsegmentationSSD &source);
+ virtual ~AliITSsegmentationSSD(){}
+ AliITSsegmentationSSD& operator=(AliITSsegmentationSSD &source);
+
+
+ // Detector size: x,z,y
+ virtual void SetDetSize
+ (Float_t p1=72960., Float_t p2=40000., Float_t p3= 300.)
+ {fDx=p1; fDz=p2; fDy=p3;}
+
+ // Strip size
+ virtual void SetCellSize(Float_t pitch=95., Float_t dummy=1.)
+ {fPitch=pitch;}
+
+ // Maximum number of strips along the two coordinates
+ virtual void SetNCells(Int_t p1=768, Int_t dummy=1)
+ {fNstrips=p1;}
+
+
+ // Set stereo angles Pside-Nside
+ virtual void SetAngles(Float_t pa=0.0175, Float_t na=0.0175)
+ {fStereoP=pa; fStereoN=na;}
+
+ // Transform from real coordinates to strips
+ virtual void GetCellIxz
+ (Float_t &x ,Float_t &z ,Int_t &iP,Int_t &iN);
+ // Transform from strips to real coordinates
+ virtual void GetCellCxz
+ (Int_t iP, Int_t iN, Float_t &x , Float_t &z);
+
+ // Transform from real global to local coordinates
+ virtual void GetLocal(Int_t module,Float_t *g ,Float_t *l) {}
+ // Transform from real local to global coordinates
+ virtual void GetGlobal(Int_t module,Float_t *l ,Float_t *g) {}
+
+ virtual void Init();
+
+ // Detector type geometry
+ virtual AliITSgeom* Geometry() {return 0;}
+ // Detector length
+ virtual Float_t Dx() {return fDx;}
+ // Detector width
+ virtual Float_t Dz() {return fDz;}
+ // Detector thickness
+ virtual Float_t Dy() {return fDy;}
+ // Strip size in x
+ virtual Float_t Dpx(Int_t) {return fPitch;}
+ // Strip size in z
+ virtual Float_t Dpz(Int_t) {return fDz;}
+ // Maximum number of Strips in x
+ virtual Int_t Npx() {return fNstrips;}
+ // Maximum number of Strips in z
+ virtual Int_t Npz(){return 1;}
+
+ // Angles : Pside stereo angle-Nside stereo angle
+ virtual void Angles(Float_t &aP,Float_t &aN)
+ {aP=fStereoP;aN=fStereoN;}
+
+ protected:
+
+ Int_t fNstrips; // Number of strips in x
+ Float_t fStereoP; // Stereo angle for Pside
+ Float_t fStereoN; // Stereo angle for Nside
+ Float_t fPitch; // Pitch of the strips
+ Float_t fDz; // Full width of the detector (z axis)- microns
+ Float_t fDx; // Full length of the detector (x axis)- microns
+ Float_t fDy; // Full thickness of the detector (y axis) -um
+
+ AliITSgeom *fGeom; // pointer to the geometry class
+ TF1* fCorr; // correction function
+
+ ClassDef(AliITSsegmentationSSD,1) //Segmentation class for SSD
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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 "AliITSsimulation.h"
+
+ClassImp(AliITSsimulation)
+
+AliITSsimulation::AliITSsimulation()
+{
+ // constructor
+ fSegmentation=0;
+ fResponse=0;
+}
+
+//__________________________________________________________________________
+AliITSsimulation::AliITSsimulation(const AliITSsimulation &source){
+ // Copy Constructor
+ if(&source == this) return;
+ this->fResponse = source.fResponse;
+ this->fSegmentation = source.fSegmentation;
+ return;
+}
+
+//_________________________________________________________________________
+AliITSsimulation&
+ AliITSsimulation::operator=(const AliITSsimulation &source) {
+ // Assignment operator
+ if(&source == this) return *this;
+ this->fResponse = source.fResponse;
+ this->fSegmentation = source.fSegmentation;
+ return *this;
+}
--- /dev/null
+#ifndef ALIITSSIMULATION_H
+#define ALIITSSIMULATION_H
+
+#include <TObject.h>
+
+class AliITSresponse;
+class AliITSsegmentation;
+class AliITSmodule;
+
+//___________________________________________________
+
+class AliITSsimulation : public TObject {
+
+public:
+
+ AliITSsimulation();
+ virtual ~AliITSsimulation() {
+ // destructor
+ }
+ AliITSsimulation(const AliITSsimulation &source); // copy constructor
+ AliITSsimulation& operator=(const AliITSsimulation &source); // ass.
+
+ virtual void DigitiseModule(AliITSmodule *mod,Int_t module,Int_t event) {
+ // digitize module
+ }
+
+ virtual void CreateFastRecPoints(AliITSmodule *mod) {
+ // create fast rec points
+ }
+
+protected:
+
+ AliITSresponse *fResponse; // response
+ AliITSsegmentation *fSegmentation; // segmentation
+
+ ClassDef(AliITSsimulation,1) // Simulation base class
+
+};
+
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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. *
+ **************************************************************************/
+
+/*
+$Log$
+Revision 1.1.2.1 2000/06/11 20:16:05 barbera
+New: Fast simulation class for the ITS, class as part of new ITS code
+structure.
+
+*/
+
+#include <TParticle.h>
+#include "AliITS.h"
+#include "AliITSsimulationFastPoints.h"
+#include "AliITSstatistics.h"
+
+ClassImp(AliITSsimulationFastPoints)
+
+AliITSsimulationFastPoints::AliITSsimulationFastPoints()
+{
+ //constructor
+ fSx = new AliITSstatistics(2);
+ fSz = new AliITSstatistics(2);
+}
+
+//----------------------------------------------------------
+AliITSsimulationFastPoints::~AliITSsimulationFastPoints()
+{
+ //destructor
+ delete fSx;
+ delete fSz;
+
+}
+
+//-------------------------------------------------------------
+void AliITSsimulationFastPoints::CreateFastRecPoints(AliITSmodule *mod){
+ // Fast points simulator for all of the ITS.
+ Int_t nhit,h,trk,ifirst;
+ Float_t x,y,z,t,e;// local coordinate (cm) and time of flight, and dedx.
+ Float_t x1,y1,z1;
+ AliITShit *hit;
+
+ fSx->Reset(); // Start out with things clearly zeroed
+ fSz->Reset(); // Start out with things clearly zeroed
+ e = 0.; // Start out with things clearly zeroed
+ Double_t weight=1.;
+ nhit = mod->GetNhits();
+ ifirst = 1;
+ for(h=0;h<nhit;h++){
+ hit = mod->GetHit(h);
+ hit->GetPositionL(x,y,z,t);
+ if(ifirst) {x1=x;y1=y;z1=z;}
+ e += hit->GetIonization();
+ trk = hit->GetTrack();
+ fSx->AddValue((Double_t)x,weight);
+ fSz->AddValue((Double_t)z,weight);
+ ifirst = 0;
+ if(hit->StatusExiting()|| // leaving volume
+ hit->StatusDisappeared()|| // interacted/decayed...
+ hit->StatusStop() // dropped below E cuts.
+ ){ // exiting track, write out RecPoint.
+ // if(fSz->GetRMS()>1.E-1) {
+ // TParticle *part = hit->GetParticle();
+ // printf("idpart %d energy %f \n",part->GetPdgCode(),part->Energy());
+ // printf("diffx=%e diffy=%e diffz=%e\n",x-x1,y-y1,z-z1);
+ // }
+ switch (mod->GetLayer()){
+ case 1: case 2: // SPDs
+ AddSPD(e,mod,trk);
+ break;
+ case 3: case 4: // SDDs
+ AddSDD(e,mod,trk);
+ break;
+ case 5: case 6: // SSDs
+ AddSSD(e,mod,trk);
+ break;
+ } // end switch
+ fSx->Reset();
+ fSz->Reset();
+ e = 0.;
+ ifirst = 1;
+ continue;
+ }// end if
+ } // end for h
+}
+//_______________________________________________________________________
+void AliITSsimulationFastPoints::AddSPD(Float_t &e,
+ AliITSmodule *mod,Int_t trackNumber){
+ const Float_t kcmTomicron = 1.0e4;
+ // const Float_t kdEdXtoQ = ;
+ const Float_t kRMSx = 12.0; // microns ITS TDR Table 1.3
+ const Float_t kRMSz = 70.0; // microns ITS TDR Table 1.3
+ Float_t a1,a2; // general float.
+ AliITSRecPoint rpSPD;
+ Int_t *trk = rpSPD.GetTracks();
+
+ trk[0] = trackNumber;
+ trk[1] = 0; trk[2] = 0;
+ rpSPD.SetX(kcmTomicron*fSx->GetMean());
+ rpSPD.SetZ(kcmTomicron*fSz->GetMean());
+ rpSPD.SetdEdX(0.0);
+ rpSPD.SetQ(1.0);
+ a1 = kcmTomicron*fSx->GetRMS(); a1 *= a1; a1 += kRMSx*kRMSx;
+ // if(a1>1.E5) printf("addSPD: layer=%d track #%d dedx=%e sigmaX2= %e ",
+ // mod->GetLayer(),trackNumber,e,a1);
+ rpSPD.SetSigmaX2(a1);
+ a2 = kcmTomicron*fSz->GetRMS(); a2 *= a2; a2 += kRMSz*kRMSz;
+ // if(a1>1.E5) printf(" sigmaZ2= %e\n",a2);
+ rpSPD.SetSigmaZ2(a2);
+ rpSPD.SetProbability(1.0);
+
+ (mod->GetITS())->AddRecPoint(rpSPD);
+}
+//_______________________________________________________________________
+void AliITSsimulationFastPoints::AddSDD(Float_t &e,
+ AliITSmodule *mod,Int_t trackNumber){
+
+ const Float_t kcmTomicron = 1.0e4;
+ const Float_t kdEdXtoQ = 2.778e+8; // Boris Batyuna June 10 2000.
+ const Float_t kRMSx = 38.0; // microns ITS TDR Table 1.3
+ const Float_t kRMSz = 28.0; // microns ITS TDR Table 1.3
+ Float_t a1,a2; // general float.
+ AliITSRecPoint rpSDD;
+ Int_t *trk = rpSDD.GetTracks();
+
+ trk[0] = trackNumber;
+ trk[1] = 0; trk[2] = 0;
+ rpSDD.SetX(kcmTomicron*fSx->GetMean());
+ rpSDD.SetZ(kcmTomicron*fSz->GetMean());
+ rpSDD.SetdEdX(e);
+ rpSDD.SetQ(kdEdXtoQ*e);
+ a1 = kcmTomicron*fSx->GetRMS(); a1 *= a1; a1 += kRMSx*kRMSx;
+ // if(a1>1.E5) printf("addSDD: layer=%d track #%d dedx=%e sigmaX2= %e ",
+ // mod->GetLayer(),trackNumber,e,a1);
+ rpSDD.SetSigmaX2(a1);
+ a2 = kcmTomicron*fSz->GetRMS(); a2 *= a2; a2 += kRMSz*kRMSz;
+ // if(a1>1.E5) printf(" sigmaZ2= %e\n",a2);
+ rpSDD.SetSigmaZ2(a2);
+ rpSDD.SetProbability(1.0);
+
+ (mod->GetITS())->AddRecPoint(rpSDD);
+}
+//_______________________________________________________________________
+void AliITSsimulationFastPoints::AddSSD(Float_t &e,
+ AliITSmodule *mod,Int_t trackNumber){
+
+ const Float_t kcmTomicron = 1.0e4;
+ const Float_t kdEdXtoQ = 2.778e+8; // Boris Batyuna June 10 2000.
+ const Float_t kRMSx = 20.0; // microns ITS TDR Table 1.3
+ const Float_t kRMSz = 830.0; // microns ITS TDR Table 1.3
+ Float_t a1,a2; // general float.
+ AliITSRecPoint rpSSD;
+ Int_t *trk = rpSSD.GetTracks();
+
+ trk[0] = trackNumber;
+ trk[1] = 0; trk[2] = 0;
+ rpSSD.SetX(kcmTomicron*fSx->GetMean());
+ rpSSD.SetZ(kcmTomicron*fSz->GetMean());
+ rpSSD.SetdEdX(e);
+ rpSSD.SetQ(kdEdXtoQ*e);
+ a1 = kcmTomicron*fSx->GetRMS(); a1 *= a1; a1 += kRMSx*kRMSx;
+ // if(a1>1.E5) printf("addSSD: layer=%d track #%d dedx=%e sigmaX2= %e ",
+ // mod->GetLayer(),trackNumber,e,a1);
+ rpSSD.SetSigmaX2(a1);
+ a2 = kcmTomicron*fSz->GetRMS(); a2 *= a2; a2 += kRMSz*kRMSz;
+ // if(a1>1.E5) printf(" sigmaZ2= %e RMSx=%e RMSz=%e\n",a2,fSx->GetRMS(),fSz->GetRMS());
+ rpSSD.SetSigmaZ2(a2);
+ rpSSD.SetProbability(1.0);
+
+ (mod->GetITS())->AddRecPoint(rpSSD);
+}
+//_______________________________________________________________________
--- /dev/null
+#ifndef ALIITSSIMULATIONFASTPOINTS_H
+#define ALIITSSIMULATIONFASTPOINTS_H
+
+#include "AliITSsimulation.h"
+
+class AliITSmodule;
+class AliITSstatistics;
+
+class AliITSsimulationFastPoints : public AliITSsimulation
+{
+
+public:
+ AliITSsimulationFastPoints(); // default constructor
+ virtual ~AliITSsimulationFastPoints();
+ void CreateFastRecPoints(AliITSmodule *mod);
+private:
+ void AddSPD(Float_t &e,AliITSmodule *mod,Int_t trackNumber);
+ void AddSDD(Float_t &e,AliITSmodule *mod,Int_t trackNumber);
+ void AddSSD(Float_t &e,AliITSmodule *mod,Int_t trackNumber);
+
+private:
+
+ AliITSstatistics *fSx; // pointer to AliITSstatistics class
+ AliITSstatistics *fSz; // pointer to AliITSstatistics class
+
+ ClassDef(AliITSsimulationFastPoints,1) // Fast point simulator.
+
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * 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 <iostream.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+
+
+#include "AliRun.h"
+#include "AliITSetfSDD.h"
+#include "AliITSsimulationSDD.h"
+#include "AliITSHuffman.h"
+
+const Int_t kMaxNeighbours = 4;
+
+ClassImp(AliITSsimulationSDD)
+////////////////////////////////////////////////////////////////////////
+// Version: 0
+// Written by Piergiorgio Cerello
+// November 23 1999
+//
+// AliITSsimulationSDD is the simulation of SDDs.
+ //
+//Begin_Html
+/*
+<img src="picts/ITS/AliITShit_Class_Diagram.gif">
+</pre>
+<br clear=left>
+<font size=+2 color=red>
+<p>This show the relasionships between the ITS hit class and the rest of Aliroot.
+</font>
+<pre>
+*/
+//End_Html
+//_____________________________________________________________________________
+
+Int_t power(Int_t b, Int_t e) {
+ // copute b to the e power, where bothe b and e are Int_ts.
+ Int_t power = 1,i;
+ for(i=0; i<e; i++) power *= b;
+ return power;
+}
+
+//_____________________________________________
+
+void FastFourierTransform(AliITSetfSDD *alisddetf,Double_t *real,
+ Double_t *imag,Int_t direction) {
+ // Do a Fast Fourier Transform
+
+ Int_t samples = alisddetf->GetSamples();
+ 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; j<samples; j += m1) {
+ Int_t p = 0;
+ for(k=j; k<= j+m-1; k++) {
+ Double_t wsr = alisddetf->GetWeightReal(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;
+ }
+ }
+ m1 = m;
+ m /= 2;
+ m2 += m2;
+ }
+
+ for(j=0; j<samples; j++) {
+ Int_t j1 = j;
+ Int_t p = 0;
+ Int_t i1;
+ for(i1=1; i1<=l; i1++) {
+ Int_t j2 = j1;
+ j1 /= 2;
+ p = p + p + j2 - j1 - j1;
+ }
+ if(p >= 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;
+ }
+ }
+ if(direction == -1) {
+ for(i=0; i<samples; i++) {
+ *(real+i) /= samples;
+ *(imag+i) /= samples;
+ }
+ }
+ return;
+}
+//_____________________________________________________________________________
+
+AliITSsimulationSDD::AliITSsimulationSDD(){
+ // Default constructor
+
+ fResponse = 0;
+ fSegmentation = 0;
+ fHis = 0;
+ fD.Set(0);
+ fT1.Set(0);
+ fT2.Set(0);
+ fTol.Set(0);
+}
+//_____________________________________________________________________________
+AliITSsimulationSDD::AliITSsimulationSDD(AliITSsimulationSDD &source){
+ // Copy constructor to satify Coding roules only.
+ if(this==&source) return;
+ printf("Not allowed to make a copy of AliITSsimulationSDD "
+ "Using default creater instead\n");
+ AliITSsimulationSDD();
+}
+//_____________________________________________________________________________
+AliITSsimulationSDD& AliITSsimulationSDD::operator=(AliITSsimulationSDD
+ &source){
+ // Copy constructor to satify Coding roules only.
+ if(this==&source) return *this;
+ printf("Not allowed to make a = with AliITSsimulationSDD "
+ "Using default creater instead\n");
+ return *this ;
+}
+//_____________________________________________________________________________
+
+AliITSsimulationSDD::AliITSsimulationSDD(AliITSsegmentation *seg,
+ AliITSresponse *resp) {
+ // Constructor
+ fResponse = resp;
+ fSegmentation = seg;
+
+ fHitMap2 = new AliITSMapA2(fSegmentation);
+ fHitMap1 = new AliITSMapA1(fSegmentation);
+
+ //
+ fNofMaps=fSegmentation->Npz();
+ fMaxNofSamples=fSegmentation->Npx();
+
+ 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);
+ }
+
+ if(timeStep*fMaxNofSamples < sddLength/driftSpeed) {
+ Error("AliITSsimulationSDD",
+ "Time Interval > Allowed Time Interval: exit\n");
+ return;
+ }
+
+ fElectronics = new AliITSetfSDD(timeStep);
+
+ Option_t *opt1, *opt2;
+ 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);
+ }
+
+ //
+ Option_t *opt=fResponse->ZeroSuppOption();
+ if (strstr(fParam,"file") ) {
+ fD.Set(fNofMaps);
+ fT1.Set(fNofMaps);
+ if (strstr(opt,"2D")) {
+ fT2.Set(fNofMaps);
+ fTol.Set(0);
+ Init2D(); // desactivate if param change module by module
+ } else if(strstr(opt,"1D")) {
+ fT2.Set(2);
+ fTol.Set(2);
+ Init1D(); // desactivate if param change module by module
+ }
+ } else {
+ fD.Set(2);
+ fTol.Set(2);
+ fT1.Set(2);
+ fT2.Set(2);
+ SetCompressParam();
+ }
+
+
+ Bool_t write=fResponse->OutputOption();
+ if(write && strstr(opt,"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);
+
+}
+
+
+//_____________________________________________________________________________
+
+AliITSsimulationSDD::~AliITSsimulationSDD() {
+ // destructor
+
+ delete fHitMap1;
+ delete fHitMap2;
+ delete fStream;
+
+ fD.Set(0);
+ fT1.Set(0);
+ fT2.Set(0);
+ fTol.Set(0);
+ fNoise.Set(0);
+ fBaseline.Set(0);
+
+ if (fHis) {
+ fHis->Delete();
+ delete fHis;
+ }
+}
+//_____________________________________________________________________________
+
+void AliITSsimulationSDD::DigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){
+ // create maps to build the lists of tracks
+ // for each digit
+
+ fModule=md;
+ fEvent=ev;
+
+ TObjArray *fHits = mod->GetHits();
+ Int_t nhits = fHits->GetEntriesFast();
+ if (!nhits) return;
+
+
+ TObjArray *list=new TObjArray;
+ static TClonesArray *padr=0;
+ if(!padr) padr=new TClonesArray("TVector",1000);
+ Int_t arg[5] = {0,0,0,0,0};
+ fHitMap1->SetArray(list);
+
+
+ Int_t NofAnodes=fNofMaps/2;
+
+ Float_t sddLength = fSegmentation->Dx();
+ Float_t sddWidth = fSegmentation->Dz();
+
+ Int_t dummy=0;
+ Float_t anodePitch = fSegmentation->Dpz(dummy);
+ Float_t timeStep = fSegmentation->Dpx(dummy);
+
+ Float_t driftSpeed=fResponse->DriftSpeed();
+
+ // 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=1000000.; // GeV->KeV
+ Int_t ii;
+ for(ii=0; ii<nhits; ii++) {
+ AliITShit *hit = (AliITShit*) fHits->At(ii);
+ Int_t hitDetector = hit->GetDetector();
+ Float_t xL[3];
+ hit->GetPositionL(xL[0],xL[1],xL[2]);
+ // cout << "hit local coordinates: " << xL[0] << "," << xL[1] << "," << xL[2] << endl;
+ // Deposited energy in keV
+ Float_t avpath = 0.;
+ Float_t avanod = 0.;
+ Float_t depEnergy = kconv*hit->GetIonization();
+ AliITShit *hit1 = 0;
+ if(depEnergy == 0.) {
+ ii++;
+ Float_t xL1[3];
+ hit1 = (AliITShit*) fHits->At(ii);
+ hit1->GetPositionL(xL1[0],xL1[1],xL1[2]);
+ //cout << "hit1 local coordinates: " << xL1[0] << "," << xL1[1] << "," << xL1[2] << endl;
+ //cout << "radius1: " << TMath::Sqrt(xL1[0]*xL1[0]+xL1[1]*xL1[1]) << ", azimuth: " << TMath::ATan2(xL1[0],xL1[1]) << endl;
+ avpath = xL1[0];
+ avanod = xL1[2];
+ depEnergy = kconv*hit1->GetIonization();
+ }
+ Float_t avDrft = xL[0]+avpath;
+ Float_t avAnode = xL[2]+avanod;
+
+ if(avpath != 0.) avDrft /= 2.;
+ if(avanod != 0.) avAnode /= 2.;
+
+ Float_t driftPath = 10000.*avDrft;
+ //printf("sddLength %f avDrft driftPath %f %f\n",sddLength,avDrft, driftPath);
+ Int_t iWing = 2;
+ if(driftPath < 0) {
+ iWing = 1;
+ driftPath = -driftPath;
+ }
+ driftPath = sddLength-driftPath;
+ Int_t detector = 2*(hitDetector-1) + iWing;
+ if(driftPath < 0) {
+ cout << "Warning: negative drift path " << driftPath << endl;
+ continue;
+ }
+
+ // Drift Time
+ Float_t driftTime = driftPath/driftSpeed;
+ Int_t timeSample = (Int_t) (driftTime/timeStep + 1);
+ if(timeSample > fMaxNofSamples) {
+ cout << "Warning: Wrong Time Sample: " << timeSample << endl;
+ continue;
+ }
+
+ // Anode
+ Float_t xAnode = 10000.*(avAnode)/anodePitch + NofAnodes/2; // +1?
+ // Int_t iAnode = 0.5+xAnode; // xAnode?
+ if(xAnode*anodePitch > sddWidth || xAnode*anodePitch < 0.)
+ { cout << "Warning: Z = " << xAnode*anodePitch << endl; }
+ Int_t iAnode = (Int_t) (1.+xAnode); // xAnode?
+ // cout << "iAnode " << iAnode << endl;
+ if(iAnode < 0 || iAnode > NofAnodes) {
+ cout << "Warning: Wrong iAnode: " << iAnode << endl;
+ continue;
+ }
+
+
+ // work with the idtrack=entry number in the TreeH
+ // Int_t idtrack=mod->GetHitTrackIndex(ii);
+ // or store straight away the particle position in the array
+ // of particles :
+ Int_t idtrack = hit->GetTrack();
+
+ // Signal 2d Shape
+ Double_t qRef = (Double_t)fResponse->Qref();
+ Double_t diffCoeff = (Double_t)fResponse->DiffCoeff();
+
+ Double_t gamma = 1. + 0.155*depEnergy/qRef;
+ // Squared Sigma along the anodes
+ Double_t sigma2A = 2.*diffCoeff*driftTime*gamma;
+ Double_t sigmaT = TMath::Sqrt(sigma2A)/driftSpeed;
+
+ // Peak amplitude in nanoAmpere
+ Double_t eVpairs = 3.6;
+ Double_t amplitude = 160.*depEnergy/(timeStep*eVpairs*2.*acos(-1.)*sigmaT*TMath::Sqrt(sigma2A));
+
+ // Spread the charge
+ // Pixel index
+ Int_t ja = iAnode;
+ Int_t jt = timeSample;
+ // Sub-pixel index
+ Int_t nsplit = 8;
+ nsplit = (nsplit+1)/2*2;
+ // Sub-pixel size
+ Double_t aStep = anodePitch/nsplit;
+ Double_t tStep = timeStep/nsplit;
+ // Define SDD window corresponding to the hit
+ Int_t anodeWindow = (Int_t) (4.*TMath::Sqrt(sigma2A)/anodePitch + 1);
+ Int_t timeWindow = (Int_t) (4.*sigmaT/timeStep + 1);
+ Int_t jamin = (ja - anodeWindow/2 - 1)*nsplit + 1;
+ Int_t jamax = (ja + anodeWindow/2)*nsplit;
+ if(jamin <= 0) jamin = 1;
+ if(jamax > NofAnodes*nsplit) jamax = NofAnodes*nsplit;
+ Int_t jtmin = (jt - timeWindow/2 - 1)*nsplit + 1;
+ Int_t jtmax = (jt + timeWindow/2)*nsplit;
+ if(jtmin <= 0) jtmin = 1;
+ if(jtmax > fMaxNofSamples*nsplit) jtmax = fMaxNofSamples*nsplit;
+ Double_t rlAnode = log(aStep*amplitude);
+ // Spread the charge in the anode-time window
+ Int_t ka;
+ for(ka=jamin; ka <=jamax; ka++) {
+ Int_t ia = (ka-1)/nsplit + 1;
+ if(ia <= 0) { cout << "Warning: ia < 1: " << endl; continue; }
+ if(ia > NofAnodes) ia = NofAnodes;
+ Double_t aExpo = aStep*(ka)-xAnode*anodePitch;
+ Double_t anodeAmplitude = rlAnode - 0.5*aExpo*aExpo/sigma2A;
+ // Protect against overflows
+ if(anodeAmplitude > -87.3)
+ anodeAmplitude = exp(anodeAmplitude);
+ else
+ anodeAmplitude = 0;
+ if(anodeAmplitude) {
+ Double_t rlTime = log(tStep*anodeAmplitude);
+ Int_t kt;
+ for(kt=jtmin; kt<=jtmax; kt++) {
+ Int_t it = (kt-1)/nsplit+1;
+ if(it<=0) { cout << "Warning: it < 1: " << endl; continue; }
+ if(it>fMaxNofSamples) it = fMaxNofSamples;
+ Double_t tExpo = (tStep*(kt)-driftTime)/sigmaT;
+ Double_t timeAmplitude = rlTime - 0.5*tExpo*tExpo;
+ // Protect against overflows
+ if(timeAmplitude > -87.3)
+ timeAmplitude = exp(timeAmplitude);
+ else
+ timeAmplitude = 0;
+
+ Int_t index = ((detector+1)%2)*NofAnodes+ia-1;
+ // build the list of digits for this module
+ arg[0]=index;
+ arg[1]=it;
+ arg[2]=idtrack;
+ ListOfFiredCells(arg,timeAmplitude,list,padr);
+ } // loop over time in window
+ } // end if anodeAmplitude
+ } // loop over anodes in window
+ } // end loop over hits
+
+ Int_t nentries=list->GetEntriesFast();
+ // introduce the electronics effects and do zero-suppression if required
+ if (nentries) {
+ ChargeToSignal();
+
+ Option_t *opt=fResponse->ZeroSuppOption();
+ ZeroSuppression(opt);
+ }
+
+ // clean memory
+ list->Delete();
+ delete list;
+
+ padr->Delete();
+
+ fHitMap1->ClearMap();
+ fHitMap2->ClearMap();
+
+ //gObjectTable->Print();
+}
+
+
+//____________________________________________
+
+void AliITSsimulationSDD::ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,
+ TObjArray *list,TClonesArray *padr){
+ // Returns the list of "fired" cells.
+
+ Int_t index=arg[0];
+ Int_t it=arg[1];
+ Int_t idtrack=arg[2];
+ Int_t counter=arg[3];
+ Int_t countadr=arg[4];
+
+ Int_t digits[3];
+
+ digits[0]=index;
+ digits[1]=it-1;
+ digits[2]=(Int_t)timeAmplitude;
+ Float_t phys;
+ if (idtrack >= 0) phys=(Float_t)timeAmplitude;
+ else phys=0;
+
+ Double_t charge=timeAmplitude;
+ AliITSTransientDigit* pdigit;
+ // build the list of fired cells and update the info
+ if (!fHitMap1->TestHit(index, it-1)) {
+
+ new((*padr)[countadr++]) TVector(2);
+ TVector &trinfo=*((TVector*) (*padr)[countadr-1]);
+ trinfo(0)=(Float_t)idtrack;
+ trinfo(1)=(Float_t)timeAmplitude;
+
+ list->AddAtAndExpand(
+ new AliITSTransientDigit(phys,digits),counter);
+
+ fHitMap1->SetHit(index, it-1, counter);
+ fHitMap2->SetHit(index, it-1, charge);
+ counter++;
+
+ pdigit=(AliITSTransientDigit*)list->
+ At(list->GetLast());
+ // list of tracks
+ TObjArray *trlist=(TObjArray*)pdigit->TrackList();
+ trlist->Add(&trinfo);
+
+ } else {
+ pdigit=
+ (AliITSTransientDigit*) fHitMap1->GetHit(index, it-1);
+ charge += fHitMap2->GetSignal(index,it-1);
+ fHitMap2->SetHit(index, it-1, charge);
+ // update charge
+ (*pdigit).fSignal=(Int_t)charge;
+ (*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(1));
+
+ if (lasttrack==idtrack ) {
+ lastcharge+=(Float_t)timeAmplitude;
+ trlist->RemoveAt(lastentry);
+ trinfo(0)=lasttrack;
+ trinfo(1)=lastcharge;
+ trlist->AddAt(&trinfo,lastentry);
+ } else {
+
+ new((*padr)[countadr++]) TVector(2);
+ TVector &trinfo=*((TVector*) (*padr)[countadr-1]);
+ trinfo(0)=(Float_t)idtrack;
+ trinfo(1)=(Float_t)timeAmplitude;
+
+ trlist->Add(&trinfo);
+ }
+
+#ifdef print
+ // check the track list - debugging
+ Int_t trk[50];
+ Float_t chtrk[50];
+ Int_t nptracks=trlist->GetEntriesFast();
+ if (nptracks > 2) {
+ Int_t tr;
+ for(tr=0;tr<nptracks;tr++) {
+ TVector *pptrkp=(TVector*)trlist->At(tr);
+ TVector &pptrk=*pptrkp;
+ trk[tr]=Int_t(pptrk(0));
+ chtrk[tr]=(pptrk(1));
+ printf("nptracks %d \n",nptracks);
+ // set printings
+ }
+ } // end if nptracks
+#endif
+ } // end if pdigit
+
+ arg[3]=counter;
+ arg[4]=countadr;
+
+
+}
+
+
+//____________________________________________
+
+void AliITSsimulationSDD::AddDigit(Int_t i, Int_t j, Int_t signal){
+ // Adds a Digit.
+ // tag with -1 signals coming from background tracks
+ // tag with -2 signals coming from pure electronic noise
+
+ Int_t digits[3], tracks[3];
+ Float_t phys, charges[3];
+
+ Int_t trk[20];
+ Float_t chtrk[20];
+
+ signal=Convert8to10(signal); // set a flag in case non-ZS are 10-bit
+ AliITSTransientDigit *obj = (AliITSTransientDigit*)fHitMap1->GetHit(i,j);
+ digits[0]=i;
+ digits[1]=j;
+ digits[2]=signal;
+ // printf("module anode, time, signal %d %d %d %d\n",fModule,i,j,signal);
+ if (!obj) {
+ phys=0;
+ Int_t k;
+ for(k=0;k<3;k++) {
+ tracks[k]=-2;
+ charges[k]=0;
+ }
+ fITS->AddDigit(1,phys,digits,tracks,charges);
+ } else {
+ phys=obj->fPhysics;
+ //printf("AddDigit - test: fCoord1 fCoord2 fSignal %d %d %d i j signal %d %d %d \n",obj->fCoord1,obj->fCoord2,obj->fSignal,i,j,signal);
+
+ TObjArray* trlist=(TObjArray*)obj->TrackList();
+ Int_t nptracks=trlist->GetEntriesFast();
+
+ if (nptracks > 20) {
+ cout<<"Attention - nptracks > 20 "<<nptracks<<endl;
+ nptracks=20;
+ }
+ Int_t tr;
+ for(tr=0;tr<nptracks;tr++) {
+ TVector &pp =*((TVector*)trlist->At(tr));
+ trk[tr]=Int_t(pp(0));
+ chtrk[tr]=(pp(1));
+ }
+ if (nptracks > 1) {
+ //printf("AddDigit: nptracks %d\n",nptracks);
+ SortTracks(trk,chtrk,nptracks);
+ }
+ Int_t i;
+ if (nptracks < 3 ) {
+ for(i=0; i<nptracks; i++) {
+ tracks[i]=trk[i];
+ charges[i]=chtrk[i];
+ }
+ for(i=nptracks; i<3; i++) {
+ tracks[i]=0;
+ charges[i]=0;
+ }
+ } else {
+ for(i=0; i<3; i++) {
+ tracks[i]=trk[i];
+ charges[i]=chtrk[i];
+ }
+ }
+
+ fITS->AddDigit(1,phys,digits,tracks,charges);
+
+ }
+
+}
+
+//____________________________________________
+
+void AliITSsimulationSDD::SortTracks(Int_t *tracks,Float_t *charges,Int_t ntr){
+ //
+ // Sort the list of tracks contributing to a given digit
+ // Only the 3 most significant tracks are acctually sorted
+ //
+
+ //
+ // Loop over signals, only 3 times
+ //
+
+
+ Float_t qmax;
+ Int_t jmax;
+ Int_t idx[3] = {-3,-3,-3};
+ Float_t jch[3] = {-3,-3,-3};
+ Int_t jtr[3] = {-3,-3,-3};
+ Int_t i,j,imax;
+
+ if (ntr<3) imax=ntr;
+ else imax=3;
+ for(i=0;i<imax;i++){
+ qmax=0;
+ jmax=0;
+
+ for(j=0;j<ntr;j++){
+
+ if((i == 1 && j == idx[i-1] )
+ ||(i == 2 && (j == idx[i-1] || j == idx[i-2]))) continue;
+
+ if(charges[j] > qmax) {
+ qmax = charges[j];
+ jmax=j;
+ }
+ }
+
+ if(qmax > 0) {
+ idx[i]=jmax;
+ jch[i]=charges[jmax];
+ jtr[i]=tracks[jmax];
+ }
+
+ }
+
+ for(i=0;i<3;i++){
+ if (jtr[i] == -3) {
+ charges[i]=0;
+ tracks[i]=0;
+ } else {
+ charges[i]=jch[i];
+ tracks[i]=jtr[i];
+ }
+ }
+
+}
+//____________________________________________
+void AliITSsimulationSDD::ChargeToSignal() {
+ // add baseline, noise, electronics and ADC saturation effects
+
+ Double_t InZR[fMaxNofSamples];
+ Double_t InZI[fMaxNofSamples];
+ Double_t OutZR[fMaxNofSamples];
+ Double_t OutZI[fMaxNofSamples];
+
+
+ Float_t maxadc = fResponse->MaxAdc();
+ Float_t TopValue = fResponse->MagicValue();
+ Float_t norm = maxadc/TopValue;
+
+
+ Option_t *opt1, *opt2;
+ 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;
+ Bool_t first=kTRUE;
+
+ TRandom *random = new TRandom();
+ Int_t i,k;
+ for(i=0;i<=fNofMaps;i++) {
+ if (read) GetAnodeBaseline(i,baseline,noise);
+ if (!first) FastFourierTransform(fElectronics,&InZR[0],&InZI[0],1);
+ for(k=0;k<fMaxNofSamples;k++) {
+ if (!first) {
+ // analog to digital ?
+ Double_t signal = OutZR[k]*norm;
+ if (signal > maxadc) signal = maxadc;
+ // back to analog: ?
+ signal /=norm;
+ //printf("ChargeToSignal: signal %f\n",signal);
+ fHitMap2->SetHit(i-1,k,signal);
+
+ Double_t rw = fElectronics->GetTraFunReal(k);
+ Double_t iw = fElectronics->GetTraFunImag(k);
+ OutZR[k] = InZR[k]*rw - InZI[k]*iw;
+ OutZI[k] = InZR[k]*iw + InZI[k]*rw;
+ if(i+1 < fNofMaps) InZR[k] = fHitMap2->GetSignal(i+1,k);
+ }
+
+ if (first) {
+ InZR[k] = fHitMap2->GetSignal(i,k);
+ }
+ InZI[k] = 0.;
+ // add baseline and noise
+ contrib = baseline + noise*random->Gaus();
+ InZR[k] += contrib;
+
+ } // loop over time
+
+ if (first) {
+ FastFourierTransform(fElectronics,&InZR[0],&InZI[0],1);
+ for(k=0; k<fMaxNofSamples; k++) {
+ Double_t rw = fElectronics->GetTraFunReal(k);
+ Double_t iw = fElectronics->GetTraFunImag(k);
+ OutZR[k] = InZR[k]*rw - InZI[k]*iw;
+ OutZI[k] = InZR[k]*iw + InZI[k]*rw;
+ InZR[k] = fHitMap2->GetSignal(i+1,k);
+ InZI[k] = 0.;
+ // add baseline and noise
+ contrib = baseline + noise*random->Gaus();
+ InZR[k] += contrib;
+ }
+ }
+ FastFourierTransform(fElectronics,&OutZR[0],&OutZI[0],-1);
+ first = kFALSE;
+ } // loop over anodes
+
+}
+
+//____________________________________________
+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::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];
+ } else {
+ db=fD[0]; tl=fT1[0]; th=fT2[0];
+ }
+ }
+}
+//____________________________________________
+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];
+ } else {
+ db=fD[0]; tl=fT1[0];
+ }
+ }
+
+}
+//____________________________________________
+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];
+ /*
+ printf("\n i, fD, fT1, fT2, fTol %d %d %d %d %d\n",
+ i,fD[i],fT1[i],fT2[i],fTol[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;
+ const char *kinput, *base,*kparam;
+ char *filtmp;
+
+ fResponse->Filenames(kinput,base,kparam);
+ fFileName=base;
+//
+ filtmp = gSystem->ExpandPathName(fFileName.Data());
+ FILE *bline = fopen(filtmp,"r");
+ printf("filtmp %s\n",filtmp);
+ na = 0;
+
+ if(bline) {
+ while(fscanf(bline,"%d %f %f",&pos, &bl, &n) != EOF) {
+ //printf("na, pos, bl, n %d %d %f %f\n",na, pos, bl, n);
+ if (pos != na+1) {
+ Error("ReadBaseline","Anode number not in increasing order!",
+ filtmp);
+ exit(1);
+ }
+ fBaseline[na]=bl;
+ fNoise[na]=n;
+ na++;
+ }
+ } 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) {
+ // 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;
+
+}
+
+//____________________________________________
+Int_t AliITSsimulationSDD::Convert8to10(Int_t signal) {
+ // Undo the lossive 10 to 8 bit compression.
+ // code from Davide C. and Albert W.
+ if (signal < 0 || signal > 255) {
+ printf("<Convert8to10> out of range %d \n",signal);
+ return 0;
+ }
+
+ if (signal < 128) return signal;
+ if (signal < 192) {
+ if (TMath::Odd(signal)) return (128+((signal-128)<<1));
+ else return (128+((signal-128)<<1)+1);
+ }
+ if (signal < 224) {
+ if (TMath::Odd(signal)) return (256+((signal-192)<<3)+3);
+ else return (256+((signal-192)<<3)+4);
+ }
+ if (TMath::Odd(signal)) return (512+((signal-224)<<4)+7);
+ else return (512+((signal-224)<<4)+7);
+ return 0;
+
+}
+
+//____________________________________________
+AliITSMap* AliITSsimulationSDD::HitMap(Int_t i){
+ //Return the correct map.
+ return ((i==0)? fHitMap1 : fHitMap2);
+}
+
+
+//____________________________________________
+void AliITSsimulationSDD::ZeroSuppression(Option_t *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();
+
+}
+
+//____________________________________________
+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,"file")) return;
+
+ Int_t na,pos,tempTh;
+ Float_t mu,sigma;
+ Float_t savemu[fNofMaps], savesigma[fNofMaps];
+ const char *kinput,*kbasel,*kpar;
+ char *filtmp;
+
+
+ Int_t minval = fResponse->MinVal();
+
+ fResponse->Filenames(kinput,kbasel,kpar);
+ fFileName=kpar;
+
+//
+ 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);
+ }
+ 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;
+
+
+
+}
+//____________________________________________
+void AliITSsimulationSDD::Compress2D(){
+ //
+ // simple ITS cluster finder -- online zero-suppression conditions
+ //
+ //
+
+ //printf("Compress2D!\n");
+
+ Int_t db,tl,th;
+ Int_t minval = fResponse->MinVal();
+ Bool_t write=fResponse->OutputOption();
+
+ Int_t nz, nl, nh, low, i, j;
+
+ for(i=0; i<fNofMaps; i++) {
+ CompressionParam(i,db,tl,th);
+ nz=0;
+ nl=0;
+ nh=0;
+ low=0;
+ for(j=0; j<fMaxNofSamples; j++) {
+ Int_t signal=(Int_t)(fHitMap2->GetSignal(i,j));
+ signal -= db; // if baseline eq. is done here
+ if (signal <= 0) {nz++; continue;}
+ if ((signal - tl) < minval) low++;
+ if ((signal - th) >= minval) {
+ &n