Updated AliZDCPreprocessor class
authorcoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jul 2008 17:23:51 +0000 (17:23 +0000)
committercoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Jul 2008 17:23:51 +0000 (17:23 +0000)
ZDC/AliZDCPreprocessor.cxx
ZDC/AliZDCPreprocessor.h
ZDC/TestZDCPreprocessor.C

index 8e93a70..7e48fce 100644 (file)
@@ -38,7 +38,9 @@ AliZDCPreprocessor::AliZDCPreprocessor(AliShuttleInterface* shuttle) :
   AddRunType("STANDALONE_PEDESTAL");
   AddRunType("STANDALONE_LASER");
   AddRunType("STANDALONE_EMD");
-  AddRunType("ALL");
+  AddRunType("STANDALONE_COSMIC");
+  AddRunType("STANDALONE_BC");
+  AddRunType("PHYSICS");
 }
 
 
@@ -69,6 +71,95 @@ void AliZDCPreprocessor::Initialize(Int_t run, UInt_t startTime,
 }
 
 //______________________________________________________________________________________________
+UInt_t AliZDCPreprocessor::ProcessChMap(TString runType)
+{ 
+  // Writing channel map in the OCDB
+  TList* daqSource;
+  if(runType.CompareTo("STANDALONE_PEDESTAL"))
+    daqSource = GetFileSources(kDAQ, "PEDESTALS");
+  else if(runType.CompareTo("STANDALONE_LASER"))
+    daqSource = GetFileSources(kDAQ, "LASER");
+  else if(runType.CompareTo("STANDALONE_EMD"))
+    daqSource = GetFileSources(kDAQ, "EMDCALIB");
+  else if(runType.CompareTo("STANDALONE_COSMIC"))
+    daqSource = GetFileSources(kDAQ, "COSMICS");
+  else if(runType.CompareTo("STANDALONE_BC"))
+    daqSource = GetFileSources(kDAQ, "BC");
+  else if(runType.CompareTo("PHYSICS"))
+    daqSource = GetFileSources(kDAQ, "PHYSICS");
+  
+  if(!daqSource){
+    AliError(Form("No sources run %d for run type %s!", fRun, runType));
+    return 1;
+  }
+  Log("\t List of sources "); daqSource->Print();
+  //
+  TIter iter(daqSource);
+  TObjString* source = 0;
+  Int_t isou=0;
+  while((source = dynamic_cast<TObjString*> (iter.Next()))){
+     Log(Form("\n\t Getting file #%d\n",++isou));
+     TString fileName;
+     if(runType.CompareTo("STANDALONE_PEDESTAL"))
+      fileName = GetFile(kDAQ, "PEDESTALS", source->GetName());
+     else if(runType.CompareTo("STANDALONE_LASER"))
+      fileName = GetFile(kDAQ, "LASER", source->GetName());
+     else if(runType.CompareTo("STANDALONE_EMD"))
+      fileName = GetFile(kDAQ, "EMDCALIB", source->GetName());
+     else if(runType.CompareTo("STANDALONE_COSMIC"))
+      fileName = GetFile(kDAQ, "COSMICS", source->GetName());
+     else if(runType.CompareTo("STANDALONE_BC"))
+      fileName = GetFile(kDAQ, "BC", source->GetName());
+     else if(runType.CompareTo("PHYSICS"))
+      fileName = GetFile(kDAQ, "PHYSICS", source->GetName());
+
+     if(fileName.Length() <= 0){
+       Log(Form("No file from source %s!", source->GetName()));
+       return 1;
+     }
+     // --- Initializing pedestal calibration object
+     AliZDCChMap *mapCalib = new AliZDCChMap("ZDC");
+     // --- Reading file with pedestal calibration data
+     const char* fname = fileName.Data();
+     if(fname){
+       FILE *file;
+       if((file = fopen(fname,"r")) == NULL){
+        printf("Cannot open file %s \n",fname);
+         return 1;
+       }
+       Log(Form("File %s connected to process data for ADC mapping", fname));
+       //
+       Int_t chMap[48][6]; 
+       for(Int_t j=0; j<48; j++){        
+           for(Int_t k=0; k<6; k++){
+             fscanf(file,"%d",&chMap[j][k]);
+           }
+          mapCalib->SetADCModule(j,chMap[j][1]);
+          mapCalib->SetADCChannel(j,chMap[j][2]);
+          mapCalib->SetDetector(j,chMap[j][4]);
+          mapCalib->SetSector(j,chMap[j][5]);
+       }
+       fclose(file);
+     }
+     else{
+       Log(Form("File %s not found", fname));
+       return 1;
+     }
+     //mapCalib->Print("");
+    // 
+    AliCDBMetaData metaData;
+    metaData.SetBeamPeriod(0);
+    metaData.SetResponsible("Chiara Oppedisano");
+    metaData.SetComment("Filling AliZDCChMap object");  
+    //
+    Int_t res = Store("Calib","ChMap",mapCalib, &metaData, 0, 1);
+    return res;
+  }
+  delete daqSource; daqSource=0;
+
+}
+
+//______________________________________________________________________________________________
 UInt_t AliZDCPreprocessor::Process(TMap* dcsAliasMap)
 {
   // *************** From DCS ******************
@@ -124,65 +215,6 @@ TString runType = GetRunType();
 printf("\n\t AliZDCPreprocessor -> beamType %s\n",beamType);
 printf("\t AliZDCPreprocessor -> runType  %s\n\n",runType.Data());
 
-// ******************************************
-//   ZDC ADC channel mapping
-// ******************************************
-TList* daqAllSources = GetFileSources(kDAQ, "ALL");
-if(!daqAllSources){
-  AliError(Form("No sources run %d !", fRun));
-  return 1;
-}
-Log("\t List of sources "); daqAllSources->Print();
-//
-TIter iterAll(daqAllSources);
-TObjString* sourceAll = 0;
-Int_t iAll=0;
-while((sourceAll = dynamic_cast<TObjString*> (iterAll.Next()))){
-     Log(Form("\n\t Getting file #%d\n",++iAll));
-     TString fileName = GetFile(kDAQ, "ALL", sourceAll->GetName());
-     if(fileName.Length() <= 0){
-       Log(Form("No file from source %s!", sourceAll->GetName()));
-       return 1;
-     }
-     // --- Initializing pedestal calibration object
-     AliZDCChMap *mapCalib = new AliZDCChMap("ZDC");
-     // --- Reading file with pedestal calibration data
-     const char* fname = fileName.Data();
-     if(fname){
-       FILE *fileAll;
-       if((fileAll = fopen(fname,"r")) == NULL){
-        printf("Cannot open file %s \n",fname);
-         return 1;
-       }
-       Log(Form("File %s connected to process data for ADC mapping", fname));
-       //
-       Int_t chMap[48][6]; 
-       for(Int_t j=0; j<48; j++){        
-           for(Int_t k=0; k<6; k++){
-             fscanf(fileAll,"%d",&chMap[j][k]);
-           }
-          mapCalib->SetADCModule(j,chMap[j][1]);
-          mapCalib->SetADCChannel(j,chMap[j][2]);
-          mapCalib->SetDetector(j,chMap[j][4]);
-          mapCalib->SetSector(j,chMap[j][5]);
-       }
-       fclose(fileAll);
-     }
-     else{
-       Log(Form("File %s not found", fname));
-       return 1;
-     }
-     //mapCalib->Print("");
-    // 
-    AliCDBMetaData metaData;
-    metaData.SetBeamPeriod(0);
-    metaData.SetResponsible("Chiara Oppedisano");
-    metaData.SetComment("Filling AliZDCChMap object");  
-    //
-    resChMap = Store("Calib","ChMap",mapCalib, &metaData, 0, 1);
-}
-
-// 
 if(strcmp(beamType,"p-p")==0){
 
    // --- Initializing pedestal calibration object
@@ -204,6 +236,10 @@ if(strcmp(beamType,"p-p")==0){
    //
    resECal = Store("Calib","EMDCalib",eCalib, &metaData, 0, 1);
 }
+// ******************************************
+//   ZDC ADC channel mapping
+// ******************************************
+resChMap = ProcessChMap(runType);
 // 
 // *****************************************************
 // [a] PEDESTALS -> Pedestal subtraction
@@ -420,10 +456,7 @@ else if(runType=="STANDALONE_EMD"){
       resECal = Store("Calib","EMDCalib",eCalib, &metaData, 0, 1);
   }
 }
-else {
-  Log(Form("Nothing to do: run type is %s", runType.Data()));
-  return 0;
-} 
+
 
   // note that the parameters are returned as character strings!
   const char* nEvents = GetRunParameter("totalEvents");
index 34c6c45..bc12bfa 100644 (file)
@@ -24,6 +24,7 @@ class AliZDCPreprocessor : public AliPreprocessor
   protected:
     virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
     virtual UInt_t Process(TMap* dcsAliasMap);
+    virtual UInt_t ProcessChMap(TString runType);
     AliZDCPreprocessor(const AliZDCPreprocessor&);
     AliZDCPreprocessor& operator=(const AliZDCPreprocessor&);
 
index 693c1d0..1098633 100644 (file)
@@ -61,11 +61,20 @@ void TestZDCPreprocessor(Int_t obj=0)
   // Three files originating from different LDCs but with the same id are also added
   // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
   // the "online" naming convention ALICE-INT-2003-039.
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "ALL", "LDC0", "ZDCChMapping.dat");
   //
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALS", "LDC0", "ZDCPedestal.dat");
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "LASER",     "LDC0", "ZDCLaserCalib.dat");
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB",  "LDC0", "ZDCEMDCalib.dat");
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALS", "LDC0", "ZDCChMapping.dat");
+  //
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "LASER", "LDC0", "ZDCLaserCalib.dat");
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "LASER", "LDC0", "ZDCChMapping.dat");
+  //
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB", "LDC0", "ZDCEMDCalib.dat");
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB", "LDC0", "ZDCChMapping.dat");
+  //
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PHYSICS", "LDC0", "ZDCChMapping.dat");
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "COSMICS", "LDC0", "ZDCChMapping.dat");
+  //
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "BC", "LDC0", "ZDCChMapping.dat");
 
   // TODO(3)
   //
@@ -75,6 +84,9 @@ void TestZDCPreprocessor(Int_t obj=0)
   if(obj==1)      shuttle->SetInputRunType("STANDALONE_PEDESTAL");
   else if(obj==2) shuttle->SetInputRunType("STANDALONE_LASER");
   else if(obj==3) shuttle->SetInputRunType("STANDALONE_EMD");
+  else if(obj==4) shuttle->SetInputRunType("STANDALONE_COSMIC");
+  else if(obj==5) shuttle->SetInputRunType("STANDALONE_BC");
+  else if(obj==6) shuttle->SetInputRunType("PHYSICS");
 
   // TODO(4)
   //
@@ -82,8 +94,8 @@ void TestZDCPreprocessor(Int_t obj=0)
   // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
   // using GetRunParameter function.
   // In real life the parameters will be retrieved automatically from the run logbook;
-  shuttle->AddInputRunParameter("beamType", "Pb-Pb");
-  //shuttle->AddInputRunParameter("beamType", "p-p");
+  //shuttle->AddInputRunParameter("beamType", "Pb-Pb");
+  shuttle->AddInputRunParameter("beamType", "p-p");
   shuttle->AddInputRunParameter("totalEvents", "1000");
   shuttle->AddInputRunParameter("NumberOfGDCs", "1");