/************************************************************************** * 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: AliTOFLvHvDataPoints.cxx,v $ */ // AliTOFLvHvDataPoints class // main aim to introduce the aliases for the TOF LV and HV DCS // data points to be then // stored in the OCDB, and to process them. // Process() method called by TOF preprocessor #include "TString.h" #include "TTimeStamp.h" #include "TMap.h" #include "TMath.h" #include "AliDCSValue.h" #include "AliLog.h" #include "AliBitPacking.h" #include "AliTOFLvHvDataPoints.h" #include "AliTOFGeometry.h" class AliCDBMetaData; class TDatime; ClassImp(AliTOFLvHvDataPoints) //--------------------------------------------------------------- AliTOFLvHvDataPoints::AliTOFLvHvDataPoints(): TObject(), fRun(0), fStartTime(0), fEndTime(0), fStartTimeDCSQuery(0), fEndTimeDCSQuery(0), fIsProcessed(kFALSE), fFDR(kFALSE), fNumberOfLVdataPoints(0), fNumberOfHVdataPoints(0), fNumberOfHVandLVmaps(0), fHisto(0x0) { // main constructor } //--------------------------------------------------------------- AliTOFLvHvDataPoints::AliTOFLvHvDataPoints(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t startTimeDCSQuery, UInt_t endTimeDCSQuery): TObject(), fRun(nRun), fStartTime(startTime), fEndTime(endTime), fStartTimeDCSQuery(startTimeDCSQuery), fEndTimeDCSQuery(endTimeDCSQuery), fIsProcessed(kFALSE), fFDR(kFALSE), fNumberOfLVdataPoints(0), fNumberOfHVdataPoints(0), fNumberOfHVandLVmaps(0), fHisto(new TH1C("histo","",kNpads,-0.5,kNpads-0.5)) { // constructor with arguments AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", nRun, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString(), TTimeStamp(startTimeDCSQuery).AsString(), TTimeStamp(endTimeDCSQuery).AsString())); Init(); } //--------------------------------------------------------------- AliTOFLvHvDataPoints::AliTOFLvHvDataPoints(const AliTOFLvHvDataPoints & data): TObject(data), fRun(data.fRun), fStartTime(data.fStartTime), fEndTime(data.fEndTime), fStartTimeDCSQuery(data.fStartTimeDCSQuery), fEndTimeDCSQuery(data.fEndTimeDCSQuery), fIsProcessed(data.fIsProcessed), fFDR(data.fFDR), fNumberOfLVdataPoints(data.fNumberOfLVdataPoints), fNumberOfHVdataPoints(data.fNumberOfHVdataPoints), fNumberOfHVandLVmaps(data.fNumberOfHVandLVmaps), fHisto(data.fHisto) { // copy constructor for(int i=0;iGetTime()==fLVDataPoints[jj]->GetTime()) counter++; } fNumberOfHVandLVmaps = fNumberOfHVdataPoints-2+fNumberOfLVdataPoints-2-counter+2; AliInfo(Form(" Number of TOF HVandLV dps in the current run = %d",fNumberOfHVandLVmaps)); counter=-1; Int_t timeMaps[kNmaxDataPoints]; for (Int_t ii=0; iiGetTime(); Bool_t check = kTRUE; for (Int_t jj=0; jjGetTime()!=timeMaps[ii]); if (check) { counter++; timeMaps[fNumberOfHVdataPoints+counter]=fLVDataPoints[jj]->GetTime(); } } if (fNumberOfHVdataPoints+counter+1!=fNumberOfHVandLVmaps) AliWarning("Something is wrong!"); Int_t controller[kNmaxDataPoints]; for (Int_t ii=0; iiGetCellValue(iPad)*fLVDataPoints[0]->GetCellValue(iPad); time = timeMaps[controller[0]]; AliTOFDCSmaps *object0 = new AliTOFDCSmaps(time,array); fMap[0]= object0; // HVandLV status map during run for (Int_t index=1; indexGetTime()==time && fHVDataPoints[ii+1]->GetTime()>time ) && ( fLVDataPoints[jj]->GetTime()<=time && fLVDataPoints[jj+1]->GetTime()>time ) ) || ( ( fLVDataPoints[jj]->GetTime()==time && fLVDataPoints[jj+1]->GetTime()>time ) && ( fHVDataPoints[ii]->GetTime()<=time && fHVDataPoints[ii+1]->GetTime()>time ) ) ) { AliDebug(2,Form(" HVdp_time=%d, LVdp_time=%d ",fHVDataPoints[ii]->GetTime(), fLVDataPoints[jj]->GetTime())); for (Int_t iPad=0; iPadGetCellValue(iPad)*fLVDataPoints[jj]->GetCellValue(iPad); AliTOFDCSmaps *object = new AliTOFDCSmaps(time,array); fMap[index]= object; break; } } } // HVandLV status map @ EOR for (Int_t iPad=0; iPadGetCellValue(iPad)*fLVDataPoints[fNumberOfLVdataPoints-1]->GetCellValue(iPad); time = timeMaps[controller[fNumberOfHVandLVmaps-1]]; AliTOFDCSmaps *object1 = new AliTOFDCSmaps(time,array); fMap[fNumberOfHVandLVmaps-1]= object1; return kTRUE; } //--------------------------------------------------------------- Bool_t AliTOFLvHvDataPoints::MergeHVmap() { // // Create HV maps from HV dps // Bool_t check= kFALSE; for (Int_t iPad=0; iPad %1d",iPad,fHVDataPoints[0]->GetCellValue(iPad))); if (fNumberOfHVdataPoints==2) check=kTRUE; else { for (Int_t ii=1; iiGetCellValue(iPad)==-1) fHVDataPoints[ii]->SetCellValue(iPad,fHVDataPoints[ii-1]->GetCellValue(iPad)); } for (Int_t iPad=0; iPad %1d",ii,iPad,fHVDataPoints[ii]->GetCellValue(iPad))); } check=kTRUE; } return kTRUE; } //--------------------------------------------------------------- Bool_t AliTOFLvHvDataPoints::MergeLVmap() { // // Create LV maps from LV dps // Bool_t check= kFALSE; for (Int_t iPad=0; iPad %1d",iPad,fLVDataPoints[0]->GetCellValue(iPad))); if (fNumberOfLVdataPoints==2) check=kTRUE; else { for (Int_t ii=1; iiGetCellValue(iPad)==-1) fLVDataPoints[ii]->SetCellValue(iPad,fLVDataPoints[ii-1]->GetCellValue(iPad)); } for (Int_t iPad=0; iPad %1d",ii,iPad,fLVDataPoints[ii]->GetCellValue(iPad))); } check=kTRUE; } return check; } //--------------------------------------------------------------- Bool_t AliTOFLvHvDataPoints::ReadHVDataPoints(TMap& aliasMap) { // // Read HV dps // TObjArray *aliasArr; AliDCSValue* aValue; AliDCSValue* aValuePrev; UInt_t val = 0; Int_t time = 0; Int_t nEntries = 0; Short_t dummy[kNpads]; for (Int_t iBin=0; iBinGetEntries(); if (nEntries==0) { AliError(Form("Alias %s has no entries! Nothing will be stored", fAliasNamesXHVmap[i][j].Data())); continue; } else { for (Int_t iEntry=0; iEntryAt(iEntry); val = aValue->GetUInt(); time = aValue->GetTimeStamp(); if (iEntry==0 || iEntry==nEntries-1) { FillHVarrayPerDataPoint(i,j,val,dummy); AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); InsertHVDataPoint(object); } else { aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1); if (aValuePrev->GetUInt()!=val) { FillHVarrayPerDataPoint(i,j,val,dummy); AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); InsertHVDataPoint(object); } } } } } if (fNumberOfHVdataPoints==0) { AliInfo("Valid LV dps not found. By default all HV TOF channels (except the ones in the PHOS holes) switched ON."); for (int i=0; iGetEntries(); if (nEntries==0) { AliError(Form("Alias %s has no entries! Nothing will be stored", fAliasNamesXLVmap[i].Data())); continue; } else { for (Int_t iEntry=0; iEntryAt(iEntry); val = aValue->GetUInt(); time = aValue->GetTimeStamp(); if (iEntry==0 || iEntry==nEntries-1) { FillLVarrayPerDataPoint(i,val,dummy); AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); InsertLVDataPoint(object); } else { aValuePrev = (AliDCSValue*) aliasArr->At(iEntry-1); if (aValuePrev->GetUInt()!=val) { FillLVarrayPerDataPoint(i,val,dummy); AliTOFDCSmaps *object = new AliTOFDCSmaps(time,dummy); InsertLVDataPoint(object); } } } } } if (fNumberOfLVdataPoints==0) { AliInfo("Valid LV dps not found. By default all LV TOF channels switched ON."); for (int i=0; iGetTime()==fHVDataPoints[index]->GetTime()) { fHVDataPoints[index]->Update(object); return 0; } } Int_t ii = FindHVdpIndex(object->GetTime()); memmove(fHVDataPoints+ii+1 ,fHVDataPoints+ii,(fNumberOfHVdataPoints-ii)*sizeof(AliTOFDCSmaps*)); fHVDataPoints[ii] = object; fNumberOfHVdataPoints++; return 0; } //_________________________________________________________________________ Int_t AliTOFLvHvDataPoints::FindHVdpIndex(Int_t z) const { // // This function returns the index of the nearest HV DP in time // if (fNumberOfHVdataPoints==0) return 0; if (z <= fHVDataPoints[0]->GetTime()) return 0; if (z > fHVDataPoints[fNumberOfHVdataPoints-1]->GetTime()) return fNumberOfHVdataPoints; Int_t b = 0, e = fNumberOfHVdataPoints-1, m = (b+e)/2; for (; b fHVDataPoints[m]->GetTime()) b=m+1; else e=m; } return m; } //--------------------------------------------------------------- Int_t AliTOFLvHvDataPoints::InsertLVDataPoint(AliTOFDCSmaps *object) { // // Insert LV dp in the LV dps array. // The LV dps array is sorted according to increasing dp timeStamp value // if (fNumberOfLVdataPoints==kNmaxDataPoints) { AliError("Too many LV data points!"); return 1; } if (fNumberOfLVdataPoints==0) { fLVDataPoints[fNumberOfLVdataPoints++] = object; return 0; } for (Int_t index=0; indexGetTime()==fLVDataPoints[index]->GetTime()) { fLVDataPoints[index]->Update(object); return 0; } } Int_t ii = FindLVdpIndex(object->GetTime()); memmove(fLVDataPoints+ii+1 ,fLVDataPoints+ii,(fNumberOfLVdataPoints-ii)*sizeof(AliTOFDCSmaps*)); fLVDataPoints[ii] = object; fNumberOfLVdataPoints++; return 0; } //_________________________________________________________________________ Int_t AliTOFLvHvDataPoints::FindLVdpIndex(Int_t z) const { // // This function returns the index of the nearest LV DP in time // if (fNumberOfLVdataPoints==0) return 0; if (z <= fLVDataPoints[0]->GetTime()) return 0; if (z > fLVDataPoints[fNumberOfLVdataPoints-1]->GetTime()) return fNumberOfLVdataPoints; Int_t b = 0, e = fNumberOfLVdataPoints-1, m = (b+e)/2; for (; b fLVDataPoints[m]->GetTime()) b=m+1; else e=m; } return m; } //--------------------------------------------------------------- void AliTOFLvHvDataPoints::Init(){ // // Initialize aliases and DCS data // TString sindex; for(int i=0;i=kNddl || nFEAC<0 || nFEAC>=8) return; switch (nDDL%4) { case 0: firstPadX = 0; lastPadX = AliTOFGeometry::NpadX()/2-1; if (nFEAC<=2) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC; else if (nFEAC==3) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC; else if (nFEAC==4) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1; else if (nFEAC==5) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1; else if (nFEAC==6) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2; else if (nFEAC==7) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-2; break; case 1: firstPadX = AliTOFGeometry::NpadX()/2; lastPadX = AliTOFGeometry::NpadX()-1; if (nFEAC<=2) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC; else if (nFEAC==3) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC; else if (nFEAC==4) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1; else if (nFEAC==5) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-1; else if (nFEAC==6) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=ii+6*nFEAC-1; else if (nFEAC==7) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=ii+6*nFEAC-2; break; case 2: firstPadX = AliTOFGeometry::NpadX()/2; lastPadX = AliTOFGeometry::NpadX()-1; if (nFEAC<=2) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC); else if (nFEAC==3) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC); else if (nFEAC==4) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); else if (nFEAC==5) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); else if (nFEAC==6) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2); else if (nFEAC==7) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-2); break; case 3: firstPadX = 0; lastPadX = AliTOFGeometry::NpadX()/2-1; if (nFEAC<=2) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC); else if (nFEAC==3) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC); else if (nFEAC==4) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); else if (nFEAC==5) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); else if (nFEAC==6) for (Int_t ii=0; ii<5; ii++) iStrip[ii]=90-(ii+6*nFEAC-1); else if (nFEAC==7) for (Int_t ii=0; ii<6; ii++) iStrip[ii]=90-(ii+6*nFEAC-2); break; } } //--------------------------------------------------------------- void AliTOFLvHvDataPoints::Draw(const Option_t* /*option*/) { // // Draw all histos and graphs // if(!fIsProcessed) return; /* TCanvas *ch; TString canvasHistoName="Histos"; ch = new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600); ch->cd(); */ // to be implemented } //--------------------------------------------------------------- void AliTOFLvHvDataPoints::DrawHVandLVMap(Int_t index) { // // Draw HV+LV map labelled as index // if(!fIsProcessed) return; if (index>=fNumberOfHVandLVmaps) return; AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVandLVmap(index); char title[100]; if (index==0) sprintf(title,"HVandLV map at time %d (%dst map)",mappa->GetTime(),index+1); else if (index==1) sprintf(title,"HVandLV map at time %d (%dnd map)",mappa->GetTime(),index+1); else if (index==2) sprintf(title,"HVandLV map at time %d (%drd map)",mappa->GetTime(),index+1); else if (index>=3) sprintf(title,"HVandLV map at time %d (%dth map)",mappa->GetTime(),index+1); fHisto->Delete(); fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5); //fHisto->Clear(); fHisto->SetTitle(title); for (Int_t ii=0; iiSetBinContent(ii+1,mappa->GetCellValue(ii)); fHisto->Draw(); } //--------------------------------------------------------------- void AliTOFLvHvDataPoints::DrawLVMap(Int_t index) { // // Draw LV map labelled as index // if(!fIsProcessed) return; if (index>=fNumberOfLVdataPoints) return; AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetLVmap(index); char title[100]; if (index==0) sprintf(title,"LV map at time %d (%dst map)",mappa->GetTime(),index+1); else if (index==1) sprintf(title,"LV map at time %d (%dnd map)",mappa->GetTime(),index+1); else if (index==2) sprintf(title,"LV map at time %d (%drd map)",mappa->GetTime(),index+1); else if (index>=3) sprintf(title,"LV map at time %d (%dth map)",mappa->GetTime(),index+1); fHisto->Delete(); fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5); //fHisto->Clear(); fHisto->SetTitle(title); for (Int_t ii=0; iiSetBinContent(ii+1,mappa->GetCellValue(ii)); fHisto->Draw(); } //--------------------------------------------------------------- void AliTOFLvHvDataPoints::DrawHVMap(Int_t index) { // // Draw HV map labelled as index // if(!fIsProcessed) return; if (index>=fNumberOfHVdataPoints) return; AliTOFDCSmaps *mappa=(AliTOFDCSmaps*)GetHVmap(index); char title[100]; if (index==0) sprintf(title,"HV map at time %d (%dst map)",mappa->GetTime(),index+1); else if (index==1) sprintf(title,"HV map at time %d (%dnd map)",mappa->GetTime(),index+1); else if (index==2) sprintf(title,"HV map at time %d (%drd map)",mappa->GetTime(),index+1); else if (index>=3) sprintf(title,"HV map at time %d (%dth map)",mappa->GetTime(),index+1); fHisto->Delete(); fHisto = new TH1C("histo","",kNpads,-0.5,kNpads-0.5); //fHisto->Clear(); fHisto->SetTitle(title); for (Int_t ii=0; iiSetBinContent(ii+1,mappa->GetCellValue(ii)); fHisto->Draw(); } //--------------------------------------------------------------- AliTOFDCSmaps *AliTOFLvHvDataPoints::GetHVandLVmapAtEOR() { // // Returns HVandLV status map at EOR. // If the end-of-run has been caused by TOF self, // the last but two value of HVandLV status map // will be taken into account. // This last condition is true // if the time interval between the second-last DP and the last one // is less than 60s. // AliTOFDCSmaps * lvANDhvMap = 0; if (fNumberOfHVandLVmaps==2) { // nothing changed during the run lvANDhvMap = fMap[fNumberOfHVandLVmaps-1]; } else { if (fMap[fNumberOfHVandLVmaps-1]->GetTime()-fMap[fNumberOfHVandLVmaps-2]->GetTime()<=60) lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-3]; else lvANDhvMap = (AliTOFDCSmaps*)fMap[fNumberOfHVandLVmaps-1]; } return lvANDhvMap; }