]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALPreprocessor.cxx
Parameters for track finding in AliITStrackerSA added to AliITSRecoParam (F. Prino)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALPreprocessor.cxx
index f4c13cacf49079b7cc9bbeb362a31bffe703bcd7..e63abad2879956ac1e72d1f3be210cc1cd305595 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.7  2007/06/20 08:50:14  gustavo
+ * Change wrong directory data name from EmcGainPedestals to Data
+ *
+ * Revision 1.6  2007/04/29 15:06:19  gustavo
+ * New return value, and some minor fixes
+ *
+ * Revision 1.5  2007/02/01 15:02:42  gustavo
+ * Added log message in case there are no source files
+ *
+ * Revision 1.4  2007/01/24 16:57:14  gustavo
+ * Calibratio file sources machines are now not hardcoded but retreived from shuttle
+ *
+ * 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
+ *
  * Revision 1.1  2006/12/07 16:32:16  gustavo
  * First shuttle code, online calibration histograms producer, EMCAL preprocessor
  * 
@@ -38,7 +56,9 @@
 #include "TRandom.h"
 #include "TKey.h"
 #include "TList.h"
-#include "Riostream.h"
+#include "TString.h"
+#include "TObjString.h"
+
 //AliRoot
 #include "AliEMCALPreprocessor.h"
 #include "AliLog.h"
@@ -59,97 +79,124 @@ AliEMCALPreprocessor::AliEMCALPreprocessor(AliShuttleInterface* shuttle):
 AliPreprocessor("EMC",shuttle)
 {
   // Constructor
+  AddRunType("PHYSICS");
+  AddRunType("STANDALONE");
+
 }
 
 //_______________________________________________________________________________________
 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
 
-  const char* fileName = GetFile(kDAQ, "AMPLITUDES", "GDC");
-  AliInfo(Form("Got filename: %s",fileName));
-
-  TFile f(fileName);
-
-  if(!f.IsOpen()) {
-    AliInfo(Form("File %s is not opened, something goes wrong!",fileName));
-    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;
+   gRandom->SetSeed(0); //the seed is set to the current  machine clock!
+  AliEMCALCalibData calibData;
   
-  //Check if the file contains any histogram
-  if(nkeys< 2){
-    AliInfo(Form("Not enough histograms for calibration, nhist = %d",nkeys));
+  
+  TList* list = GetFileSources(kDAQ, "AMPLITUDES");
+  if(!list) {
+    Log("Sources list not found, exit.");
     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){
-      AliInfo("No histogram with enough statistics for reference");
+  AliInfo("The following sources produced files with the id AMPLITUDES");
+  list->Print();
+  
+  TIter iter(list);
+  TObjString *source;
+  
+  while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
+    AliInfo(Form("found source %s", source->String().Data()));
+       
+    TString fileName = GetFile(kDAQ, "AMPLITUDES", source->GetName());
+    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 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);
-         AliInfo(Form("mod %d col %d row %d  coeff %f\n",mod,col,row,coeff));
+       
+       
+    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); 
        }
-        else
-          calibData.SetADCchannel(mod+1,col+1,row+1,-111); 
       }
     }
-  }
-
-  AliCDBMetaData metaData;
-  Int_t result = Store("Calib", "Data", &calibData, &metaData);
-
-  f.Close();
-  return result;
-
+    f.Close();
+  }//while
+  
+  //Store EMCAL calibration data
+  
+  AliCDBMetaData emcalMetaData;
+  Bool_t emcalOK = Store("Calib", "Data", &calibData, &emcalMetaData);
+  
+  if(emcalOK) return 0;
+  else
+    return 1;
+  
 }