/************************************************************************** * 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.3.6.2 2003/05/19 16:24:40 hristov Merging with v3-09-09 (partial, AliITCclustererV2 is excluded from compilation and has to be adapted to NewIO, AliITStrackerV2 needs additional changes) Revision 1.10 2003/01/22 01:58:38 nilsen Small patch to allow new Dubna modle to reproduce BS model. Revision 1.9 2002/10/22 14:45:45 alibrary Introducing Riostream.h Revision 1.8 2002/10/14 14:57:08 hristov Merging the VirtualMC branch to the main development branch (HEAD) Revision 1.3.8.2 2002/10/14 13:14:08 hristov Updating VirtualMC to v3-09-02 Revision 1.7 2002/09/09 17:23:28 nilsen Minor changes in support of changes to AliITSdigitS?D class'. Revision 1.6 2002/08/21 22:09:58 nilsen Updated SPD simulation with difusion effects. ReWritten Hit to SDigits code. */ #include #include #include #include #include #include #include "AliRun.h" #include "AliITS.h" #include "AliITShit.h" #include "AliITSdigit.h" #include "AliITSmodule.h" #include "AliITSMapA2.h" #include "AliITSpList.h" #include "AliITSsimulationSPDdubna.h" #include "AliITSsegmentationSPD.h" #include "AliITSresponseSPDdubna.h" //#define DEBUG ClassImp(AliITSsimulationSPDdubna) //////////////////////////////////////////////////////////////////////// // Version: 0 // Written by Boris Batyunya // December 20 1999 // // AliITSsimulationSPDdubna is the simulation of SPDs //______________________________________________________________________ AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(){ // constructor fResponse = 0; fSegmentation = 0; fMapA2 = 0; fpList = 0; fModule = 0; fEvent = 0; fHis = 0; fNoise = 0.; fBaseline = 0.; fNPixelsZ = 0; fNPixelsX = 0; } //______________________________________________________________________ AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(AliITSsegmentation *seg, AliITSresponse *resp){ // standard constructor const Double_t kmictocm = 1.0e-4; // convert microns to cm. fHis = 0; fResponse = resp; fSegmentation = seg; fModule = 0; fEvent = 0; fNPixelsZ=GetSeg()->Npz(); fNPixelsX=GetSeg()->Npx(); GetResp()->GetNoiseParam(fNoise,fBaseline); GetResp()->SetDistanceOverVoltage(kmictocm*GetSeg()->Dy(),50.0); // fMapA2 = new AliITSMapA2(GetSeg()); fMapA2 = 0; fpList = new AliITSpList(fNPixelsZ+1,fNPixelsX+1); } //______________________________________________________________________ AliITSsimulationSPDdubna::~AliITSsimulationSPDdubna(){ // destructor if(fMapA2) delete fMapA2; if (fHis) { fHis->Delete(); delete fHis; } // end if fHis } //______________________________________________________________________ AliITSsimulationSPDdubna::AliITSsimulationSPDdubna(const AliITSsimulationSPDdubna &source){ // Copy Constructor if(&source == this) return; this->fMapA2 = source.fMapA2; this->fNoise = source.fNoise; this->fBaseline = source.fBaseline; this->fNPixelsX = source.fNPixelsX; this->fNPixelsZ = source.fNPixelsZ; this->fHis = source.fHis; return; } //______________________________________________________________________ AliITSsimulationSPDdubna& AliITSsimulationSPDdubna::operator=(const AliITSsimulationSPDdubna &source){ // Assignment operator if(&source == this) return *this; this->fMapA2 = source.fMapA2; this->fNoise = source.fNoise; this->fBaseline = source.fBaseline; this->fNPixelsX = source.fNPixelsX; this->fNPixelsZ = source.fNPixelsZ; this->fHis = source.fHis; return *this; } //______________________________________________________________________ void AliITSsimulationSPDdubna::InitSimulationModule(Int_t module, Int_t event){ // This function creates maps to build the list of tracks for each // summable digit. // // Inputs: // Int_t module // Module number to be simulated // Int_t event // Event number to be simulated // // Outputs: // none // // Returns: // none fModule = module; fEvent = event; // fMapA2->ClearMap(); fpList->ClearMap(); } //_____________________________________________________________________ void AliITSsimulationSPDdubna::SDigitiseModule(AliITSmodule *mod, Int_t mask, Int_t event){ // This function begins the work of creating S-Digits // // Inputs: // AliITSmodule *mod // module // Int_t mask // mask to be applied to the module // // Outputs: // none // // Return: // test // test returns kTRUE if the module contained hits // // test returns kFALSE if it did not contain hits Int_t module = 0; if(!(mod->GetNhits())) return;// if module has no hits don't create Sdigits fModule = mod->GetIndex(); HitToSDigit(mod, module, mask, fpList); WriteSDigits(fpList); // fMapA2->ClearMap(); fpList->ClearMap(); } //______________________________________________________________________ void AliITSsimulationSPDdubna::WriteSDigits(AliITSpList *pList){ // This function adds each S-Digit to pList // // Inputs: // AliITSpList *pList // // Outputs: // none // // Return: // none Int_t ix, nix, iz, niz; static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS"); pList->GetMaxMapIndex(niz, nix); for(iz=0; izGetSignalOnly(iz+1,ix+1)>0.0){ aliITS->AddSumDigit(*(pList->GetpListItem(iz+1,ix+1))); #ifdef DEBUG cout <<"SDigits " << iz << "," << ix << "," << *(pList->GetpListItem(iz+1,ix+1)) << endl; #endif } // end if pList } // end for iz,ix return; } //______________________________________________________________________ void AliITSsimulationSPDdubna::FinishSDigitiseModule(){ // This function calls SDigitsToDigits which creates Digits from SDigits // // Inputs: // none // // Outputs: // none // Return // none SDigitsToDigits(fModule, fpList); return; } //______________________________________________________________________ void AliITSsimulationSPDdubna::SDigitsToDigits(Int_t module, AliITSpList *pList){ // This function adds electronic noise to the S-Digits and then adds them // to a new pList // // Inputs: // Int_t module // module number // AliITSpList *pList // pList // // Outputs: // pList is passed along to the functions ChargeToSignal and GetList // // Return: // none fModule = module; ChargeToSignal(pList); // Charge To Signal both adds noise and // fMapA2->ClearMap(); pList->ClearMap(); } //______________________________________________________________________ void AliITSsimulationSPDdubna::DigitiseModule(AliITSmodule *mod, Int_t module, Int_t dummy){ // This function creates Digits straight from the hits and then adds // electronic noise to the digits before adding them to pList // // Inputs: // AliITSmodule *mod // module // Int_t module // module number Dummy. // Int_t dummy // // Outputs: // Each of the input variables is passed along to HitToSDigit // // Return: // none fModule = mod->GetIndex(); //This calls the module for HitToSDigit HitToSDigit(mod,fModule, dummy, fpList); ChargeToSignal(fpList); // fMapA2->ClearMap(); fpList->ClearMap(); } //______________________________________________________________________ void AliITSsimulationSPDdubna::UpdateMapSignal(Int_t iz, Int_t ix, Int_t trk, Int_t ht, Int_t module, Double_t signal, AliITSpList *pList){ // This function adds a signal to the pList from the pList class // // Inputs: // Int_t iz // row number // Int_t ix // column number // Int_t trk // track number // Int_t ht // hit number // Double_t signal // signal strength // AliITSpList *pList // pList // // Outputs: // All of the inputs are passed to AliITSpList::AddSignal // Int_t ix // row number // Int_t iz // column number // Double_t sig // signal strength // // These three variables are defined to preserve the // // assignments used in the function AliITSMapA2::AddSignal // // Return: // none // fMapA2->AddSignal(iz, ix, signal); pList->AddSignal(iz+1,ix+1, trk, ht, fModule, signal); } //______________________________________________________________________ void AliITSsimulationSPDdubna::UpdateMapNoise(Int_t iz, Int_t ix, Int_t fModule, Double_t sig, Float_t noise, AliITSpList *pList){ // This function adds noise to data in the MapA2 as well as the pList // // Inputs: // Int_t iz // row number // Int_t ix // column number // Int_t mod // module number // Double_t sig // signal strength // Double_t noise // electronic noise generated by ChargeToSignal // AliITSpList *pList // pList // // Outputs: // All of the inputs are passed to AliITSMapA2::AddSignal or // AliITSpList::AddNoise // // Return: // none // fMapA2->AddSignal(iz, ix, noise); pList->AddNoise(iz+1,ix+1, fModule, noise); } //______________________________________________________________________ void AliITSsimulationSPDdubna::HitToDigit(AliITSmodule *mod, Int_t module, Int_t dummy){ DigitiseModule(mod, module, dummy); } //______________________________________________________________________ void AliITSsimulationSPDdubna::HitToSDigit(AliITSmodule *mod, Int_t module, Int_t dummy,AliITSpList *pList){ // Does the charge distributions using Gaussian diffusion charge charing. const Double_t kmictocm = 1.0e-4; // convert microns to cm. TObjArray *hits = mod->GetHits(); Int_t nhits = hits->GetEntriesFast(); Int_t h,ix,iz; Int_t idtrack; Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0; Double_t x,y,z,t,tp,st,dt=0.2,el,sig; Double_t thick = kmictocm*GetSeg()->Dy(); if(nhits<=0) return; for(h=0;hGetHit(h)) << endl; #endif if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){ st =TMath::Sqrt(x1*x1+y1*y1+z1*z1); if(st>0.0){ st = (Double_t)((Int_t)(1.0E+04*st)); // number of microns if(st<=0.0) st = 1.0; dt = 1.0/st; for(t=0;t<1.0;t+=dt){ // Integrate over t tp = t+0.5*dt; el = GetResp()->GeVToCharge((Float_t)(dt*de)); #ifdef DEBUG if(el<=0.0) cout << "el="<GetHit(h)) << endl; #endif if(mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)){ st =TMath::Sqrt(x1*x1+y1*y1+z1*z1); if(st>0.0){ st =TMath::Sqrt(x1*x1+y1*y1+z1*z1)*(ta[i+1]-ta[i]); ta = CreateFindCellEdges(x0,x1,z0,z1,n); for(i=0;iGeVToCharge((Float_t)(dt*de)); #ifdef DEBUG if(el<=0.0) cout << "el="<At(hit); #ifdef DEBUG cout << "Hits=" << hit << "," << *iHit << endl; #endif //Int_t layer = iHit->GetLayer(); Float_t yPix0 = -spdThickness/2; // work with the idtrack=entry number in the TreeH //Int_t idhit,idtrack; //! //mod->GetHitTrackAndHitIndex(hit,idtrack,idhit); //! //Int_t idtrack=mod->GetHitTrackIndex(hit); // or store straight away the particle position in the array // of particles : if(iHit->StatusEntering()) idhit=hit; Int_t itrack = iHit->GetTrack(); Int_t dray = 0; if (lasttrack != itrack || hit==(nhits-1)) first = kTRUE; //Int_t parent = iHit->GetParticle()->GetFirstMother(); Int_t partcode = iHit->GetParticle()->GetPdgCode(); // partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0, // 211 - pi+, 310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda Float_t pmod = iHit->GetParticle()->P(); // total momentum at the // vertex pmod *= 1000; if(partcode == 11 && pmod < 6) dray = 1; // delta ray is e- // at p < 6 MeV/c // Get hit z and x(r*phi) cordinates for each module (detector) // in local system. Float_t zPix = kconv*iHit->GetZL(); Float_t xPix = kconv*iHit->GetXL(); Float_t yPix = kconv*iHit->GetYL(); // Get track status Int_t status = iHit->GetTrackStatus(); // Check boundaries if(zPix > spdLength/2) { #ifdef DEBUG cout<<"!!! SPD: z outside ="<MinVal(); Int_t j; // Int_t digits[3], tracks[3], hits[3]; // Float_t charges[3]; Float_t electronics; // Float_t phys; Double_t sig; const Int_t nmaxtrk=AliITSdigitSPD::GetNTracks(); static AliITSdigitSPD dig; for(Int_t iz=0; izGaus(); sig = pList->GetSignalOnly(iz+1,ix+1); UpdateMapNoise(iz,ix,fModule,sig,electronics,pList); #ifdef DEBUG // cout << sig << "+" << electronics <<">threshold=" << threshold // << endl; #endif if (sig+electronics > threshold) { dig.fCoord1 = iz; dig.fCoord2 = ix; dig.fSignal = 1; dig.fSignalSPD = (Int_t) pList->GetSignal(iz+1,ix+1); /* digits[0] = iz; digits[1] = ix; digits[2] = 1; */ for(j=0;jGetNEnteries()) { dig.fTracks[j] = pList->GetTrack(iz+1,ix+1,j); dig.fHits[j] = pList->GetHit(iz+1,ix+1,j); /* tracks[j] = pList->GetTrack(iz+1,ix+1,j); hits[j] = pList->GetHit(iz+1,ix+1,j); */ }else { // Default values dig.fTracks[j] = -3; dig.fHits[j] = -1; /* tracks[j] = -2; //noise hits[j] = -1; */ } // end if pList } // end for j // charges[0] = (Float_t) pList->GetSumSignal(iz+1,ix+1); /* if(tracks[0] == tracks[1] && tracks[0] == tracks[2]) { tracks[1] = -3; hits[1] = -1; tracks[2] = -3; hits[2] = -1; } else if(tracks[0] == tracks[1] && tracks[0] != tracks[2]) { tracks[1] = -3; hits[1] = -1; } else if(tracks[0] == tracks[2] && tracks[0] != tracks[1]) { tracks[2] = -3; hits[2] = -1; } else if(tracks[1] == tracks[2] && tracks[0] != tracks[1]) { tracks[2] = -3; hits[2] = -1; } // end if */ // phys = 0.0; #ifdef DEBUG cout << iz << "," << ix << "," << *(pList->GetpListItem(iz+1,ix+1)) << endl; #endif // aliITS->AddSimDigit(0, phys, digits, tracks, hits, charges); aliITS->AddSimDigit(0,&dig); } // } // } // } //______________________________________________________________________ void AliITSsimulationSPDdubna::CreateHistograms(){ // create 1D histograms for tests printf("SPD - create histograms\n"); fHis=new TObjArray(fNPixelsZ); TString spdName("spd_"); for (Int_t i=0;iAddAt(new TH1F(spdName.Data(),"SPD maps", fNPixelsX,0.,(Float_t) fNPixelsX), i); } // end for i } //______________________________________________________________________ void AliITSsimulationSPDdubna::ResetHistograms(){ // // Reset histograms for this detector // for ( int i=0;iReset(); if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset(); } // end for i }