]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPedestal.cxx
A few fixes
[u/mrichter/AliRoot.git] / MUON / AliMUONPedestal.cxx
index 70bd7296781adc96a70ab4d358f7e61cb2b950f0..b8453640326629f923dadcacd2b820f8aaf89a93 100644 (file)
@@ -27,6 +27,7 @@
 #include <TTree.h>
 #include <TFile.h>
 #include <TH1F.h>
+#include <THashList.h>
 #include <Riostream.h>
 
 #include <sstream>
@@ -52,6 +53,7 @@ AliMUONPedestal::AliMUONPedestal()
 //fN(0),
 fNCurrentEvents(0),
 fNEvthreshold(0),
+fSorting(0),
 fNEvents(0),
 fRunNumber(0),
 fNChannel(0),
@@ -103,7 +105,6 @@ void AliMUONPedestal::LoadConfig(const char* dbfile)
     { 
       filein >> busPatchId >> manuId;
 
-      AliMUONErrorCounter* manuCounter;
       AliMUONVCalibParam* ped = 
        static_cast<AliMUONVCalibParam*>(fPedestalStore ->FindObject(busPatchId, manuId));
 
@@ -113,10 +114,10 @@ void AliMUONPedestal::LoadConfig(const char* dbfile)
   ped = new AliMUONCalibParamND(2, AliMpConstants::ManuNofChannels(),busPatchId, manuId, -1.); // put default wise -1, not connected channel
        fPedestalStore ->Add(ped);  
 
-       if (!(manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId))))
+        if ( ! fManuBuspatchTable->FindObject(busPatchId,manuId) )
          {
            // New (buspatch,manu)
-           manuCounter = new AliMUONErrorCounter(busPatchId,manuId);
+           AliMUONErrorCounter* manuCounter = new AliMUONErrorCounter(busPatchId,manuId);
            fManuBuspatchTable->Add(manuCounter);
          }
       }
@@ -347,21 +348,45 @@ void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
   out<<"//      BP     MANU     CH.      MEAN    SIGMA"<<endl;
   out<<"//---------------------------------------------------------------------------" << endl;
 
-  // iterator over pedestal
-  TIter next(fPedestalStore ->CreateIterator());
-  AliMUONVCalibParam* ped;
-  
-  while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
-    {
-      Int_t busPatchId = ped->ID0();
-      Int_t manuId = ped->ID1();
+  TIter next(fPedestalStore->CreateIterator());
+  AliMUONVCalibParam* ped;  
 
-      for ( Int_t channelId = 0; channelId < ped->Size(); ++channelId ) 
+  // Sorting 
+  if  (fSorting)
+    {
+      cout << " ..... sorting pedestal values ....."  << endl;
+      THashList pedtable(100,2);
+      while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
+      {
+        pedtable.Add(ped);
+      }
+      pedtable.Sort();
+      //      iterator over sorted pedestal
+      TIter nextSorted(&pedtable);
+      while ( (ped = (AliMUONVCalibParam*)(nextSorted()) ) )
+      {
+        Int_t busPatchId = ped->ID0();
+        Int_t manuId = ped->ID1();
+        for ( Int_t channelId = 0; channelId < ped->Size(); ++channelId ) 
+        {
+          Double_t pedMean  = ped->ValueAsDouble(channelId, 0);
+          Double_t pedSigma = ped->ValueAsDouble(channelId, 1);
+          out << "\t" << busPatchId << "\t" << manuId <<"\t"<< channelId << "\t" << pedMean <<"\t"<< pedSigma << endl;
+        }
+      }
+    }
+  else
+    {
+      while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
        {
-         Double_t pedMean  = ped->ValueAsDouble(channelId, 0);
-         Double_t pedSigma = ped->ValueAsDouble(channelId, 1);
-
-         out << "\t" << busPatchId << "\t" << manuId <<"\t"<< channelId << "\t" << pedMean <<"\t"<< pedSigma << endl;
+         Int_t busPatchId = ped->ID0();
+         Int_t manuId = ped->ID1();
+         for ( Int_t channelId = 0; channelId < ped->Size(); ++channelId ) 
+           {
+             Double_t pedMean  = ped->ValueAsDouble(channelId, 0);
+             Double_t pedSigma = ped->ValueAsDouble(channelId, 1);
+             out << "\t" << busPatchId << "\t" << manuId <<"\t"<< channelId << "\t" << pedMean <<"\t"<< pedSigma << endl;
+           }
        }
     }
 }
@@ -388,22 +413,16 @@ void AliMUONPedestal::MakeControlHistos()
   fHistoFileName=Form("%s.root",fPrefixDA.Data());
   histoFile = new TFile(fHistoFileName,"RECREATE","MUON Tracking pedestals");
 
-  Char_t name[255];
-  Char_t title[255];
-  sprintf(name,"pedmean_allch");
-  sprintf(title,"Pedestal mean all channels");
   Int_t nx = ADCMax()+1;
   Int_t xmin = 0;
   Int_t xmax = ADCMax(); 
-  pedMeanHisto = new TH1F(name,title,nx,xmin,xmax);
+  pedMeanHisto = new TH1F("pedmean_allch","Pedestal mean all channels",nx,xmin,xmax);
   pedMeanHisto->SetDirectory(histoFile);
 
-  sprintf(name,"pedsigma_allch");
-  sprintf(title,"Pedestal sigma all channels");
   nx = 201;
   xmin = 0;
   xmax = 200; 
-  pedSigmaHisto = new TH1F(name,title,nx,xmin,xmax);
+  pedSigmaHisto = new TH1F("pedsigma_allch","Pedestal sigma all channels",nx,xmin,xmax);
   pedSigmaHisto->SetDirectory(histoFile);
 
   tree = new TTree("t","Pedestal tree");