+ Int_t fBCID=Int_t (rawReader->GetBCID());
+ Int_t trmbunch= myrawreader.GetTRMBunchID();
+ AliDebug(10,Form(" CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch ));
+
+ if(type == 7 ) { //only physics
+ for (Int_t i=0; i<105; i++) {
+ for (Int_t iHit=0; iHit<5; iHit++)
+ {
+ allData[i][iHit] = myrawreader.GetData(i,iHit);
+ }
+ }
+ Int_t ref=0;
+ if (refPoint>0)
+ ref = allData[refPoint][0]-5000;
+
+ Float_t channelWidth = fParam->GetChannelWidth() ;
+
+ // Int_t meanT0 = fParam->GetMeanT0();
+
+ for (Int_t in=0; in<12; in++)
+ {
+ for (Int_t iHit=0; iHit<5; iHit++)
+ {
+ if(allData[in+1][iHit] > low[in+1] &&
+ allData[in+1][iHit] < high[in+1])
+ {
+ timeCFD[in] = allData[in+1][iHit] ;
+ break;
+ }
+ }
+ for (Int_t iHit=0; iHit<5; iHit++)
+ {
+ if(allData[in+12+1][iHit] > low[in+12+1] &&
+ allData[in+1+12][iHit] < high[in+12+1])
+ {
+ timeLED[in] = allData[in+12+1][iHit] ;
+ break;
+ }
+ }
+ for (Int_t iHit=0; iHit<5; iHit++)
+ {
+ if(allData[in+1+56][iHit] > low[in+1+56] &&
+ allData[in+1+56][iHit] < high[in+1+56])
+ {
+ timeCFD[in+12] = allData[in+56+1][iHit] ;
+ break;
+ }
+ }
+
+ for (Int_t iHit=0; iHit<5; iHit++)
+ {
+ if(allData[in+1+68][iHit] > low[in+1+68] &&
+ allData[in+1+68][iHit] < high[in+1+68])
+ {
+ timeLED[in+12] = allData[in+68+1][iHit] ;
+ break;
+ }
+ }
+ AliDebug(10, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ",
+ in, timeCFD[in],timeCFD[in+12],timeLED[in],
+ timeLED[in+12]));
+
+ }
+
+
+ for (Int_t in=0; in<12; in++)
+ {
+ chargeQT0[in]=allData[2*in+25][0];
+ chargeQT1[in]=allData[2*in+26][0];
+ AliDebug(10, Form(" readed Raw %i %i %i",
+ in, chargeQT0[in],chargeQT1[in]));
+ }
+ for (Int_t in=12; in<24; in++)
+ {
+ chargeQT0[in]=allData[2*in+57][0];
+ chargeQT1[in]=allData[2*in+58][0];
+ AliDebug(10, Form(" readed Raw %i %i %i",
+ in, chargeQT0[in],chargeQT1[in]));
+
+ }
+
+ for (Int_t iHit=0; iHit<5; iHit++)
+ {
+ if(allData[49][iHit] > low[49] &&
+ allData[49][iHit] < high[49]){
+ onlineMean = allData[49][iHit];
+ break;
+ }
+ }
+ Double32_t time[24], adc[24], noncalibtime[24];
+ for (Int_t ipmt=0; ipmt<24; ipmt++) {
+ if(timeCFD[ipmt]>0 ){
+ //for simulated data
+ //for physics data
+ if(( chargeQT0[ipmt] - chargeQT1[ipmt])>0) {
+ adc[ipmt] = chargeQT0[ipmt] - chargeQT1[ipmt];
+ }
+ else
+ adc[ipmt] = 0;
+ time[ipmt] = fCalib-> WalkCorrection(Int_t (refAmp), ipmt, Int_t(adc[ipmt]), timeCFD[ipmt] ) ;
+
+ Double_t sl = timeLED[ipmt] - timeCFD[ipmt];
+ // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD[ipmt] ) ;
+ AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
+ ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl)));
+ Double_t ampMip =( (TGraph*)fAmpLED.At(ipmt))->Eval(sl);
+ Double_t qtMip = ((TGraph*)fQTC.At(ipmt))->Eval(adc[ipmt]);
+ AliDebug(10,Form(" Amlitude in MIPS LED %f ; QTC %f; in channels %f\n ",ampMip,qtMip, adc[ipmt]));
+ //bad peak removing
+ frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
+ // frecpoints->SetTime(ipmt,Double32_t(timeCFD[ipmt]));
+ frecpoints->SetAmp(ipmt, Double32_t( qtMip)); //for cosmic &pp beam
+ frecpoints->SetAmpLED(ipmt, Double32_t(ampMip));
+ noncalibtime[ipmt]= Double32_t (timeCFD[ipmt]);
+ }
+ else {
+ time[ipmt] = 0;
+ adc[ipmt] = 0;
+ noncalibtime[ipmt] = 0;
+ }
+ }
+ fESDTZEROfriend->SetT0timeCorr(noncalibtime) ;
+ for (Int_t ipmt=0; ipmt<12; ipmt++){
+ if(time[ipmt] > 1 && ipmt != badpmt && adc[ipmt]>0.1 )
+ {
+ if(time[ipmt]<besttimeC){
+ besttimeC=time[ipmt]; //timeC
+ pmtBestC=ipmt;
+ }
+ }
+ }
+ for ( Int_t ipmt=12; ipmt<24; ipmt++)
+ {
+ if(time[ipmt] > 1 && ipmt != badpmt && adc[ipmt]>0.1)
+ {
+ if(time[ipmt]<besttimeA) {
+ besttimeA=time[ipmt]; //timeA
+ pmtBestA=ipmt;
+ }
+ }
+ }
+ if(besttimeA < 999999)
+ frecpoints->SetTimeBestA(besttimeA * channelWidth - 1000.*fLatencyHPTDC + 1000.*fLatencyL1A - 1000.*fGRPdelays);
+ if( besttimeC < 999999 )
+ frecpoints->SetTimeBestC(besttimeC * channelWidth - 1000.*fLatencyHPTDC +1000.*fLatencyL1C - 1000.*fGRPdelays);
+ AliDebug(10,Form(" pmtA %i besttimeA %f ps, pmtC %i besttimeC %f ps",
+ pmtBestA,besttimeA, pmtBestC, besttimeC));
+ if(besttimeA <999999 && besttimeC < 999999 ){
+ timeDiff = ( besttimeA - besttimeC)* 0.001* channelWidth + fLatencyL1A - fLatencyL1C;
+ timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - 1000.*fLatencyHPTDC + 1000.*fLatencyL1 - 1000.*fGRPdelays;
+ meanTime = (besttimeA+besttimeC-2.*Float_t(ref))/2.;
+ vertex = meanVertex - c*(timeDiff)/2. ; //+ (fdZonA - fdZonC)/2;
+ }
+ } //if phys event
+ AliDebug(5,Form(" timeDiff %f #channel, meanTime %f #channel, TOFmean%f vertex %f cm meanVertex %f online mean %i \n",timeDiff, meanTime,timeclock, vertex,meanVertex, onlineMean));
+ frecpoints->SetT0clock(timeclock);
+ frecpoints->SetVertex(vertex);
+ frecpoints->SetMeanTime(meanTime);
+ frecpoints->SetOnlineMean(Int_t(onlineMean));
+ // Set triggers
+
+ Bool_t tr[5];
+ Int_t trchan[5]= {50,51,52,55,56};
+ for (Int_t i=0; i<5; i++) tr[i]=false;
+ for (Int_t itr=0; itr<5; itr++) {
+ for (Int_t iHit=0; iHit<5; iHit++)
+ {
+ Int_t trr=trchan[itr];
+ if(allData[trr][iHit] > low[trr] &&
+ allData[trr][iHit] < high[trr]&&
+ allData[trr][iHit] > 0) tr[itr]=true;
+ }