From: shahoian Date: Mon, 29 Mar 2010 12:56:35 +0000 (+0000) Subject: The class for LHC DIP data was completely changed X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=799c6677b6680ab272afa9ac679fb18be1d60282;p=u%2Fmrichter%2FAliRoot.git The class for LHC DIP data was completely changed --- diff --git a/STEER/AliLHCData.cxx b/STEER/AliLHCData.cxx index bf1967c3521..ba9d3d455be 100755 --- a/STEER/AliLHCData.cxx +++ b/STEER/AliLHCData.cxx @@ -1,485 +1,827 @@ -/************************************************************************** - * 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. * - * * - **************************************************************************/ - - -#include "AliLHCData.h" -#include "TMap.h" - - -ClassImp(AliLHCData) - -const Char_t* AliLHCData::fgkDCSNames[] = { - "lhcMon_LHCIntensityBeam%d.totalIntensity", - "lhcInst_BeamIntensityPerBunchBeam%d.averageBeamIntensity", - "lhcInst_BeamIntensityPerBunchBeam%d_Avgerage.averageBunchIntensities", - "lhcMon_LHCLumAverageBRANB_4%c2.meanLuminosity", - "lhcInst_BeamLuminosityPerBunchBRANB_4%c2_Average.bunchByBunchLuminosity", - "lhcMon_LHCLumAverageBRANB_4%c2.meanCrossingAngle", - "lhcMon_LHCCirculatingBunchConfig_Beam%d.value", - "lhcMon_LHCFillNumber.payload", - // - "lhcMon_LHCBeamSizeBeam%d.planeSet%d", - "lhcMon_LHCBeamSizeBeam%d.amplitudeSet%d", - "lhcMon_LHCBeamSizeBeam%d.positionSet%d", - "lhcMon_LHCBeamSizeBeam%d.sigmaSet%d" -}; - -const Char_t* AliLHCData::fgkDCSColNames[] = { - "lhcMon_LHCCollimatorPos_TCTVB_4L2.%s", - "lhcMon_LHCCollimatorPos_TCTVB_4R2.%s", - "lhcMon_LHCCollimatorPos_TCLIA_4R2.%s" -}; - -const Char_t* AliLHCData::fgkDCSColJaws[] = { - "lvdt_gap_downstream","lvdt_gap_upstream","lvdt_left_downstream", - "lvdt_left_upstream","lvdt_right_downstream","lvdt_right_upstream"}; - -//___________________________________________________________________ -AliLHCData::AliLHCData(const TMap* dcsMap, double tmin, double tmax, int avPeriod) - : fPeriod(avPeriod),fTMin(tmin),fTMax(tmax) -{ - FillData(dcsMap,tmin,tmax); -} - -//___________________________________________________________________ -Bool_t AliLHCData::FillData(const TMap* dcsMap, double tmin, double tmax) -{ - // process DCS map and fill all fields. - // Accept only entries with timestamp between tmin and tmax - const double ktReal = 1200000000.; - const double kCollTolerance = 100e-4; // tolerance on collimator move (cm) - char buff[100]; - TObjArray* arr; - AliDCSArray* dcsVal; - Double_t tPeriodEnd=0; - Int_t dcsSize,nEntries,iEntry; - // - SetTMin(tmin); - SetTMax(tmax); - // - // -------------------------- extract Fill Number - arr = GetDCSEntry(dcsMap,fgkDCSNames[kRecFillNum],iEntry,tmin,tmax); - if (arr && iEntry>=0) SetFillNumber( ((AliDCSArray*)arr->At(iEntry))->GetInt(0) ); - // - // -------------------------- extract total intensities for beam 1 and 2 (DC BCT: slow average) - for (int ibm=0;ibm<2;ibm++) { - // - sprintf(buff,fgkDCSNames[kRecTotInt],ibm+1); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,tmin,tmax)) || iEntry<0 ) continue; - AliLHCDipValD* curVal = 0; - tPeriodEnd = 0; - // - nEntries = arr->GetEntriesFast(); - while (iEntryAt(iEntry++); - double tstamp = dcsVal->GetTimeStamp(); - if (tstamp>tmax) break; - if (tstamp>tPeriodEnd) { - curVal = new AliLHCDipValD(1,0.,0); // start new period - fIntTot[ibm].Add(curVal); - // if tmin is provided, count periods from it, otherwise from the 1st timestamp - if (tPeriodEnd<1) tPeriodEnd = ((tmin>ktReal) ? tmin : tstamp); - tPeriodEnd += fPeriod; - } - *curVal += *dcsVal; - } - for (int i=fIntTot[ibm].GetEntries();i--;) ((AliLHCDipValD*)(fIntTot[ibm])[i])->Average(); - } - // - // -------------------------- extract total intensities for beam 1 and 2 (BCTFR: fast average) - for (int ibm=0;ibm<2;ibm++) { - // - sprintf(buff,fgkDCSNames[kRecTotIntBunch],ibm+1); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,tmin,tmax)) || iEntry<0 ) continue; - AliLHCDipValD* curVal = 0; - tPeriodEnd = 0; - // - nEntries = arr->GetEntriesFast(); - while (iEntryAt(iEntry++); - double tstamp = dcsVal->GetTimeStamp(); - if (tstamp>tmax) break; - if (tstamp>tPeriodEnd) { - curVal = new AliLHCDipValD(1,0.,0); // start new period - fIntTotBunch[ibm].Add(curVal); - // if tmin is provided, count periods from it, otherwise from the 1st timestamp - if (tPeriodEnd<1) tPeriodEnd = ((tmin>ktReal) ? tmin : tstamp); - tPeriodEnd += fPeriod; - } - *curVal += *dcsVal; - } - for (int i=fIntTotBunch[ibm].GetEntries();i--;) ((AliLHCDipValD*)(fIntTotBunch[ibm])[i])->Average(); - } - // - // -------------------------- extract total luminosities according L and R detectors - for (int ilr=0;ilr<2;ilr++) { - // - sprintf(buff,fgkDCSNames[kRecTotLum],ilr ? 'L':'R'); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,tmin,tmax)) || iEntry<0 ) continue; - AliLHCDipValD* curVal = 0; - tPeriodEnd = 0; - // - nEntries = arr->GetEntriesFast(); - while (iEntryAt(iEntry++); - double tstamp = dcsVal->GetTimeStamp(); - if (tstamp>tmax) break; - if (tstamp>tPeriodEnd) { - curVal = new AliLHCDipValD(1,0.,0); // start new period - fLuminTot[ilr].Add(curVal); - // if tmin is provided, count periods from it, otherwise from the 1st timestamp - if (tPeriodEnd<1) tPeriodEnd = ((tmin>ktReal) ? tmin : tstamp); - tPeriodEnd += fPeriod; - } - *curVal += *dcsVal; - } - for (int i=fLuminTot[ilr].GetEntries();i--;) ((AliLHCDipValD*)(fLuminTot[ilr])[i])->Average(); - } - // - // -------------------------- extract mean crossing angles according to L and R detectors - for (int ilr=0;ilr<2;ilr++) { - // - sprintf(buff,fgkDCSNames[kRecCrossAngle],ilr ? 'L':'R'); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,tmin,tmax)) || iEntry<0 ) continue; - AliLHCDipValD* curVal = 0; - tPeriodEnd = 0; - // - nEntries = arr->GetEntriesFast(); - while (iEntryAt(iEntry++); - double tstamp = dcsVal->GetTimeStamp(); - if (tstamp>tmax) break; - if (tstamp>tPeriodEnd) { - curVal = new AliLHCDipValD(1,0.,0); // start new period - fCrossAngle[ilr].Add(curVal); - // if tmin is provided, count periods from it, otherwise from the 1st timestamp - if (tPeriodEnd<1) tPeriodEnd = ((tmin>ktReal) ? tmin : tstamp); - tPeriodEnd += fPeriod; - } - *curVal += *dcsVal; - } - for (int i=fCrossAngle[ilr].GetEntries();i--;) ((AliLHCDipValD*)(fCrossAngle[ilr])[i])->Average(); - } - // - // - // ------------------------- extract bunch configuration for beam 1 and 2 - int nbunch[2]; - for (int ibm=0;ibm<2;ibm++) { - // - nbunch[ibm] = -1; - sprintf(buff,fgkDCSNames[kRecBunchConf],ibm+1); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,tmin,tmax)) || iEntry<0 ) continue; - dcsVal = (AliDCSArray*) arr->At(iEntry); - nEntries = dcsVal->GetNEntries(); // count number of actual bunches - nbunch[ibm] = 0; - while(nbunch[ibm]GetInt(nbunch[ibm])) nbunch[ibm]++; - if (!nbunch[ibm]) { - AliWarning(Form("Beam%d bunches configuration record is present but empty",ibm+1)); - continue; - } - fBunchConfig[ibm].SetSize(nbunch[ibm]); - fBunchConfig[ibm] += *dcsVal; - } - // -------------------------- extract intensities per bunch for beam 1 and 2 - for (int ibm=0;ibm<2;ibm++) { - // - sprintf(buff,fgkDCSNames[kRecBunchInt],ibm+1); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,tmin,tmax)) || iEntry<0 ) continue; - AliLHCDipValD* curVal = 0; - tPeriodEnd = 0; - // - dcsVal = (AliDCSArray*)arr->At(iEntry); - nEntries = dcsVal->GetNEntries(); // count number of actual bunches - dcsSize = 0; - while(dcsSizeGetDouble(dcsSize)>0) dcsSize++; - if (!dcsSize) { - AliWarning(Form("Beam%d bunch intensities record is present but empty",ibm+1)); - continue; - } - if (nbunch[ibm]>0) { // bunch pattern was provided - if (dcsSize>nbunch[ibm]) { - AliWarning(Form("Beam%d declares %d bunches but %d bunch intensities are non-0. Take first %d", - ibm+1,nbunch[ibm],dcsSize,nbunch[ibm])); - dcsSize = nbunch[ibm]; - } - else if (dcsSizeGetEntriesFast(); - while (iEntryAt(iEntry++); - double tstamp = dcsVal->GetTimeStamp(); - if (tstamp>tmax) break; - if (tstamp>tPeriodEnd) { - curVal = new AliLHCDipValD(dcsSize,0.,0); // start new period - fIntBunch[ibm].Add(curVal); - // if tmin is provided, count periods from it, otherwise from the 1st timestamp - if (tPeriodEnd<1) tPeriodEnd = ((tmin>ktReal) ? tmin : tstamp); - tPeriodEnd += fPeriod; - } - *curVal += *dcsVal; - } - for (int i=fIntBunch[ibm].GetEntries();i--;) ((AliLHCDipValD*)(fIntBunch[ibm])[i])->Average(); - } - // - // -------------------------- extract per bunch luminosities according L and R detectors - for (int ilr=0;ilr<2;ilr++) { - // - sprintf(buff,fgkDCSNames[kRecBunchLum],ilr ? 'L':'R'); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,tmin,tmax)) || iEntry<0 ) continue; - AliLHCDipValD* curVal = 0; - tPeriodEnd = 0; - // - dcsVal = (AliDCSArray*) arr->At(iEntry); - nEntries = dcsVal->GetNEntries(); // count number of actual bunches - dcsSize = 0; - while(dcsSizeGetDouble(dcsSize)>0) dcsSize++; - if (!dcsSize) { - AliWarning(Form("Probe%c bunch luminosities record is present but empty",ilr ? 'R':'L')); - continue; - } - // - if (nbunch[ilr]>0) { // bunch pattern was provided - if (dcsSize>nbunch[ilr]) { - AliWarning(Form("Beam%d declares %d bunches but %d bunch luminosities are non-0. Take first %d", - ilr+1,nbunch[ilr],dcsSize,nbunch[ilr])); - dcsSize = nbunch[ilr]; - } - else if (dcsSizeGetEntriesFast(); - while (iEntryAt(iEntry++); - double tstamp = dcsVal->GetTimeStamp(); - if (tstamp>tmax) break; - if (tstamp>tPeriodEnd) { - curVal = new AliLHCDipValD(dcsSize,0.,0); // start new period - fLuminBunch[ilr].Add(curVal); - // if tmin is provided, count periods from it, otherwise from the 1st timestamp - if (tPeriodEnd<1) tPeriodEnd = ((tmin>ktReal) ? tmin : tstamp); - tPeriodEnd += fPeriod; - } - *curVal += *dcsVal; - } - for (int i=fLuminBunch[ilr].GetEntries();i--;) ((AliLHCDipValD*)(fLuminBunch[ilr])[i])->Average(); - } - // - // ------------------------- extract gaussian fit params for beam 1 and 2 profiles - for (int ibm=0;ibm<2;ibm++) { - for (int ixy=0;ixy<2;ixy++) { - // determine which projection corresponds actually to given ixy - sprintf(buff,fgkDCSNames[kRecPrfPrID],ibm+1,ixy+1); - if ( !(arr=GetDCSEntry(dcsMap,buff,iEntry,0/*tmin*/,tmax)) || iEntry<0 ) continue; - dcsVal = (AliDCSArray*) arr->At(iEntry); - int proj = dcsVal->GetInt(0)-1; // beam projection - // - if (proj!=kX && proj!=kY) { - AliError(Form("Unknown beam projection %d for %s",proj,buff)); - continue; - } - // Amp,Pos,Sig - each one have separate entry and time stamp (though come from the single fit) - int entPar[3]; - TObjArray *arrPar[3]; - AliDCSArray *dcsPar[3]; - AliLHCDipValD* curVal = 0; - double tstamp = 0; - int npars = 0; - for (int ipar=0;ipar<3;ipar++) { - sprintf(buff,fgkDCSNames[ipar+kRecPrfAmp],ibm+1,ixy+1); - if ( !(arrPar[ipar]=GetDCSEntry(dcsMap,buff,entPar[ipar],tmin,tmax)) || entPar[ipar]<0 ) break; - dcsPar[ipar] = (AliDCSArray*) arrPar[ipar]->At(entPar[ipar]); - if (dcsPar[ipar]->GetTimeStamp()>tstamp) tstamp = dcsPar[ipar]->GetTimeStamp(); // max time among 1st entries - npars++; - } - if (npars<3) continue; // ignore incomplete data - // - tPeriodEnd = 0; - // start recording from max timeStamp: - // the entries for different params must correspond to same timestamp - while(1) { - // - // read next timestamp for which all 3 params are present - npars = 0; // align the first entries to read to same timestamp - for (int ipar=0;ipar<3;ipar++) { - while(entPar[ipar]GetEntriesFast()) { - dcsPar[ipar] = (AliDCSArray*) arrPar[ipar]->At(entPar[ipar]); - double df = dcsPar[ipar]->GetTimeStamp() - tstamp; - if (TMath::Abs(df)<0.5) { // same time stamp, ok - npars++; - break; - } - if (df<0) entPar[ipar]++; // check next entry - else { - tstamp = dcsPar[ipar]->GetTimeStamp(); - ipar = -1; // reference tstamp was changed, check all arrays again - npars = 0; - break; - } - } - } // - if (npars<3) break; // no more data - for (int ipar=0;ipar<3;ipar++) entPar[ipar]++; - // - if (tstamp>tmax) break; - if (tstamp>tPeriodEnd) { - curVal = new AliLHCDipValD(3,0.,0); // start new period - fBeamPos[ibm][proj].Add(curVal); - // if tmin is provided, count periods from it, otherwise from the 1st timestamp - if (tPeriodEnd<1) tPeriodEnd = ((tmin>ktReal) ? tmin : tstamp); - tPeriodEnd += fPeriod; - } - int nsamp = curVal->GetNSamplesUsed()+1; - curVal->SetTimeStamp( (tstamp + curVal->GetNSamplesUsed()*curVal->GetTimeStamp())/nsamp); - curVal->SetNSamplesUsed(nsamp); - for (int ipar=3;ipar--;) (*curVal)[ipar] += dcsPar[ipar]->GetDouble(0); - // - } - // - for (int i=fBeamPos[ibm][proj].GetEntriesFast();i--;) ((AliLHCDipValD*)(fBeamPos[ibm][proj])[i])->Average(); - // - } // projection - } // beam - // - // ------------------------- extract collimators data - for (int icl=0;iclAt(iEntry); - AliLHCDipValD* curVal = new AliLHCDipValD(1,dcsVal->GetTimeStamp(),1); - (*curVal)[0] = dcsVal->GetDouble(0)/10; // gap in cm - fCollimators[icl][jaw].Add(curVal); - // - // now track the changes above the threshold (100 um?) - nEntries = arr->GetEntriesFast(); - while(++iEntryAt(iEntry); - if (dcsVal->GetTimeStamp() > tmax) break; // out of time - double val = dcsVal->GetDouble(0)/10; - if ( TMath::Abs(val-curVal->GetValue(0))GetTimeStamp(),1); - (*curVal)[0] = val; // gap in cm - fCollimators[icl][jaw].Add(curVal); - } - } // jaws - } // collimators - // - return kTRUE; -} - -//___________________________________________________________________ -TObjArray* AliLHCData::GetDCSEntry(const TMap* dcsMap,const char* key,int &entry,double tmin,double tmax) const -{ - // extract array from the DCS map and find the first entry within the time limits - TObjArray* arr = (TObjArray*)dcsMap->GetValue(key); - if (!arr || !arr->GetEntriesFast()) { - AliWarning(Form("No data for %s",key)); - return 0; - } - int ntot = arr->GetEntriesFast(); - for (entry=0;entryAt(entry); - if (ent->GetTimeStamp()>=tmin && ent->GetTimeStamp()<=tmax) break; - } - if (entry==ntot) { - entry = -1; - TString str; - str += AliLHCDipValD::TimeAsString(tmin); - str += " : "; - str += AliLHCDipValD::TimeAsString(tmax); - AliWarning(Form("All entries for %s are outside the requested range:\n%s",key,str.Data())); - } - return arr; -} - -//___________________________________________________________________ -void AliLHCData::Print(const Option_t* opt) const -{ - // print everything - printf("LHC DIP Data | Fill Number#%d (Averaging time: %d sec.)\n",GetFillNumber(),fPeriod); - printf("Validity period: %s : %s\n\n", - fTMin<1.23e9 ? "N/A": AliLHCDipValD::TimeAsString(fTMin), - fTMax>7.00e9 ? "N/A": AliLHCDipValD::TimeAsString(fTMax) ); - // - int n=0; - for (int ibm=0;ibm<2;ibm++) { - printf("*** Bunch Configuration for Beam%d: %s\n",ibm,(n=fBunchConfig[ibm].GetSize()) ? "":"N/A"); - if (n) fBunchConfig[ibm].Print(opt); - } - printf("\n"); - // - for (int ibm=0;ibm<2;ibm++) { - printf("*** Average total intensity for Beam%d (DCBCT): %s\n",ibm,(n=fIntTot[ibm].GetEntriesFast()) ? "":"N/A"); - for (int i=0;iPrint(opt); - } - printf("\n"); - // - for (int ibm=0;ibm<2;ibm++) { - printf("*** Total intensity for Beam%d (BCTFR): %s\n",ibm,(n=fIntTotBunch[ibm].GetEntriesFast()) ? "":"N/A"); - for (int i=0;iPrint(opt); - } - printf("\n"); // - for (int ibm=0;ibm<2;ibm++) { - printf("*** Bunch intensities for Beam%d: %s\n",ibm,(n=fIntBunch[ibm].GetEntriesFast()) ? "":"N/A"); - for (int i=0;iPrint(opt); - } - printf("\n"); - // - for (int ibm=0;ibm<2;ibm++) { - printf("*** Total luminosity for probe%c: %s\n",ibm ? 'R':'L',(n=fLuminTot[ibm].GetEntriesFast()) ? "":"N/A"); - for (int i=0;iPrint(opt); - } - printf("\n"); - // - for (int ibm=0;ibm<2;ibm++) { - printf("*** Bunch luminosities for probe%c: %s\n",ibm ? 'R':'L',(n=fLuminBunch[ibm].GetEntriesFast()) ? "":"N/A"); - for (int i=0;iPrint(opt); - } - printf("\n"); - // - for (int ibm=0;ibm<2;ibm++) { - printf("*** Crossing angle for probe%c: %s\n",ibm ? 'L':'R',(n=fCrossAngle[ibm].GetEntriesFast()) ? "":"N/A"); - for (int i=0;iPrint(opt); - } - printf("\n"); - // - for (int ibm=0;ibm<2;ibm++) { - for (int ixy=0;ixy<2;ixy++) { - printf("*** Gaussian fit for Beam%d %c profile: %s\n",ibm,ixy ? 'Y':'X',(n=fBeamPos[ibm][ixy].GetEntriesFast()) ? "":"N/A"); - for (int i=0;iPrint(opt); - } - } - // - for (int icl=0;iclPrint(opt); - } - } - // -} +/************************************************************************** + * 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. * + * * + **************************************************************************/ + +/******************************************************************************** +* * +* AliLHCData: summary of the LHC related information from LHC DIP. * +* Created from the TMap provided by the AliLHCReader with optional beginning * +* * +* The data are (wrapped in the AliLHCDipValT): * +* made of TimeStamp (double) and array of values * +* * +* Multiple entries for each type of data are possible. To obtaine number of * +* records (with distinct timestamp) for give type od records use: * +* int GetNBunchConfigMeasured(int beam) (with beam=0,1) etc. * +* * +* To get i-th entry, use brec= AliLHCDipValI* GetBunchConfigMeasured(bm,i); * +* Note: exact type of templated AliLHCDipValT pointer depends on the record * +* type, concult getters to know it. * +* * +* Then, once the pointer is obtained, details can be accessed: * +* int nBunches = brec->GetSize(); * +* for (int i=0;i +#include + +ClassImp(AliLHCData) + +const Char_t* AliLHCData::fgkDCSNames[] = { + "LHC_IntensityBeam%d_totalIntensity", + "LHC_BeamIntensityPerBunchBeam%d_averageBeamIntensity", + "LHC_BeamIntensityPerBunchBeam%d_Average_BunchIntensities", + // + "LHC_LumAverageBRANB_4%c2_acqMode", + "LHC_LumAverageBRANB_4%c2_meanLuminosity", + "LHC_LumAverageBRANB_4%c2_meanLuminosityError", + "LHC_BeamLuminosityPerBunchBRANB_4%c2_Average_BunchLuminosity", + "LHC_BeamLuminosityPerBunchBRANB_4%c2_BunchLuminosityError", + "LHC_LumAverageBRANB_4%c2_meanCrossingAngle", + "LHC_LumAverageBRANB_4%c2_meanCrossingAngleError", + "LHC_CirculatingBunchConfig_Beam%d", + "LHC_FillNumber", + // + "LHC_BunchLengthBeam%d_nBunches", + "LHC_BunchLengthBeam%d_bunchesLenghts", + "LHC_BunchLengthBeam%d_filledBuckets", + // + "LHC_RunControl_ActiveInjectionScheme", + "LHC_RunControl_BetaStar", + "LHC_RunControl_IP2_Xing_Murad", + "LHC_RunControl_IP2_ALICE_Murad", + + "LHC_BeamSizeBeam%d_acqMode", + "LHC_BeamSizeBeam%d_sigmaH", + "LHC_BeamSizeBeam%d_sigmaV", + "LHC_BeamSizeBeam%d_emittanceH", + "LHC_BeamSizeBeam%d_emittanceV", + "LHC_BeamSizeBeam%d_errorSigmaH", + "LHC_BeamSizeBeam%d_errorSigmaV", + // + "LHC_CollimatorPos_%s_lvdt_%s" +}; + +const Char_t* AliLHCData::fgkDCSColNames[] = { + "TCTVB_4L2", + "TCTVB_4R2", + "TCLIA_4R2" +}; + +const Char_t* AliLHCData::fgkDCSColJaws[] = { + "gap_downstream","gap_upstream","left_downstream", + "left_upstream","right_downstream","right_upstream"}; + +//___________________________________________________________________ +AliLHCData::AliLHCData(const TMap* dcsMap, double tmin, double tmax) + : fTMin(tmin),fTMax(tmax),fFillNumber(0),fData(0) +{ + Clear(); + SetTMin(tmin); + SetTMin(tmax); + FillData(dcsMap); +} + +//___________________________________________________________________ +Bool_t AliLHCData::FillData(const TMap* dcsMap, double tmin, double tmax) +{ + // process DCS map and fill all fields. + // Accept only entries with timestamp between tmin and tmax + // + char buff[100],buff1[100]; + // + SetTMin(tmin); + SetTMax(tmax); + // + // -------------------------- extract Fill Number + int iEntry; + TObjArray* arr = GetDCSEntry(dcsMap, fgkDCSNames[kFillNum],iEntry,fTMin,fTMax); + if (arr && iEntry>=0) SetFillNumber( ExtractInt( (AliDCSArray*)arr->At(iEntry), 0) ); + // + for (int ibm=0;ibm<2;ibm++) { + // + sprintf(buff,fgkDCSNames[kBunchConf],ibm+1); // ----- declared bunch configuration + FillBunchConfig(dcsMap, fBunchConfDecl[ibm], buff); + // + sprintf(buff,fgkDCSNames[kBunchLgtFillB],ibm+1); // ----- measured bunch configuration + FillBunchConfig(dcsMap, fBunchConfMeas[ibm], buff); + // + sprintf(buff,fgkDCSNames[kBunchLgt],ibm+1); // ----- maesured bunch lenghts + FillBunchInfo(dcsMap, fBunchLengths[ibm],buff,ibm,kFALSE); + // + sprintf(buff,fgkDCSNames[kIntBunchAv],ibm+1); // ----- B-by-B intensities + FillBunchInfo(dcsMap, fIntensPerBunch[ibm],buff,ibm,kTRUE); + // + // + sprintf(buff,fgkDCSNames[kIntTot],ibm+1); // ----- total intensities for beam 1 and 2 + FillScalarRecord(dcsMap, fIntensTotal[ibm], buff); + // + sprintf(buff,fgkDCSNames[kIntTotAv],ibm+1); // ----- total intensities for beam 1 and 2 from B-by-B average + FillScalarRecord(dcsMap, fIntensTotalAv[ibm], buff); + // + sprintf(buff,fgkDCSNames[kBeamSzEmittH],ibm+1); // ----- H emittance for beam 1 and 2 + FillScalarRecord(dcsMap, fEmittanceH[ibm], buff); + // + sprintf(buff,fgkDCSNames[kBeamSzEmittV],ibm+1); // ----- V emittance for beam 1 and 2 + FillScalarRecord(dcsMap, fEmittanceV[ibm], buff); + // + sprintf(buff ,fgkDCSNames[kBeamSzSigH], ibm+1); // ----- H sigmas and errors for beam 1 and 2 + sprintf(buff1,fgkDCSNames[kBeamSzSigHErr],ibm+1); + FillScalarRecord(dcsMap, fBeamSigmaH[ibm], buff, buff1); + // + sprintf(buff ,fgkDCSNames[kBeamSzSigV], ibm+1); // ----- V sigmas and errors for beam 1 and 2 + sprintf(buff1,fgkDCSNames[kBeamSzSigVErr],ibm+1); + FillScalarRecord(dcsMap, fBeamSigmaV[ibm], buff, buff1); + // + } + // + for (int ilr=0;ilr<2;ilr++) { + // + sprintf(buff ,fgkDCSNames[kLumBunch], ilr ? 'R':'L'); // ---- BC-by-BC luminosity at IP2 and its error + sprintf(buff1,fgkDCSNames[kLumBunchErr], ilr ? 'R':'L'); + FillBCLuminosities(dcsMap, fLuminPerBC[ilr], buff, buff1, kTRUE); + // + sprintf(buff ,fgkDCSNames[kLumTot] , ilr ? 'R':'L'); // ---- total luminosity at IP2 and its error + sprintf(buff1,fgkDCSNames[kLumTotErr], ilr ? 'R':'L'); + FillScalarRecord(dcsMap, fLuminTotal[ilr], buff, buff1); + // + sprintf(buff ,fgkDCSNames[kLumAcqMode], ilr ? 'R':'L'); // ---- luminosity acquisition mode + FillAcqMode(dcsMap, fLuminAcqMode[ilr], buff); + // + sprintf(buff, fgkDCSNames[kLumCrossAng] , ilr ? 'R':'L'); //----- crossing angle at IP2 and its error + sprintf(buff1,fgkDCSNames[kLumCrossAngErr], ilr ? 'R':'L'); + FillScalarRecord(dcsMap, fCrossAngle[ilr], buff, buff1); + // + } + // + for (int icl=0;iclGetValue(key); + if (!arr || !arr->GetEntriesFast()) { + AliWarning(Form("No data for %s",key)); + return 0; + } + int ntot = arr->GetEntriesFast(); + for (entry=0;entryAt(entry); + if (ent->GetTimeStamp()>=tmin && ent->GetTimeStamp()<=tmax) break; + } + if (entry==ntot) { + entry = -1; + TString str; + str += AliLHCDipValD::TimeAsString(tmin); + str += " : "; + str += AliLHCDipValD::TimeAsString(tmax); + AliWarning(Form("All entries for %s are outside the requested range:\n%s",key,str.Data())); + } + return arr; +} + +//___________________________________________________________________ +Int_t AliLHCData::TimeDifference(double v1,double v2,double tol) const +{ + // return 0 if the times are the same within the tolerance + // 1 if v1>v2 + // -1 if v1tol) return 1; + if (v1<-tol) return -1; + return 0; +} + +//___________________________________________________________________ +Bool_t AliLHCData::GoodPairID(int beam) const +{ + // check for correct beam identifier + if (beam>kBeam2||beam<0) {AliError(Form("BeamID can be 0 or 1, %d requested",beam)); return kFALSE;} + return kTRUE; +} + +//___________________________________________________________________ +AliLHCDipValI* AliLHCData::GetBunchConfigMeasured(int beam,double tstamp) const +{ + // find measured bunch configuration valid for given tstamp + if (!GoodPairID(beam)) return 0; + return (AliLHCDipValI*)FindRecValidFor(fBunchConfMeas[beam][kStart],fBunchConfMeas[beam][kNStor],tstamp); +} + +//___________________________________________________________________ +AliLHCDipValI* AliLHCData::GetBunchConfigDeclared(int beam,double tstamp) const +{ + // find declared bunch configuration valid for given tstamp + if (!GoodPairID(beam)) return 0; + return (AliLHCDipValI*)FindRecValidFor(fBunchConfDecl[beam][kStart],fBunchConfDecl[beam][kNStor],tstamp); +} + +//___________________________________________________________________ +TObject* AliLHCData::FindRecValidFor(int start,int nrec, double tstamp) const +{ + // find record within this limits valid for given tstamp (i.e. the last one before or equal to tstamp) + AliLHCDipValI *prevObj = 0; + for (int i=0;iGetTimeStamp())>0) break; + prevObj = curObj; + } + if (!prevObj && nrec>0) prevObj = (AliLHCDipValI*)fData[start]; // if no exact match, return the 1st one + return prevObj; +} + +//___________________________________________________________________ +Int_t AliLHCData::FillScalarRecord(const TMap* dcsMap, int refs[2], const char* rec, const char* recErr) +{ + // fill record for scalar value, optionally accompanied by measurement error + // + AliInfo(Form("Acquiring record: %s",rec)); + // + TObjArray *arr,*arrE; + Int_t nEntries,nEntriesE,iEntry,iEntryE; + // + refs[kStart] = fData.GetEntriesFast(); + refs[kNStor] = 0; + // + if ( !(arr=GetDCSEntry(dcsMap,rec,iEntry,fTMin,fTMax)) || iEntry<0 ) return -1; + nEntries = arr->GetEntriesFast(); + // + int dim = 1; + if (recErr) { + if ( !(arrE=GetDCSEntry(dcsMap,recErr,iEntryE,fTMin,fTMax)) || iEntryE<0 ) nEntriesE = -999; + else nEntriesE = arrE->GetEntriesFast(); + dim += 1; + } + // + while (iEntryAt(iEntry++); + double tstamp = dcsVal->GetTimeStamp(); + if (tstamp>fTMax) break; + // + AliLHCDipValF* curValF = new AliLHCDipValF(dim,tstamp); // start new period + (*curValF)[0] = ExtractDouble(dcsVal,0); // value + // + if (recErr) { + double errVal = -1; + while (iEntryEAt(iEntryE); + double tstampE = dcsValE->GetTimeStamp(); + if (tstampE>fTMax) break; + int tdif = TimeDifference(tstamp,tstampE); + if (!tdif) { // error matches to value + errVal = ExtractDouble(dcsValE,0); + iEntryE++; + break; + } + else if (tdif>0) iEntryE++; // error time lags behind, read the next one + else break; // error time is ahead of value, no error associated + } + (*curValF)[dim-1] = errVal; // error + curValF->SetLastSpecial(); // lable the last entry as an error + } + // + fData.Add(curValF); + refs[kNStor]++; + } + // + return refs[kNStor]; +} + +//___________________________________________________________________ +Int_t AliLHCData::FillBunchConfig(const TMap* dcsMap, int refs[2],const char* rec) +{ + // fill record for bunch configuration + // + AliInfo(Form("Acquiring record: %s",rec)); + TObjArray *arr; + Int_t nEntries,iEntry; + // + refs[kStart] = fData.GetEntriesFast(); + refs[kNStor] = 0; + // + if ( !(arr=GetDCSEntry(dcsMap,rec,iEntry,fTMin,fTMax)) || iEntry<0 ) return -1; + nEntries = arr->GetEntriesFast(); + // + AliLHCDipValI* prevRecI=0; + while (iEntryAt(iEntry++); + double tstamp = dcsVal->GetTimeStamp(); + if (tstamp>fTMax) break; + // + int bucket=0, nbunch=0, ndiff=0; + int nSlots = dcsVal->GetNEntries(); // count number of actual bunches (non-zeros) + int* dcsArr = dcsVal->GetInt(); + while(nbunchGetSize()>nbunch && bucket!=prevRecI->GetValue(nbunch)) ndiff++; + nbunch++; + } + if (!nbunch) AliWarning(Form("%s record is present but empty: no beam?",rec)); + if (prevRecI && !ndiff && nbunch==prevRecI->GetSize()) continue; // record similar to previous one + AliLHCDipValI* curValI = new AliLHCDipValI(nbunch,tstamp); + for (int i=nbunch;i--;) (*curValI)[i] = dcsArr[i]; + fData.Add(curValI); + refs[kNStor]++; + prevRecI = curValI; + } + // + return refs[kNStor]; +} + +//___________________________________________________________________ +Int_t AliLHCData::FillAcqMode(const TMap* dcsMap, int refs[2],const char* rec) +{ + // fill acquisition mode + // + AliInfo(Form("Acquiring record: %s",rec)); + TObjArray *arr; + Int_t nEntries,iEntry; + // + refs[kStart] = fData.GetEntriesFast(); + refs[kNStor] = 0; + // + if ( !(arr=GetDCSEntry(dcsMap,rec,iEntry,fTMin,fTMax)) || iEntry<0 ) return -1; + nEntries = arr->GetEntriesFast(); + // + AliLHCDipValI* prevRecI=0; + while (iEntryAt(iEntry++); + double tstamp = dcsVal->GetTimeStamp(); + if (tstamp>fTMax) break; + // + int nSlots = dcsVal->GetNEntries(); + if (nSlots<1) continue; + int acqMode = dcsVal->GetInt()[0]; + if (prevRecI && (*prevRecI)[0] == acqMode) continue; // record similar to previous one + AliLHCDipValI* curValI = new AliLHCDipValI(1,tstamp); + (*curValI)[0] = acqMode; + fData.Add(curValI); + refs[kNStor]++; + prevRecI = curValI; + } + // + return refs[kNStor]; +} + +//___________________________________________________________________ +Int_t AliLHCData::FillStringRecord(const TMap* dcsMap, int refs[2],const char* rec) +{ + // fill record with string value + // + AliInfo(Form("Acquiring record: %s",rec)); + TString prevRec; + TObjArray *arr; + Int_t nEntries,iEntry; + // + refs[kStart] = fData.GetEntriesFast(); + refs[kNStor] = 0; + // + if ( !(arr=GetDCSEntry(dcsMap,rec,iEntry,fTMin,fTMax)) || iEntry<0 ) return -1; + nEntries = arr->GetEntriesFast(); + // + while (iEntryAt(iEntry++); + double tstamp = dcsVal->GetTimeStamp(); + if (tstamp>fTMax) break; + // + TString &str = ExtractString(dcsVal); + if (!prevRec.IsNull()) {if (str == prevRec) continue;} // skip similar record + else prevRec = str; + // + AliLHCDipValC* curValS = new AliLHCDipValC(1,tstamp); + curValS->SetValues(str.Data(),str.Length()+1); + // + fData.Add(curValS); + refs[kNStor]++; + } + return refs[kNStor]; +} + +//___________________________________________________________________ +Int_t AliLHCData::FillBunchInfo(const TMap* dcsMap, int refs[2],const char* rec, int ibm, Bool_t inRealSlots) +{ + // fill bunch properties for beam ibm + // if inRealSlots = true, then the value is taken from bunchRFbucket/10, otherwise, the value + // for the i-th bunch is taken from the i-th element + // + AliInfo(Form("Acquiring record: %s",rec)); + TObjArray *arr; + Int_t nEntries,iEntry; + // + refs[kStart] = fData.GetEntriesFast(); + refs[kNStor] = 0; + // + if ( !(arr=GetDCSEntry(dcsMap,rec,iEntry,fTMin,fTMax)) || iEntry<0 ) return -1; + nEntries = arr->GetEntriesFast(); + // + while (iEntryAt(iEntry++); + double tstamp = dcsVal->GetTimeStamp(); + if (tstamp>fTMax) break; + // + AliLHCDipValI *bconf = GetBunchConfigMeasured(ibm,tstamp); + if (!bconf) { + AliWarning(Form("Mearured bunch configuration for beam %d at t=%.1f is not available, trying declared one",ibm+1,tstamp)); + bconf = GetBunchConfigDeclared(ibm,tstamp); + } + if (!bconf) { + AliWarning(Form("Declared bunch configuration for beam %d at t=%.1f is not available, skip this record",ibm+1,tstamp)); + return -1; + } + int nSlots = dcsVal->GetNEntries(); // count number of actual bunches (non-zeros) + int nbunch = bconf->GetSize(); + if (nbunch>nSlots) { + AliWarning(Form("More N bunches than slots in %s at time %.1f",rec,tstamp)); + continue; + } + double* dcsArr = dcsVal->GetDouble(); + AliLHCDipValF* curValF = new AliLHCDipValF(nbunch,tstamp); + for (int i=nbunch;i--;) { + int ind = inRealSlots ? (*bconf)[i]/10 : i; + if (ind>nSlots) { + AliError(Form("Bunch %d refers to wrong slot %d, set to -1",i,(*bconf)[i])); + (*curValF)[i] = -1; + } + else (*curValF)[i] = dcsArr[ind]; + } + fData.Add(curValF); + refs[kNStor]++; + } + return refs[kNStor]; + // +} + +//___________________________________________________________________ +Int_t AliLHCData::FillBCLuminosities(const TMap* dcsMap, int refs[2],const char* rec, const char* recErr, Bool_t opt) +{ + // fill luminosities per bunch crossing + // + AliInfo(Form("Acquiring record: %s",rec)); + TObjArray *arr,*arrE; + Int_t nEntries,nEntriesE,iEntry,iEntryE; + // + refs[kStart] = fData.GetEntriesFast(); + refs[kNStor] = 0; + // + if ( !(arr=GetDCSEntry(dcsMap,rec,iEntry,fTMin,fTMax)) || iEntry<0 ) return -1; + nEntries = arr->GetEntriesFast(); + // + while (iEntryAt(iEntry++); + double tstamp = dcsVal->GetTimeStamp(); + if (tstamp>fTMax) break; + // + AliLHCDipValI *bconf = GetBunchConfigMeasured(0,tstamp); // luminosities are stored according to 1st beam bunches + if (!bconf) { + AliWarning(Form("Mearured bunch configuration for beam 1 at t=%.1f is not available, trying declared one",tstamp)); + bconf = GetBunchConfigDeclared(0,tstamp); + } + if (!bconf) { + AliWarning(Form("Declared bunch configuration for beam 1 at t=%.1f is not available, skip this record",tstamp)); + return -1; + } + int nSlots = dcsVal->GetNEntries(); // count number of actual bunches (non-zeros) + int nbunch = bconf->GetSize(); + double* dcsArr = dcsVal->GetDouble(); + // + // ATTENTION: FOR THE MOMENT STORE ALL SLOTS CORRESPONDING TO FILLED BUNCHES (until the scheme is clarified) + if (nbunch>nSlots) { + AliWarning(Form("More N bunches than slots in %s at time %.1f",rec,tstamp)); + continue; + } + int dim = nbunch; + if (recErr) { + if ( !(arrE=GetDCSEntry(dcsMap,recErr,iEntryE,fTMin,fTMax)) || iEntryE<0 ) nEntriesE = -999; + else nEntriesE = arrE->GetEntriesFast(); + dim += 1; + } + AliLHCDipValF* curValF = new AliLHCDipValF(dim,tstamp); + for (int i=nbunch;i--;) { + int ind = opt ? (*bconf)[i]/10 : i; + if (ind>nSlots) { + AliError(Form("Bunch %d refers to wrong slot %d, set to -1",i,(*bconf)[i])); + (*curValF)[i] = -1; + } + else (*curValF)[i] = dcsArr[ind]; + } + // + if (recErr) { + double errVal = -1; + while (iEntryEAt(iEntryE); + double tstamp1 = dcsValE->GetTimeStamp(); + if (tstamp1>fTMax) break; + int tdif = TimeDifference(tstamp,tstamp1); + if (!tdif) { // error matches to value + errVal = dcsValE->GetDouble()[0]; + iEntryE++; + break; + } + else if (tdif>0) iEntryE++; // error time lags behind, read the next one + else break; // error time is ahead of value, no error associated + } + (*curValF)[dim-1] = errVal; // error + curValF->SetLastSpecial(); // lable the last entry as an error + } + // + fData.Add(curValF); + refs[kNStor]++; + } + return refs[kNStor]; + // +} + +//___________________________________________________________________ +Int_t AliLHCData::ExtractInt(AliDCSArray* dcsArray,Int_t el) const +{ + // extract integer from the dcsArray + int val = -1; + // + int sz = dcsArray->GetNEntries(); + if (sz<=el) return val; + // + if (dcsArray->GetType()==AliDCSArray::kInt) val = dcsArray->GetInt(el); + else if (dcsArray->GetType()==AliDCSArray::kString) { + TObjString *stro = dcsArray->GetStringArray(el); + if (stro) val = stro->GetString().Atoi(); + else AliError(Form("DCSArray TObjString for element %d is missing",el)); + } + else if (dcsArray->GetType()==AliDCSArray::kUInt) val = dcsArray->GetUInt(el); + else AliError(Form("Integer requested from DCSArray of type %d",dcsArray->GetType())); + return val; +} + +//___________________________________________________________________ +Double_t AliLHCData::ExtractDouble(AliDCSArray* dcsArray,Int_t el) const +{ + // extract double from the dcsArray + double val = 0; + // + int sz = dcsArray->GetNEntries(); + if (sz<=el) return val; + // + if (dcsArray->GetType()==AliDCSArray::kDouble) val = dcsArray->GetDouble(el); + else if (dcsArray->GetType()==AliDCSArray::kFloat) val = dcsArray->GetFloat(el); + else if (dcsArray->GetType()==AliDCSArray::kString) { + TObjString *stro = dcsArray->GetStringArray(el); + if (stro) val = stro->GetString().Atof(); + else AliError(Form("DCSArray has TObjString for element %d is missing",el)); + } + else if (dcsArray->GetType()==AliDCSArray::kChar) val = dcsArray->GetChar(el); + else if (dcsArray->GetType()==AliDCSArray::kInt) val = dcsArray->GetInt(el); + else if (dcsArray->GetType()==AliDCSArray::kUInt) val = dcsArray->GetUInt(el); + else AliError(Form("Double requested from DCSArray of type %d",dcsArray->GetType())); + return val; +} + +//___________________________________________________________________ +TString& AliLHCData::ExtractString(AliDCSArray* dcsArray) const +{ + // extract string from the dcsArray + static TString str; + str = ""; + // + int sz = dcsArray->GetNEntries(); + if (dcsArray->GetType()!=AliDCSArray::kString) { + AliError(Form("String requested from DCSArray of type %d",dcsArray->GetType())); + return str; + } + // + for (int i=0;iGetStringArray(i)->GetString(); + if (i(number of records): for 1st record only\n"); + full = kFALSE; + } + printf("Fill#%6d Validity: %s - %s\n",fFillNumber, + AliLHCDipValI::TimeAsString(fTMin),AliLHCDipValI::TimeAsString(fTMax)); + // + printf("********** SETTINGS FROM RUN CONTROL **********\n"); + // + printf("** Injection Scheme"); + PrintAux(full,fRCInjScheme); + // + printf("** Beta Star"); + PrintAux(full,fRCBeta); + // + printf("** Horisontal Crossing Angle"); + PrintAux(full,fRCAngH); + // + printf("** Vertical Crossing Angle"); + PrintAux(full,fRCAngV); + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d bunch filling scheme [negative: bunch interacting at IR2!]",ib+1); + PrintAux(full,fBunchConfDecl[ib]); + } + // + printf("\n********** MEASURED DATA **********\n"); + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d bunch filling scheme [negative: bunch interacts at IR2!]",ib+1); + PrintAux(full,fBunchConfMeas[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d total intensity",ib+1); + PrintAux(full,fIntensTotal[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d total intensity from bunch average",ib+1); + PrintAux(full,fIntensTotalAv[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d intensity per bunch",ib+1); + PrintAux(full,fIntensPerBunch[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d bunch lengths",ib+1); + PrintAux(full,fBunchLengths[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d H. emittance",ib+1); + PrintAux(full,fEmittanceH[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d V. emittance",ib+1); + PrintAux(full,fEmittanceV[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d H. sigma",ib+1); + PrintAux(full,fBeamSigmaH[ib]); + } + // + for (int ib=0;ib<2;ib++) { + printf("** Beam%d V. sigma",ib+1); + PrintAux(full,fBeamSigmaV[ib]); + } + // + for (int lr=0;lr<2;lr++) { + printf("** Total luminosity from BRANB_4%c2",lr ? 'R':'L'); + PrintAux(full,fLuminTotal[lr]); + } + // + for (int lr=0;lr<2;lr++) { + printf("** Luminosity acquisition mode, BRANB_4%c2",lr ? 'R':'L'); + PrintAux(full,fLuminPerBC[lr]); + } + // + for (int lr=0;lr<2;lr++) { + printf("** Luminosity per Bunch Crossing from BRANB_4%c2",lr ? 'R':'L'); + PrintAux(full,fLuminPerBC[lr]); + } + // + for (int lr=0;lr<2;lr++) { + printf("** Crossing angle, side %c",lr ? 'R':'L'); + PrintAux(full,fCrossAngle[lr]); + } + // + for (int coll=0;collGetSizeTotal(); // dimension of the record + Bool_t isStr = ((AliLHCDipValI*)fData[refs[kStart]])->IsTypeC(); + if ((!isStr && sz>2) || nrec>1) printf("\n"); // long record, open new line + for (int i=0;iPrint(); + // +} + +//___________________________________________________________________ +void AliLHCData::Clear(const Option_t *) +{ + // clear all info + fData.Delete(); + fFillNumber = 0; + fTMin = 0; + fTMax = 1e10; + for (int i=2;i--;) { + fRCInjScheme[i] = 0; + fRCBeta[i] = 0; + fRCAngH[i] = 0; + fRCAngV[i] = 0; + // + for (int icl=kNCollimators;icl--;) for (int jaw=kNJaws;jaw--;) fCollimators[icl][jaw][i]=0; + // + for (int j=2;j--;) { + fBunchConfDecl[j][i] = 0; + fBunchConfMeas[j][i] = 0; + fBunchLengths[j][i] = 0; + fIntensTotal[j][i] = 0; + fIntensTotalAv[j][i] = 0; + fIntensPerBunch[j][i] = 0; + fCrossAngle[j][i] = 0; + fEmittanceH[j][i] = 0; + fEmittanceV[j][i] = 0; + fBeamSigmaH[j][i] = 0; + fBeamSigmaV[j][i] = 0; + fLuminTotal[j][i] = 0; + fLuminPerBC[j][i] = 0; + fLuminAcqMode[j][i] = 0; + } + } +} + +//___________________________________________________________________ +Int_t AliLHCData::GetNInteractingBunchesMeasured(int i) const +{ + // get number of interacting bunches at IR2 + AliLHCDipValI* rec = GetBunchConfigMeasured(kBeam1,i); + if (!rec) {AliInfo(Form("No record %d found",i)); return -1;} + if (!rec->IsProcessed1()) { AliInfo("Interacting bunches were not marked"); return -1;} + int n = 0; + for (int i=rec->GetSize();i--;) if ( (*rec)[i]<0 ) n++; + return n; +} + +//___________________________________________________________________ +Int_t AliLHCData::GetNInteractingBunchesDeclared(int i) const +{ + // get number of interacting bunches at IR2 + AliLHCDipValI* rec = GetBunchConfigMeasured(kBeam1,i); + if (!rec) {AliInfo(Form("No record %d found",i)); return -1;} + if (!rec->IsProcessed1()) { AliInfo("Interacting bunches were not marked"); return -1; } + int n = 0; + for (int i=rec->GetSize();i--;) if ( (*rec)[i]<0 ) n++; + return n; +} + +//___________________________________________________________________ +Int_t AliLHCData::IsPilotPresent(int i) const +{ + // check in the filling scheme is the pilot bunch is present + AliLHCDipValC* rec = GetInjectionScheme(); + if (!rec) {AliInfo(Form("No record %d found",i)); return -1;} + TString scheme = rec->GetValues(); + return scheme.Contains("wp",TString::kIgnoreCase); +} diff --git a/STEER/AliLHCData.h b/STEER/AliLHCData.h index 1269b10d3d2..40a02cac51c 100755 --- a/STEER/AliLHCData.h +++ b/STEER/AliLHCData.h @@ -1,103 +1,304 @@ -#ifndef ALILHCDATA_H -#define ALILHCDATA_H - -///////////////////////////////////////////////////////////////////////////////// -// // -// AliLHCData: summary of the lumnosity related information from LHC DIP. // -// The time dependent values are averaged over the fPeriod (default: 10 min) // -// Created from the TMap provided by the AliLHCReader with optional beginning // -// and end time stamps to account. // -// // -// The data are (wrapped in the AliLHCDipValT): // -// Total beam intensities ( eg GetIntensityTotal(beam) for beam=0,1 // -// Total beam luminosities ( eg GetLuminTotal(side) for side=0,1 (left/right)// -// Bunched intensities and luminosities and crossing angle: // -// GetIntensityBunch(beam),GetLuminBunch(side),GetCrossAngle(side) // -// Bunches configuration: GetBunchConfig(beam) // -// // -// Collimators information (initial position + changes > 100 microns) // -// GetCollimator(collID,jawID) with collID={kTCTVB4L2, kTCTVB4R2, kTCLIA4R2} // -// and jawID={kGapDn,kGapUp,kLeftDn,kLeftUp,kRightDn,kRightUp} // -// // -// Author: ruben.shahoyan@cern.ch // -// // -///////////////////////////////////////////////////////////////////////////////// -#include "TObject.h" -#include "AliLHCDipValT.h" - -class TMap; - -class AliLHCData : public TObject -{ - public: - enum BeamID_t {kBeam1,kBeam2}; - enum Proj_t {kX,kY}; - enum Side_t {kLeft,kRight}; - enum Collim_t {kTCTVB4L2, kTCTVB4R2, kTCLIA4R2, kNCollimators}; - enum ColJaw_t {kGapDn,kGapUp,kLeftDn,kLeftUp,kRightDn,kRightUp,kNJaws}; - enum {kRecTotInt,kRecTotIntBunch,kRecBunchInt,kRecTotLum,kRecBunchLum,kRecCrossAngle,kRecBunchConf,kRecFillNum, - kRecPrfPrID,kRecPrfAmp,kRecPrfPos,kRecPrfSig}; - // - public: - // - AliLHCData() : fPeriod(600),fTMin(0),fTMax(1e20) {} - AliLHCData(const TMap* dcsMap, double tmin=0, double tmax=1.e20,int avPeriod=600); - virtual ~AliLHCData() {} - // - Bool_t FillData(const TMap* dcsMap, double tmin=0, double tmax=1.e20); - // - const TObjArray& GetIntensityTotal(BeamID_t b) const {return fIntTot[b];} - const TObjArray& GetIntensityTotalBunch(BeamID_t b) const {return fIntTotBunch[b];} - const TObjArray& GetIntensityBunch(BeamID_t b) const {return fIntBunch[b];} - const TObjArray& GetBeamPos(BeamID_t b,Proj_t p) const {return fBeamPos[b][p];} - const TObjArray& GetLuminTotal(Side_t s) const {return fLuminTot[s];} - const TObjArray& GetLuminBunch(Side_t s) const {return fLuminBunch[s];} - const TObjArray& GetCrossAngle(Side_t s) const {return fCrossAngle[s];} - const AliLHCDipValI& GetBunchConfig(BeamID_t b) const {return fBunchConfig[b];} - const TObjArray& GetCollimator(Collim_t c,ColJaw_t jaw) const {return fCollimators[c][jaw];} - // - Double_t GetTMin() const {return fTMin;} - Double_t GetTMax() const {return fTMax;} - Int_t GetPeriod() const {return fPeriod;} - Int_t GetNBunches(BeamID_t b) const {return GetBunchConfig(b).GetSize();} - Int_t GetBunchRFBeam1(BeamID_t b,Int_t bunch) const {return GetBunchConfig(b).GetValue(bunch);} - Int_t GetFillNumber() const {return GetUniqueID();} - void SetFillNumber(Int_t fill) {SetUniqueID(fill);} - void SetPeriod(Int_t nsec=600) {fPeriod = nsec;} - void SetTMin(Double_t t) {fTMin = t;} - void SetTMax(Double_t t) {fTMax = t;} - virtual void Print(const Option_t *opt="") const; - // - protected: - TObjArray* GetDCSEntry(const TMap* dcsMap,const char* key,int &entry,double tmin,double tmax) const; - - AliLHCData(const AliLHCData& src) : TObject(src),fPeriod(src.fPeriod),fTMin(src.fTMin),fTMax(src.fTMax) { /*dummy*/ } - AliLHCData& operator=(const AliLHCData& ) { /*dummy*/ return *this;} - - protected: - // - Int_t fPeriod; // averaging period in seconds - Double_t fTMin; // selection timeMin - Double_t fTMax; // selection timeMax - AliLHCDipValI fBunchConfig[2]; // bunches configuration for beam1 and beam2 - // - TObjArray fIntTot[2]; // total intensity (DC BCT) for beam1 and beam2 (AliLHCDipValD) - TObjArray fIntTotBunch[2]; // total intensity (BCTFR) for beam1 and beam2 (AliLHCDipValD) - TObjArray fIntBunch[2]; // bunch by bunch intensity for beam1 and beam2 (AliLHCDipValD) - // - TObjArray fBeamPos[2][2]; // horizontal and vertical projection gaussian fit params for beam1 and beam2 (AliLHCDipValD: amp,pos,sigma) - // - TObjArray fLuminTot[2]; // total luminosity from BRANB_4L2 and BRANB_4R2 (AliLHCDipValD) - TObjArray fLuminBunch[2]; // bunch by bunch luminosity from BRANB_4L2 and BRANB_4R2 (AliLHCDipValD) - TObjArray fCrossAngle[2]; // beams crossing angle from BRANB_4L2 and BRANB_4R2 (AliLHCDipValD) - // - TObjArray fCollimators[kNCollimators][kNJaws];// collimators data (AliLHCDipValD: kGapDn,kGapUp,kLeftDn,kLeftUp,kRightDn,kRightUp) - // - static const Char_t *fgkDCSNames[]; // beam related DCS names to extract - static const Char_t *fgkDCSColNames[]; // collimators to extract - static const Char_t *fgkDCSColJaws[]; // names of collimator pieces - - ClassDef(AliLHCData,2) -}; - -#endif +#ifndef ALILHCDATA_H +#define ALILHCDATA_H + +/******************************************************************************** +* * +* AliLHCData: summary of the LHC related information from LHC DIP. * +* Created from the TMap provided by the AliLHCReader with optional beginning * +* * +* The data are (wrapped in the AliLHCDipValT): * +* made of TimeStamp (double) and array of values * +* * +* Multiple entries for each type of data are possible. To obtaine number of * +* records (with distinct timestamp) for give type od records use: * +* int GetNBunchConfigMeasured(int beam) (with beam=0,1) etc. * +* * +* To get i-th entry, use brec= AliLHCDipValI* GetBunchConfigMeasured(bm,i); * +* Note: exact type of templated AliLHCDipValT pointer depends on the record * +* type, concult getters to know it. * +* * +* Then, once the pointer is obtained, details can be accessed: * +* int nBunches = brec->GetSize(); * +* for (int i=0;i1e10?1e10:t);} + void SetTMax(Double_t t) {fTMax = t<0?0:(t>1e10?1e10:t);} + virtual void Print(const Option_t *opt="") const; + virtual void Clear(const Option_t *opt=""); + // + Int_t GetNBunchConfigMeasured(int bm) const {return GoodPairID(bm)?fBunchConfMeas[bm][kNStor]:-1;} + Int_t GetNBunchConfigDeclared(int bm) const {return GoodPairID(bm)?fBunchConfDecl[bm][kNStor]:-1;} + Int_t GetNBunchLengths(int bm) const {return GoodPairID(bm)?fBunchLengths[bm][kNStor]:-1;} + Int_t GetNTotalIntensity(int bm) const {return GoodPairID(bm)?fIntensTotal[bm][kNStor]:-1;} + Int_t GetNTotalIntensityAv(int bm) const {return GoodPairID(bm)?fIntensTotalAv[bm][kNStor]:-1;} + Int_t GetNIntensityPerBunch(int bm) const {return GoodPairID(bm)?fIntensPerBunch[bm][kNStor]:-1;} + Int_t GetNEmittanceH(int bm) const {return GoodPairID(bm)?fEmittanceH[bm][kNStor]:-1;} + Int_t GetNEmittanceV(int bm) const {return GoodPairID(bm)?fEmittanceV[bm][kNStor]:-1;} + Int_t GetNBeamSigmaH(int bm) const {return GoodPairID(bm)?fBeamSigmaH[bm][kNStor]:-1;} + Int_t GetNBeamSigmaV(int bm) const {return GoodPairID(bm)?fBeamSigmaV[bm][kNStor]:-1;} + // + Int_t GetNLuminosityTotal(int lr) const {return GoodPairID(lr)?fLuminTotal[lr][kNStor]:-1;} + Int_t GetNLuminosityPerBunch(int lr) const {return GoodPairID(lr)?fLuminPerBC[lr][kNStor]:-1;} + Int_t GetNLuminosityAcqMode(int lr) const {return GoodPairID(lr)?fLuminAcqMode[lr][kNStor]:-1;} + Int_t GetNCrossingAngle(int lr) const {return GoodPairID(lr)?fCrossAngle[lr][kNStor]:-1;} + // + Int_t GetNInjectionScheme() const {return fRCInjScheme[kNStor];} + Int_t GetNRCBetaStar() const {return fRCBeta[kNStor];} + Int_t GetNRCAngleH() const {return fRCAngH[kNStor];} + Int_t GetNRCAngleV() const {return fRCAngV[kNStor];} + // + Int_t GetNCollimatorJawPos(int coll,int jaw) const; + // + AliLHCDipValI* GetBunchConfigMeasured(int bm, int i=0) const; + AliLHCDipValF* GetBunchLengths(int bm, int i=0) const; + AliLHCDipValI* GetBunchConfigDeclared(int bm, int i=0) const; + AliLHCDipValF* GetTotalIntensity(int bm, int i=0) const; + AliLHCDipValF* GetTotalIntensityAv(int bm, int i=0) const; + AliLHCDipValF* GetIntensityPerBunch(int bm, int i=0) const; + AliLHCDipValF* GetEmittanceH(int bm, int i=0) const; + AliLHCDipValF* GetEmittanceV(int bm, int i=0) const; + AliLHCDipValF* GetBeamSigmaH(int bm, int i=0) const; + AliLHCDipValF* GetBeamSigmaV(int bm, int i=0) const; + AliLHCDipValF* GetLuminosityTotal(int lr, int i=0) const; + AliLHCDipValF* GetLuminosityPerBunch(int lr, int i=0) const; + AliLHCDipValI* GetLuminosityAcqMode(int lr, int i=0) const; + AliLHCDipValF* GetCrossAngle(int lr, int i=0) const; + AliLHCDipValC* GetInjectionScheme(int i=0) const; + AliLHCDipValF* GetRCBetaStar(int i=0) const; + AliLHCDipValF* GetRCAngleH(int i=0) const; + AliLHCDipValF* GetRCAngleV(int i=0) const; + AliLHCDipValF* GetCollimJawPos(int coll, int jaw, int i=0) const; + // + TObject* FindRecValidFor(int start,int nrec, double tstamp) const; + AliLHCDipValI* GetBunchConfigMeasured(int beam,double tstamp) const; + AliLHCDipValI* GetBunchConfigDeclared(int beam,double tstamp) const; + Int_t GetNInteractingBunchesMeasured(int i=0) const; + Int_t GetNInteractingBunchesDeclared(int i=0) const; + Int_t IsPilotPresent(int i=0) const; + // + // return array with beginning [0] and number of records for corresponding info (in the fData) + const Int_t* GetOffsBunchConfigMeasured(int bm) const {return GoodPairID(bm)?fBunchConfMeas[bm]:0;} + const Int_t* GetOffsBunchConfigDeclared(int bm) const {return GoodPairID(bm)?fBunchConfDecl[bm]:0;} + const Int_t* GetOffsBunchLengths(int bm) const {return GoodPairID(bm)?fBunchLengths[bm]:0;} + const Int_t* GetOffsTotalIntensity(int bm) const {return GoodPairID(bm)?fIntensTotal[bm]:0;} + const Int_t* GetOffsTotalIntensityAv(int bm) const {return GoodPairID(bm)?fIntensTotalAv[bm]:0;} + const Int_t* GetOffsIntensityPerBunch(int bm) const {return GoodPairID(bm)?fIntensPerBunch[bm]:0;} + const Int_t* GetOffsEmittanceH(int bm) const {return GoodPairID(bm)?fEmittanceH[bm]:0;} + const Int_t* GetOffsEmittanceV(int bm) const {return GoodPairID(bm)?fEmittanceV[bm]:0;} + const Int_t* GetOffsBeamSigmaH(int bm) const {return GoodPairID(bm)?fBeamSigmaH[bm]:0;} + const Int_t* GetOffsBeamSigmaV(int bm) const {return GoodPairID(bm)?fBeamSigmaV[bm]:0;} + // + const Int_t* GetOffsLuminosityTotal(int lr) const {return GoodPairID(lr)?fLuminTotal[lr]:0;} + const Int_t* GetOffsLuminosityPerBunch(int lr) const {return GoodPairID(lr)?fLuminPerBC[lr]:0;} + const Int_t* GetOffsLuminosityAcqMode(int lr) const {return GoodPairID(lr)?fLuminAcqMode[lr]:0;} + const Int_t* GetOffsCrossingAngle(int lr) const {return GoodPairID(lr)?fCrossAngle[lr]:0;} + // + const Int_t* GetOffsInjectionScheme() const {return fRCInjScheme;} + const Int_t* GetOffsRCBetaStar() const {return fRCBeta;} + const Int_t* GetOffsRCAngleH() const {return fRCAngH;} + const Int_t* GetOffsRCAngleV() const {return fRCAngV;} + // + const Int_t* GetOffsCollimatorJawPos(int coll,int jaw) const; + // + const TObjArray& GetData() const {return fData;} + // + protected: + // + void PrintAux(Bool_t full,const Int_t refs[2]) const; + TObjArray* GetDCSEntry(const TMap* dcsMap,const char* key,int &entry,double tmin,double tmax) const; + Int_t FillScalarRecord( const TMap* dcsMap, int refs[2], const char* rec, const char* recErr=0); + Int_t FillBunchConfig( const TMap* dcsMap, int refs[2], const char* rec); + Int_t FillStringRecord( const TMap* dcsMap, int refs[2], const char* rec); + Int_t FillAcqMode( const TMap* dcsMap, int refs[2], const char* rec); + Int_t FillBunchInfo( const TMap* dcsMap, int refs[2], const char* rec,int ibm, Bool_t inRealSlots); + Int_t FillBCLuminosities(const TMap* dcsMap, int refs[2], const char* rec, const char* recErr, Bool_t opt); + // + Int_t ExtractInt(AliDCSArray* dcsArray,Int_t el) const; + Double_t ExtractDouble(AliDCSArray* dcsArray,Int_t el) const; + TString& ExtractString(AliDCSArray* dcsArray) const; + AliLHCData(const AliLHCData& src) : TObject(src),fTMin(0),fTMax(0),fFillNumber(0),fData(0) { /*dummy*/ } + AliLHCData& operator=(const AliLHCData& ) { /*dummy*/ return *this;} + Int_t TimeDifference(double v1,double v2,double tol=0.9) const; + Bool_t IzZero(double val, double tol=1e-16) const {return TMath::Abs(val)=0&&coll=0&&jaw=0&&coll=0&&jaw=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && i=0 && coll=0 && jaw=0 && i #include #include -#include "AliDCSArray.h" #include "AliLog.h" @@ -24,12 +23,17 @@ template class AliLHCDipValT : public TObject { public: // - AliLHCDipValT(Int_t size=0, Double_t t=0,Int_t nv=1); - AliLHCDipValT(AliLHCDipValT &src); + enum { + kLastSpecial=BIT(14), // last element of array is special (e.g. assigned error etc) + kProcessed1 =BIT(15), // last element of array is special (e.g. assigned error etc) + kChar=BIT(22), + kFloat=BIT(23) + }; + // + AliLHCDipValT(Int_t size=0, Double_t t=0); + AliLHCDipValT(const AliLHCDipValT &src); virtual ~AliLHCDipValT() {delete[] fArray;} AliLHCDipValT& operator=(const AliLHCDipValT &src); - AliLHCDipValT& operator+=(const AliLHCDipValT &src); - AliLHCDipValT& operator+=(const AliDCSArray &src); Element& operator[](Int_t i); Element operator[](Int_t i) const; // @@ -37,16 +41,22 @@ template class AliLHCDipValT : public TObject void SetValue(Int_t i,Element v); void SetValues(const Element *v, Int_t n); void SetTimeStamp(Double_t v) {fTimeStamp = v;} - void SetNSamplesUsed(Int_t n) {SetUniqueID((UInt_t)n);} // - Int_t GetSize() const {return fSize;} + Int_t GetSizeTotal() const {return GetUniqueID();} Element GetValue(Int_t i=0) const; Element* GetValues() const {return (Element*)fArray;} Double_t GetTimeStamp() const {return fTimeStamp;} - Int_t GetNSamplesUsed() const {return GetUniqueID();} Char_t* GetTimeAsString() const {return TimeAsString(fTimeStamp);} // - virtual void Average(const Option_t *opt=""); + void SetProcessed1(Bool_t v=kTRUE) {SetBit(kProcessed1,v);} + void SetLastSpecial(Bool_t v=kTRUE) {SetBit(kLastSpecial,v);} + Bool_t IsProcessed1() const {return TestBit(kProcessed1);} + Bool_t IsLastSpecial() const {return TestBit(kLastSpecial);} + Int_t GetSize() const {return IsLastSpecial() ? GetSizeTotal()-1:GetSizeTotal();} + Bool_t IsTypeC() const {return TestBit(kChar);} + Bool_t IsTypeF() const {return TestBit(kFloat);} + Bool_t IsTypeI() const {return !TestBit(kFloat|kChar);} + // virtual void Clear(const Option_t *opt=""); virtual void Print(const Option_t *opt="") const; // @@ -55,8 +65,7 @@ template class AliLHCDipValT : public TObject protected: // Double_t fTimeStamp; // timestamp of the entry - Int_t fSize; - Element* fArray; //[fSize] array of entries + Element* fArray; //[fUniqueID] array of entries // ClassDef(AliLHCDipValT,1) }; @@ -64,22 +73,26 @@ template class AliLHCDipValT : public TObject //__________________________________________________________________________ template -AliLHCDipValT::AliLHCDipValT(Int_t size,Double_t t,Int_t nv) -: fTimeStamp(t),fSize(0),fArray(0) +AliLHCDipValT::AliLHCDipValT(Int_t size,Double_t t) +: fTimeStamp(t),fArray(0) { //def. constructor - SetNSamplesUsed(nv); SetSize(size); + if (!strcmp(typeid(fArray).name(),typeid(Char_t*).name())) SetBit(kChar); + else if (!strcmp(typeid(fArray).name(),typeid(Double_t*).name()) || + !strcmp(typeid(fArray).name(),typeid(Float_t*).name() )) SetBit(kFloat); + // } //__________________________________________________________________________ template -AliLHCDipValT::AliLHCDipValT(AliLHCDipValT &src) -: TObject(src),fTimeStamp(src.fTimeStamp),fSize(0),fArray(0) +AliLHCDipValT::AliLHCDipValT(const AliLHCDipValT &src) +: TObject(src),fTimeStamp(src.fTimeStamp),fArray(0) { //copy constructor - SetSize(src.fSize); - memcpy(fArray,src.fArray,fSize*sizeof(Element)); + SetUniqueID(0); + SetSize(src.GetSizeTotal()); + memcpy(fArray,src.fArray,GetSizeTotal()*sizeof(Element)); } //__________________________________________________________________________ @@ -89,83 +102,14 @@ AliLHCDipValT& AliLHCDipValT::operator=(const AliLHCDipValToperator=(src); + SetUniqueID(0); + if (GetSizeTotal()!=src.GetSizeTotal()) SetSize(src.GetSizeTotal()); SetTimeStamp(src.GetTimeStamp()); - if (fSize!=src.fSize) SetSize(src.fSize); - memcpy(fArray,src.fArray,fSize*sizeof(Element)); + memcpy(fArray,src.fArray,GetSizeTotal()*sizeof(Element)); } return *this; } -//__________________________________________________________________________ -template -AliLHCDipValT& AliLHCDipValT::operator+=(const AliLHCDipValT &src) -{ - //addition - TString tp = typeid(fArray).name(); - if (tp == typeid(Char_t*).name()) { - if (fSize<1 && src.fSize>0) *this=src; // for strings reassign only if this is empty - } - else if (fSize!=src.fSize) { - AliError(Form("Sizes of arrays to add must be the same (%d vs %d)",fSize,src.fSize)); - return *this; - } - else { - double wtime0 = fTimeStamp*GetNSamplesUsed(); - double wtime1 = src.fTimeStamp*src.GetNSamplesUsed(); - int wtot = GetNSamplesUsed() + src.GetNSamplesUsed(); - SetNSamplesUsed(wtot); - if (wtot>0) SetTimeStamp( (wtime0 + wtime1)/wtot ); - for (int i=fSize;i--;) fArray[i] += src.fArray[i]; - } - return *this; -} - -//__________________________________________________________________________ -template -AliLHCDipValT& AliLHCDipValT::operator+=(const AliDCSArray &src) -{ - //addition - TString tp = typeid(fArray).name(); - int isstr = (tp==typeid(Char_t*).name()) + (src.GetType()==AliDCSArray::kString); - if ( isstr == 1) { - AliError("Only one of the sides is of the string type"); - return *this; - } - else if (isstr == 2) { // both are string type - if (fSize<1 && src.GetNEntries()>0) { - TString str; - for (int i=0;iGetName(); - str += " "; - } - SetSize(str.Length()+1); - memcpy(fArray,str.Data(),fSize*sizeof(char)); - } - } else { - if (fSize>src.GetNEntries()) { - AliError(Form("Size of RHS (%d) is smaller than size of LHS (%d)",src.GetNEntries(),fSize)); - return *this; - } - for (int i=fSize;i--;) { - Element &val = fArray[i]; - if (src.GetType() == AliDCSArray::kDouble) val += src.GetDouble()[i]; - else if (src.GetType() == AliDCSArray::kFloat) val += src.GetFloat()[i]; - else if (src.GetType() == AliDCSArray::kInt) val += src.GetInt()[i]; - else if (src.GetType() == AliDCSArray::kUInt) val += src.GetUInt()[i]; - else if (src.GetType() == AliDCSArray::kChar) val += src.GetChar()[i]; - else if (src.GetType() == AliDCSArray::kBool) val += src.GetBool()[i]; - } - } - // - double wtime0 = fTimeStamp*GetNSamplesUsed(); - double wtime1 = src.GetTimeStamp(); - int wtot = GetNSamplesUsed() + 1; - SetNSamplesUsed(wtot); - if (wtot>0) SetTimeStamp( (wtime0 + wtime1)/wtot ); - // - return *this; -} - //__________________________________________________________________________ template Char_t* AliLHCDipValT::TimeAsString(double t) @@ -181,8 +125,8 @@ template void AliLHCDipValT::SetValue(Int_t i,Element v) { //assign value - if (i>=fSize || i<0) { - AliError(Form("Index %d is out of range 0:%d",i,fSize-1)); + if (i>=GetSizeTotal() || i<0) { + AliError(Form("Index %d is out of range 0:%d",i,GetSizeTotal()-1)); return; } fArray[i] = v; @@ -193,7 +137,7 @@ template void AliLHCDipValT::SetValues(const Element* v, Int_t n) { //assign value - if (n!=fSize) SetSize(n); + if (n!=GetSizeTotal()) SetSize(n); memcpy(fArray,v,n*sizeof(Element)); } @@ -202,8 +146,8 @@ template Element& AliLHCDipValT::operator[](Int_t i) { //obtain value refeterence - if (i>=fSize || i<0) { - AliError(Form("Index %d is out of range 0:%d",i,fSize-1)); + if (i>=GetSizeTotal() || i<0) { + AliError(Form("Index %d is out of range 0:%d",i,GetSizeTotal()-1)); return fArray[0]; } return fArray[i]; @@ -214,8 +158,8 @@ template Element AliLHCDipValT::operator[](Int_t i) const { //obtain value - if (i>=fSize || i<0) { - AliError(Form("Index %d is out of range 0:%d",i,fSize-1)); + if (i>=GetSizeTotal() || i<0) { + AliError(Form("Index %d is out of range 0:%d",i,GetSizeTotal()-1)); return 0; } return fArray[i]; @@ -226,8 +170,8 @@ template Element AliLHCDipValT::GetValue(Int_t i) const { //obtain value - if (i>=fSize || i<0) { - AliError(Form("Index %d is out of range 0:%d",i,fSize-1)); + if (i>=GetSizeTotal() || i<0) { + AliError(Form("Index %d is out of range 0:%d",i,GetSizeTotal()-1)); return 0; } return fArray[i]; @@ -241,16 +185,16 @@ void AliLHCDipValT::SetSize(Int_t sz) Element* arr = 0; if (sz>0) { arr = new Element[sz]; - int nc = fSize > sz ? sz:fSize; // n elems to copy + int nc = GetSizeTotal() > sz ? sz:GetSizeTotal(); // n elems to copy if (nc) memcpy(arr, fArray, nc*sizeof(Element)); if (nc::Print(const Option_t *opt) const // print time and value TString str = opt; str.ToLower(); - printf("Timestamp: "); - if (str.Contains("raw")) printf("%f",GetTimeStamp()); - else printf("%s",GetTimeAsString()); - printf(" | samples %6d | Value: ",GetNSamplesUsed()); + if (str.Contains("raw")) printf("%.1f ",GetTimeStamp()); + else printf("[%s] ",GetTimeAsString()); // TString tp = typeid(fArray).name(); - if ( tp==typeid(Char_t*).name() ) printf(" => %s\n",(Char_t*)fArray); + if ( tp==typeid(Char_t*).name() ) printf(": %s\n",(Char_t*)fArray); else { - if (fSize>1) printf("\n"); - for (int i=0;i1) printf("\n"); + Bool_t eolOK = kFALSE; + for (int i=0;i1 && !eolOK) {printf("\n"); eolOK = kTRUE;} + if (tp == typeid(Double_t*).name() || tp == typeid(Float_t*).name()) { + printf(" Error: %+e\n",(Float_t)fArray[sz]); + eolOK = kTRUE; + } } - if (fSize%5) printf("\n"); + if (!eolOK) printf("\n"); } // } @@ -286,19 +238,8 @@ template void AliLHCDipValT::Clear(const Option_t *) { // reset to 0 everything - SetNSamplesUsed(0); SetTimeStamp(0); - memset(fArray,0,fSize*sizeof(Element)); -} - -//__________________________________________________________________________ -template -void AliLHCDipValT::Average(const Option_t *) -{ - // average of samples - int n = GetNSamplesUsed(); - if (n>0) for (int i=fSize;i--;) fArray[i] /= n; - // + memset(fArray,0,GetSizeTotal()*sizeof(Element)); }