/// This class provides ITS SSD data handling
/// used by DA.
// Author: Oleksandr Borysov
-// Date: 20/04/2008
+// Date: 19/05/2008
///////////////////////////////////////////////////////////////////////////////
#include <Riostream.h>
const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModules = 1698; // Number of SSD modules in ITS
const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerDdl = 108; // Number of SSD modules in DDL
const Int_t AliITSHandleDaSSD::fgkNumberOfSSDModulesPerSlot = 12; // Number of SSD modules in Slot
+const Int_t AliITSHandleDaSSD::fgkNumberOfSSDDDLs = 16; // Number of SSD modules in Slot
const Float_t AliITSHandleDaSSD::fgkPedestalThresholdFactor = 3.0; // Defalt value for fPedestalThresholdFactor
const Float_t AliITSHandleDaSSD::fgkCmThresholdFactor = 3.0; // Defalt value for fCmThresholdFactor
fModIndRead(0),
fModIndex(NULL),
fNumberOfEvents(0),
+ fStaticBadChannelsMap(NULL),
+ fDDLModuleMap(NULL),
fLdcId(0),
fRunId(0),
fPedestalThresholdFactor(fgkPedestalThresholdFactor),
fModIndRead(0),
fModIndex(NULL),
fNumberOfEvents(0),
+ fStaticBadChannelsMap(NULL),
+ fDDLModuleMap(NULL),
fLdcId(0),
fRunId(0),
fPedestalThresholdFactor(fgkPedestalThresholdFactor) ,
fModIndRead(ssdadldc.fModIndRead),
fModIndex(NULL),
fNumberOfEvents(ssdadldc.fNumberOfEvents),
+ fStaticBadChannelsMap(ssdadldc.fStaticBadChannelsMap),
+ fDDLModuleMap(ssdadldc.fDDLModuleMap),
fLdcId(ssdadldc.fLdcId),
fRunId(ssdadldc.fRunId),
fPedestalThresholdFactor(ssdadldc.fPedestalThresholdFactor),
delete [] fModules;
}
if (fModIndex) delete [] fModIndex;
+ if (fStaticBadChannelsMap) { fStaticBadChannelsMap->Delete(); delete fStaticBadChannelsMap; }
+ if (fDDLModuleMap) delete [] fDDLModuleMap;
}
fModules = NULL;
}
if (fModIndex) { delete [] fModIndex; fModIndex = NULL; }
+/*
+ if (fStaticBadChannelsMap) {
+ fStaticBadChannelsMap->Delete();
+ delete fStaticBadChannelsMap;
+ fStaticBadChannelsMap = NULL;
+ }
+ if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL; }
+*/
fRawDataFileName = NULL;
fModIndProcessed = fModIndRead = 0;
fNumberOfEvents = 0;
+//______________________________________________________________________________
+Bool_t AliITSHandleDaSSD::ReadStaticBadChannelsMap(const Char_t *filename)
+{
+// Reads Static Bad Channels Map from the file
+ TFile *bcfile;
+ if (!filename) {
+ AliWarning("No file name is specified for Static Bad Channels Map!");
+ return kFALSE;
+ }
+ bcfile = new TFile(filename, "READ");
+ if (bcfile->IsZombie()) {
+ AliWarning(Form("Error reading file %s with Static Bad Channels Map!", filename));
+ return kFALSE;
+ }
+ bcfile->GetObject("BadChannels;1", fStaticBadChannelsMap);
+ if (!fStaticBadChannelsMap) {
+ AliWarning("Error fStaticBadChannelsMap == NULL!");
+ bcfile->Close();
+ delete bcfile;
+ return kFALSE;
+ }
+ bcfile->Close();
+ delete bcfile;
+ return kTRUE;
+}
+
+
+
+Bool_t AliITSHandleDaSSD::ReadDDLModuleMap(const Char_t *filename)
+{
+// Reads the SSD DDL Map from the file
+ ifstream ddlmfile;
+ AliRawReaderDate *rwr = NULL;
+ AliITSRawStreamSSD *rsm = NULL;
+ void *event = NULL;
+ if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL;}
+ fDDLModuleMap = new (nothrow) Int_t [fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl];
+ if (!fDDLModuleMap) {
+ AliWarning("Error allocation memory for DDL Map!");
+ return kFALSE;
+ }
+ if (!filename) {
+ AliWarning("No file name is specified for SSD DDL Map, using the one from AliITSRawStreamSSD!");
+ rwr = new AliRawReaderDate(event);
+ rsm = new AliITSRawStreamSSD(rwr);
+ rsm->Setv11HybridDDLMapping();
+ for (Int_t ddli = 0; ddli < fgkNumberOfSSDDDLs; ddli++)
+ for (Int_t mi = 0; mi < fgkNumberOfSSDModulesPerDdl; mi++)
+ fDDLModuleMap[(ddli * fgkNumberOfSSDModulesPerDdl + mi)] = rsm->GetModuleNumber(ddli, mi);
+ if (rsm) delete rsm;
+ if (rwr) delete rwr;
+ return kTRUE;
+ }
+ ddlmfile.open(filename, ios::in);
+ if (!ddlmfile.is_open()) {
+ AliWarning(Form("Error reading file %s with SSD DDL Map!", filename));
+ if (fDDLModuleMap) { delete [] fDDLModuleMap; fDDLModuleMap = NULL;}
+ return kFALSE;
+ }
+ Int_t ind = 0;
+ while((!ddlmfile.eof()) && (ind < (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl))) {
+ ddlmfile >> fDDLModuleMap[ind++];
+ }
+ if (ind != (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl))
+ AliWarning(Form("Only %i (< %i) entries were read from DDL Map!", ind, (fgkNumberOfSSDDDLs * fgkNumberOfSSDModulesPerDdl)));
+ ddlmfile.close();
+ return kTRUE;
+}
+
+
+
//______________________________________________________________________________
Int_t AliITSHandleDaSSD::ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber)
{
AliError("AliITSHandleDaSSD: Error ReadModuleRawData: no structure was allocated for data");
return 0;
}
+ if (!fDDLModuleMap) if (!ReadDDLModuleMap()) AliWarning("DDL map is not defined, ModuleID will be set to 0!");
stream = new AliITSRawStreamSSD(rawreaderdate);
stream->Setv11HybridDDLMapping();
rawreaderdate->SelectEvents(-1);
if (((modpos > 0) && (modpos < fModIndRead)) || ((modpos < 0) && (modind == modulesnumber))) continue;
if ((modpos < 0) && (modind < modulesnumber)) {
module = new AliITSModuleDaSSD(AliITSModuleDaSSD::GetStripsPerModuleConst());
- Int_t mddli = ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2));
- if ((ddlID < AliITSRawStreamSSD::kDDLsNumber) && (mddli < AliITSRawStreamSSD::kModulesPerDDL)) {
- mddli = stream->GetModuleNumber(ddlID, mddli);
- }
- else {
- AliWarning(Form("Module index = %d or ddlID = %d is out of range -1 is rturned", ddlID, mddli));
- mddli = 0;
- }
+ Int_t mddli;
+ if (fDDLModuleMap) mddli = RetrieveModuleId(ddlID, ad, adc);
+ else mddli = 0;
if (!module->SetModuleIdData (ddlID, ad, adc, mddli)) return 0;
// if (!module->SetModuleIdData (ddlID, ad, adc, RetrieveModuleId(ddlID, ad, adc))) return 0;
module->SetModuleRorcId (equipid, equiptype);
Short_t AliITSHandleDaSSD::RetrieveModuleId(const UChar_t ddlID, const UChar_t ad, const UChar_t adc) const
{
// Retrieve ModuleId from the DDL map which is defined in AliITSRawStreamSSD class
-
- Int_t mddli = (ad - 1) * 12 + ((adc<6) ? adc : (adc-2));
- if ((ddlID < AliITSRawStreamSSD::kDDLsNumber) && (mddli < AliITSRawStreamSSD::kModulesPerDDL)) {
- mddli = AliITSRawStreamSSD::GetModuleNumber(ddlID, mddli);
- if (mddli > SHRT_MAX) return SHRT_MAX;
- else return (Short_t)mddli;
- }
+ if (!fDDLModuleMap) return 0;
+ Int_t mddli = ((ad - 1) * fgkNumberOfSSDModulesPerSlot) + (adc < 6 ? adc : (adc - 2));
+ if ((ddlID < fgkNumberOfSSDDDLs) && (mddli < fgkNumberOfSSDModulesPerDdl)) {
+ mddli = fDDLModuleMap[ddlID * fgkNumberOfSSDModulesPerDdl + mddli];
+ }
else {
- AliWarning(Form("Module index = %d or ddlID = %d is out of range -1 is rturned", ddlID, mddli));
- return -1;
+ AliWarning(Form("Module index = %d or ddlID = %d is out of range 0 is rturned", ddlID, mddli));
+ mddli = 0;
}
+ if (mddli > SHRT_MAX) return SHRT_MAX;
+ else return (Short_t)mddli;
}
}
fileRun->WriteTObject(ldcn);
fileRun->WriteTObject(ldcp);
- fileRun->WriteTObject(ldcbc);
+ if (fStaticBadChannelsMap) fileRun->WriteTObject(fStaticBadChannelsMap);
+ else fileRun->WriteTObject(ldcbc);
fileRun->Close();
ldcn->Delete();
delete fileRun;
for (UShort_t modind = 0; modind < fNumberOfModules; modind++) fModules[modind]->SetModuleId(modind + 1080);
return kTRUE;
}
-
/// This class provides ITS SSD data handling
/// used by DA.
// Author: Oleksandr Borysov
-// Date: 20/04/2008
+// Date: 19/05/2008
///////////////////////////////////////////////////////////////////////////////
class TObjArray;
void SetModIndRead (Int_t mr) {fModIndRead = mr;}
Bool_t SetNumberOfModules (const Int_t numberofmodules);
Bool_t SetModule(AliITSModuleDaSSD *const module, const Int_t index);
+ virtual Bool_t ReadStaticBadChannelsMap(const Char_t *filename = NULL);
+ virtual Bool_t ReadDDLModuleMap(const Char_t *filename = NULL);
Int_t ReadCalibrationDataFile (char* fileName, const Long_t eventsnumber);
Int_t ReadModuleRawData (const Int_t modulesnumber);
static Int_t GetNumberOfSSDModulesConst() { return fgkNumberOfSSDModules; }
protected :
+
static const Int_t fgkNumberOfSSDModules ; // Number of SSD modules in ITS
static const Int_t fgkNumberOfSSDModulesPerDdl; // Number of SSD modules in DDL
static const Int_t fgkNumberOfSSDModulesPerSlot; // Number of SSD modules in Slot
+ static const Int_t fgkNumberOfSSDDDLs; // Number of DDLs in SSD
static const Float_t fgkPedestalThresholdFactor; // Defalt value for fPedestalThresholdFactor
static const Float_t fgkCmThresholdFactor; // Defalt value for fCmThresholdFactor
-
+
Char_t *fRawDataFileName; // Name of the file with raw data
Int_t fNumberOfModules; // number of AliITSModuleDaSSD to allocate
AliITSModuleDaSSD **fModules; //[fNumberOfModules] array of pointer on AliITSModuleDaSSD objects (1698 SSD Modules)
Int_t fModIndRead; //! index of the last module in fModules array with adc data present (read)
Int_t *fModIndex; //! index array for fModules
Long_t fNumberOfEvents; // Number of physics or calibration events in raw data file fRawDataFileName
+
+ TObjArray *fStaticBadChannelsMap; // Static bad channels map read from the file
+ Int_t *fDDLModuleMap; //! DDL map
UInt_t fLdcId; // LDC number, read from header
UInt_t fRunId; // Run number, read from header
private :
Bool_t SignalOutOfRange (const Short_t signal) const { return (signal >= AliITSChannelDaSSD::GetOverflowConst()); }
- ClassDef(AliITSHandleDaSSD, 4)
+ ClassDef(AliITSHandleDaSSD, 5)
};
#endif
-
- Run Type:
- DA Type: LDC
- Number of events needed: >=500
-- Input Files: ssdpeddaconfig, raw_data_file_on_LDC
+- Input Files: raw_data_file_on_LDC, ssdddlmap.txt, badchannels.root
- Output Files: ./ssddaldc_<LDCID>.root, FXS_name=ITSSSDda_<LDCID>.root
local files are persistent over runs: data source
- Trigger types used:
int main( int argc, char** argv )
{
AliITSHandleDaSSD *ssddaldc;
- TString feefname, fcdbsave;
+ TString feefname, fcdbsave, lfname;
Int_t status;
Char_t *dafname = NULL;
+ const Char_t *bcfname = "badchannels.root";
+ const Char_t *ddlmfname = "ssdddlmap.txt";
gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
}
char *datafilename = argv[1];
-
ssddaldc = new AliITSHandleDaSSD(datafilename);
if (ssddaldc->IsZombie()) return -1;
+
+ lfname.Form("./%s", bcfname);
+ status = daqDA_DB_getFile(bcfname, lfname.Data());
+ if (!status) {
+ if (!ssddaldc->ReadStaticBadChannelsMap(lfname.Data())) cerr << "Error reading static bad channels map " << lfname.Data() << " !\n";
+ } else fprintf(stderr, "Failed to import file %s from the detector db: %d, %s \n", bcfname, status, lfname.Data());
+
+ lfname.Form("./%s", ddlmfname);
+ status = daqDA_DB_getFile(ddlmfname, lfname.Data());
+ if (!status) {
+ if (!ssddaldc->ReadDDLModuleMap(lfname.Data())) cerr << "Error reading DDL map from file " << lfname.Data() << " !\n";
+ } else {
+ fprintf(stderr, "Failed to import file %s from the detector db: %d, %s \n", bcfname, status, lfname.Data());
+ if (!ssddaldc->ReadDDLModuleMap()) cerr << "Failed to load the DDL map from AliITSRawStreamSSD!\n";
+ }
+
if (!ssddaldc->ProcessRawData())
{
cerr << "Error !ssddaldc->ProcessRawData()" << endl;
fcdbsave.Form("ssddaldc_%i.root", ssddaldc->GetLdcId());
status = daqDA_DB_storeFile(feefname.Data(), fcdbsave.Data());
if (status) fprintf(stderr, "Failed to export file %s to the detector db: %d, %s \n", feefname.Data(), status, fcdbsave.Data());
- fcdbsave.Form("ssddaldc_%i_%i.root", ssddaldc->GetLdcId(), ssddaldc->GetRunId());
- status = daqDA_DB_storeFile(feefname.Data(), fcdbsave.Data());
- if (status) fprintf(stderr, "Failed to export file %s to the detector db: %d, %s \n", feefname.Data(), status, fcdbsave.Data());
delete ssddaldc;
daqDA_progressReport(100);