]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Calibratio file sources machines are now not hardcoded but retreived from shuttle
authorgustavo <gustavo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Jan 2007 16:57:14 +0000 (16:57 +0000)
committergustavo <gustavo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Jan 2007 16:57:14 +0000 (16:57 +0000)
EMCAL/AliEMCALPreprocessor.cxx

index 752c90259f363b71cf79cbda7452e7fe0888aad9..501f1a1039b7f550c143ce6c0bfee326b2e417a9 100644 (file)
@@ -17,6 +17,9 @@
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.3  2006/12/20 10:53:28  gustavo
+ * Change const char * by TString, change AliInfos per AliPreprocessor::Log or AliDebug
+ *
  * Revision 1.2  2006/12/12 17:16:09  gustavo
  * Detector name hardcoded in Preprocesor with new detector name notation (3 letters). New way to take reference histogram to avoid problems in case of low number of entries or no existing histogram. Change return 0 by return 1
  *
@@ -42,6 +45,7 @@
 #include "TKey.h"
 #include "TList.h"
 #include "TString.h"
+#include "TObjString.h"
 
 //AliRoot
 #include "AliEMCALPreprocessor.h"
@@ -69,92 +73,111 @@ AliPreprocessor("EMC",shuttle)
 UInt_t AliEMCALPreprocessor::Process(TMap* /*valueSet*/)
 {
   // process data retrieved by the Shuttle
-
+  
   // The fileName with the histograms which have been produced by
   // AliEMCALCalibHistoProducer.
   // It is a responsibility of the SHUTTLE framework to form the fileName
-
-  TString  fileName = GetFile(kDAQ, "AMPLITUDES", "GDC");
-  Log(Form("Got filename: %s",fileName.Data()));
-
-  TFile f(fileName);
-
-  if(!f.IsOpen()) {
-    Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
-    return 0;
-  }
-
-  const Int_t nMod=12; // 1:5 modules
-  const Int_t nCol=48; //1:56 columns in each module
-  Int_t nRow=24; //1:64 rows in each module
-  const Int_t nRowHalfSM = 12; //Supermodules 11 and 12 are half supermodules
-
-  Double_t coeff;
-  char hnam[80];
-  TH1F* histo=0;
-
-
-  //Get reference histogram
-  TList * keylist = f.GetListOfKeys();
-  Int_t nkeys   = f.GetNkeys();
-  Bool_t ok = kFALSE;
-  TKey  *key;
-  TString refHistoName= "";
-  Int_t ikey = 0;
-  Int_t counter = 0;
-  TH1F* hRef = new TH1F();
   
-  //Check if the file contains any histogram
-  if(nkeys< 2){
-    Log(Form("Not enough histograms for calibration, nhist = %d",nkeys));
-    return 1;
-  }
+  AliEMCALCalibData calibData;
   
-  while(!ok){
-    ikey = gRandom->Integer(nkeys);
-    key = (TKey*)keylist->At(ikey);
-    refHistoName = key->GetName();
-    hRef = (TH1F*)f.Get(refHistoName);
-    counter++;
-    // Check if the reference has too little statistics and 
-    // if the histogram has the correct name (2 kinds, mod#col#row for 
-    // reference here, and mod#, see AliEMCALHistoProducer.
-    if(refHistoName.Contains("col") && hRef->GetEntries()>2 && hRef->GetMean()>0) 
-      ok=kTRUE;
-    if(!ok && counter >= nMod*nCol*nRow+nMod){
-      Log("No histogram with enough statistics for reference");
-      return 1;
-    }
-  }
   
-  Double_t refMean=hRef->GetMean();
-
-  // Calculates relative calibration coefficients for all non-zero channels
-  AliEMCALCalibData calibData;
-
-  for(Int_t mod=0; mod<nMod; mod++) {
-    if(mod > 10) nRow = nRowHalfSM ;
-    for(Int_t col=0; col<nCol; col++) {
-      for(Int_t row=0; row<nRow; row++) {
-        sprintf(hnam,"mod%dcol%drow%d",mod,col,row);
-        histo = (TH1F*)f.Get(hnam);
-       //TODO: dead channels exclusion!
-        if(histo && histo->GetMean() > 0) {
-         coeff = histo->GetMean()/refMean;
-         calibData.SetADCchannel(mod+1,col+1,row+1,1./coeff);
-         AliDebug(1,Form("mod %d col %d row %d  coeff %f\n",mod,col,row,coeff));
+  TList* list = GetFileSources(kDAQ, "AMPLITUDES");
+  if (list)
+    {
+      AliInfo("The following sources produced files with the id AMPLITUDES");
+      list->Print();
+      TIter iter(list);
+      TObjString *source;
+      while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
+       //TObjString * str = dynamic_cast<TObjString*> (list->At(0));//Only one source?
+       AliInfo(Form("found source %s", source->String().Data()));
+       
+       TString fileName = GetFile(kDAQ, "AMPLITUDES", source->GetName());
+       
+       //TString  fileName = GetFile(kDAQ, "AMPLITUDES", "GDC");
+       Log(Form("Got filename: %s",fileName.Data()));
+       
+       TFile f(fileName);
+       
+       if(!f.IsOpen()) {
+         Log(Form("File %s is not opened, something goes wrong!",fileName.Data()));
+         return 0;
        }
-        else
-          calibData.SetADCchannel(mod+1,col+1,row+1,-111); 
-      }
-    }
-  }
-
+       
+       
+       const Int_t nMod=12; // 1:5 modules
+       const Int_t nCol=48; //1:56 columns in each module
+       Int_t nRow=24; //1:64 rows in each module
+       const Int_t nRowHalfSM = 12; //Supermodules 11 and 12 are half supermodules
+       
+       Double_t coeff;
+       char hnam[80];
+       TH1F* histo=0;
+       
+       
+       //Get reference histogram
+       TList * keylist = f.GetListOfKeys();
+       Int_t nkeys   = f.GetNkeys();
+       Bool_t ok = kFALSE;
+       TKey  *key;
+       TString refHistoName= "";
+       Int_t ikey = 0;
+       Int_t counter = 0;
+       TH1F* hRef = new TH1F();
+       
+       //Check if the file contains any histogram
+       if(nkeys< 2){
+         Log(Form("Not enough histograms for calibration, nhist = %d",nkeys));
+         return 1;
+       }
+       
+       while(!ok){
+         ikey = gRandom->Integer(nkeys);
+         key = (TKey*)keylist->At(ikey);
+         refHistoName = key->GetName();
+         hRef = (TH1F*)f.Get(refHistoName);
+         counter++;
+         // Check if the reference has too little statistics and 
+         // if the histogram has the correct name (2 kinds, mod#col#row for 
+         // reference here, and mod#, see AliEMCALHistoProducer.
+         if(refHistoName.Contains("col") && hRef->GetEntries()>2 && hRef->GetMean()>0) 
+           ok=kTRUE;
+         if(!ok && counter >= nMod*nCol*nRow+nMod){
+           Log("No histogram with enough statistics for reference");
+           return 1;
+         }
+       }
+       
+       Double_t refMean=hRef->GetMean();
+       
+       // Calculates relative calibration coefficients for all non-zero channels
+       
+       for(Int_t mod=0; mod<nMod; mod++) {
+         if(mod > 10) nRow = nRowHalfSM ;
+         for(Int_t col=0; col<nCol; col++) {
+           for(Int_t row=0; row<nRow; row++) {
+             sprintf(hnam,"mod%dcol%drow%d",mod,col,row);
+             histo = (TH1F*)f.Get(hnam);
+             //TODO: dead channels exclusion!
+             if(histo && histo->GetMean() > 0) {
+               coeff = histo->GetMean()/refMean;
+               calibData.SetADCchannel(mod+1,col+1,row+1,1./coeff);
+               AliDebug(1,Form("mod %d col %d row %d  coeff %f\n",mod,col,row,coeff));
+             }
+             else
+               calibData.SetADCchannel(mod+1,col+1,row+1,-111); 
+           }
+         }
+       }
+       f.Close();
+      }//while
+    }//If list
+  
   AliCDBMetaData metaData;
   Int_t result = Store("Calib", "Data", &calibData, &metaData);
+  
 
-  f.Close();
-
+  
   return result;
-
+  
 }