#include "AliITShit.h"
#include "AliITSdigit.h"
#include "AliITSmodule.h"
+#include "AliITSpList.h"
#include "AliITSMapA1.h"
#include "AliITSMapA2.h"
#include "AliITSetfSDD.h"
#include "AliITSHuffman.h"
#include "AliITSsegmentation.h"
#include "AliITSresponse.h"
+#include "AliITSsegmentationSDD.h"
+#include "AliITSresponseSDD.h"
#include "AliITSsimulationSDD.h"
ClassImp(AliITSsimulationSDD)
void FastFourierTransform(AliITSetfSDD *alisddetf,Double_t *real,
Double_t *imag,Int_t direction) {
// Do a Fast Fourier Transform
- //printf("FFT: direction %d\n",direction);
Int_t samples = alisddetf->GetSamples();
Int_t l = (Int_t) ((log((Float_t) samples)/log(2.))+0.5);
// 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");
+ Error("AliITSsimulationSSD","Not allowed to make a copy of "
+ "AliITSsimulationSDD Using default creater instead");
AliITSsimulationSDD();
}
//______________________________________________________________________
-AliITSsimulationSDD& AliITSsimulationSDD::operator=(AliITSsimulationSDD &source){
+AliITSsimulationSDD& AliITSsimulationSDD::operator=(AliITSsimulationSDD &src){
// Assignment operator to satify Coding roules only.
- if(this==&source) return *this;
- printf("Not allowed to make a = with AliITSsimulationSDD "
- "Using default creater instead\n");
+ if(this==&src) return *this;
+ Error("AliITSsimulationSSD","Not allowed to make a = with "
+ "AliITSsimulationSDD Using default creater instead");
return *this ;
}
//______________________________________________________________________
-AliITSsimulationSDD::AliITSsimulationSDD(AliITSsegmentation *seg,AliITSresponse *resp){
+AliITSsimulationSDD::AliITSsimulationSDD(AliITSsegmentation *seg,
+ AliITSresponse *resp){
+ // Standard Constructor
+
+
+ fResponse = 0;
+ fSegmentation = 0;
+ fHis = 0;
+ fHitMap1 = 0;
+ fHitMap2 = 0;
+ fElectronics = 0;
+ fStream = 0;
+ fInZR = 0;
+ fInZI = 0;
+ fOutZR = 0;
+ fOutZI = 0;
+ fNofMaps = 0;
+ fMaxNofSamples = 0;
+ fITS = 0;
+ fTreeB = 0;
+
+ Init((AliITSsegmentationSDD*)seg,(AliITSresponseSDD*)resp);
+}
+//______________________________________________________________________
+void AliITSsimulationSDD::Init(AliITSsegmentationSDD *seg,
+ AliITSresponseSDD *resp){
// Standard Constructor
- fHitMap1 = 0; // zero just in case of an error
- fHitMap2 = 0; // zero just in case of an error
- fElectronics = 0; // zero just in case of an error
- fStream = 0; // zero just in case of an error
- fHis = 0;
- fTreeB = 0;
fResponse = resp;
fSegmentation = seg;
SetScaleFourier();
if(fOutZI) delete [] fOutZI;
}
//______________________________________________________________________
+void AliITSsimulationSDD::SDigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){
+ // create maps to build the lists of tracks for each summable digit
+
+ TObjArray *fHits = mod->GetHits();
+ Int_t nhits = fHits->GetEntriesFast();
+ fModule = md;
+ fEvent = ev;
+
+ if(!nhits) return;
+
+ AliITSpList *pList = new AliITSpList(2*fSegmentation->Npz(),
+ fScaleSize*fSegmentation->Npx());
+
+ // inputs to ListOfFiredCells.
+ TObjArray *alist = new TObjArray();
+ fHitMap1->SetArray(alist);
+ static TClonesArray *padr = 0;
+ if(!padr) padr = new TClonesArray("TVector",1000);
+
+ HitsToAnalogDigits(mod,alist,padr,pList);
+
+ WriteSDigits(pList);
+
+ // clean memory
+ alist->Delete();
+ delete alist;
+ padr->Delete();
+ fHitMap1->ClearMap();
+ fHitMap2->ClearMap();
+}
+//______________________________________________________________________
void AliITSsimulationSDD::DigitiseModule(AliITSmodule *mod,Int_t md,Int_t ev){
// create maps to build the lists of tracks for each digit
return;
} else if (!nhits) return;
+ AliITSpList *pList = new AliITSpList(2*fSegmentation->Npz(),
+ fScaleSize*fSegmentation->Npx());
+
+ // inputs to ListOfFiredCells.
+ TObjArray *alist = new TObjArray();
+ fHitMap1->SetArray(alist);
+ static TClonesArray *padr = 0;
+ if(!padr) padr = new TClonesArray("TVector",1000);
+
+ HitsToAnalogDigits(mod,alist,padr,pList);
+
+ FinishDigits(alist);
+
+ // clean memory
+ alist->Delete();
+ delete alist;
+ padr->Delete();
+ fHitMap1->ClearMap();
+ fHitMap2->ClearMap();
+}
+//______________________________________________________________________
+void AliITSsimulationSDD::SDigitsToDigits(AliITSpList *pList){
+ // Take Summable digits and create Digits.
+
// inputs to ListOfFiredCells.
- TObjArray *alist = new TObjArray;
+ TObjArray *alist = new TObjArray();
fHitMap1->SetArray(alist);
static TClonesArray *padr = 0;
if(!padr) padr = new TClonesArray("TVector",1000);
- Int_t arg[6] = {0,0,0,0,0,0};
+ Int_t arg[6] = {0,0,0,0,0,0};
+ Double_t timeAmplitude;
+ Int_t i,j;
+
+ // Fill maps from pList.
+ for(i=0;i<pList->GetMaxIndex();i++){
+ pList->GetMapIndex(i,arg[0],arg[1]);
+ for(j=0;j<pList->GetNEnteries();j++){
+ timeAmplitude = pList->GetTSignal(arg[0],arg[1],j);
+ if(timeAmplitude>0.0) continue;
+ arg[2] = pList->GetTrack(arg[0],arg[1],j);
+ arg[3] = pList->GetHit(arg[0],arg[1],j);
+ ListOfFiredCells(arg,timeAmplitude,alist,padr);
+ } // end for j
+ // Make sure map has full signal in it.
+ fHitMap2->SetHit(arg[0],arg[1],pList->GetSignal(arg[0],arg[1]));
+ } // end for i
+
+ FinishDigits(alist);
+
+ // clean memory
+ alist->Delete();
+ delete alist;
+ padr->Delete();
+ fHitMap1->ClearMap();
+ fHitMap2->ClearMap();
+}
+//______________________________________________________________________
+void AliITSsimulationSDD::FinishDigits(TObjArray *alist){
+ // introduce the electronics effects and do zero-suppression if required
+ Int_t nentries=alist->GetEntriesFast();
+ if(!nentries) return;
+ ChargeToSignal();
+ const char *kopt=fResponse->ZeroSuppOption();
+ ZeroSuppression(kopt);
+}
+//______________________________________________________________________
+void AliITSsimulationSDD::HitsToAnalogDigits(AliITSmodule *mod,TObjArray *alst,
+ TClonesArray *padr,
+ AliITSpList *pList){
+ // create maps to build the lists of tracks for each digit
+
+ TObjArray *fHits = mod->GetHits();
+ Int_t nhits = fHits->GetEntriesFast();
+ Int_t arg[6] = {0,0,0,0,0,0};
Int_t dummy = 0;
Int_t nofAnodes = fNofMaps/2;
Float_t sddLength = fSegmentation->Dx();
// continue if the particle did not lose energy
// passing through detector
if (!depEnergy) {
- cout << "This particle has passed without losing energy!" << endl;
+ Warning("HitsToAnalogDigits",
+ "This particle has passed without losing energy!");
continue;
} // end if !depEnergy
if(drPath < 0) drPath = -drPath;
drPath = sddLength-drPath;
if(drPath < 0) {
- cout << "Warning: negative drift path " << drPath << endl;
+ Warning("HitsToAnalogDigits","negative drift path %e",drPath);
continue;
} // end if drPath < 0
driftPath = sddLength-driftPath;
detector = 2*(hitDetector-1) + iWing;
if(driftPath < 0) {
- cout << "Warning: negative drift path " << driftPath << endl;
+ Warning("HitsToAnalogDigits","Warning: negative drift path %e",
+ driftPath);
continue;
} // end if driftPath < 0
// the defusion.
// timeSample = (Int_t) (fScaleSize*(drTime+tof)/timeStep + 1);
if(timeSample > fScaleSize*fMaxNofSamples) {
- cout << "Warning: Wrong Time Sample: " << timeSample << endl;
+ Warning("HItsToAnalogDigits","Wrong Time Sample: %e",
+ timeSample);
continue;
} // end if timeSample > fScaleSize*fMaxNoofSamples
// Anode
xAnode = 10000.*(avAnode)/anodePitch + nofAnodes/2; // +1?
if(xAnode*anodePitch > sddWidth || xAnode*anodePitch < 0.)
- cout << "Warning: Z = " << xAnode*anodePitch << endl;
+ Warning("HitsToAnalogDigits","Z = %e",
+ xAnode*anodePitch);
iAnode = (Int_t) (1.+xAnode); // xAnode?
if(iAnode < 1 || iAnode > nofAnodes) {
- cout << "Warning: Wrong iAnode: " << iAnode << endl;
+ Warning("HitToAnalogDigits","Wrong iAnode: %d",iAnode);
continue;
} // end if iAnode < 1 || iAnode > nofAnodes
// Spread the charge in the anode-time window
for(ka=jamin; ka <=jamax; ka++) {
ia = (ka-1)/(fScaleSize*nsplit) + 1;
- if(ia <= 0) { cout << "Warning: ia < 1: " << endl; continue; }
+ if(ia <= 0) {
+ Warning("HitsToAnalogDigits","ia < 1: ");
+ continue;
+ } // end if
if(ia > nofAnodes) ia = nofAnodes;
aExpo = (aStep*(ka-0.5)-aConst);
if(TMath::Abs(aExpo) > nsigma) anodeAmplitude = 0.;
index = ((detector+1)%2)*nofAnodes+ia-1;
if(anodeAmplitude) for(kt=jtmin; kt<=jtmax; kt++) {
it = (kt-1)/nsplit+1; // it starts from 1
- if(it<=0){cout<<"Warning: it < 1: "<<endl; continue;}
+ if(it<=0){
+ Warning("HitsToAnalogDigits","it < 1:");
+ continue;
+ } // end if
if(it>fScaleSize*fMaxNofSamples)
it = fScaleSize*fMaxNofSamples;
tExpo = (tStep*(kt-0.5)-tConst);
arg[3] = ii-1; // hit number.
timeAmplitude *= norm;
timeAmplitude *= 10;
- ListOfFiredCells(arg,timeAmplitude,alist,padr);
+ ListOfFiredCells(arg,timeAmplitude,alst,padr);
+ pList->AddSignal(index,it,itrack,ii-1,
+ mod->GetIndex(),timeAmplitude);
} // end if anodeAmplitude and loop over time in window
} // loop over anodes in window
} // end loop over "sub-hits"
} // end loop over hits
-
- // introduce the electronics effects and do zero-suppression if required
- Int_t nentries=alist->GetEntriesFast();
- if (nentries) {
- ChargeToSignal();
- const char *kopt=fResponse->ZeroSuppOption();
- ZeroSuppression(kopt);
- } // end if netries
-
- // clean memory
- alist->Delete();
- delete alist;
- padr->Delete();
- fHitMap1->ClearMap();
- fHitMap2->ClearMap();
}
//______________________________________________________________________
void AliITSsimulationSDD::ListOfFiredCells(Int_t *arg,Double_t timeAmplitude,
trk[tr] = Int_t(pptrk(0));
htrk[tr] = Int_t(pptrk(1));
chtrk[tr] = (pptrk(2));
- printf("nptracks %d \n",nptracks);
- // set printings
+ cout << "nptracks "<<nptracks << endl;
} // end for tr
} // end if nptracks
#endif
TObjArray* trlist=(TObjArray*)obj->TrackList();
Int_t nptracks=trlist->GetEntriesFast();
if (nptracks > 20) {
- cout<<"Attention - nptracks > 20 "<<nptracks<<endl;
+ Warning("AddDigit","nptracks=%d > 20 nptracks set to 20",nptracks);
nptracks=20;
} // end if nptracks > 20
Int_t tr;
} // end for kk
newcont = maxcont;
if (newcont >= maxadc) newcont = maxadc -1;
- if(newcont >= baseline) cout << "newcont: " << newcont << endl;
+ if(newcont >= baseline){
+ Warning("","newcont=%d>=baseline=%d",newcont,baseline);
+ } // end if
// back to analog: ?
fHitMap2->SetHit(i,k,newcont);
} // end for k
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]);
} // end for i
}
//______________________________________________________________________
//
filtmp = gSystem->ExpandPathName(fFileName.Data());
FILE *bline = fopen(filtmp,"r");
-// printf("filtmp %s\n",filtmp);
na = 0;
if(bline) {
// Undo the lossive 10 to 8 bit compression.
// code from Davide C. and Albert W.
if (signal < 0 || signal > 255) {
- cout << "<Convert8to10> out of range "<< signal << endl;
+ Warning("Convert8to10","out of range signal=%d",signal);
return 0;
} // end if signal <0 || signal >255
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);
+ Error("Init2D","Anode number not in increasing order!",filtmp);
exit(1);
} // end if pos != na+1
savemu[na] = mu;
na++;
} // end while
} else {
- Error("Init2D "," THE FILE %s DOES NOT EXIST !",filtmp);
+ Error("Init2D","THE FILE %s DOES NOT EXIST !",filtmp);
exit(1);
} // end if(param)
nh++;
Bool_t cond=kTRUE;
FindCluster(i,j,signal,minval,cond);
- if(cond&&j&&((TMath::Abs(fHitMap2->GetSignal(i,j-1))-th)>=minval)){
+ if(cond && j &&
+ ((TMath::Abs(fHitMap2->GetSignal(i,j-1))-th)>=minval)){
if(do10to8) signal = Convert10to8(signal);
AddDigit(i,j,signal);
} // end if cond&&j&&()
fscanf(param,"%d %d %d %d ", &fT2[0], &fT2[1], &fTol[0], &fTol[1]);
while(fscanf(param,"%d %f %f",&pos, &mu, &sigma) != EOF) {
if (pos != na+1) {
- Error("Init1D ","Anode number not in increasing order!",filtmp);
+ Error("Init1D","Anode number not in increasing order!",filtmp);
exit(1);
} // end if pos != na+1
savemu[na]=mu;
na++;
} // end while
} else {
- Error("Init1D "," THE FILE %s DOES NOT EXIST !",filtmp);
+ Error("Init1D","THE FILE %s DOES NOT EXIST !",filtmp);
exit(1);
} // end if(param)
Char_t candNum[4];
sprintf(candNum,"%d",i+1);
sddName.Append(candNum);
- //PH (*fHis)[i] = new TH1F(sddName.Data(),"SDD maps",
- //PH scale*fMaxNofSamples,0.,(Float_t) scale*fMaxNofSamples);
fHis->AddAt(new TH1F(sddName.Data(),"SDD maps",scale*fMaxNofSamples,
0.,(Float_t) scale*fMaxNofSamples), i);
} // end for i
Int_t i;
for (i=0;i<fNofMaps;i++ ) {
- //PH if ((*fHis)[i]) ((TH1F*)(*fHis)[i])->Reset();
if (fHis->At(i)) ((TH1F*)fHis->At(i))->Reset();
} // end for i
}
if (!fHis) return 0;
if(wing <=0 || wing > 2) {
- cout << "Wrong wing number: " << wing << endl;
+ Warning("GetAnode","Wrong wing number: %d",wing);
return NULL;
} // end if wing <=0 || wing >2
if(anode <=0 || anode > fNofMaps/2) {
- cout << "Wrong anode number: " << anode << endl;
+ Warning("GetAnode","Wrong anode number: %d",anode);
return NULL;
} // end if ampde <=0 || andoe > fNofMaps/2
Int_t index = (wing-1)*fNofMaps/2 + anode-1;
- //PH return (TH1F*)((*fHis)[index]);
return (TH1F*)(fHis->At(index));
}
//______________________________________________________________________
hfile->cd();
Int_t i;
- //PH for(i=0; i<fNofMaps; i++) (*fHis)[i]->Write(); //fAdcs[i]->Write();
for(i=0; i<fNofMaps; i++) fHis->At(i)->Write(); //fAdcs[i]->Write();
return;
}
cout << "rnoise : " << rnoise << endl;
delete noisehist;
return rnoise;
+}//______________________________________________________________________
+void AliITSsimulationSDD::WriteSDigits(AliITSpList *pList){
+ // Fills the Summable digits Tree
+ Int_t i,ni,j,nj;
+ static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
+
+ pList->GetMaxMapIndex(ni,nj);
+ for(i=0;i<ni;i++)for(j=0;j<nj;j++){
+ if(pList->GetSignalOnly(i,j)>0.5*fT1[0]){ // above small threshold.
+ aliITS->AddSumDigit(*(pList->GetpListItem(i,j)));
+// cout << "pListSDD: " << *(pList->GetpListItem(i,j)) << endl;
+ } // end if
+ } // end for i,j
+ return;
}
//______________________________________________________________________
void AliITSsimulationSDD::Print() {