From 5ca852447b1219e62747538898f57c00503a8cfc Mon Sep 17 00:00:00 2001 From: masera Date: Thu, 30 Aug 2007 13:03:39 +0000 Subject: [PATCH] SSD Preprocessor and related test macro. Macro to build calibration objects --- ITS/AliITSPreprocessorSSD.cxx | 133 ++++++++++++++++++++++++++++++++++ ITS/AliITSPreprocessorSSD.h | 30 ++++++++ ITS/ITSrecLinkDef.h | 3 +- ITS/MakeCalibrationSSD.C | 70 ++++++++++++++++++ ITS/TestPreprocessorSSD.C | 50 +++++++++++++ ITS/libITSrec.pkg | 3 +- 6 files changed, 287 insertions(+), 2 deletions(-) create mode 100644 ITS/AliITSPreprocessorSSD.cxx create mode 100644 ITS/AliITSPreprocessorSSD.h create mode 100644 ITS/MakeCalibrationSSD.C create mode 100644 ITS/TestPreprocessorSSD.C diff --git a/ITS/AliITSPreprocessorSSD.cxx b/ITS/AliITSPreprocessorSSD.cxx new file mode 100644 index 00000000000..d32a035c614 --- /dev/null +++ b/ITS/AliITSPreprocessorSSD.cxx @@ -0,0 +1,133 @@ +#include "AliITSPreprocessorSSD.h" + +#include "AliCDBMetaData.h" +#include "AliLog.h" +#include "TFile.h" + +#include +#include + +#include "AliITSRawStreamSSD.h" +#include "AliITSNoiseSSD.h" +#include + + +// +// Author: Enrico Fragiacomo +// Date: 13/10/2006 +// +// SHUTTLE preprocessing class for SSD calibration files + +/* $Id$ */ + +ClassImp(AliITSPreprocessorSSD) + +//______________________________________________________________________________________________ +void AliITSPreprocessorSSD::Initialize(Int_t run, UInt_t startTime, + UInt_t endTime) +{ + + AliPreprocessor::Initialize(run, startTime, endTime); + + Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, + TTimeStamp(startTime).AsString(), + TTimeStamp(endTime).AsString())); + +} + +//______________________________________________________________________________________________ +UInt_t AliITSPreprocessorSSD::Process(TMap* /*dcsAliasMap*/) +{ + + // Note. To be modified: dcsAliasMap is not needed but I can not get rid + // of it unless the base class AliPreprocessor is modified accordingly. + + TObjArray calib_array(1698); + //Float_t noise=0, gain=0; + + TString runType = GetRunType(); + if(runType == "ELECTRONICS_CALIBRATION_RUN") { + + } + else if(runType == "PEDESTAL_RUN") { + + TList* list = GetFileSources(kDAQ, "CALIBRATION"); + if (list && list->GetEntries() > 0) + { + Log("The following sources produced files with the id CALIBRATION"); + list->Print(); + + // create iterator over list of LDCs (provides list of TObjString) + TIter next(list); + TObjString *ok; + + // expect to iterate 3 times (LDC0, LDC1, LDC2) + while ( (ok = (TObjString*) next()) ) { + + TString key = ok->String(); + + TString fileName = GetFile(kDAQ, "CALIBRATION", key.Data()); + if (fileName.Length() > 0) { + + Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); + + TFile *f = new TFile(fileName.Data()); + if(!f || !f->IsOpen()){ + Log("Error opening file!"); + delete list; + return 2; + } + + TObjArray *cal; + f->GetObject("TObjArray;1", cal); + f->Close(); delete f; + + if(!cal) { + Log("File does not contain expected data!"); + delete list; + } + + Int_t nmod = cal->GetEntries(); + + for(Int_t mod=0; modAt(mod); + calib_array.AddAt(calib,calib->GetMod()); + } + + } else { + Log("GetFile error!"); + delete list; + return 3; + } // if filename + } // end iteration over LDCs + + delete list; + } else { + Log("GetFileSources error!"); + if(list) delete list; + return 4; + } // if list + + //Now we have to store the final CDB file + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Enrico Fragiacomo"); + metaData.SetComment("This preprocessor fills the TObjArray of AliITSNoiseSSD"); + + if(!Store("Calib", "NoiseSSD", &calib_array, &metaData, 0, 1)) { + Log("no store"); + return 1; + } + + } // end if noise_run + else { + Log("Nothing to do"); + return 0; + } + + Log("Database updated"); + return 0; // 0 means success + +} + diff --git a/ITS/AliITSPreprocessorSSD.h b/ITS/AliITSPreprocessorSSD.h new file mode 100644 index 00000000000..51a1d1958ba --- /dev/null +++ b/ITS/AliITSPreprocessorSSD.h @@ -0,0 +1,30 @@ +#ifndef ALI_ITS_PREPROCESSOR_SSD_H +#define ALI_ITS_PREPROCESSOR_SSD_H + +#include "AliPreprocessor.h" + +// +// Author: Enrico Fragiacomo +// Date: 13/10/2006 +// +// SHUTTLE preprocessing class for SSD calibration files + +/* $Id$ */ + +class AliITSPreprocessorSSD : public AliPreprocessor +{ + public: + AliITSPreprocessorSSD(AliShuttleInterface* shuttle): + AliPreprocessor("SSD",shuttle) {} + virtual ~AliITSPreprocessorSSD() {;} + enum {kDDLperLDC = 4}; // number of DDLs in LDC + + protected: + virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime); + virtual UInt_t Process(TMap* dcsAliasMap); + + private: + ClassDef(AliITSPreprocessorSSD, 0); +}; + +#endif diff --git a/ITS/ITSrecLinkDef.h b/ITS/ITSrecLinkDef.h index b61b11f2671..074fdc5ff93 100644 --- a/ITS/ITSrecLinkDef.h +++ b/ITS/ITSrecLinkDef.h @@ -83,7 +83,7 @@ #pragma link C++ class AliITSBeamTestDigitizer+; //multiplicity #pragma link C++ class AliITSMultReconstructor+; -// SPD and SDD preprocessing +// SPD, SDD and SSD preprocessing #pragma link C++ class AliITSBadChannelsAuxSPD+; #pragma link C++ class AliITSBadChannelsSPD+; #pragma link C++ class AliITSChannelSPD+; @@ -109,5 +109,6 @@ #pragma link C++ class AliITSOnlineSDDBTP+; #pragma link C++ class AliITSOnlineSDDCMN+; #pragma link C++ class AliITSOnlineSDDInjectors+; +#pragma link C++ class AliITSPreprocessorSSD+; #endif diff --git a/ITS/MakeCalibrationSSD.C b/ITS/MakeCalibrationSSD.C new file mode 100644 index 00000000000..19fbee82ba0 --- /dev/null +++ b/ITS/MakeCalibrationSSD.C @@ -0,0 +1,70 @@ +void MakeCalibrationSSD(Int_t firstRun=0,Int_t lastRun=9999999 ){ + + if(!AliCDBManager::Instance()->IsDefaultStorageSet()) { + AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/"); + } + + AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object + md1->SetObjectClassName("AliITSCalibration"); + md1->SetResponsible("Enrico Fragiacomo"); + md1->SetBeamPeriod(0); + md1->SetAliRootVersion("head 23/08/07"); //root version + + AliCDBId idNoiseSSD("ITS/Calib/NoiseSSD",firstRun, lastRun); + AliCDBId idGainSSD("ITS/Calib/GainSSD",firstRun, lastRun); + AliCDBId idBadChannelsSSD("ITS/Calib/BadChannelsSSD",firstRun, lastRun); + + TObjArray noiseSSD(1698); + TObjArray gainSSD(1698); + TObjArray badchannelsSSD(1698); + + noiseSSD.SetOwner(kFALSE); + gainSSD.SetOwner(kFALSE); + badchannelsSSD.SetOwner(kFALSE); + + Double_t noiseP[768]; + Double_t noiseN[768]; + + Double_t gainP[768]; + Double_t gainN[768]; + + // loop over SSD modules + for(Int_t i=0;i<1698;i++){ + + AliITSNoiseSSD* noise = new AliITSNoiseSSD(); + AliITSGainSSD* gain = new AliITSGainSSD(); + AliITSBadChannelsSSD* badchannels = new AliITSBadChannelsSSD(); + + // 768 strips on P- and N-side + noise->SetNNoiseP(768); + noise->SetNNoiseN(768); + gain->SetNGainP(768); + gain->SetNGainN(768); + badchannels->SetNBadPChannelsList(10); + badchannels->SetNBadNChannelsList(10); + + // take a reasonable averaged value for the noise on P- and N-side strips + for(Int_t j=0; j<768; j++) { + noise->AddNoiseP(j,2.); + gain->AddGainP(j,1.); + noise->AddNoiseN(j,4.); + gain->AddGainN(j,1.); + } + + // 10 random strips per module tagged as "bad" + for(Int_t j=0; j<10; j++) { + badchannels->AddBadPChannel(j,gRandom->Uniform(0,767)); + badchannels->AddBadNChannel(j,gRandom->Uniform(0,767)); + } + + noiseSSD.Add(noise); + gainSSD.Add(gain); + badchannelsSSD.Add(badchannels); + + } + + AliCDBManager::Instance()->GetDefaultStorage()->Put(&noiseSSD, idNoiseSSD, md1); + AliCDBManager::Instance()->GetDefaultStorage()->Put(&gainSSD, idGainSSD, md1); + AliCDBManager::Instance()->GetDefaultStorage()->Put(&badchannelsSSD, idBadChannelsSSD, md1); + +} diff --git a/ITS/TestPreprocessorSSD.C b/ITS/TestPreprocessorSSD.C new file mode 100644 index 00000000000..e7ae53da603 --- /dev/null +++ b/ITS/TestPreprocessorSSD.C @@ -0,0 +1,50 @@ +/* $Id$ */ + +// This class runs the test preprocessor +// It uses AliTestShuttle to simulate a full Shuttle process + +void TestPreprocessorSSD() +{ + // load library + gSystem->Load("libTestShuttle.so"); + + // initialize location of CDB + // AliCDBManager::Instance()->SetDefaultStorage("local://${ALICE_ROOT}/SHUTTLE/TestShuttle/TestCDB"); + + AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); + AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); + + printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); + printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); + + // create AliTestShuttle instance + // The parameters are run, startTime, endTime + + AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1); + shuttle->SetInputRunType("PEDESTAL_RUN"); + + shuttle->AddInputFile(AliTestShuttle::kDAQ, "SSD", "CALIBRATION", "LDC0", "ITSSSDda_LDC0.root"); + shuttle->AddInputFile(AliTestShuttle::kDAQ, "SSD", "CALIBRATION", "LDC1", "ITSSSDda_LDC1.root"); + shuttle->AddInputFile(AliTestShuttle::kDAQ, "SSD", "CALIBRATION", "LDC2", "ITSSSDda_LDC2.root"); + + // TODO(3) + // Create the preprocessor that should be tested, it registers itself automatically to the shuttle + AliPreprocessor *pp = new AliITSPreprocessorSSD(shuttle); + + // Test the preprocessor + shuttle->Process(); + + + // + // Check the file which should have been created + AliCDBManager::Instance()->SetDefaultStorage("local://${ALICE_ROOT}/SHUTTLE/TestShuttle/TestCDB"); + AliCDBEntry* entry = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD", 7); + if (!entry) + { + printf("The file is not there. Something went wrong.\n"); + return; + } + + +} + diff --git a/ITS/libITSrec.pkg b/ITS/libITSrec.pkg index ef15729de1d..f4262da28d2 100644 --- a/ITS/libITSrec.pkg +++ b/ITS/libITSrec.pkg @@ -75,7 +75,8 @@ SRCS = AliITSDetTypeRec.cxx \ AliITSOnlineSDDTP.cxx \ AliITSOnlineSDDBTP.cxx \ AliITSOnlineSDDInjectors.cxx \ - AliITSOnlineSDDCMN.cxx + AliITSOnlineSDDCMN.cxx \ + AliITSPreprocessorSSD.cxx HDRS:= $(SRCS:.cxx=.h) -- 2.39.3