/* $Id$ */
+/******************************************************************
+ * Produde digits from hits
+ * digits is TObject and includes
+ * We are writing array if C & A TDC
+ * C & A ADC (will need for slow simulation)
+ * TOF first particle C & A
+ * mean time and time difference (vertex position)
+ *
+ * Alla.Maevskaya@cern.ch
+ ****************************************************************/
+
+
#include <TArrayI.h>
-#include <TDirectory.h>
-#include <TError.h>
#include <TFile.h>
#include <TGraph.h>
#include <TH1F.h>
#include "AliT0hit.h"
#include "AliT0digit.h"
#include "AliRunDigitizer.h"
-#include <AliDetector.h>
#include "AliRun.h"
#include <AliLoader.h>
#include <AliRunLoader.h>
#include <stdlib.h>
-#include <Riostream.h>
-#include <Riostream.h>
#include "AliT0Parameters.h"
-#include "AliCDBLocal.h"
-#include "AliCDBStorage.h"
-#include "AliCDBManager.h"
-#include "AliCDBEntry.h"
ClassImp(AliT0Digitizer)
fADC(new TArrayI(24)),
fADC0 (new TArrayI(24)),
fSumMult(0),
- fEffPMT(0)
-
+ fAmpLED(0),
+ fAmpQTC(0),
+ fParam(0)
{
fADC(new TArrayI(24)),
fADC0 (new TArrayI(24)),
fSumMult(0),
- fEffPMT(0)
+ fAmpLED(0),
+ fAmpQTC(0),
+ fParam(0)
{
// ctor which should be used
AliDebug(1,"processed");
+ fParam = AliT0Parameters::Instance();
+ fParam->Init();
-
+ for (Int_t i=0; i<24; i++){
+ TGraph* gr = fParam ->GetAmpLED(i);
+ Int_t np = gr->GetN();
+ Double_t *x = gr->GetX();
+ Double_t *y = gr->GetY();
+
+ Double_t *x1 = new Double_t[np];
+ Double_t *y1 = new Double_t[np];
+ for (Int_t ii=0; ii<np; ii++) {
+ y1[ii]=y[np-ii-1];
+ x1[ii]=x[np-ii-1];
+ }
+
+ TGraph *grInverse = new TGraph(np,y1,x1);
+ fAmpLED.AddAtAndExpand(grInverse,i);
+ }
+ for (Int_t i=0; i<24; i++){
+ TGraph* grq = fParam ->GetQTC(i);
+ Int_t npq = grq->GetN();
+ Double_t *xq = grq->GetX();
+ Double_t *yq = grq->GetY();
+ Double_t *x1q = new Double_t[npq];
+ Double_t *y1q = new Double_t[npq];
+ for (Int_t ii=1; ii<npq; ii++) {
+ y1q[ii]=yq[ii-1];
+ x1q[ii]=xq[ii-1];
+ }
+ TGraph *grInverseQTC = new TGraph(npq,y1q,x1q);
+ fAmpQTC.AddAtAndExpand(grInverseQTC,i);
+ }
}
//------------------------------------------------------------------------
delete fADC;
delete ftimeLED;
delete fADC0;
+ // delete fAmpLED;
}
- //------------------------------------------------------------------------
+//------------------------------------------------------------------------
Bool_t AliT0Digitizer::Init()
{
// Initialization
return kTRUE;
}
-
//---------------------------------------------------------------------
-
void AliT0Digitizer::Exec(Option_t* /*option*/)
{
//
// From hits to digits
//
- Int_t hit, nhits;
+ Int_t hit, nhits;
Int_t countE[24];
Int_t volume, pmt, trCFD, trLED;
Float_t sl, qt;
- Int_t bestATDC, bestCTDC, qtCh;
+ Int_t bestATDC=0;
+ Int_t bestCTDC=0;
+ Float_t qtCh=0;
Float_t time[24], besttime[24], timeGaus[24] ;
- //Q->T-> coefficients !!!! should be asked!!!
- Float_t timeDelayCFD[24], timeDelayLED[24];
+ //Q->T-> coefficients !!!! should be asked!!!
+ Float_t timeDelayCFD[24];
Int_t threshold =50; //photoelectrons
Float_t zdetA, zdetC;
- Int_t sumMultCoeff = 100;
- TObjArray slewingLED;
- TObjArray walk;
- TH1F *hr ;
+ Int_t sumMultCoeff = 100;
+ Int_t refpoint=0;
+
+ Int_t ph2Mip = fParam->GetPh2Mip();
+ Float_t channelWidth = fParam->GetChannelWidth() ;
+ Float_t delayVertex = fParam->GetTimeDelayTVD();
+
- AliT0Parameters* param = AliT0Parameters::Instance();
- param->Init();
-
- Int_t ph2Mip = param->GetPh2Mip();
- Int_t channelWidth = param->GetChannelWidth() ;
- Float_t delayVertex = param->GetTimeDelayTVD();
- for (Int_t i=0; i<24; i++){
- timeDelayCFD[i] = param->GetTimeDelayCFD(i);
- timeDelayLED[i] = param->GetTimeDelayLED(i);
- TGraph* gr = param ->GetSlew(i);
- slewingLED.AddAtAndExpand(gr,i);
-
- TGraph* fu = param ->GetWalk(i);
- walk.AddAtAndExpand(fu,i);
-
- TGraph* grEff = param ->GetPMTeff(i);
- fEffPMT.AddAtAndExpand(grEff,i);
- }
-
- zdetC = param->GetZposition(0);
- zdetA = param->GetZposition(1);
+ zdetC = TMath::Abs(fParam->GetZPosition("T0/C/PMT1"));
+ zdetA = TMath::Abs(fParam->GetZPosition("T0/A/PMT15"));
+ // printf(" !!!!!Z det A = %f C = % f",zdetA,zdetC);
AliT0hit *startHit;
TBranch *brHits=0;
Int_t nFiles=fManager->GetNinputs();
for (Int_t inputFile=0; inputFile<nFiles; inputFile++) {
if (inputFile < nFiles-1) {
- AliWarning(Form("ignoring input stream %d", inputFile));
- continue;
-
+ AliWarning(Form("ignoring input stream %d", inputFile));
+ continue;
+
}
Float_t besttimeC=99999.;
Float_t besttimeA=99999.;
- Int_t pmtBestC=9999;
- Int_t pmtBestA=9999;
- Int_t timeDiff=999, meanTime=0;
+ Int_t pmtBestC=99999;
+ Int_t pmtBestA=99999;
+ Int_t timeDiff=99999, meanTime=99999;
Int_t sumMult =0; fSumMult=0;
bestATDC = 99999; bestCTDC = 99999;
ftimeLED ->Reset();
for (Int_t i0=0; i0<24; i0++)
{
- time[i0]=besttime[i0]=timeGaus[i0]=99999; countE[i0]=0;
+ time[i0]=besttime[i0]=timeGaus[i0]=999999; countE[i0]=0;
}
AliRunLoader * inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
AliLoader * pInStartLoader = inRL->GetLoader("T0Loader");
if (!inRL->GetAliRun()) inRL->LoadgAlice();
- AliT0 *fT0 = (AliT0*)inRL ->GetAliRun()->GetDetector("T0");
+ fT0 = (AliT0*)inRL ->GetAliRun()->GetDetector("T0");
//read Hits
pInStartLoader->LoadHits("READ");//probably it is necessary to load them before
- TClonesArray *fHits = fT0->Hits ();
+ fHits = fT0->Hits ();
TTree *th = pInStartLoader->TreeH();
brHits = th->GetBranch("T0");
if (brHits) {
fT0->SetHitsAddressBranch(brHits);
}else{
- AliError("Branch T0 hit not found");
- exit(111);
+ AliWarning("Branch T0 hit not found for this event");
+ // fT0->AddDigit(bestATDC,bestCTDC,meanTime,timeDiff,fSumMult, refpoint,
+ // ftimeCFD,fADC0,ftimeLED,fADC);
+ continue;
}
Int_t ntracks = (Int_t) th->GetEntries();
Double_t e=startHit->Etot();
volume = startHit->Volume();
- // if(e>0 && RegisterPhotoE(numpmt,e)) {
if(e>0 ) {
countE[numpmt]++;
besttime[numpmt] = startHit->Time();
if(timeGaus[ipmt]<besttimeC){
besttimeC=timeGaus[ipmt]; //timeC
pmtBestC=ipmt;}
- }
+ }
}
- for ( Int_t ipmt=12; ipmt<24; ipmt++){
+ for ( Int_t ipmt=12; ipmt<24; ipmt++){
if(countE[ipmt] > threshold) {
timeGaus[ipmt]=gRandom->Gaus(time[ipmt],25);
if(timeGaus[ipmt]<besttimeA) {
pmtBestA=ipmt;}
}
}
- //folding with alignmentz position distribution
- if( besttimeC > 10000. && besttimeC <15000)
- bestCTDC=Int_t ((besttimeC+timeDelayCFD[pmtBestC])
- /channelWidth);
-
- if( besttimeA > 10000. && besttimeA <15000)
- bestATDC=Int_t ((besttimeA+timeDelayCFD[pmtBestA])
- /channelWidth);
- if (bestATDC < 99999 && bestCTDC < 99999)
- {
- timeDiff=Int_t (((besttimeC-besttimeA)+1000*delayVertex)
- /channelWidth);
- meanTime=Int_t (((besttimeC+timeDelayCFD[pmtBestC]+
- besttimeA+timeDelayCFD[pmtBestA])/2.)
- /channelWidth);
- }
- AliDebug(10,Form(" time A& C %i %i time diff && mean time in channels %i %i",bestATDC,bestCTDC, timeDiff, meanTime));
+ timeDelayCFD[0] = fParam->GetTimeDelayCFD(0);
+
for (Int_t i=0; i<24; i++)
{
Float_t al = countE[i];
// phe -> mV 0.3; 1MIP ->500phe -> ln (amp (mV)) = 5;
// max 200ns, HIJING mean 50000phe -> 15000mv -> ln = 15 (s zapasom)
// channel 25ps
- qt= 50.*al/ph2Mip; // 50mv/Mip amp in mV
+ qt= al/ph2Mip; // 50mv/Mip amp in mV
+ // before will we have calibration for high multiplicity
+ // if (qt > 115.) qt =115.; //must be fix!!!
// fill TDC
- trCFD = Int_t (timeGaus[i]/channelWidth + (timeDelayCFD[i]-timeDelayCFD[0]));
- trLED= Int_t (timeGaus[i] + timeDelayLED[i]);
- sl = ((TGraph*)slewingLED.At(i))->Eval(qt);
- trLED = Int_t(( trLED + 1000*sl )/channelWidth);
- qtCh=Int_t (1000.*TMath::Log(qt)) / channelWidth;
+ timeDelayCFD[i] = fParam->GetTimeDelayCFD(i);
+ trCFD = Int_t (timeGaus[i]/channelWidth + timeDelayCFD[i]);
+
+ TGraph* gr = ((TGraph*)fAmpLED.At(i));
+ sl = gr->Eval(qt);
+
+ TGraph* gr1 = ((TGraph*)fAmpQTC.At(i));
+ qtCh = gr1->Eval(qt);
fADC0->AddAt(0,i);
fADC->AddAt(qtCh,i);
- ftimeLED->AddAt(trLED,i);
// sumMult += Int_t ((al*gain[i]/ph2Mip)*50) ;
- sumMult += Int_t (qt/sumMultCoeff) ;
+ sumMult += Int_t (qtCh/sumMultCoeff) ;
- AliDebug(10,Form(" pmt %i : time in ns %f time in channels %i ",
- i, timeGaus[i],trCFD ));
- AliDebug(10,Form(" qt in mV %f qt in ns %f qt in channels %i ",qt,
- TMath::Log(qt), qtCh));
- // put slewing
- TGraph *fu1=(TGraph*) walk.At(i);
- Float_t slew=fu1->Eval(Float_t(qtCh));
- hr=fu1->GetHistogram();
- Float_t maxValue=hr->GetMaximum(50);
- trCFD=trCFD-Int_t((maxValue-slew)/channelWidth);
- ftimeCFD->AddAt(Int_t (trCFD),i);
- cout<<" slew "<<slew<<" "<<maxValue<<" "<<trCFD<<endl;
+ // put slewing
+ TGraph *fu=(TGraph*) fParam ->GetWalk(i);
+ Float_t slew=fu->Eval(Float_t(qtCh));
+
+ // trCFD=trCFD-Int_t(fMaxValue[i]-slew);
+ trCFD = trCFD + slew; //for the same channel as cosmic
+ ftimeCFD->AddAt(Int_t (trCFD),i);
+ trLED = Int_t(trCFD + sl );
+ ftimeLED->AddAt(trLED,i);
+ AliDebug(10,Form(" pmt %i : time in ns %f time in channels %i LEd %i ", i, timeGaus[i],trCFD, trLED ));
+ AliDebug(10,Form(" qt in MIP %f led-cfd in %f qt in channels %f ",qt, sl, qtCh));
+
}
} //pmt loop
+ //folding with alignmentz position distribution
+ if( besttimeC > 10000. && besttimeC <15000)
+ bestCTDC=Int_t ((besttimeC+timeDelayCFD[pmtBestC])
+ /channelWidth);
+
+ if( besttimeA > 10000. && besttimeA <15000)
+ bestATDC=Int_t ((besttimeA+timeDelayCFD[pmtBestA])
+ /channelWidth);
+
+ if (bestATDC < 99999 && bestCTDC < 99999)
+ {
+ timeDiff=Int_t (((besttimeC-besttimeA)+1000*delayVertex)
+ /channelWidth);
+ meanTime=Int_t (((besttimeC+besttimeA)/2. )/channelWidth);
+ }
+
if (sumMult > threshold){
fSumMult = Int_t (1000.* TMath::Log(Double_t(sumMult) / Double_t(sumMultCoeff))
/channelWidth);
sumMult, fSumMult, fSumMult*channelWidth));
}
- fT0->AddDigit(bestATDC,bestCTDC,meanTime,timeDiff,fSumMult,
+ fT0->AddDigit(bestATDC,bestCTDC,meanTime,timeDiff,fSumMult, refpoint,
ftimeCFD,fADC0,ftimeLED,fADC);
- AliDebug(10,Form(" Digits wrote bestATDC %i bestCTDC %i meanTime %i timeDiff %i fSumMult %i ", bestATDC,bestCTDC,meanTime,timeDiff,fSumMult ));
+
+ AliDebug(10,Form(" Digits wrote refpoint %i bestATDC %i bestCTDC %i meanTime %i timeDiff %i fSumMult %i ",refpoint ,bestATDC,bestCTDC,meanTime,timeDiff,fSumMult ));
pOutStartLoader->UnloadHits();
} //input streams loop