]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
SSD Preprocessor and related test macro. Macro to build calibration objects
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 30 Aug 2007 13:03:39 +0000 (13:03 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 30 Aug 2007 13:03:39 +0000 (13:03 +0000)
ITS/AliITSPreprocessorSSD.cxx [new file with mode: 0644]
ITS/AliITSPreprocessorSSD.h [new file with mode: 0644]
ITS/ITSrecLinkDef.h
ITS/MakeCalibrationSSD.C [new file with mode: 0644]
ITS/TestPreprocessorSSD.C [new file with mode: 0644]
ITS/libITSrec.pkg

diff --git a/ITS/AliITSPreprocessorSSD.cxx b/ITS/AliITSPreprocessorSSD.cxx
new file mode 100644 (file)
index 0000000..d32a035
--- /dev/null
@@ -0,0 +1,133 @@
+#include "AliITSPreprocessorSSD.h"
+
+#include "AliCDBMetaData.h"
+#include "AliLog.h"
+#include "TFile.h"
+
+#include <TTimeStamp.h>
+#include <TObjString.h>
+
+#include "AliITSRawStreamSSD.h"
+#include "AliITSNoiseSSD.h"
+#include <Riostream.h>
+
+
+//
+// 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; mod<nmod; mod++) {
+
+             AliITSNoiseSSD *calib = (AliITSNoiseSSD*) cal->At(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 (file)
index 0000000..51a1d19
--- /dev/null
@@ -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
index b61b11f2671217f12bca483c701694c5c3379f6d..074fdc5ff93f14b83c5e28632111845cce0f5537 100644 (file)
@@ -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+;
 #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 (file)
index 0000000..19fbee8
--- /dev/null
@@ -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 (file)
index 0000000..e7ae53d
--- /dev/null
@@ -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;
+  }
+  
+
+}
+
index ef15729de1db99d92c762fe53dd76e62047438c8..f4262da28d2dc8081537faa2a0d1dbf7a184139b 100644 (file)
@@ -75,7 +75,8 @@ SRCS =        AliITSDetTypeRec.cxx \
                AliITSOnlineSDDTP.cxx \
                AliITSOnlineSDDBTP.cxx \
                AliITSOnlineSDDInjectors.cxx \
-                AliITSOnlineSDDCMN.cxx 
+                AliITSOnlineSDDCMN.cxx \
+               AliITSPreprocessorSSD.cxx 
 
 HDRS:=  $(SRCS:.cxx=.h)