restore threshold getters after parameter dynamics update (fw v. >= A012)
[u/mrichter/AliRoot.git] / FMD / FMDPedestalda.cxx
index 88eadb7..5160565 100644 (file)
 #include "TROOT.h"
 #include "TPluginManager.h"
 #include <AliLog.h>
-
+#ifdef ALI_AMORE
+# include <AmoreDA.h>
+# include <TH2.h>
+#endif
 
 int main(int argc, char **argv) 
 {
@@ -34,36 +37,81 @@ int main(int argc, char **argv)
                                        "TStreamerInfo",
                                        "RIO",
                                        "TStreamerInfo()");
+  gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", "Minuit", 
+                                       "TMinuitMinimizer",
+                                       "Minuit", 
+                                       "TMinuitMinimizer(const char *)");
+  gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
+                                       "GSLMultiMin", 
+                                       "ROOT::Math::GSLMinimizer",
+                                       "MathMore", 
+                                       "GSLMinimizer(const char *)");
+  gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
+                                       "GSLMultiFit", 
+                                       "ROOT::Math::GSLNLSMinimizer",
+                                       "MathMore", "GSLNLSMinimizer(int)");
+  gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
+                                       "GSLSimAn", 
+                                       "ROOT::Math::GSLSimAnMinimizer",
+                                       "MathMore", 
+                                       "GSLSimAnMinimizer(int)");
+  gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
+                                       "Linear", 
+                                       "TLinearMinimizer",
+                                       "Minuit", 
+                                       "TLinearMinimizer(const char *)");
+  gROOT->GetPluginManager()->AddHandler("ROOT::Math::Minimizer", 
+                                       "Fumili", 
+                                       "TFumiliMinimizer",
+                                       "Fumili", 
+                                       "TFumiliMinimizer(int)");
+
+
   
   
   Bool_t diagnostics = kFALSE;
-  Char_t* fileName = argv[1];
-  TString secondArgument(argv[2]);
-  
-  if(secondArgument.Contains("--diagnostics=true"))
-    diagnostics = kTRUE;
-  if(secondArgument.Contains("--help")) {
-    std::cout<<"Usage: filename --diagnostics=true/false . --help this help"<<std::endl;
+  if (argc < 2) { 
+    std::cerr << "No input file given" << std::endl;
+    return 1;
+  }
+  TString fileName(argv[1]);
+  if (fileName.Contains("--help")) { 
+    std::cout << "Usage: " << argv[0] << " FILENAME [OPTIONS]\n\n"
+             << "Options:\n" 
+             << "    --diagnostics=BOOL Make diagnostics ROOT file\n"
+             << std::endl;
     return 0;
   }
-  
-  if(!secondArgument.IsWhitespace() && !secondArgument.Contains("--help") 
-     && !secondArgument.Contains("--diagnostics=true")) {
-    std::cout<<"Second argument wrong. Use --help"<<std::endl;
-    return -1;
+      
+  for (int i = 2; i < argc; i++) { 
+    TString arg(argv[i]);
+    if      (arg.Contains("--diagnostics=true")) diagnostics = kTRUE;
+    else if (arg.Contains("--help")) { 
+      std::cout << "Usage: " << argv[0] << " FILENAME [OPTIONS]\n\n"
+               << "Options:\n" 
+               << "    --diagnostics=BOOL Make diagnostics ROOT file\n"
+               << std::endl;
+      return 0;
+    }
+    else { 
+      std::cerr << "Unknown option: " << arg << "\n"
+               << "Try '" << argv[0] << " --help" << std::endl;
+      return 1;
+    }
   }
   Bool_t old = kTRUE;
 
-  AliLog::SetModuleDebugLevel("FMD", 1);
+  AliLog::EnableDebug(kFALSE);
   AliFMDParameters::Instance()->Init(kFALSE,0);
   AliFMDParameters::Instance()->UseCompleteHeader(old);
 
   AliRawReader *reader = 0;
-  TString fileNam(fileName);
-  if (fileNam.EndsWith(".root")) reader = new AliRawReaderRoot(fileName);
-  else reader = new AliRawReaderDate(fileName);
+  if (fileName.EndsWith(".root")) 
+    reader = new AliRawReaderRoot(fileName.Data());
+  else 
+    reader = new AliRawReaderDate(fileName.Data());
   if (!reader) { 
-    std::cerr << "Don't know how to make reader for " << fileNam 
+    std::cerr << "Don't know how to make reader for " << fileName
              << std::endl;
     return -2;
   }
@@ -71,18 +119,48 @@ int main(int argc, char **argv)
   timer.Start();
   AliFMDPedestalDA pedDA;
   pedDA.SetSaveDiagnostics(diagnostics);
+#ifdef ALI_AMORE
+  pedDA.SetMakeSummaries(kTRUE);
+#endif
   pedDA.Run(reader);
   
   timer.Stop();
   timer.Print();
  
-  Int_t  retvalConditions = daqDA_FES_storeFile("conditions.csv", AliFMDParameters::Instance()->GetConditionsShuttleID());
-  Int_t  retvalPeds = daqDA_FES_storeFile("peds.csv", AliFMDParameters::Instance()->GetPedestalShuttleID());
+  Int_t  retvalConditions = 
+    daqDA_FES_storeFile("conditions.csv", 
+                       AliFMDParameters::Instance()->GetConditionsShuttleID());
+  Int_t  retvalPeds = 
+    daqDA_FES_storeFile("peds.csv", 
+                       AliFMDParameters::Instance()->GetPedestalShuttleID());
 
   if(retvalConditions!=0 || retvalPeds!=0)
     std::cerr << "Pedestal DA failed" << std::endl;
   
+#ifdef ALI_AMORE
+  try { 
+    amore::da::AmoreDA myAmore(amore::da::AmoreDA::kSender);
+
+    UShort_t det = 0;
+    for (det = 1; det <= 3; det++) 
+      if (pedDA.HasSeenDetector(det)) break;
+    if (det >= 1 && det <= 3) { 
+      TObject* runNo = new TObject;
+      runNo->SetUniqueID(reader->GetRunNumber());
+      myAmore.Send(Form("pedRunNoFMD%d", det), runNo);
+    }
+
+    TIter     next(&pedDA.GetSummaries());
+    TObject*  obj = 0;
+    while ((obj = next())) 
+      myAmore.Send(obj->GetName(), obj);
+  }
+  catch (std::exception& e) {
+    std::cerr << "Failed to make AMORE instance: " << e.what() << std::endl;
+  }
+                              
+#endif
   if(retvalPeds != 0) return retvalPeds;
-  else return retvalConditions;
-  
+  return retvalConditions;
+
 }