#include <fstream>
#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
#include "AliEMCALBiasAPD.h"
}
//____________________________________________________________________________
-void AliEMCALBiasAPD::ReadBiasAPDInfo(Int_t nSM, const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALBiasAPD::ReadTextBiasAPDInfo(Int_t nSM, const TString &txtFileName,
+ Bool_t swapSides)
{
//Read data from txt file. ; coordinates given on SuperModule basis
}
//____________________________________________________________________________
-void AliEMCALBiasAPD::WriteBiasAPDInfo(const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALBiasAPD::WriteTextBiasAPDInfo(const TString &txtFileName,
+ Bool_t swapSides)
{
// write data to txt file. ; coordinates given on SuperModule basis
return;
}
+//____________________________________________________________________________
+void AliEMCALBiasAPD::ReadRootBiasAPDInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ //Read data from root file. ; coordinates given on SuperModule basis
+ TFile inputFile(rootFileName, "read");
+
+ TTree *tree = (TTree*) inputFile.Get("tree");
+
+ ReadTreeBiasAPDInfo(tree, swapSides);
+
+ inputFile.Close();
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALBiasAPD::ReadTreeBiasAPDInfo(TTree *tree,
+ Bool_t swapSides)
+{
+ // how many SuperModule's worth of entries / APDs do we have?
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+ fNSuperModule = tree->GetEntries() / nAPDPerSM;
+
+ if (fSuperModuleData) delete [] fSuperModuleData;
+ fSuperModuleData = new AliEMCALSuperModuleBiasAPD[fNSuperModule];
+
+ Int_t iSM = 0; // SuperModule index
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+ // list of values to be read
+ Int_t iElecId = 0;
+ Int_t iDAC = 0;
+ Float_t voltage = 0;
+ // end - all values
+
+ // declare the branches
+ tree->SetBranchAddress("iSM", &iSM);
+ tree->SetBranchAddress("iCol", &iCol);
+ tree->SetBranchAddress("iRow", &iRow);
+ tree->SetBranchAddress("iElecId", &iElecId);
+ tree->SetBranchAddress("iDAC", &iDAC);
+ tree->SetBranchAddress("voltage", &voltage);
+
+ for (int ient=0; ient<tree->GetEntries(); ient++) {
+ tree->GetEntry(ient);
+
+ // assume the index SuperModules come in order: i=iSM
+ AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[iSM];
+ t.fSuperModuleNum = iSM;
+
+ // assume that this info is already swapped and done for this basis?
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+ t.fElecId[iCol][iRow] = iElecId;
+ t.fDAC[iCol][iRow] = iDAC;
+ t.fVoltage[iCol][iRow] = voltage;
+
+ } //
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALBiasAPD::WriteRootBiasAPDInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ // write data to root file. ; coordinates given on SuperModule basis
+ TFile destFile(rootFileName, "recreate");
+ if (destFile.IsZombie()) {
+ return;
+ }
+ destFile.cd();
+
+ TTree *tree = new TTree("tree","");
+
+ // variables for filling the TTree
+ Int_t iSM = 0; // SuperModule index
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+ Int_t iElecId = 0;
+ Int_t iDAC = 0;
+ Float_t voltage = 0;
+ // declare the branches
+ tree->Branch("iSM", &iSM, "iSM/I");
+ tree->Branch("iCol", &iCol, "iCol/I");
+ tree->Branch("iRow", &iRow, "iRow/I");
+ tree->Branch("iElecId", &iElecId, "iElecId/I");
+ tree->Branch("iDAC", &iDAC, "iDAC/I");
+ tree->Branch("voltage", &voltage, "voltage/F");
+
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+
+ for (iSM = 0; iSM < fNSuperModule; iSM++) {
+ AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[iSM];
+
+ for (Int_t j=0; j<nAPDPerSM; j++) {
+ iCol = j / AliEMCALGeoParams::fgkEMCALRows;
+ iRow = j % AliEMCALGeoParams::fgkEMCALRows;
+
+ iElecId = t.fElecId[iCol][iRow];
+ iDAC = t.fDAC[iCol][iRow];
+ voltage = t.fVoltage[iCol][iRow];
+
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+ tree->Fill();
+ }
+
+ } // i, SuperModule
+
+ tree->Write();
+ destFile.Close();
+
+ return;
+}
+
//____________________________________________________________________________
AliEMCALBiasAPD::~AliEMCALBiasAPD()
{
}
//____________________________________________________________________________
-AliEMCALBiasAPD::AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDId(Int_t supModIndex)const
+AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDId(Int_t supModIndex)const
{
AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
}
//____________________________________________________________________________
-AliEMCALBiasAPD::AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDNum(Int_t supModIndex)const
+AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDNum(Int_t supModIndex)const
{
AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
#include <TObject.h>
#include "AliEMCALGeoParams.h"
class TString;
+class TTree;
/*
- Objects of this class read txt file with APD data
- AliEMCALBiasAPD inherits TObject only to use AliLog "functions".
+ Objects of this class contain info on APD bias settings/voltages
*/
+// ******* internal class definition *************
+// 1 SuperModule's worth of info
+class AliEMCALSuperModuleBiasAPD : public TObject {
+ public:
+ AliEMCALSuperModuleBiasAPD() : TObject(), // just init values
+ fSuperModuleNum(0)
+ {
+ for (int icol=0; icol<AliEMCALGeoParams::fgkEMCALCols; icol++) {
+ for (int irow=0; irow<AliEMCALGeoParams::fgkEMCALRows; irow++) {
+ fElecId[icol][irow] = 0;
+ fDAC[icol][irow] = 0;
+ fVoltage[icol][irow] = 0;
+ }
+ }
+ }
+
+ public:
+ Int_t fSuperModuleNum; // SM index
+ Int_t fElecId[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // ElectronicsIndex/Address - we keep this to help ensure that the column/row info matches with electronics indices
+ Int_t fDAC[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // 0-0x3ff register
+ Float_t fVoltage[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // 210 to ca 417 V. (function of DAC setting)
+
+ ClassDef(AliEMCALSuperModuleBiasAPD, 1) // help class
+};
+// ******* end of internal class definition *************
+
class AliEMCALBiasAPD : public TObject {
public:
AliEMCALBiasAPD();
// Read and Write txt I/O methods are normally not used, but are useful for
// filling the object before it is saved in OCDB
- void ReadBiasAPDInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
-
- void WriteBiasAPDInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadTextBiasAPDInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteTextBiasAPDInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadRootBiasAPDInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadTreeBiasAPDInfo(TTree *tree, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteRootBiasAPDInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
virtual ~AliEMCALBiasAPD();
- struct AliEMCALSuperModuleBiasAPD {
- Int_t fSuperModuleNum;
- Int_t fElecId[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // ElectronicsIndex/Address - we keep this to help ensure that the column/row info matches with electronics indices
- Int_t fDAC[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // 0-0x3ff register
- Float_t fVoltage[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // 210 to ca 417 V. (function of DAC setting)
- };
-
// pointer to stored info.
Int_t GetNSuperModule() const { return fNSuperModule; };
AliEMCALSuperModuleBiasAPD * GetSuperModuleData() const { return fSuperModuleData; };
AliEMCALBiasAPD(const AliEMCALBiasAPD &);
AliEMCALBiasAPD &operator = (const AliEMCALBiasAPD &);
- ClassDef(AliEMCALBiasAPD, 1) //BiasAPD data reader
+ ClassDef(AliEMCALBiasAPD, 2) //BiasAPD data reader
};
#endif
#include <fstream>
#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
#include "AliEMCALCalibAbs.h"
}
//____________________________________________________________________________
-void AliEMCALCalibAbs::ReadCalibAbsInfo(Int_t nSM, const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALCalibAbs::ReadTextCalibAbsInfo(Int_t nSM, const TString &txtFileName,
+ Bool_t swapSides)
{
//Read data from txt file. ; coordinates given on SuperModule basis
}
//____________________________________________________________________________
-void AliEMCALCalibAbs::WriteCalibAbsInfo(const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALCalibAbs::WriteTextCalibAbsInfo(const TString &txtFileName,
+ Bool_t swapSides)
{
// write data to txt file. ; coordinates given on SuperModule basis
outputFile << j << " " << t.fTemperature[j] << " " << t.fTemperatureRMS[j] << endl;
}
+ // third: info for each tower
for (Int_t j=0; j<nAPDPerSM; j++) {
iCol = j / AliEMCALGeoParams::fgkEMCALRows;
iRow = j % AliEMCALGeoParams::fgkEMCALRows;
return;
}
+//____________________________________________________________________________
+void AliEMCALCalibAbs::ReadRootCalibAbsInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ //Read data from root file. ; coordinates given on SuperModule basis
+ TFile inputFile(rootFileName, "read");
+
+ TTree *tree = (TTree*) inputFile.Get("tree");
+
+ ReadTreeCalibAbsInfo(tree, swapSides);
+
+ inputFile.Close();
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALCalibAbs::ReadTreeCalibAbsInfo(TTree *tree,
+ Bool_t swapSides)
+{
+ // how many SuperModule's worth of entries / APDs do we have?
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+ fNSuperModule = tree->GetEntries() / nAPDPerSM;
+
+ if (fSuperModuleData) delete [] fSuperModuleData;
+ fSuperModuleData = new AliEMCALSuperModuleCalibAbs[fNSuperModule];
+
+ Int_t iSM = 0; // SuperModule index
+ // list of values to be read
+ // first: overall values for the whole SuperModule
+ Int_t CalibMethod;
+ Int_t CalibPass= {0};
+ Int_t CalibTime= {0};
+ Float_t AbsoluteGain= {0};
+ // second: additional info for LED Reference and SM temperature
+ Float_t LEDRefAmp[AliEMCALGeoParams::fgkEMCALLEDRefs]= {0};
+ Float_t LEDRefAmpRMS[AliEMCALGeoParams::fgkEMCALLEDRefs]= {0};
+ Float_t LEDRefHighLowRatio[AliEMCALGeoParams::fgkEMCALLEDRefs]= {0};
+ Int_t LEDRefHighLow[AliEMCALGeoParams::fgkEMCALLEDRefs]= {0};
+ Float_t Temperature[AliEMCALGeoParams::fgkEMCALTempSensors]= {0};
+ Float_t TemperatureRMS[AliEMCALGeoParams::fgkEMCALTempSensors]= {0};
+ // third: info for each tower
+ Float_t RelativeGain[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Float_t HighLowRatio[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Int_t HighLow[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Float_t LEDAmp[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Float_t LEDAmpRMS[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ // end - all values
+
+ // just to make the initializations of the arrays are done correctly, let's use memset
+ memset(LEDRefAmp, 0, sizeof(LEDRefAmp));
+ memset(LEDRefAmpRMS, 0, sizeof(LEDRefAmpRMS));
+ memset(LEDRefHighLowRatio, 0, sizeof(LEDRefHighLowRatio));
+ memset(LEDRefHighLow, 0, sizeof(LEDRefHighLow));
+ memset(Temperature, 0, sizeof(Temperature));
+ memset(TemperatureRMS, 0, sizeof(TemperatureRMS));
+ memset(RelativeGain, 0, sizeof(RelativeGain));
+ memset(HighLowRatio, 0, sizeof(HighLowRatio));
+ memset(HighLow, 0, sizeof(HighLow));
+ memset(LEDAmp, 0, sizeof(LEDAmp));
+ memset(LEDAmpRMS, 0, sizeof(LEDAmpRMS));
+
+ // declare the branches
+ tree->SetBranchAddress("iSM", &iSM);
+ tree->SetBranchAddress("CalibMethod", &CalibMethod);
+ tree->SetBranchAddress("CalibPass", &CalibPass);
+ tree->SetBranchAddress("CalibTime", &CalibTime);
+ tree->SetBranchAddress("AbsoluteGain", &AbsoluteGain);
+ //
+ tree->SetBranchAddress("LEDRefAmp", LEDRefAmp);
+ tree->SetBranchAddress("LEDRefAmpRMS", LEDRefAmpRMS);
+ tree->SetBranchAddress("LEDRefHighLowRatio", LEDRefHighLowRatio);
+ tree->SetBranchAddress("LEDRefHighLow", LEDRefHighLow);
+ tree->SetBranchAddress("Temperature", Temperature);
+ tree->SetBranchAddress("TemperatureRMS", TemperatureRMS);
+ //
+ tree->SetBranchAddress("RelativeGain", RelativeGain);
+ tree->SetBranchAddress("HighLowRatio", HighLowRatio);
+ tree->SetBranchAddress("HighLow", HighLow);
+ tree->SetBranchAddress("LEDAmp", LEDAmp);
+ tree->SetBranchAddress("LEDAmpRMS", LEDAmpRMS);
+
+ // indices for looping over the towers
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+
+ for (int ient=0; ient<tree->GetEntries(); ient++) {
+ tree->GetEntry(ient);
+
+ // assume the index SuperModules come in order: i=iSM
+ AliEMCALSuperModuleCalibAbs &t = fSuperModuleData[iSM];
+ t.fSuperModuleNum = iSM;
+ // first, overall values
+ t.fCalibMethod = CalibMethod;
+ t.fCalibPass = CalibPass;
+ t.fCalibTime = CalibTime;
+ t.fAbsoluteGain = AbsoluteGain;
+
+ // second: additional info for LED references and SM temperatures
+ for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALLEDRefs; j++) {
+ t.fLEDRefAmp[j] = LEDRefAmp[j];
+ t.fLEDRefAmpRMS[j] = LEDRefAmpRMS[j];
+ t.fLEDRefHighLowRatio[j] = LEDRefHighLowRatio[j];
+ t.fLEDRefHighLow[j] = LEDRefHighLow[j];
+ }
+ for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALTempSensors; j++) {
+ t.fTemperature[j] = Temperature[j];
+ t.fTemperatureRMS[j] = TemperatureRMS[j];
+ }
+
+ // third: info for each tower
+ for (Int_t j=0; j<nAPDPerSM; j++) {
+ iCol = j / AliEMCALGeoParams::fgkEMCALRows;
+ iRow = j % AliEMCALGeoParams::fgkEMCALRows;
+
+ // help variables: possibly modified or swapped indices
+ int iColMod = iCol;
+ int iRowMod = iRow;
+ // assume that this info is already swapped and done for this basis?
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iColMod = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRowMod = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+ AliEMCALCalibAbsVal &v = t.fAPDVal[iColMod][iRowMod];
+
+ v.fRelativeGain = RelativeGain[iCol][iRow];
+ v.fHighLowRatio = HighLowRatio[iCol][iRow];
+ v.fHighLow = HighLow[iCol][iRow];
+ v.fLEDAmp = LEDAmp[iCol][iRow];
+ v.fLEDAmpRMS = LEDAmpRMS[iCol][iRow];
+ }
+
+ } // loop over entries
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALCalibAbs::WriteRootCalibAbsInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ // write data to root file. ; coordinates given on SuperModule basis
+ TFile destFile(rootFileName, "recreate");
+ if (destFile.IsZombie()) {
+ return;
+ }
+ destFile.cd();
+
+ TTree *tree = new TTree("tree","");
+
+ // variables for filling the TTree
+ Int_t iSM = 0; // SuperModule index
+ // list of values to be written
+ // first: overall values for the whole SuperModule
+ Int_t CalibMethod = 0;
+ Int_t CalibPass = 0;
+ Int_t CalibTime = 0;
+ Float_t AbsoluteGain = 0;
+ // second: additional info for LED Reference and SM temperature
+ Float_t LEDRefAmp[AliEMCALGeoParams::fgkEMCALLEDRefs] = {0};
+ Float_t LEDRefAmpRMS[AliEMCALGeoParams::fgkEMCALLEDRefs]= {0};
+ Float_t LEDRefHighLowRatio[AliEMCALGeoParams::fgkEMCALLEDRefs]= {0};
+ Int_t LEDRefHighLow[AliEMCALGeoParams::fgkEMCALLEDRefs]= {0};
+ Float_t Temperature[AliEMCALGeoParams::fgkEMCALTempSensors]= {0};
+ Float_t TemperatureRMS[AliEMCALGeoParams::fgkEMCALTempSensors]= {0};
+ // third: info for each tower
+ Float_t RelativeGain[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Float_t HighLowRatio[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Int_t HighLow[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Float_t LEDAmp[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ Float_t LEDAmpRMS[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]= {0};
+ // end - all values
+
+ // just to make the initializations of the arrays are done correctly, let's use memset
+ memset(LEDRefAmp, 0, sizeof(LEDRefAmp));
+ memset(LEDRefAmpRMS, 0, sizeof(LEDRefAmpRMS));
+ memset(LEDRefHighLowRatio, 0, sizeof(LEDRefHighLowRatio));
+ memset(LEDRefHighLow, 0, sizeof(LEDRefHighLow));
+ memset(Temperature, 0, sizeof(Temperature));
+ memset(TemperatureRMS, 0, sizeof(TemperatureRMS));
+ memset(RelativeGain, 0, sizeof(RelativeGain));
+ memset(HighLowRatio, 0, sizeof(HighLowRatio));
+ memset(HighLow, 0, sizeof(HighLow));
+ memset(LEDAmp, 0, sizeof(LEDAmp));
+ memset(LEDAmpRMS, 0, sizeof(LEDAmpRMS));
+
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+ // for looping over towers
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+
+ // declare the branches
+ // first
+ tree->Branch("iSM", &iSM, "iSM/I");
+ tree->Branch("CalibMethod", &CalibMethod, "CalibMethod/I");
+ tree->Branch("CalibPass", &CalibPass, "CalibPass/I");
+ tree->Branch("CalibTime", &CalibTime, "CalibTime/I");
+ tree->Branch("AbsoluteGain", &AbsoluteGain, "AbsoluteGain/F");
+ // second
+ tree->Branch( "LEDRefAmp", &LEDRefAmp, Form("LEDRefAmp[%d]/F", AliEMCALGeoParams::fgkEMCALLEDRefs) );
+ tree->Branch( "LEDRefAmpRMS", &LEDRefAmpRMS, Form("LEDRefAmpRMS[%d]/F", AliEMCALGeoParams::fgkEMCALLEDRefs) );
+ tree->Branch( "LEDRefHighLowRatio", &LEDRefHighLowRatio, Form("LEDRefHighLowRatio[%d]/F", AliEMCALGeoParams::fgkEMCALLEDRefs) );
+ tree->Branch( "LEDRefHighLow", &LEDRefHighLow, Form("LEDRefHighLow[%d]/I", AliEMCALGeoParams::fgkEMCALLEDRefs) );
+ tree->Branch( "Temperature", &Temperature, Form("Temperature[%d]/F", AliEMCALGeoParams::fgkEMCALTempSensors) );
+ tree->Branch( "TemperatureRMS", &TemperatureRMS, Form("TemperatureRMS[%d]/F", AliEMCALGeoParams::fgkEMCALTempSensors) );
+ // third: info for each tower; see if a 2D array works OK or if we'll have to use 1D arrays instead
+ tree->Branch( "RelativeGain", &RelativeGain, Form("RelativeGain[%d][%d]/F", AliEMCALGeoParams::fgkEMCALCols, AliEMCALGeoParams::fgkEMCALRows) );
+ tree->Branch( "HighLowRatio", &HighLowRatio, Form("HighLowRatio[%d][%d]/F", AliEMCALGeoParams::fgkEMCALCols, AliEMCALGeoParams::fgkEMCALRows) );
+ tree->Branch( "HighLow", &HighLow, Form("HighLow[%d][%d]/I", AliEMCALGeoParams::fgkEMCALCols, AliEMCALGeoParams::fgkEMCALRows) );
+ tree->Branch( "LEDAmp", &LEDAmp, Form("LEDAmp[%d][%d]/F", AliEMCALGeoParams::fgkEMCALCols, AliEMCALGeoParams::fgkEMCALRows) );
+ tree->Branch( "LEDAmpRMS", &LEDAmpRMS, Form("LEDAmpRMS[%d][%d]/F", AliEMCALGeoParams::fgkEMCALCols, AliEMCALGeoParams::fgkEMCALRows) );
+
+ for (iSM = 0; iSM < fNSuperModule; iSM++) {
+ AliEMCALSuperModuleCalibAbs &t = fSuperModuleData[iSM];
+
+ iSM = t.fSuperModuleNum;
+ // first, overall values
+ CalibMethod = t.fCalibMethod;
+ CalibPass = t.fCalibPass;
+ CalibTime = t.fCalibTime;
+ AbsoluteGain = t.fAbsoluteGain;
+
+ // second: additional info for LED references and SM temperatures
+ for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALLEDRefs; j++) {
+ LEDRefAmp[j] = t.fLEDRefAmp[j];
+ LEDRefAmpRMS[j] = t.fLEDRefAmpRMS[j];
+ LEDRefHighLowRatio[j] = t.fLEDRefHighLowRatio[j];
+ LEDRefHighLow[j] = t.fLEDRefHighLow[j];
+ }
+ for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALTempSensors; j++) {
+ Temperature[j] = t.fTemperature[j];
+ TemperatureRMS[j] = t.fTemperatureRMS[j];
+ }
+
+ // third: info for each tower
+ for (Int_t j=0; j<nAPDPerSM; j++) {
+ iCol = j / AliEMCALGeoParams::fgkEMCALRows;
+ iRow = j % AliEMCALGeoParams::fgkEMCALRows;
+
+ // help variables: possibly modified or swapped indices
+ int iColMod = iCol;
+ int iRowMod = iRow;
+ // assume that this info is already swapped and done for this basis?
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iColMod = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRowMod = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+ AliEMCALCalibAbsVal &v = t.fAPDVal[iColMod][iRowMod];
+
+ RelativeGain[iCol][iRow] = v.fRelativeGain;
+ HighLowRatio[iCol][iRow] = v.fHighLowRatio;
+ HighLow[iCol][iRow] = v.fHighLow;
+ LEDAmp[iCol][iRow] = v.fLEDAmp;
+ LEDAmpRMS[iCol][iRow] = v.fLEDAmpRMS;
+ }
+
+ tree->Fill();
+ } // i, SuperModule
+
+ tree->Write();
+ destFile.Close();
+
+ return;
+}
+
//____________________________________________________________________________
AliEMCALCalibAbs::~AliEMCALCalibAbs()
{
}
//____________________________________________________________________________
-AliEMCALCalibAbs::AliEMCALSuperModuleCalibAbs AliEMCALCalibAbs::GetSuperModuleCalibAbsId(Int_t supModIndex)const
+AliEMCALSuperModuleCalibAbs AliEMCALCalibAbs::GetSuperModuleCalibAbsId(Int_t supModIndex)const
{
AliEMCALSuperModuleCalibAbs t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
}
//____________________________________________________________________________
-AliEMCALCalibAbs::AliEMCALSuperModuleCalibAbs AliEMCALCalibAbs::GetSuperModuleCalibAbsNum(Int_t supModIndex)const
+AliEMCALSuperModuleCalibAbs AliEMCALCalibAbs::GetSuperModuleCalibAbsNum(Int_t supModIndex)const
{
AliEMCALSuperModuleCalibAbs t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
#include <TObject.h>
#include "AliEMCALGeoParams.h"
class TString;
+class TTree;
/*
Objects of this class contain basis for absolute calibrations
- AliEMCALCalibAbs inherits TObject only to use AliLog "functions".
*/
+// total calibration factor is a product of
+// a) overall calibration factor [fAbsoluteGain]
+// b) individual gain factor per tower [fRelativeGain]
+// c) time-dependent correction
+// In this class we store a), b) and the needed static ingredients for c)
+
+// ******* internal class definition *************
+// values per single tower
+class AliEMCALCalibAbsVal : public TObject {
+
+ public:
+ AliEMCALCalibAbsVal() : TObject(), // just init values
+ fRelativeGain(0),
+ fHighLowRatio(0),
+ fHighLow(0),
+ fLEDAmp(0),
+ fLEDAmpRMS(0)
+ {
+ }
+
+ void Init() {
+ fRelativeGain = 0;
+ fHighLowRatio = 0;
+ fHighLow = 0;
+ fLEDAmp = 0;
+ fLEDAmpRMS = 0;
+ return;
+ }
+
+ public:
+ Float_t fRelativeGain; // (ADC>GeV relative gain/conversion), value around 1
+ Float_t fHighLowRatio; // value around 16 or so
+ Int_t fHighLow; // 0 (low) or 1 (high) gain, used for LEDAmp info
+ Float_t fLEDAmp; // LED amplitude
+ Float_t fLEDAmpRMS; // RMS
+
+ ClassDef(AliEMCALCalibAbsVal, 1) // help class
+};
+
+// 1 SuperModule's worth of info: info on where the different APDs are
+class AliEMCALSuperModuleCalibAbs : public TObject {
+
+ public:
+ AliEMCALSuperModuleCalibAbs() : TObject(), // just init values
+ fSuperModuleNum(0),
+ fCalibMethod(0),
+ fCalibPass(0),
+ fCalibTime(0),
+ fAbsoluteGain(0)
+ {
+ for (int iref=0; iref<AliEMCALGeoParams::fgkEMCALLEDRefs; iref++) {
+ fLEDRefAmp[iref] = 0;
+ fLEDRefAmpRMS[iref] = 0;
+ fLEDRefHighLowRatio[iref] = 0;
+ fLEDRefHighLow[iref] = 0;
+ }
+
+ for (int itemp=0; itemp<AliEMCALGeoParams::fgkEMCALTempSensors; itemp++) {
+ fTemperature[itemp] = 0;
+ fTemperatureRMS[itemp] = 0;
+ }
+
+ for (int icol=0; icol<AliEMCALGeoParams::fgkEMCALCols; icol++) {
+ for (int irow=0; irow<AliEMCALGeoParams::fgkEMCALRows; irow++) {
+ fAPDVal[icol][irow].Init();
+ }
+ }
+ }
+
+ public:
+ // first: overall values for the whole SuperModule
+ Int_t fSuperModuleNum; // which SuperModule is this?
+ Int_t fCalibMethod; // a la 0=cosmics, 1=pi0, 2=electrons,3=using ecore,
+ Int_t fCalibPass; // which analysis iteration is this.. 1,2,..N
+ Int_t fCalibTime; // t0, unix timestamp
+ Float_t fAbsoluteGain; // (ADC>GeV absolute gain/conversion)
+
+ // second: additional info for LED Reference and SM temperature
+ Float_t fLEDRefAmp[AliEMCALGeoParams::fgkEMCALLEDRefs]; // LED amplitude at t0, low gain equivalent
+ Float_t fLEDRefAmpRMS[AliEMCALGeoParams::fgkEMCALLEDRefs]; // RMS
+ Float_t fLEDRefHighLowRatio[AliEMCALGeoParams::fgkEMCALLEDRefs]; // value around 16 or so
+ Int_t fLEDRefHighLow[AliEMCALGeoParams::fgkEMCALLEDRefs]; // 0 (low) or 1 (high) gain
+
+ Float_t fTemperature[AliEMCALGeoParams::fgkEMCALTempSensors]; // temperature at t0
+ Float_t fTemperatureRMS[AliEMCALGeoParams::fgkEMCALTempSensors]; // RMS
+
+ // third: individual info for each tower
+ AliEMCALCalibAbsVal fAPDVal[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // at t0
+
+ ClassDef(AliEMCALSuperModuleCalibAbs, 1) // help class
+};
+// ******* end of internal class definition *************
+
class AliEMCALCalibAbs : public TObject {
public:
AliEMCALCalibAbs();
// Read and Write txt I/O methods are normally not used, but are useful for
- // debug purposes
- void ReadCalibAbsInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
-
- void WriteCalibAbsInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ // filling the object before it is saved in OCDB
+ void ReadTextCalibAbsInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteTextCalibAbsInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadRootCalibAbsInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadTreeCalibAbsInfo(TTree *tree, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteRootCalibAbsInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
virtual ~AliEMCALCalibAbs();
- // total calibration factor is a product of
- // a) overall calibration factor [fAbsoluteGain]
- // b) individual gain factor per tower [fRelativeGain]
- // c) time-dependent correction
- // In this class we store a), b) and the needed static ingredients for c)
-
- // values per single tower
- struct AliEMCALCalibAbsVal {
- Float_t fRelativeGain; // (ADC>GeV relative gain/conversion), value around 1
- Float_t fHighLowRatio; // value around 16 or so
- Int_t fHighLow; // 0 (low) or 1 (high) gain, used for LEDAmp info
- Float_t fLEDAmp; // LED amplitude
- Float_t fLEDAmpRMS; // RMS
- };
-
- // 1 SuperModule's worth of info: info on where the different APDs are
- struct AliEMCALSuperModuleCalibAbs {
- // first: overall values for the whole SuperModule
- Int_t fSuperModuleNum; // which SuperModule is this?
- Int_t fCalibMethod; // a la 0=cosmics, 1=pi0, 2=electrons,3=using ecore,
- Int_t fCalibPass; // which analysis iteration is this.. 1,2,..N
- Int_t fCalibTime; // t0, unix timestamp
- Float_t fAbsoluteGain; // (ADC>GeV absolute gain/conversion)
-
- // second: additional info for LED Reference and SM temperature
- Float_t fLEDRefAmp[AliEMCALGeoParams::fgkEMCALLEDRefs]; // LED amplitude at t0, low gain equivalent
- Float_t fLEDRefAmpRMS[AliEMCALGeoParams::fgkEMCALLEDRefs]; // RMS
- Float_t fLEDRefHighLowRatio[AliEMCALGeoParams::fgkEMCALLEDRefs]; // value around 16 or so
- Int_t fLEDRefHighLow[AliEMCALGeoParams::fgkEMCALLEDRefs]; // 0 (low) or 1 (high) gain
-
- Float_t fTemperature[AliEMCALGeoParams::fgkEMCALTempSensors]; // temperature at t0
- Float_t fTemperatureRMS[AliEMCALGeoParams::fgkEMCALTempSensors]; // RMS
-
- // third: individual info for each tower
- AliEMCALCalibAbsVal fAPDVal[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows]; // at t0
- };
-
// pointer to stored info.
-
Int_t GetNSuperModule() const { return fNSuperModule; };
AliEMCALSuperModuleCalibAbs * GetSuperModuleData() const { return fSuperModuleData; };
AliEMCALCalibAbs(const AliEMCALCalibAbs &);
AliEMCALCalibAbs &operator = (const AliEMCALCalibAbs &);
- ClassDef(AliEMCALCalibAbs, 1) //CalibAbs data reader
+ ClassDef(AliEMCALCalibAbs, 2) //CalibAbs data reader
};
#endif
#include <fstream>
#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
#include "AliEMCALCalibMapAPD.h"
}
//____________________________________________________________________________
-void AliEMCALCalibMapAPD::ReadCalibMapAPDInfo(Int_t nSM, const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALCalibMapAPD::ReadTextCalibMapAPDInfo(Int_t nSM, const TString &txtFileName,
+ Bool_t swapSides)
{
//Read data from txt file. ; coordinates given on SuperModule basis
}
//____________________________________________________________________________
-void AliEMCALCalibMapAPD::WriteCalibMapAPDInfo(const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALCalibMapAPD::WriteTextCalibMapAPDInfo(const TString &txtFileName,
+ Bool_t swapSides)
{
// write data to txt file. ; coordinates given on SuperModule basis
return;
}
+//____________________________________________________________________________
+void AliEMCALCalibMapAPD::ReadRootCalibMapAPDInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ //Read data from root file. ; coordinates given on SuperModule basis
+ TFile inputFile(rootFileName, "read");
+
+ TTree *tree = (TTree*) inputFile.Get("tree");
+
+ ReadTreeCalibMapAPDInfo(tree, swapSides);
+
+ inputFile.Close();
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALCalibMapAPD::ReadTreeCalibMapAPDInfo(TTree *tree,
+ Bool_t swapSides)
+{
+ // how many SuperModule's worth of entries / APDs do we have?
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+ fNSuperModule = tree->GetEntries() / nAPDPerSM;
+
+ if (fSuperModuleData) delete [] fSuperModuleData;
+ fSuperModuleData = new AliEMCALSuperModuleCalibMapAPD[fNSuperModule];
+
+ Int_t iSM = 0; // SuperModule index
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+ // list of values to be read
+ Int_t iHW = 0;
+ Int_t APDNum = 0;
+ Float_t V30 = 0;
+ Float_t Par[3] = {0};
+ Float_t ParErr[3] = {0};
+ Int_t BreakDown = 0;
+ Float_t DarkCurrent = 0;
+ // end - all values
+
+ // declare the branches
+ tree->SetBranchAddress("iSM", &iSM);
+ tree->SetBranchAddress("iCol", &iCol);
+ tree->SetBranchAddress("iRow", &iRow);
+ tree->SetBranchAddress("iHW", &iHW);
+ tree->SetBranchAddress("APDNum", &APDNum);
+ tree->SetBranchAddress("V30", &V30);
+ tree->SetBranchAddress("Par", Par);
+ tree->SetBranchAddress("ParErr", ParErr);
+ tree->SetBranchAddress("BreakDown", &BreakDown);
+ tree->SetBranchAddress("DarkCurrent", &DarkCurrent);
+
+ for (int ient=0; ient<tree->GetEntries(); ient++) {
+ tree->GetEntry(ient);
+
+ // assume the index SuperModules come in order: i=iSM
+ AliEMCALSuperModuleCalibMapAPD &t = fSuperModuleData[iSM];
+ t.fSuperModuleNum = iSM;
+
+ // assume that this info is already swapped and done for this basis?
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+ AliEMCALCalibMapAPDVal &v = t.fAPDVal[iCol][iRow];
+
+ v.fHardWareId = iHW;
+ v.fAPDNum = APDNum;
+ v.fV30 = V30;
+ v.fPar[0] = Par[0];
+ v.fPar[1] = Par[1];
+ v.fPar[2] = Par[2];
+ v.fParErr[0] = ParErr[0];
+ v.fParErr[1] = ParErr[1];
+ v.fParErr[2] = ParErr[2];
+ v.fBreakDown = BreakDown;
+ v.fDarkCurrent = DarkCurrent;
+
+ } //
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALCalibMapAPD::WriteRootCalibMapAPDInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ // write data to root file. ; coordinates given on SuperModule basis
+ TFile destFile(rootFileName, "recreate");
+ if (destFile.IsZombie()) {
+ return;
+ }
+ destFile.cd();
+
+ TTree *tree = new TTree("tree","");
+
+ // variables for filling the TTree
+ Int_t iSM = 0; // SuperModule index
+ Int_t iHW = 0;
+ Int_t APDNum = 0;
+ Float_t V30 = 0;
+ Float_t Par[3] = {0};
+ Float_t ParErr[3] = {0};
+ Int_t BreakDown = 0;
+ Float_t DarkCurrent = 0;
+ //
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+ // declare the branches
+ tree->Branch("iSM", &iSM, "iSM/I");
+ tree->Branch("iCol", &iCol, "iCol/I");
+ tree->Branch("iRow", &iRow, "iRow/I");
+ tree->Branch("iHW", &iHW, "iHW/I");
+ tree->Branch("APDNum", &APDNum, "APDNum/I");
+ tree->Branch("V30", &V30, "V30/F");
+ tree->Branch("Par", &Par, "Par[3]/F");
+ tree->Branch("ParErr", &ParErr, "ParErr[3]/F");
+ tree->Branch("BreakDown", &BreakDown, "BreakDown/I");
+ tree->Branch("DarkCurrent", &DarkCurrent, "DarkCurrent/F");
+
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+
+ for (iSM = 0; iSM < fNSuperModule; iSM++) {
+ AliEMCALSuperModuleCalibMapAPD &t = fSuperModuleData[iSM];
+
+ for (Int_t j=0; j<nAPDPerSM; j++) {
+ iCol = j / AliEMCALGeoParams::fgkEMCALRows;
+ iRow = j % AliEMCALGeoParams::fgkEMCALRows;
+
+ AliEMCALCalibMapAPDVal &v = t.fAPDVal[iCol][iRow];
+
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+ iHW = v.fHardWareId;
+ APDNum = v.fAPDNum;
+ V30 = v.fV30;
+ for (int k=0; k<3; k++) {
+ Par[k] = v.fPar[k];
+ ParErr[k] = v.fParErr[k];
+ }
+ BreakDown = v.fBreakDown;
+ DarkCurrent = v.fDarkCurrent;
+
+ tree->Fill();
+ }
+
+ } // i, SuperModule
+
+ tree->Write();
+ destFile.Close();
+
+ return;
+}
+
//____________________________________________________________________________
AliEMCALCalibMapAPD::~AliEMCALCalibMapAPD()
{
}
//____________________________________________________________________________
-AliEMCALCalibMapAPD::AliEMCALSuperModuleCalibMapAPD AliEMCALCalibMapAPD::GetSuperModuleCalibMapAPDId(Int_t supModIndex)const
+AliEMCALSuperModuleCalibMapAPD AliEMCALCalibMapAPD::GetSuperModuleCalibMapAPDId(Int_t supModIndex)const
{
AliEMCALSuperModuleCalibMapAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
}
//____________________________________________________________________________
-AliEMCALCalibMapAPD::AliEMCALSuperModuleCalibMapAPD AliEMCALCalibMapAPD::GetSuperModuleCalibMapAPDNum(Int_t supModIndex)const
+AliEMCALSuperModuleCalibMapAPD AliEMCALCalibMapAPD::GetSuperModuleCalibMapAPDNum(Int_t supModIndex)const
{
AliEMCALSuperModuleCalibMapAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
#include "AliEMCALGeoParams.h"
#include <cmath>
class TString;
+class TTree;
/*
- Objects of this class read txt file with APD data
- AliEMCALCalibMapAPD inherits TObject only to use AliLog "functions".
+ Objects of this class contain info on APD calibration and map info
*/
+// ******* internal class definition *************
+// values per single APD
+class AliEMCALCalibMapAPDVal : public TObject {
+
+ public:
+ AliEMCALCalibMapAPDVal() : TObject(), // just init values
+ fHardWareId(0),
+ fAPDNum(0),
+ fV30(0),
+ fBreakDown(0),
+ fDarkCurrent(0)
+ {
+ Init();
+ }
+
+ void Init() {
+ fHardWareId = 0;
+ fAPDNum = 0;
+ fV30 = 0;
+ fBreakDown = 0;
+ fDarkCurrent = 0;
+ for (int i=0; i<3; i++) {
+ fPar[i] = 0;
+ fParErr[i] = 0;
+ }
+ return;
+ }
+
+ public:
+ Int_t fHardWareId; // HardWareIndex
+ // info from APD calibrations
+ Int_t fAPDNum; // assigned APD-PA number; Catania 10000-, Houston: 20000-
+ Float_t fV30; // Catania/Houston Voltage V30 (V) at T = 25 deg C
+ Float_t fPar[3]; // fit parameters, p0,p1,p2 - for ADC vs bias measurement
+ Float_t fParErr[3]; // error on fit parameters
+
+ Int_t fBreakDown; // Hamamatsu Breakdown Voltage (V)
+ Float_t fDarkCurrent; // Hamamatsu Dark Current (A)
+
+ ClassDef(AliEMCALCalibMapAPDVal, 1) // help class
+}; // AliEMCALCalibAPDVal
+
+// 1 SuperModule's worth of info: info on where the different APDs are
+class AliEMCALSuperModuleCalibMapAPD : public TObject {
+ public:
+ // AliEMCALSuperModuleCalibMapAPD(Int_t nSM = 0);
+ AliEMCALSuperModuleCalibMapAPD() : TObject(), // just init values
+ fSuperModuleNum(0)
+ {
+ for (int icol=0; icol<AliEMCALGeoParams::fgkEMCALCols; icol++) {
+ for (int irow=0; irow<AliEMCALGeoParams::fgkEMCALRows; irow++) {
+ fAPDVal[icol][irow].Init();
+ }
+ }
+ }
+
+ public:
+ Int_t fSuperModuleNum;
+ AliEMCALCalibMapAPDVal fAPDVal[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows];
+
+ ClassDef(AliEMCALSuperModuleCalibMapAPD, 1) // help class
+};
+// ******* end of internal class definition *************
+
class AliEMCALCalibMapAPD : public TObject {
public:
// Read and Write txt I/O methods are normally not used, but are useful for
// filling the object before it is saved in OCDB
- void ReadCalibMapAPDInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
-
- void WriteCalibMapAPDInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadTextCalibMapAPDInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteTextCalibMapAPDInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadRootCalibMapAPDInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadTreeCalibMapAPDInfo(TTree *tree, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteRootCalibMapAPDInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
virtual ~AliEMCALCalibMapAPD();
- // values per single APD
- struct AliEMCALCalibMapAPDVal {
-
- Int_t fHardWareId; // HardWareIndex
- // info from APD calibrations
- Int_t fAPDNum; // assigned APD-PA number; Catania 10000-, Houston: 20000-
- Float_t fV30; // Catania/Houston Voltage V30 (V) at T = 25 deg C
- Float_t fPar[3]; // fit parameters, p0,p1,p2 - for ADC vs bias measurement
- Float_t fParErr[3]; // error on fit parameters
-
- Int_t fBreakDown; // Hamamatsu Breakdown Voltage (V)
- Float_t fDarkCurrent; // Hamamatsu Dark Current (A)
- };
-
- // 1 SuperModule's worth of info: info on where the different APDs are
- struct AliEMCALSuperModuleCalibMapAPD {
- Int_t fSuperModuleNum;
- AliEMCALCalibMapAPDVal fAPDVal[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows];
- };
-
// pointer to stored info.
-
Int_t GetNSuperModule() const { return fNSuperModule; };
AliEMCALSuperModuleCalibMapAPD * GetSuperModuleData() const { return fSuperModuleData; };
AliEMCALCalibMapAPD(const AliEMCALCalibMapAPD &);
AliEMCALCalibMapAPD &operator = (const AliEMCALCalibMapAPD &);
- ClassDef(AliEMCALCalibMapAPD, 1) //MapAPD data reader
+ ClassDef(AliEMCALCalibMapAPD, 2) //CalibMapAPD data info
};
#endif
// pick up Preprocessor output, based on fRun (most recent version)
AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/BiasAPD", fRun);
if (entry) {
- fBiasAPD = (AliEMCALBiasAPD *) entry->GetObject();
+ fBiasAPD->ReadTreeBiasAPDInfo( (TTree *) entry->GetObject() );
}
if (fBiasAPD) {
{
// pick up Preprocessor output, based on fRun (most recent version)
AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/MapAPD", fRun);
+ // stored object should be a TTree; read the info
if (entry) {
- fCalibMapAPD = (AliEMCALCalibMapAPD *) entry->GetObject();
+ fCalibMapAPD->ReadTreeCalibMapAPDInfo( (TTree *) entry->GetObject() );
}
if (fCalibMapAPD) {
// pick up Preprocessor output, based on fRun (most recent version)
AliCDBEntry* entry = AliCDBManager::Instance()->Get("EMCAL/Calib/MapAPD", fRun);
if (entry) {
- fCalibAbs = (AliEMCALCalibAbs *) entry->GetObject();
+ fCalibAbs->ReadTreeCalibAbsInfo( (TTree *) entry->GetObject() );
}
if (fCalibAbs) {
Int_t nRemaining = 0; // we count the towers for which we could not get valid data
// sanity check; same SuperModule indices for corrections as for regular calibrations
- AliEMCALCalibAbs::AliEMCALSuperModuleCalibAbs * CalibAbsData = fCalibAbs->GetSuperModuleData();
- AliEMCALCalibTimeDepCorrection::AliEMCALSuperModuleCalibTimeDepCorrection * CalibTimeDepCorrectionData = fCalibTimeDepCorrection->GetSuperModuleData();
+ AliEMCALSuperModuleCalibAbs * CalibAbsData = fCalibAbs->GetSuperModuleData();
+ AliEMCALSuperModuleCalibTimeDepCorrection * CalibTimeDepCorrectionData = fCalibTimeDepCorrection->GetSuperModuleData();
for (int i = 0; i < nSM; i++) {
int iSMAbs = CalibAbsData[i].fSuperModuleNum;
for (iRow = 0; iRow < AliEMCALGeoParams::fgkEMCALRows; iRow++) {
// Calc. R(t0):
- AliEMCALCalibAbs::AliEMCALCalibAbsVal &v = CalibAbsData[i].fAPDVal[iCol][iRow];
+ AliEMCALCalibAbsVal &v = CalibAbsData[i].fAPDVal[iCol][iRow];
iGain = v.fHighLow; // gain value used for abs. calibration
refGain = CalibAbsData[i].fLEDRefHighLow[iStrip]; // LED reference gain value used for abs. calibration
// go over fTimeDepCorrection info
Int_t nRemaining = 0; // we count the towers for which we could not get valid data
- AliEMCALCalibTimeDepCorrection::AliEMCALSuperModuleCalibTimeDepCorrection * CalibTimeDepCorrectionData = fCalibTimeDepCorrection->GetSuperModuleData();
+ AliEMCALSuperModuleCalibTimeDepCorrection * CalibTimeDepCorrectionData = fCalibTimeDepCorrection->GetSuperModuleData();
// for calculating StripAverage info
int nValidTower = 0;
Int_t nRemaining = 0;
// info containers
- AliEMCALBiasAPD::AliEMCALSuperModuleBiasAPD * BiasAPDData = fBiasAPD->GetSuperModuleData();
- AliEMCALCalibMapAPD::AliEMCALSuperModuleCalibMapAPD * CalibMapAPDData = fCalibMapAPD->GetSuperModuleData();
- AliEMCALCalibAbs::AliEMCALSuperModuleCalibAbs * CalibAbsData = fCalibAbs->GetSuperModuleData();
+ AliEMCALSuperModuleBiasAPD * BiasAPDData = fBiasAPD->GetSuperModuleData();
+ AliEMCALSuperModuleCalibMapAPD * CalibMapAPDData = fCalibMapAPD->GetSuperModuleData();
+ AliEMCALSuperModuleCalibAbs * CalibAbsData = fCalibAbs->GetSuperModuleData();
// correction container
- AliEMCALCalibTimeDepCorrection::AliEMCALSuperModuleCalibTimeDepCorrection * CalibTimeDepCorrectionData = fCalibTimeDepCorrection->GetSuperModuleData();
+ AliEMCALSuperModuleCalibTimeDepCorrection * CalibTimeDepCorrectionData = fCalibTimeDepCorrection->GetSuperModuleData();
int iSM = 0;
int iCol = 0;
// first calculate the M=Gain values, and TemperatureCoeff, for all towers in this SuperModule, from BiasAPD and CalibMapAPD info
for (iCol = 0; iCol < AliEMCALGeoParams::fgkEMCALCols; iCol++) {
for (iRow = 0; iRow < AliEMCALGeoParams::fgkEMCALRows; iRow++) {
- AliEMCALCalibMapAPD::AliEMCALCalibMapAPDVal &mapAPD = CalibMapAPDData[i].fAPDVal[iCol][iRow];
+ AliEMCALCalibMapAPDVal &mapAPD = CalibMapAPDData[i].fAPDVal[iCol][iRow];
MGain = fCalibMapAPD->GetGain(mapAPD.fPar[0], mapAPD.fPar[1], mapAPD.fPar[2],
BiasAPDData[i].fVoltage[iCol][iRow]);
TempCoeff[iCol][iRow] = GetTempCoeff(mapAPD.fDarkCurrent, MGain);
/* $Id: $ */
-// Objects of this class contain info on APD bias settings/voltages
+// Objects of this class contain info on time-dependent corrections
//
#include <fstream>
#include <TString.h>
#include <TArrayF.h>
+#include <TFile.h>
+#include <TTree.h>
#include "AliEMCALCalibTimeDepCorrection.h"
}
//____________________________________________________________________________
-void AliEMCALCalibTimeDepCorrection::InitCorrection(Int_t nSM, Int_t nBins, Float_t val)
+void AliEMCALCalibTimeDepCorrection::InitCorrection(Int_t nSM, Int_t nBins, Float_t val=1.0)
{
// This methods assumes that you are using SuperModules 0..nSM-1
fNSuperModule = nSM;
}
//____________________________________________________________________________
-void AliEMCALCalibTimeDepCorrection::ReadCalibTimeDepCorrectionInfo(Int_t nSM, const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALCalibTimeDepCorrection::ReadTextInfo(Int_t nSM, const TString &txtFileName,
+ Bool_t swapSides)
{
//Read data from txt file. ; coordinates given on SuperModule basis
std::ifstream inputFile(txtFileName.Data());
if (!inputFile) {
- printf("AliEMCALCalibTimeDepCorrection::ReadCalibTimeDepCorrectionInfo - Cannot open the APD info file %s\n", txtFileName.Data());
+ printf("AliEMCALCalibTimeDepCorrection::ReadTextInfo - Cannot open the APD info file %s\n", txtFileName.Data());
return;
}
Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+ // read header info
+ inputFile >> fStartTime >> fNTimeBins >> fTimeBinSize;
+
for (Int_t i = 0; i < fNSuperModule; i++) {
AliEMCALSuperModuleCalibTimeDepCorrection &t = fSuperModuleData[i];
if (!inputFile) {
- printf("AliEMCALCalibTimeDepCorrection::ReadCalibTimeDepCorrectionInfo - Error while reading input file; likely EOF..");
+ printf("AliEMCALCalibTimeDepCorrection::ReadTextInfo - Error while reading input file; likely EOF..");
return;
}
inputFile >> iSM;
}
//____________________________________________________________________________
-void AliEMCALCalibTimeDepCorrection::WriteCalibTimeDepCorrectionInfo(const TString &txtFileName,
- Bool_t swapSides)
+void AliEMCALCalibTimeDepCorrection::WriteTextInfo(const TString &txtFileName,
+ Bool_t swapSides)
{
// write data to txt file. ; coordinates given on SuperModule basis
std::ofstream outputFile(txtFileName.Data());
if (!outputFile) {
- printf("AliEMCALCalibTimeDepCorrection::WriteCalibTimeDepCorrectionInfo - Cannot open the APD output file %s\n", txtFileName.Data());
+ printf("AliEMCALCalibTimeDepCorrection::WriteTextInfo - Cannot open the APD output file %s\n", txtFileName.Data());
return;
}
Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+ // write header info
+ outputFile << fStartTime << " " << fNTimeBins << " " << fTimeBinSize << endl;
+
for (Int_t i = 0; i < fNSuperModule; i++) {
AliEMCALSuperModuleCalibTimeDepCorrection &t = fSuperModuleData[i];
outputFile << t.fSuperModuleNum << endl;
return;
}
+//____________________________________________________________________________
+void AliEMCALCalibTimeDepCorrection::ReadRootInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ //Read data from root file. ; coordinates given on SuperModule basis
+ TFile inputFile(rootFileName, "read");
+
+ TTree *treeGlob = (TTree*) inputFile.Get("treeGlob");
+ TTree *treeCorr = (TTree*) inputFile.Get("treeCorr");
+
+ ReadTreeInfo(treeGlob, treeCorr, swapSides);
+
+ inputFile.Close();
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALCalibTimeDepCorrection::ReadTreeInfo(TTree *treeGlob, TTree *treeCorr,
+ Bool_t swapSides)
+{
+ // how many SuperModule's worth of entries / APDs do we have?
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+ fNSuperModule = treeCorr->GetEntries() / nAPDPerSM;
+
+ // global variables : only one entry
+ treeGlob->SetBranchAddress("fStartTime", &fStartTime);
+ treeGlob->SetBranchAddress("fNTimeBins", &fNTimeBins);
+ treeGlob->SetBranchAddress("fTimeBinSize", &fTimeBinSize);
+ treeGlob->GetEntry(0);
+
+ if (fSuperModuleData) delete [] fSuperModuleData;
+ fSuperModuleData = new AliEMCALSuperModuleCalibTimeDepCorrection[fNSuperModule];
+
+ Int_t iSM = 0; // SuperModule index
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+ // list of values to be read
+ Int_t nCorr = 0;
+ Float_t correction[fgkMaxTimeBins] = {0};
+ // make sure it's really initialized correctly
+ memset(correction, 0, sizeof(correction)); // better safe than sorry
+ // end - all values
+
+ // declare the branches
+ treeCorr->SetBranchAddress("iSM", &iSM);
+ treeCorr->SetBranchAddress("iCol", &iCol);
+ treeCorr->SetBranchAddress("iRow", &iRow);
+ treeCorr->SetBranchAddress("nCorr", &nCorr);
+ treeCorr->SetBranchAddress("correction", correction);
+
+ for (int ient=0; ient<treeCorr->GetEntries(); ient++) {
+ treeCorr->GetEntry(ient);
+
+ // assume the index SuperModules come in order: i=iSM
+ AliEMCALSuperModuleCalibTimeDepCorrection &t = fSuperModuleData[iSM];
+ t.fSuperModuleNum = iSM;
+
+ // assume that this info is already swapped and done for this basis?
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+
+ // set size of TArray
+ t.fCorrection[iCol][iRow].Set(nCorr);
+ for (Int_t k=0; k<nCorr; k++) {
+ // add to TArray
+ t.fCorrection[iCol][iRow].AddAt(correction[k], k);
+ }
+
+ } // entry
+
+ return;
+}
+
+//____________________________________________________________________________
+void AliEMCALCalibTimeDepCorrection::WriteRootInfo(const TString &rootFileName,
+ Bool_t swapSides)
+{
+ // write data to root file. ; coordinates given on SuperModule basis
+ TFile destFile(rootFileName, "recreate");
+ if (destFile.IsZombie()) {
+ return;
+ }
+ destFile.cd();
+
+ TTree *treeGlob = new TTree("treeGlob","");
+ TTree *treeCorr = new TTree("treeCorr","");
+
+ // global part only has one entry
+ treeGlob->Branch("fStartTime", &fStartTime, "fStartTime/I"); // really unsigned int..
+ treeGlob->Branch("fNTimeBins", &fNTimeBins, "fNTimeBins/I");
+ treeGlob->Branch("fTimeBinSize", &fTimeBinSize, "fTimeBinSize/I");
+ treeGlob->Fill();
+
+ // variables for filling the TTree
+ Int_t iSM = 0; // SuperModule index
+ Int_t iCol = 0;
+ Int_t iRow = 0;
+ Int_t nCorr = 0;
+ Float_t correction[fgkMaxTimeBins] = {0};
+ // make sure it's really initialized correctly
+ memset(correction, 0, sizeof(correction)); // better safe than sorry
+
+ // declare the branches
+ treeCorr->Branch("iSM", &iSM, "iSM/I");
+ treeCorr->Branch("iCol", &iCol, "iCol/I");
+ treeCorr->Branch("iRow", &iRow, "iRow/I");
+ treeCorr->Branch("nCorr", &nCorr, "nCorr/I");
+ treeCorr->Branch("correction", &correction, "correction[nCorr]/F");
+
+ Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
+
+ for (iSM = 0; iSM < fNSuperModule; iSM++) {
+ AliEMCALSuperModuleCalibTimeDepCorrection &t = fSuperModuleData[iSM];
+
+ for (Int_t j=0; j<nAPDPerSM; j++) {
+ iCol = j / AliEMCALGeoParams::fgkEMCALRows;
+ iRow = j % AliEMCALGeoParams::fgkEMCALRows;
+
+ nCorr = t.fCorrection[iCol][iRow].GetSize();
+ if (nCorr > fgkMaxTimeBins) {
+ printf("AliEMCALCalibTimeDepCorrection::WriteRootInfo - too many correction/timebins %d kept\n", nCorr);
+ return;
+ }
+
+ if (swapSides) {
+ // C side, oriented differently than A side: swap is requested
+ iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
+ iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
+ }
+
+ for (Int_t k=0; k<nCorr; k++) {
+ correction[k] = t.fCorrection[iCol][iRow].At(k);
+ }
+
+ treeCorr->Fill();
+ }
+
+ } // i, SuperModule
+
+ treeGlob->Write();
+ treeCorr->Write();
+ destFile.Close();
+
+ return;
+}
+
//____________________________________________________________________________
AliEMCALCalibTimeDepCorrection::~AliEMCALCalibTimeDepCorrection()
{
}
//____________________________________________________________________________
-AliEMCALCalibTimeDepCorrection::AliEMCALSuperModuleCalibTimeDepCorrection AliEMCALCalibTimeDepCorrection::GetSuperModuleCalibTimeDepCorrectionId(Int_t supModIndex)const
+AliEMCALSuperModuleCalibTimeDepCorrection AliEMCALCalibTimeDepCorrection::GetSuperModuleCalibTimeDepCorrectionId(Int_t supModIndex)const
{
AliEMCALSuperModuleCalibTimeDepCorrection t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
}
//____________________________________________________________________________
-AliEMCALCalibTimeDepCorrection::AliEMCALSuperModuleCalibTimeDepCorrection AliEMCALCalibTimeDepCorrection::GetSuperModuleCalibTimeDepCorrectionNum(Int_t supModIndex)const
+AliEMCALSuperModuleCalibTimeDepCorrection AliEMCALCalibTimeDepCorrection::GetSuperModuleCalibTimeDepCorrectionNum(Int_t supModIndex)const
{
AliEMCALSuperModuleCalibTimeDepCorrection t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
if (!fSuperModuleData)
#include <TArrayF.h>
#include "AliEMCALGeoParams.h"
class TString;
-class TArrayF;
+class TTree;
/*
- Objects of this class read txt file with APD data
- AliEMCALCalibTimeDepCorrection inherits TObject only to use AliLog "functions".
+ Objects of this class contain info on time-dependent corrections
*/
+// ******* internal class definition *************
+// 1 SuperModule's worth of info
+class AliEMCALSuperModuleCalibTimeDepCorrection : public TObject {
+ public:
+ AliEMCALSuperModuleCalibTimeDepCorrection() : TObject(), // just init values
+ fSuperModuleNum(0)
+ {
+ for (int icol=0; icol<AliEMCALGeoParams::fgkEMCALCols; icol++) {
+ for (int irow=0; irow<AliEMCALGeoParams::fgkEMCALRows; irow++) {
+ fCorrection[icol][irow].Reset();
+ }
+ }
+ }
+
+ public:
+ Int_t fSuperModuleNum;
+ TArrayF fCorrection[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows];
+
+ ClassDef(AliEMCALSuperModuleCalibTimeDepCorrection, 1) // help class
+};
+// ******* end of internal class definition *************
+
class AliEMCALCalibTimeDepCorrection : public TObject {
-public:
+ public:
AliEMCALCalibTimeDepCorrection();
// interface methods; getting the whole struct should be more efficient though
- void InitCorrection(Int_t nSM, Int_t nBins, Float_t val=1.0); // assign a certain value to all
+ void InitCorrection(Int_t nSM, Int_t nBins, Float_t val); // assign a certain value to all
// use the methods below with caution: take care that your argument ranges are valid
void SetCorrection(Int_t smIndex, Int_t iCol, Int_t iRow, Int_t iBin, Float_t val=1.0); // assign a certain value to a given bin
Float_t GetCorrection(Int_t smIndex, Int_t iCol, Int_t iRow, Int_t iBin) const; // assign a certain value to a given bin
// Read and Write txt I/O methods are normally not used, but are useful for
// filling the object before it is saved in OCDB
- void ReadCalibTimeDepCorrectionInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
-
- void WriteCalibTimeDepCorrectionInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadTextInfo(Int_t nSM, const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteTextInfo(const TString &txtFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadRootInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void ReadTreeInfo(TTree *treeGlob, TTree *treeCorr, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
+ void WriteRootInfo(const TString &rootFileName, Bool_t swapSides=kFALSE); // info file is for nSm=1 to 12 SuperModules
virtual ~AliEMCALCalibTimeDepCorrection();
- struct AliEMCALSuperModuleCalibTimeDepCorrection {
- Int_t fSuperModuleNum;
- TArrayF fCorrection[AliEMCALGeoParams::fgkEMCALCols][AliEMCALGeoParams::fgkEMCALRows];
- };
-
// pointer to stored info.
Int_t GetNSuperModule() const { return fNSuperModule; };
AliEMCALSuperModuleCalibTimeDepCorrection * GetSuperModuleData() const { return fSuperModuleData; };
Int_t GetNTimeBins() const { return fNTimeBins; } //
Int_t GetTimeBinSize() const { return fTimeBinSize; } //
+ static Int_t GetMaxTimeBins() { return fgkMaxTimeBins; }
+
protected:
Int_t fNSuperModule; // Number of supermodules.
Int_t fNTimeBins; // how many timestamp bins do we have
Int_t fTimeBinSize; // seconds per time-bin
+ static const Int_t fgkMaxTimeBins = 50; // we are not going to have more correction time bins than this for a single runnumber..
+
ClassDef(AliEMCALCalibTimeDepCorrection, 2) //
};