]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
DA upgrade: take now into account the current configuration of the DiMuon Tracker...
authorlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Oct 2009 15:28:20 +0000 (15:28 +0000)
committerlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 Oct 2009 15:28:20 +0000 (15:28 +0000)
MUON/AliMUONGain.cxx
MUON/AliMUONPedestal.cxx
MUON/AliMUONPedestal.h
MUON/MUONTRKGAINda.cxx
MUON/MUONTRKPEDda.cxx

index 5244914c9e474d0a9c3de4f8706ec06390c126fc..7cb41198e7f6aa1049fc4a0365a62be8ac3a1af2 100644 (file)
@@ -211,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;
@@ -246,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);
@@ -281,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];
@@ -495,7 +499,7 @@ void AliMUONGain::MakeGainStore(TString shuttleFile)
            {
              Int_t k = j + fnInit;
              x[j]    = pedMean[k];
-             if(x[j]==0. || x[j]== kADCMax)fitproceed=0;
+             if(x[j]<=0. || x[j]== kADCMax)fitproceed=0;
              xErr[j] = pedSigma[k];
              y[j]    = injCharge[k];
              yErr[j] = injChargeErr[k];
index bf9bf33bebbeeb8ca813912574b66b65ecc8a7db..273ab9cbc9a475f93082fc2fee9690d540ae670a 100644 (file)
@@ -54,12 +54,15 @@ fNEvents(0),
 fRunNumber(0),
 fNChannel(0),
 fNManu(0),
+fNManu_config(0),
 fErrorBuspatchTable(new AliMUON2DMap(kFALSE)),
 fManuBuspatchTable(new AliMUON2DMap(kFALSE)),
+fManuBPoutofconfigTable(new AliMUON2DMap(kFALSE)),
 fDate(new TTimeStamp()),
 fFilcout(0),
 fPedestalStore(new AliMUON2DMap(kTRUE)),
-fIndex(-1)
+fIndex(-1),
+fConfig(1)
 {
 /// Default constructor
   sprintf(fHistoFileName," ");
@@ -74,8 +77,41 @@ AliMUONPedestal::~AliMUONPedestal()
   delete fErrorBuspatchTable;
   delete fManuBuspatchTable;
   delete fPedestalStore;
+  delete fManuBPoutofconfigTable;
 }
 
+//______________________________________________________________________________
+void AliMUONPedestal::Load_config(char* dbfile)
+{
+  /// Load MUONTRK configuration from ascii file "dbfile" (in DetDB)
+
+  Int_t manuId;
+  Int_t busPatchId;
+
+  ifstream fileinit(dbfile,ios::in);
+  while (!fileinit.eof())
+    { 
+      fileinit >> busPatchId >> manuId;
+
+      AliMUONErrorCounter* manuCounter;
+      AliMUONVCalibParam* ped = 
+       static_cast<AliMUONVCalibParam*>(fPedestalStore ->FindObject(busPatchId, manuId));
+
+      if (!ped) {
+       fNManu_config++;
+       fNChannel+=64;
+       ped = new AliMUONCalibParamND(2, kNChannels,busPatchId, manuId, -1.); // put default wise -1, not connected channel
+       fPedestalStore ->Add(ped);  
+
+       if (!(manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId))))
+         {
+           // New (buspatch,manu)
+           manuCounter = new AliMUONErrorCounter(busPatchId,manuId);
+           fManuBuspatchTable->Add(manuCounter);
+         }
+      }
+    }
+} 
 //______________________________________________________________________________
 void AliMUONPedestal::MakePed(Int_t busPatchId, Int_t manuId, Int_t channelId, Int_t charge)
 {
@@ -83,14 +119,27 @@ void AliMUONPedestal::MakePed(Int_t busPatchId, Int_t manuId, Int_t channelId, I
   AliMUONVCalibParam* ped = 
     static_cast<AliMUONVCalibParam*>(fPedestalStore ->FindObject(busPatchId, manuId));
 
-  if (!ped) {
-    fNManu++;
-    ped = new AliMUONCalibParamND(2, kNChannels,busPatchId, manuId, -1.); // put default wise -1, not connected channel
-    fPedestalStore ->Add(ped);  
-  }
+  if (!ped)   
+    {
+      if(fConfig) 
+       {  // Fill out_of_config (buspatch,manu) table
+         if (!(static_cast<AliMUONErrorCounter*>(fManuBPoutofconfigTable->FindObject(busPatchId,manuId))))
+           fManuBPoutofconfigTable->Add(new AliMUONErrorCounter(busPatchId,manuId));
+         cout << " !!! WARNING  : busPatchId = " << busPatchId << " manuId = " << manuId << " not in the Detector configuration " << endl;
+       }
+      else {fNManu++;}
+      fNChannel+=64;
+      // put default wise -1, not connected channel
+      ped = new AliMUONCalibParamND(2, kNChannels,busPatchId, manuId, -1.); 
+      fPedestalStore ->Add(ped);  
+    }
 
   // Initialization for the first value
-  if (ped->ValueAsDouble(channelId, 0) == -1) ped->SetValueAsDouble(channelId, 0, 0.);
+  if (ped->ValueAsDouble(channelId, 0) == -1)  
+    { 
+      if(fConfig && channelId == 0){fNManu++;}
+      ped->SetValueAsDouble(channelId, 0, 0.);
+    }
   if (ped->ValueAsDouble(channelId, 1) == -1) ped->SetValueAsDouble(channelId, 1, 0.);
 
   Double_t pedMean  = ped->ValueAsDouble(channelId, 0) + (Double_t) charge;
@@ -112,7 +161,6 @@ void AliMUONPedestal::MakePed(Int_t busPatchId, Int_t manuId, Int_t channelId, I
       manuCounter->Increment();
     }  
 }
-
 //______________________________________________________________________________
 void AliMUONPedestal::Finalize()
 {
@@ -124,103 +172,139 @@ void AliMUONPedestal::Finalize()
 
   // print in logfile
   if (fErrorBuspatchTable->GetSize())
-  {
-    cout<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
-    (*fFilcout)<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
-    TIter nextParityError(fErrorBuspatchTable->CreateIterator());
-    AliMUONErrorCounter* parityerror;
-    while((parityerror = static_cast<AliMUONErrorCounter*>(nextParityError())))
     {
-      cout<<"  bp "<<parityerror->BusPatch()<<": events used = "<<fNEvents-parityerror->Events()<<endl;
-      (*fFilcout)<<"  bp "<<parityerror->BusPatch()<<": events used = "<<fNEvents-parityerror->Events()<<endl;
+      cout<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
+      (*fFilcout)<<"\n* Buspatches with less statistics (due to parity errors)"<<endl;
+      TIter nextParityError(fErrorBuspatchTable->CreateIterator());
+      AliMUONErrorCounter* parityerror;
+      while((parityerror = static_cast<AliMUONErrorCounter*>(nextParityError())))
+       {
+         cout<<"  bp "<<parityerror->BusPatch()<<": events used = "<<fNEvents-parityerror->Events()<<endl;
+         (*fFilcout)<<"  bp "<<parityerror->BusPatch()<<": events used = "<<fNEvents-parityerror->Events()<<endl;
+       }
     }
-  }
 
-// iterator over pedestal
+  // iterator over pedestal
   TIter next(fPedestalStore ->CreateIterator());
   AliMUONVCalibParam* ped;
 
   while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
-  {
-    busPatchId              = ped->ID0();
-    manuId                  = ped->ID1();
-    if(manuId==0)
-      {
-       cout << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << endl;
-       (*fFilcout) << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << endl;
-      }
-    Int_t eventCounter;
-    // Correct the number of events for buspatch with errors
-    AliMUONErrorCounter* errorCounter;
-    if ((errorCounter = (AliMUONErrorCounter*)fErrorBuspatchTable->FindObject(busPatchId)))
-    {
-      eventCounter = fNEvents - errorCounter->Events();
-    }
-    else
     {
-      eventCounter = fNEvents;
-    }
-
-    Int_t occupancy;
-    // value of (buspatch, manu) occupancy
-    AliMUONErrorCounter* manuCounter;
-    manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId));
-    occupancy = manuCounter->Events()/64/eventCounter;
-    if(occupancy>1)
-    {
-      cout << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl;
-      (*fFilcout) << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << " occupancy (>1) = " << occupancy <<endl;
-    }
-
-    for (channelId = 0; channelId < ped->Size() ; ++channelId) 
-    {
-      pedMean  = ped->ValueAsDouble(channelId, 0);
-
-      if (pedMean > 0) // connected channels
-      {
-         ped->SetValueAsDouble(channelId, 0, pedMean/(Double_t)eventCounter);
+      busPatchId              = ped->ID0();
+      manuId                  = ped->ID1();
+      if(manuId==0)
+       {
+         cout << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << endl;
+         (*fFilcout) << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << endl;
+       }
+      Int_t eventCounter;
+      // Correct the number of events for buspatch with errors
+      AliMUONErrorCounter* errorCounter;
+      if ((errorCounter = (AliMUONErrorCounter*)fErrorBuspatchTable->FindObject(busPatchId)))
+       {
+         eventCounter = fNEvents - errorCounter->Events();
+       }
+      else
+       {
+         eventCounter = fNEvents;
+       }
+
+      Int_t occupancy=0; // channel missing in raw data or read but rejected (case of parity error)
+      // value of (buspatch, manu) occupancy
+      AliMUONErrorCounter* manuCounter;
+      manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId));
+      if(eventCounter>0)occupancy = manuCounter->Events()/64/eventCounter;
+      if(occupancy>1)
+       {
+         cout << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl;
+         (*fFilcout) << " !!! BIG WARNING: ManuId = " << manuId << " !!! in  BP = " << busPatchId << " occupancy (>1) = " << occupancy <<endl;
+       }
+
+      for (channelId = 0; channelId < ped->Size() ; ++channelId) 
+       {
          pedMean  = ped->ValueAsDouble(channelId, 0);
-         pedSigma = ped->ValueAsDouble(channelId, 1);
-         ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean)));
-         if(manuId == 0 || occupancy>1)
-         {
+
+         if (pedMean > 0) // connected channels
+           {
+             ped->SetValueAsDouble(channelId, 0, pedMean/(Double_t)eventCounter);
+             pedMean  = ped->ValueAsDouble(channelId, 0);
+             pedSigma = ped->ValueAsDouble(channelId, 1);
+             ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean)));
+             if(manuId == 0)
+               {
+                 ped->SetValueAsDouble(channelId, 0, kADCMax);
+                 ped->SetValueAsDouble(channelId, 1, kADCMax);
+               }
+             if(occupancy>1)
+               {
+                 ped->SetValueAsDouble(channelId, 0, kADCMax);
+                 ped->SetValueAsDouble(channelId, 1, kADCMax);
+                 if(channelId==0)ped->SetValueAsDouble(channelId, 0, kADCMax+occupancy);
+               }
+           }
+         else
+           {
              ped->SetValueAsDouble(channelId, 0, kADCMax);
              ped->SetValueAsDouble(channelId, 1, kADCMax);
-         }
-      }
-      else
-      {
-         ped->SetValueAsDouble(channelId, 0, kADCMax);
-         ped->SetValueAsDouble(channelId, 1, kADCMax);
-      }
+           }
+       }
     }
-  }
 }
-
 //______________________________________________________________________________
 void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
 {
-/// put pedestal store in the output stream
+  /// put pedestal store in the output stream
 
   out<<"//===========================================================================" << endl;
-  out<<"//                       Pedestal file calculated by MUONTRKda"<<endl;
+  out<<"//                 Pedestal file calculated by "<< fprefixDA << endl;
   out<<"//===========================================================================" << endl;
   out<<"//       * Run           : " << fRunNumber << endl; 
   out<<"//       * Date          : " << fDate->AsString("l") <<endl;
   out<<"//       * Statictics    : " << fNEvents << endl;
-  out<<"//       * # of MANUS    : " << fNManu << endl;
+  if(fConfig)
+    out<<"//       * # of MANUS    : " << fNManu_config << " read in the Det. config. " << endl;
+  out<<"//       * # of MANUS    : " << fNManu << " read in raw data " << endl;
+  out<<"//       * # of MANUS    : " << fNChannel/64 << " written in pedestal file " << endl;
   out<<"//       * # of channels : " << fNChannel << endl;
   if (fErrorBuspatchTable->GetSize())
-  {
-    out<<"//"<<endl;
-    out<<"//       * Buspatches with less statistics (due to parity errors)"<<endl;
-    TIter next(fErrorBuspatchTable->CreateIterator());
-    AliMUONErrorCounter* parityerror;
-    while((parityerror = static_cast<AliMUONErrorCounter*>(next())))
     {
-      out<<"//         bp "<<parityerror->BusPatch()<<" events used "<<fNEvents-parityerror->Events()<<endl;
+      out<<"//"<<endl;
+      out<<"//    * Buspatches with less statistics (due to parity errors)"<<endl;
+      TIter next(fErrorBuspatchTable->CreateIterator());
+      AliMUONErrorCounter* parityerror;
+      while((parityerror = static_cast<AliMUONErrorCounter*>(next())))
+       {
+         out<<"//      BusPatch = "<<parityerror->BusPatch()<<"\t Nevents used = "<<fNEvents-parityerror->Events()<<endl;
+       }
+    }  
+
+  out<<"//"<<endl;
+  out<<"//    * Puzzling (Buspatch,Manu) read in raw data ?"<<endl;
+  Int_t occupancy=1; 
+  if(occupancy){
+  TIter next(fPedestalStore ->CreateIterator());
+  AliMUONVCalibParam* ped;
+  while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
+    {
+      Int_t busPatchId = ped->ID0();
+      Int_t manuId = ped->ID1();
+      Double_t pedMean  = ped->ValueAsDouble(0, 0); // check pedestal value for channelId=0
+
+      if(pedMean>kADCMax) 
+       {
+         occupancy=pedMean-kADCMax;
+         ped->SetValueAsDouble(0, 0, kADCMax);
+         out<<"//      BusPatch = "<< busPatchId <<"\t ManuId =  "<< manuId << "\t occupancy = " << occupancy  <<endl;
+       }
+
+      if (manuId==0 || (fConfig && static_cast<AliMUONErrorCounter*>(fManuBPoutofconfigTable->FindObject(busPatchId,manuId))))
+       {
+         out<<"//      BusPatch = "<< busPatchId <<"\t ManuId =  "<< manuId << "\t missing in the mapping" << endl;
+       }
     }
-  }  
+}
+
+
   out<<"//"<<endl;
   out<<"//---------------------------------------------------------------------------" << endl;
   out<<"//---------------------------------------------------------------------------" << endl;
@@ -232,18 +316,18 @@ void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
   AliMUONVCalibParam* ped;
   
   while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
-  {
-    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;        
+      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;
+       }
     }
-  }
 }
 
 //______________________________________________________________________________
index 373b81492b3ff840b2ca2f37a233eae5a7b45b01..35c8dbf94f745f4fc5c859e013b06991f144e51d 100644 (file)
@@ -44,8 +44,13 @@ class AliMUONPedestal : public TObject
     AliMUONVStore* GetErrorBuspatchTable() {return fErrorBuspatchTable;}
     /// return the name of DAPedestal .root file
     Char_t* GetHistoFileName() {return fHistoFileName;}
+    /// load MuonTrk configuration from ascii dbfile
+    void Load_config(char* dbfile);
+    /// sum pedestal values for mean and sigma determination
     void MakePed(Int_t bp,Int_t manu,Int_t ch,Int_t charge);
 
+    /// set config flag
+    void SetconfigDA(Int_t ind) {fConfig = ind;}
     /// set specific  DA prefixname
     void SetprefixDA(char* folder) {sprintf(fprefixDA,"%s",folder);}
     /// set the index of calibration runs
@@ -63,8 +68,11 @@ class AliMUONPedestal : public TObject
     Int_t fRunNumber; ///< run number
     Int_t fNChannel; ///< Nb of channels (pads)
     Int_t fNManu; ///<  Nb of Manu
+    Int_t fNManu_config; ///<  Nb of Manu in the current detector configuration
+    Int_t fConfig; ///< flag 1(0) for reading(or not) configuration ascii file
     AliMUONVStore* fErrorBuspatchTable; ///< Table for buspatches with parity errors 
     AliMUONVStore* fManuBuspatchTable; ///< Occupancy rate for each (buspatch, manu)
+    AliMUONVStore* fManuBPoutofconfigTable; ///< (buspatch, manu) out of config
  
     TTimeStamp* fDate; ///< date
     ofstream* fFilcout; ///< .log output file
index be6987e614e0a4097d3fa6f37471f1bae260cc8f..8d71f04cdd101cdda6eb384200ee5a0234f2dad7 100644 (file)
@@ -29,7 +29,7 @@
 
 /*
  -------------------------------------------------------------------------
- 2009-05-18 New version: MUONTRKGAINda.cxx,v 1.1
+ 2009-10-06 New version: MUONTRKGAINda.cxx,v 1.3
  -------------------------------------------------------------------------
 
  Version for MUONTRKGAINda MUON tracking
@@ -135,7 +135,6 @@ int main(Int_t argc, Char_t **argv)
  Int_t nEventsRecovered = 0;
  Int_t nEvents = 0;
  UInt_t runNumber   = 0;
- Int_t  nChannel    = 0;
  ofstream filcout;
  Int_t nIndex = -1; 
 
@@ -174,22 +173,6 @@ int main(Int_t argc, Char_t **argv)
          i++;
          shuttleFile = argv[i];
          break;
-//     case 'd' :
-//       i++; 
-//       printLevel=atoi(argv[i]);
-//       break;
-//     case 'g' :
-//       i++; 
-//       plotLevel=atoi(argv[i]);
-//       break;
-//     case 'i' :
-//       i++; 
-//       nbpf1=atoi(argv[i]);
-//       break;
-//     case 'j' :
-//       i++; 
-//       nInit=atoi(argv[i]);
-//       break;
        case 's' :
          i++; 
          skipEvents=atoi(argv[i]);
@@ -216,10 +199,6 @@ int main(Int_t argc, Char_t **argv)
          printf("\n-a <Flat ASCII file>       (default = %s)",shuttleFile.Data()); 
          printf("\n");
          printf("\n Options");
-//       printf("\n-d <print level>           (default = %d)",printLevel);
-//       printf("\n-g <plot level>            (default = %d)",plotLevel);
-//       printf("\n-i <nb linear points>      (default = %d)",nbpf1);
-//       printf("\n-j start point of fit      (default = %d)",nInit);
          printf("\n-m <max date events>       (default = %d)",maxDateEvents);
          printf("\n-s <skip events>           (default = %d)",skipEvents);
          printf("\n-n <max events>            (default = %d)",maxEvents);
@@ -236,16 +215,15 @@ int main(Int_t argc, Char_t **argv)
  //Gain object
  AliMUONGain* muonGain = new AliMUONGain();
  muonGain->SetprefixDA(prefixDA);
- muonGain->SetAliRootDataFileName(); // MUONTRKGAINda_data.root  
+ muonGain->SetAliRootDataFileName(); // MUONTRKGAINda_data.root
+ // Char_t* RootDataFileName=muonGain->GetRootDataFileName();// MUONTRKGAINda_data.root
+ // cout << " Root data file = " << RootDataFileName << endl;  
 
  // Reading current iteration
  nIndex = daqDA_ECS_getCurrentIteration();
- if(nIndex<0)nIndex=0; // compute gain directly from existing root data file
+ if(nIndex<0)nIndex=0; // compute gain directly from existing root data file (OFFLINE only)
 
-
-
-
- if(nIndex==0) // compute gain from existing root data file: MUONTRKGAINda_data.root
+ if(nIndex==0) // compute gain from existing root data file: MUONTRKGAINda_data.root (OFFLINE only)
    {
      sprintf(flatFile,"%s_data.log",prefixDA);
      logOutputFile=flatFile;
@@ -261,36 +239,36 @@ int main(Int_t argc, Char_t **argv)
      muonGain->SetAliInit(nInit); // fnInit
      muonGain->SetAliNbpf1(nbpf1); // fnbpf1
      muonGain->MakeGainStore(shuttleFile);
-#ifdef ALI_AMORE
-     std::ifstream in(shuttleFile.Data());
-     ostringstream stringout;
-     char line[1024];
-     while ( in.getline(line,1024) )
-       stringout << line << "\n";  
-     in.close();
-
-     amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
-     TObjString gaindata(stringout.str().c_str());
-     status = amoreDA.Send("Gains",&gaindata);
-     if ( status )
-       cout << "Warning: Failed to write Pedestals in the AMORE database : " << status << endl;
-     else 
-       cout << "amoreDA.Send(Gains) ok" << endl;  
-#else
-     cout << "Warning: MCH DA not compiled with AMORE support" << endl;
-#endif
+     // ALI_AMORE instructions below are commented (not used OFFLINE) JLC 30/09/09
+     // #ifdef ALI_AMORE
+     //      std::ifstream in(shuttleFile.Data());
+     //      ostringstream stringout;
+     //      char line[1024];
+     //      while ( in.getline(line,1024) )
+     //        stringout << line << "\n";  
+     //      in.close();
+
+     //      amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
+     //      TObjString gaindata(stringout.str().c_str());
+     //      status = amoreDA.Send("Gains",&gaindata);
+     //      if ( status )
+     //        cout << "Warning: Failed to write Pedestals in the AMORE database : " << status << endl;
+     //      else 
+     //        cout << "amoreDA.Send(Gains) ok" << endl;  
+     // #else
+     //      cout << "Warning: MCH DA not compiled with AMORE support" << endl;
+     // #endif
    }
 
-
-
- if(nIndex>0) // normal case: reading calibration runs before computing gains
+ if(nIndex>0) // normal case: reading calibration runs before computing gains (ONLINE or OFFLINE)
    {
      UShort_t manuId;  
      UChar_t channelId;
      UShort_t charge;
          
      // DAC values stored in array vDAC (reading dbfile in DETDB)
-     //   Int_t vDAC[11] = {0,200,400,800,1200,1600,2000,2500,3000,3500,4000}; // DAC values
+     //   Int_t vDAC[11] = {0,200,400,800,1200,1600,2000,2500,3000,3500,4000}
+     Int_t nConfig = 1; // flag to read or not configuration ascii file in detDB
      Int_t vDAC[11]; // DAC values
      Char_t *dbfile;
      dbfile="mutrkcalibvalues";
@@ -298,15 +276,31 @@ int main(Int_t argc, Char_t **argv)
      status=daqDA_DB_getFile(dbfile,dbfile);
      ifstream filein(dbfile,ios::in); Int_t k=0, kk;
      while (k<nEntries ) { filein >> kk >> vDAC[k] ; k++; }
+     injCharge=vDAC[nIndex-1];
+
+
      filein >> nInit; // = 0 all DAC values fitted ; = 1 DAC=0 excluded (default=1)
      filein >> nbpf1; // nb of points for linear fit (default=6) 
      filein >> printLevel;  // printout (default=0, =1 =>.ped /run, =2 => .peak & .param)
      filein >> plotLevel;  // plotout (default=1 => tree , =2 tree+Tgraph+fit)
-     cout << "nInit=" << nInit << " Nb linear pts=" << nbpf1 << "    Print level=" << printLevel << "    Plot Level=" << plotLevel << endl;
+     filein >> nConfig;  //nConfig (default=1 => read config in DetDB, otherwise =0)
+
+     cout << "nInit=" << nInit << " Nb linear pts=" << nbpf1 << "    Print level=" << printLevel << "    Plot Level=" << plotLevel << "     Config= " << nConfig << endl;
+
      muonGain->SetAliPrintLevel(printLevel);
      muonGain->SetAliPlotLevel(plotLevel);
+     muonGain->SetconfigDA(nConfig);
+
+     if(nConfig)
+       {
+        // Laod configuration ascii file from DetDB
+        Char_t dbfil[256]="";
+        sprintf(dbfil,"config_%s",getenv("DATE_ROLE_NAME"));
+        cout << "\n *** Copy ascii config file: " << dbfil << " from DetDB to working directory and reading ...*** \n" << endl;
+        status=daqDA_DB_getFile(dbfil,dbfil);
+        muonGain->Load_config(dbfil);  
+       } 
                
-     injCharge=vDAC[nIndex-1];
 
      // Rawdeader, RawStreamHP
      AliRawReader* rawReader = AliRawReader::Create(inputFile);
@@ -383,7 +377,6 @@ int main(Int_t argc, Char_t **argv)
                {
                  for(int i = 0; i < busPatch->GetLength(); ++i)
                    {
-                     if (nEvents == 0) nChannel++;
                      busPatch->GetData(i, manuId, channelId, charge);
                      muonGain->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
                    }
@@ -423,9 +416,7 @@ int main(Int_t argc, Char_t **argv)
                          // Good buspatch
                          for(int i = 0; i < busPatch->GetLength(); ++i)
                            {
-                             if (nEvents == 0) nChannel++;
                              busPatch->GetData(i, manuId, channelId, charge);
-                             // if (busPatch->GetBusPatchId()==1719 && manuId == 1 && channelId == 0) cout <<"Recovered charge "<<charge<<endl;
                              muonGain->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
                            }
                        }
@@ -496,7 +487,6 @@ int main(Int_t argc, Char_t **argv)
      muonGain->SetAliInjCharge(injCharge);
      muonGain->SetAliNEvents(nEvents);
      muonGain->SetAliRunNumber(runNumber);
-     muonGain->SetAliNChannel(nChannel);
      muonGain->MakePedStoreForGain(shuttleFile);
      
 
@@ -556,7 +546,7 @@ int main(Int_t argc, Char_t **argv)
 //      Copying files to local DB folder defined by DAQ_DETDB_LOCAL
        Char_t *dir;
       dir= getenv("DAQ_DETDB_LOCAL");
-      unsigned int nLastVersions = 99;
+      unsigned int nLastVersions = 90;
       cout << "\n ***  Local DataBase: " << dir << " (Max= " << nLastVersions << ") ***" << endl;
       status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions);
       printf(" Store file : %s   status = %d\n",logOutputFile.Data(),status);
index 678531bbb01bf4146d5722fd9dd04d8a55cc63ae..c07efd54fec6548fd331488b716eb861392df799 100644 (file)
@@ -29,7 +29,7 @@ Run Type: PEDESTAL
 
 /*
        -------------------------------------------------------------------------
-        2009-06-18 New version: MUONTRKPEDda.cxx,v 1.2
+        2009-10-06 New version: MUONTRKPEDda.cxx,v 1.3
        -------------------------------------------------------------------------
 
        Version for MUONTRKPEDda MUON tracking
@@ -39,6 +39,7 @@ Run Type: PEDESTAL
  Rem:  AliMUON2DMap stores all channels, even those which are not connected
  if pedMean == -1, channel not connected to a pad  
 
+&
 
 */
 extern "C" {
@@ -137,9 +138,7 @@ int main(Int_t argc, Char_t **argv)
   Int_t nEventsRecovered = 0;
   Int_t nEvents = 0;
   UInt_t runNumber   = 0;
-  Int_t  nChannel    = 0;
   ofstream filcout;
-//   Int_t nIndex = -1; 
 
   // decode the input line
   for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name
@@ -178,10 +177,6 @@ int main(Int_t argc, Char_t **argv)
          i++; 
          sscanf(argv[i],"%d",&maxEvents);
          break;
-//     case 'p' : 
-//       i++;
-//       sscanf(argv[i],"%d",&recoverParityErrors);
-//       break;
        case 'h' :
          i++;
          printf("\n******************* %s usage **********************",argv[0]);
@@ -199,7 +194,6 @@ int main(Int_t argc, Char_t **argv)
          printf("\n-m <max date events>       (default = %d)",maxDateEvents);
          printf("\n-s <skip events>           (default = %d)",skipEvents);
          printf("\n-n <max events>            (default = %d)",maxEvents);
-//       printf("\n-p <Recover parity errors> (default = %d)",recoverParityErrors);
 
          printf("\n\n");
          exit(-1);
@@ -219,6 +213,28 @@ int main(Int_t argc, Char_t **argv)
   AliMUONPedestal* muonPedestal = new AliMUONPedestal();
   muonPedestal->SetprefixDA(prefixDA);
 
+  // Reading configuration status via "mutrkpedvalues" file located in DetDB
+  // config=1: config ascii file read from DetDB, otherwise: config=0
+  Int_t nConfig = 1; 
+  Char_t *dbfile;
+  dbfile="mutrkpedvalues";
+  cout << "\n *** Copy: " << dbfile << " from DetDB to working directory  *** \n" << endl;
+  status=daqDA_DB_getFile(dbfile,dbfile);
+  ifstream filein(dbfile,ios::in);
+  filein >> nConfig;
+  cout << "       Config= " << nConfig << endl;
+  muonPedestal->SetconfigDA(nConfig);
+
+  if(nConfig)
+    {
+  // MuonTrk Configuration ascii file (initCROCUS.dat -> ascii file = mutrkconfig)
+  Char_t dbfil[256]="";
+  sprintf(dbfil,"config_%s",getenv("DATE_ROLE_NAME"));
+  cout << "\n *** Copy ascii config file: " << dbfil << " from DetDB to working directory and reading ...*** \n" << endl;
+  status=daqDA_DB_getFile(dbfil,dbfil);
+  muonPedestal->Load_config(dbfil);  
+    } 
+
   // Rawdeader, RawStreamHP
   AliRawReader* rawReader = AliRawReader::Create(inputFile);
   AliMUONRawStreamTrackerHP* rawStream  = new AliMUONRawStreamTrackerHP(rawReader);    
@@ -294,7 +310,6 @@ int main(Int_t argc, Char_t **argv)
            {
              for(int i = 0; i < busPatch->GetLength(); ++i)
                {
-                 if (nEvents == 0) nChannel++;
                  busPatch->GetData(i, manuId, channelId, charge);
                  muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
                }
@@ -334,9 +349,7 @@ int main(Int_t argc, Char_t **argv)
                      // Good buspatch
                      for(int i = 0; i < busPatch->GetLength(); ++i)
                        {
-                         if (nEvents == 0) nChannel++;
                          busPatch->GetData(i, manuId, channelId, charge);
-                         // if (busPatch->GetBusPatchId()==1719 && manuId == 1 && channelId == 0) cout <<"Recovered charge "<<charge<<endl;
                          muonPedestal->MakePed(busPatch->GetBusPatchId(), (Int_t)manuId, (Int_t)channelId, (Int_t)charge);
                        }
                    }
@@ -400,7 +413,6 @@ int main(Int_t argc, Char_t **argv)
   if(shuttleFile.IsNull())shuttleFile=flatFile;
   muonPedestal->SetAliNEvents(nEvents);
   muonPedestal->SetAliRunNumber(runNumber);
-  muonPedestal->SetAliNChannel(nChannel);
   
   muonPedestal->Finalize();  
   muonPedestal->MakeControlHistos();  
@@ -466,13 +478,10 @@ int main(Int_t argc, Char_t **argv)
   unsigned int nLastVersions=90;
   cout << "\n ***  Local DataBase: " << dir << " (Max= " << nLastVersions << ") ***" << endl;
   status = daqDA_localDB_storeFile(muonPedestal->GetHistoFileName(),nLastVersions);
-  //  if (!status) printf(" Failed to store file : %s   status = %d\n",muonPedestal->GetHistoFileName(),status);
   printf(" Store file : %s   status = %d\n",muonPedestal->GetHistoFileName(),status);
   status = daqDA_localDB_storeFile(shuttleFile.Data(),nLastVersions);
-  //  if (!status) printf(" Failed to store file : %s   status = %d\n",shuttleFile.Data(),status);
   printf(" Store file : %s   status = %d\n",shuttleFile.Data(),status);
   status = daqDA_localDB_storeFile(logOutputFile.Data(),nLastVersions);
-  //  if (!status) printf(" Failed to store file : %s   status = %d\n",logOutputFile.Data(),status);
   printf(" Store file : %s   status = %d\n",logOutputFile.Data(),status);
 
   // Transferring to OCDB via the SHUTTLE