]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONTRKOCCda.cxx
DQM configure file
[u/mrichter/AliRoot.git] / MUON / MUONTRKOCCda.cxx
index 6e9d0d9f3d1a27066f78a0c1f59dfa0f7eb2aa23..09b7b7d7af337e8364b86ec96e0342aaaa17fc28 100644 (file)
@@ -6,7 +6,7 @@
  Run Type: PHYSICS STANDALONE
  DA Type: MON
  Number of events needed: all (or at least as much as possible...)
- Input Files: 09000094301009.10.raw
+ Input Files: 10000119041028.20.raw 10000130367042.10.raw 10000120691024.50.raw
  Output Files: mch.occupancy, to be exported to the DAQ FXS
  Trigger types used: PHYSICS_EVENT
 */
@@ -36,6 +36,7 @@
 ///
 /// $Id$
 
+#include "AliDAQ.h"
 #include "AliMUON2DMap.h"
 #include "AliMUONCalibParamNI.h"
 #include "AliMUONRawStreamTrackerHP.h"
@@ -51,6 +52,7 @@
 #include "daqDA.h"
 #include "event.h"
 #include "monitor.h"
+#include "signal.h"
 
 #ifdef ALI_AMORE
 #include <AmoreDA.h>
@@ -60,7 +62,7 @@
 #endif
 
 const char* OUTPUT_FILE = "mch.occupancy";
-const char* DAVERSION = "MUONTRKOCCda v1.2 ($Id$)";
+const char* DAVERSION = "MUONTRKOCCda v1.61 ($Id$)";
 
 //______________________________________________________________________________
 void Add(AliMUONVStore& destStore, const AliMUONVStore& srcStore)
@@ -95,7 +97,7 @@ void Add(AliMUONVStore& destStore, const AliMUONVStore& srcStore)
 
 //______________________________________________________________________________
 void GenerateOutputFile(const AliMUONVStore& store, ostream& out, 
-                        Int_t runNumber, Int_t nevents)
+                        Int_t runNumber, Int_t nevents, Int_t numberOfEventsWithMCH)
 {
   /// Write the channel hit count (grouped by manu) in the output file.
   
@@ -111,20 +113,31 @@ void GenerateOutputFile(const AliMUONVStore& store, ostream& out,
   out << "//---------------------------------------------------------------------------" << endl;
   out << "//  BP   MANU  SUM_N  NEVENTS" << endl;
   out << "//---------------------------------------------------------------------------" << endl;
+
+  Int_t nlines(0);
   
   while ( ( manu = static_cast<AliMUONVCalibParam*>(next()) ) )
   {
     Int_t sum(0);
-//    Int_t nevents(0);
     
     for ( Int_t i = 0; i < manu->Size(); ++i ) 
     {
       sum += manu->ValueAsInt(i);
-      //      nevents = TMath::Max(nevents,manu->ValueAsInt(i,1));
-      // nevents = TMath::Max(nevents,manu->ValueAsInt(i,1));
     }
     
     out << Form("%5d %5d %10d %10d",manu->ID0(),manu->ID1(),sum,nevents) << endl;
+    ++nlines;
+  }
+  
+  if (!nlines)
+  {
+    // ok : empty output. Is it because the run was empty ? 
+    if ( !numberOfEventsWithMCH )
+    {
+      // yes. Let give a hint in the file so the Shuttle preprocessor will know about this...
+      out << Form("%5d %5d %10d %10d",-1,-1,0,0) << endl;
+    }
+    // else the preprocessor will fail, and that's good because there's something wrong somewhere...
   }
 }
   
@@ -144,6 +157,8 @@ int main(int argc, char **argv)
   /// were seen per manu, and the number of events.
   ///
   
+  signal(SIGSEGV,SIG_DFL); // to be able to get core dumps...
+  
   TStopwatch timers;
   timers.Start(kTRUE); 
   
@@ -170,6 +185,8 @@ int main(int argc, char **argv)
   Int_t numberOfBadEvents(0);
   Int_t numberOfUsedEvents(0);
   
+  Int_t numberOfEventsWithMCH(0);
+  
   AliMUON2DMap oneEventData(kTRUE);
   AliMUON2DMap accumulatedData(kTRUE);
   
@@ -201,7 +218,7 @@ int main(int argc, char **argv)
     
     for(;;)
     {
-      struct eventHeaderStruct *event;
+      struct eventHeaderStruct *event(0x0);
       eventTypeType eventT;
       
       status=monitorGetEventDynamic((void **)&event);
@@ -252,6 +269,31 @@ int main(int argc, char **argv)
         runNumber = rawReader->GetRunNumber();
       }
       
+      // *without* using the MUONTRK event decoder, we update the number
+      // of events where we have information about MUONTRK.
+      // this should be what is called subevents in the logbook
+      // we do *not* use the MCH decoder on purpose, to not mistakenly
+      // believe there's no event if the data is corrupted (and thus the decoder
+      // "sees" nothing).
+      
+      Bool_t mchThere(kFALSE);
+      
+      for ( int iDDL = 0; iDDL < AliDAQ::NumberOfDdls("MUONTRK") && !mchThere; ++iDDL )
+      {
+        rawReader->Reset();
+        rawReader->Select("MUONTRK",iDDL,iDDL);
+        if (rawReader->ReadHeader() )
+        {
+          if (rawReader->GetEquipmentSize() ) mchThere = kTRUE;
+        }      
+      }
+
+      if ( mchThere) ++numberOfEventsWithMCH;
+      
+      rawReader->Reset();
+      
+      // now do our real work with the MCH decoder
+      
       AliMUONRawStreamTrackerHP stream(rawReader);
       
       stream.DisableWarnings();
@@ -297,37 +339,42 @@ int main(int argc, char **argv)
   }
   
   
-  cout << Form("%12d events processed : %12d physics %d used ones %d bad ones",
-               numberOfEvents,numberOfPhysicsEvent,numberOfUsedEvents,numberOfBadEvents) << endl;
+  cout << Form("%12d events processed : %12d physics %d used ones %d bad ones [ %d with MCH information ]",
+               numberOfEvents,numberOfPhysicsEvent,numberOfUsedEvents,numberOfBadEvents,numberOfEventsWithMCH) << endl;
     
   ofstream fout(OUTPUT_FILE);
   
-  GenerateOutputFile(accumulatedData,fout,runNumber,numberOfUsedEvents);
+  GenerateOutputFile(accumulatedData,fout,runNumber,numberOfUsedEvents,numberOfEventsWithMCH);
   
   fout.close();
   
+  /* store the result file on FXS */  
+  if (daqDA_FES_storeFile(OUTPUT_FILE,"OCCUPANCY")) return -9;
+    
 #ifdef ALI_AMORE
   
-  // Send occupancy store (as a big string) to the AMORE DB
-  amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
-  
-  ostringstream str;
-  
-  GenerateOutputFile(accumulatedData,str,runNumber,numberOfUsedEvents);
+  if ( numberOfUsedEvents ) // do not update the AMORE pool with an empty object...
+  {
+    // Send occupancy store (as a big string) to the AMORE DB
+    amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
+    
+    ostringstream str;
+    
+    GenerateOutputFile(accumulatedData,str,runNumber,numberOfUsedEvents,numberOfEventsWithMCH);
+    
+    TObjString occupancyAsString(str.str().c_str());
+    
+    cout << "will send to amore" << endl;
     
-  TObjString occupancyAsString(str.str().c_str());
+    Int_t status = amoreDA.Send("Occupancy",&occupancyAsString);
+    if ( status )
+    {
+      cerr << "ERROR : Failed to write occupancies in the AMORE database : " << status << endl;
+    } 
+  }
   
-  Int_t status = amoreDA.Send("Occupancy",&occupancyAsString);
-  if ( status )
-  {
-    cerr << "ERROR : Failed to write occupancies in the AMORE database : " << status << endl;
-  } 
-
 #endif
-  
-  /* store the result file on FXS */  
-  if (daqDA_FES_storeFile(OUTPUT_FILE,"OCCUPANCY")) return -9;
-
+    
   timers.Stop();
   printf("\nExecution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());