- if (listTot)
- {
- AliInfo("The following sources produced files with the id DELAYS");
- listTot->Print();
- for (Int_t jj=0;jj<listTot->GetEntries();jj++){
- TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
- AliInfo(Form("found source %s", str->String().Data()));
-
- // file with summed histos, to extract calib params
- TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
- if (fileName.Length()>0){
- AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
-
- daqFile = new TFile(fileName.Data(),"READ");
- if (fh2) delete fh2;
- fh2 = (TH2S*) daqFile->Get("htoftot");
- if (!fh2){
- Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
- delete daqFile;
- return 7; //return error code for histograms not existing/junky
- }
- else {
- static const Int_t kSize=fh2->GetNbinsX();
- static const Int_t kNBins=fh2->GetNbinsY();
- static const Double_t kXBinmin=fh2->GetYaxis()->GetBinLowEdge(1);
- if (kSize != fNChannels){
- Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
- delete daqFile;
- return 7; //return error code for histograms not existing/junky
- }
- for (Int_t ich=0;ich<kSize;ich++){
- TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
- for (Int_t ibin=0;ibin<kNBins;ibin++){
- h1->SetBinContent(ibin+1,fh2->GetBinContent(ich+1,ibin+1));
- }
- Bool_t found=kFALSE;
- Float_t minContent=h1->Integral()*fgkThrPar;
- Int_t nbinsX = h1->GetNbinsX();
- Int_t startBin=1;
- for (Int_t j=1; j<=nbinsX; j++){
- if ((
- h1->GetBinContent(j) +
- h1->GetBinContent(j+1)+
- h1->GetBinContent(j+2)+
- h1->GetBinContent(j+3))>minContent){
- found=kTRUE;
- startBin=j;
- break;
- }
- }
- if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
- // Now calculate the mean over the interval.
- Double_t mean = 0;
- Double_t sumw2 = 0;
- Double_t nent = 0;
- for(Int_t k=0;k<fgkBinRangeAve;k++){
- mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
- nent=nent+h1->GetBinContent(startBin+k);
- sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
- }
- mean= mean/nent; //<x>
- sumw2=sumw2/nent; //<x^2>
- Double_t rmsmean= 0;
- rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
- if (ich<fNChannels) {
- AliTOFChannelOnline * ch = (AliTOFChannelOnline *)fCal->At(ich);
- ch->SetDelay((Double_t)mean*AliTOFGeometry::TdcBinWidth()*1.E-3); // delay in ns
- }
- delete h1;
- h1=0x0;
- }
+ if (listTot !=0x0 && listTot->GetEntries()!=0)
+ {
+ AliInfo("The following sources produced files with the id DELAYS");
+ listTot->Print();
+ for (Int_t jj=0;jj<listTot->GetEntries();jj++){
+ TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
+ AliInfo(Form("found source %s", str->String().Data()));
+
+ // file with summed histos, to extract calib params
+ TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
+ if (fileName.Length()>0){
+ AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
+
+ daqFile = new TFile(fileName.Data(),"READ");
+ if (h2) delete h2;
+ h2 = (TH2S*) daqFile->Get("htoftot");
+ if (!h2){
+ Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
+ delete listTot;
+ delete daqFile;
+ delete fCal;
+ fCal=0x0;
+ return 7; //return error code for histograms not existing/junky
+ }
+ else {
+ static const Int_t kSize=h2->GetNbinsX();
+ static const Int_t kNBins=h2->GetNbinsY();
+ static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1);
+ if (kSize != fNChannels){
+ Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
+ delete listTot;
+ delete h2;
+ delete daqFile;
+ delete fCal;
+ fCal=0x0;
+ return 7; //return error code for histograms not existing/junky
+ }
+ Int_t nNotStatistics = 0; // number of channel with not enough statistics
+
+ /* FDR flag set. do not compute delays, use nominal cable delays */
+ if (fFDRFlag) {
+
+ Log(" Not computing delays according to flag set in Config entry in OCDB!");
+ FillWithCosmicCalibration(fCal);
+
+ /* check whether the new calibration is different from the previous one */
+ if (curCal) { /* well, check also whether we have a previous calibration */
+ for (Int_t i = 0; i < fNChannels; i++) {
+ if (fCal->GetDelay(i) != curCal->GetDelay(i)) {
+ updateOCDB = kTRUE;
+ break;
+ }
+ }
+ }
+ else /* otherwise update OCDB */
+ updateOCDB = kTRUE;
+
+ }
+
+ else { // computing delays if not in FDR runs
+
+ updateOCDB = kTRUE; /* always update OCDB when computing delays */
+
+ for (Int_t ich=0;ich<kSize;ich++){
+ /* check whether channel has been read out during current run.
+ * if the status is bad it means it has not been read out.
+ * in this case skip channel in order to not affect the mean */
+ if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){
+ AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich)));
+ continue;
+ }
+ AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich));
+ TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
+ for (Int_t ibin=0;ibin<kNBins;ibin++){
+ h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1));
+ }
+ if(h1->Integral()<integralThr) {
+ nNotStatistics++;
+ Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs
+ delete h1;
+ h1=0x0;
+ continue;
+ }
+ Bool_t found=kFALSE;
+ Float_t minContent=h1->Integral()*thrPar;
+ Int_t nbinsX = h1->GetNbinsX();
+ Int_t startBin=1;
+ for (Int_t j=1; j<=nbinsX; j++){
+ if ((
+ h1->GetBinContent(j) +
+ h1->GetBinContent(j+1)+
+ h1->GetBinContent(j+2)+
+ h1->GetBinContent(j+3))>minContent){
+ found=kTRUE;
+ startBin=j;
+ break;
+ }
+ }
+ if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
+ // Now calculate the mean over the interval.
+ Double_t mean = 0;
+ Double_t sumw2 = 0;
+ Double_t nent = 0;
+ for(Int_t k=0;k<binRangeAve;k++){
+ mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
+ nent=nent+h1->GetBinContent(startBin+k);
+ sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
+ }
+ mean= mean/nent; //<x>
+ sumw2=sumw2/nent; //<x^2>
+ Double_t rmsmean= 0;
+ rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
+ if (ich<fNChannels) {
+ Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns
+ fCal->SetDelay(ich,delay); // delay in ns
+ AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich));
+ }
+ delete h1;
+ h1=0x0;
+ }
+ }
+ if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics));
+ }
+ delete h2;
+ daqFile->Close();
+ delete daqFile;
+ }
+ else{
+ Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
+ delete listTot;
+ delete fCal;
+ fCal=0x0;
+ return 6;//return error code for problems in retrieving DAQ data
+ }
+ }
+ delete listTot;