]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGain.cxx
Clarify cluster loop. Add check for cluster being 0 (seen in online reco-viz).
[u/mrichter/AliRoot.git] / MUON / AliMUONGain.cxx
index a03a29074f85fcfb017315afa1cf31cfb738e9df..5244914c9e474d0a9c3de4f8706ec06390c126fc 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");
 
@@ -256,7 +254,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
@@ -342,7 +340,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 +352,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 +398,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 +495,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 +663,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 +717,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);}