]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGain.cxx
Fixing previous change, empty argument macros not supported everywhere
[u/mrichter/AliRoot.git] / MUON / AliMUONGain.cxx
index a03a29074f85fcfb017315afa1cf31cfb738e9df..7cb41198e7f6aa1049fc4a0365a62be8ac3a1af2 100644 (file)
 #include <Riostream.h>
 
 #include <sstream>
-//
-//AMORE
-//
-#ifdef ALI_AMORE
-#include <AmoreDA.h>
-#include "TSystem.h"
-#endif
 
 #define  NFITPARAMS 4
 
@@ -167,16 +160,21 @@ void AliMUONGain::MakePedStoreForGain(TString shuttleFile)
 
 
 
+  Finalize();
+  MakeControlHistos();
   if(fPrintLevel>0)
     {
       // compute and store mean DAC values (like pedestals)
-      sprintf(flatFile,"%s_%d.ped",fprefixDA,fRunNumber);
+      sprintf(flatFile,"%s.ped",fprefixDA);
       outputFile=flatFile;
       cout << "\n" << fprefixDA << " : Flat file  generated  : " << flatFile << "\n";
-      MakePedStore(outputFile);
+      if (!outputFile.IsNull())  
+      {
+        ofstream out(outputFile.Data());
+       MakeASCIIoutput(out);
+       out.close();
+      }      
     }
-  else
-    MakePedStore("");
 
   TString mode("UPDATE");
 
@@ -213,20 +211,23 @@ void AliMUONGain::MakePedStoreForGain(TString shuttleFile)
 //______________________________________________________________________________
 TString AliMUONGain::WriteGainHeader(Int_t nInit, Int_t nEntries, Int_t nbpf2, Int_t *numrun, Double_t *injCharge) 
 {
-///
+/// Header of the calibration output file
 
   ostringstream stream;
 
 
-  stream<<"//================================================" << endl;
-  stream<<"//  Calibration file calculated by MUONTRKda" << endl;
-  stream<<"//=================================================" << endl;
+  stream<<"//=======================================================" << endl;
+  stream<<"//      Calibration file calculated by " << fprefixDA <<endl;
+  stream<<"//=======================================================" << endl;
   stream<<"//   * Run           : " << fRunNumber << endl; 
   stream<<"//   * Date          : " << fDate->AsString("l") <<endl;
   stream<<"//   * Statictics    : " << fNEvents << endl;
-  stream<<"//   * # of MANUS    : " << fNManu << endl;
+  if(fConfig)
+  stream<<"//   * # of MANUS    : " << fNManu_config << " read in the Det. config. " << endl;
+  stream<<"//   * # of MANUS    : " << fNManu << " read in raw data " << endl;
+  stream<<"//   * # of MANUS    : " << fNChannel/64 << " written in calibration file " << endl;
   stream<<"//   * # of channels : " << fNChannel << endl;
-  stream<<"//-------------------------------------------------" << endl;
+  stream<<"//-------------------------------------------------------" << endl;
 
   if(nInit==0)
     stream<<"//  "<< nEntries <<" DAC values  fit: "<< fnbpf1 << " pts (1st order) " << nbpf2 << " pts (2nd order)" << endl;
@@ -248,7 +249,7 @@ TString AliMUONGain::WriteGainHeader(Int_t nInit, Int_t nEntries, Int_t nbpf2, I
 //______________________________________________________________________________
 TString AliMUONGain::WriteGainData(Int_t BP, Int_t Manu, Int_t ch, Double_t p1, Double_t p2, Int_t threshold, Int_t q) 
 {
-///
+/// Write calibration parameters per channel
 
   ostringstream stream("");
   stream << Form("%4i %5i %2i %7.4f %10.3e %4i %2x\n",BP,Manu,ch,p1,p2,threshold,q);
@@ -256,7 +257,7 @@ TString AliMUONGain::WriteGainData(Int_t BP, Int_t Manu, Int_t ch, Double_t p1,
 
 }
 
-//__________
+//_______________________________________________________________________________
 void AliMUONGain::MakeGainStore(TString shuttleFile)
 {
   /// Store gains in ASCII files
@@ -283,6 +284,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
   // Fit with a polynomial fct
   // store the result in a flat file.
 
+  if(fIndex==0)cout << " Root data file = " << fRootDataFileName << endl;  
   TFile*  histoFile = new TFile(fRootDataFileName);
 
   AliMUON2DMap* map[11];
@@ -342,7 +344,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
     FILE *pfilen = 0;
     if(fPrintLevel>1)
       {
-        sprintf(filename,"%s_%d.param",fprefixDA,fRunNumber);
+        sprintf(filename,"%s.param",fprefixDA);
         cout << " Second fit parameter file        = " << filename << "\n";
         pfilen = fopen (filename,"w");
 
@@ -354,23 +356,18 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
       }
 
 
-
-
-  //  Write Ascii file -> Shuttle
+  // file outputs for gain
 
   ofstream pfilew;
   pfilew.open(shuttleFile.Data());
+  // Write Header Data of the .par file
   pfilew << WriteGainHeader(fnInit,nEntries,nbpf2,numrun,injCharge);
-#ifdef ALI_AMORE
-  ostringstream stringout; // String to be sent to AMORE_DB
-  stringout << WriteGainHeader(fnInit,nEntries,nbpf2,numrun,injCharge);
-#endif
 
   // print mean and sigma values in file
   FILE *pfilep = 0;
   if(fPrintLevel>1)
     {
-      sprintf(filename,"%s_%d.peak",fprefixDA,fRunNumber);
+      sprintf(filename,"%s.peak",fprefixDA);
       cout << " File containing Peak mean values = " << filename << "\n";
       pfilep = fopen (filename,"w");
 
@@ -405,7 +402,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
   TTree* tg = 0x0;
   if(fPlotLevel>0)
     {
-      sprintf(fHistoFileName,"%s_%d.root",fprefixDA,fRunNumber);
+      sprintf(fHistoFileName,"%s.root",fprefixDA);
      gainFile = new TFile(fHistoFileName,"RECREATE","MUON Tracking gains");
       tg = new TTree("tg","TTree avec class Manu_DiMu");
 
@@ -502,7 +499,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
            {
              Int_t k = j + fnInit;
              x[j]    = pedMean[k];
-             if(x[j]==0.)fitproceed=0;
+             if(x[j]<=0. || x[j]== kADCMax)fitproceed=0;
              xErr[j] = pedSigma[k];
              y[j]    = injCharge[k];
              yErr[j] = injChargeErr[k];
@@ -670,12 +667,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
            }
 
 
-         tempstring = WriteGainData(busPatchId,manuId,channelId,par[1],par[2],threshold,q);
-         pfilew << tempstring;
-#ifdef ALI_AMORE
-         stringout << tempstring;
-#endif
-
+         pfilew << WriteGainData(busPatchId,manuId,channelId,par[1],par[2],threshold,q);
        }
       nmanu++;
       if(nmanu % 500 == 0)std::cout << " Nb manu = " << nmanu << std::endl;
@@ -729,27 +721,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
        << " mV/fC (capa= " << capaManu << " pF)" 
        <<  "  Prob(chi2)>  = " <<  meanProbChi2 << endl;
   
-  // file outputs for gain
-
   pfilew.close();
-#ifdef ALI_AMORE
-  //
-  //Send objects to the AMORE DB
-  //
-  const char *role=gSystem->Getenv("AMORE_DA_NAME");
-  if ( role ){
-    amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
-//  TObjString peddata(stringout.str().c_str());
-    TObjString gaindata(stringout.str().c_str());
-    Int_t status =0;
-    status = amoreDA.Send("Pedestals",&gaindata);
-    if ( status )
-      cout << "Warning: Failed to write Pedestals in the AMORE database : " << status << endl;
-  } 
-  else {
-    cout << "Warning: environment variable 'AMORE_DA_NAME' not set. Cannot write to the AMORE database" << endl;
-  }
-#endif
 
   if(fPlotLevel>0){tg->Write();histoFile->Close();}
   if(fPrintLevel>1){fclose(pfilep); fclose(pfilen);}