]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDBaseDA.cxx
small corrections to previous checkin
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.cxx
index ac4892e7ad235c8e95e2e90dc91c2fe444f51359..82debd4040703f2b38f6590dd09bab6f8a543d09 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "AliFMDBaseDA.h"
 #include "iostream"
-
 #include "AliFMDRawReader.h"
 #include "AliFMDCalibSampleRate.h"
 #include "AliFMDCalibStripRange.h"
@@ -97,6 +96,7 @@ AliFMDBaseDA::AliFMDBaseDA() :
   fRequiredEvents(0),
   fCurrentEvent(0)
  {
+   fSeenDetectors[0] = fSeenDetectors[1] = fSeenDetectors[2] = kFALSE;
   fDetectorArray.SetOwner();
   fConditionsFile.open("conditions.csv");
 }
@@ -113,6 +113,10 @@ AliFMDBaseDA::AliFMDBaseDA(const AliFMDBaseDA & baseDA) :
   fRequiredEvents(baseDA.fRequiredEvents),
   fCurrentEvent(baseDA.fCurrentEvent)
 {
+  fSeenDetectors[0] = baseDA.fSeenDetectors[0];
+  fSeenDetectors[1] = baseDA.fSeenDetectors[1];
+  fSeenDetectors[2] = baseDA.fSeenDetectors[2];
+
   fDetectorArray.SetOwner();
   
 }
@@ -134,10 +138,7 @@ void AliFMDBaseDA::Run(AliRawReader* reader)
   
   
   
-  InitContainer(diagFile);
-  //Init();
-
-
+  
   reader->Reset();
   
   AliFMDRawReader* fmdReader  = new AliFMDRawReader(reader,0);
@@ -159,37 +160,42 @@ void AliFMDBaseDA::Run(AliRawReader* reader)
     }
   }
   
+  InitContainer(diagFile);
+  
   if(!SOD_read) 
     AliWarning("No SOD event detected!");
   
   int lastProgress = 0;
   
+  
+  
   for(Int_t n =1;n <= GetRequiredEvents(); n++) {
     if(!reader->NextEvent()) continue;
-    
     SetCurrentEvent(n);
     digitArray->Clear();
     fmdReader->ReadAdcs(digitArray);
-    //std::cout<<"in event "<<*(reader->GetEventId())<<"   "<<n<<std::endl;
-    //AliDebug(5, Form("In event # %d with %d entries", 
-    //              *(reader->GetEventId()), digitArray->GetEntriesFast()));
     
     for(Int_t i = 0; i<digitArray->GetEntriesFast();i++) {
       AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitArray->At(i));
+      fSeenDetectors[digit->Detector()-1] = kTRUE;
       FillChannels(digit);
     }
     
+   
     FinishEvent();
+    
     int progress = int((n *100)/ GetRequiredEvents()) ;
     if (progress <= lastProgress) continue;
     lastProgress = progress;
     std::cout << "Progress: " << lastProgress << " / 100 " << std::endl;
+    
   }
-
+  
   AliInfo(Form("Looped over %d events",GetCurrentEvent()));
   WriteHeaderToFile();
   
   for(UShort_t det=1;det<=3;det++) {
+    if (!fSeenDetectors[det-1]) continue;
     std::cout << "FMD" << det << std::endl;
     UShort_t FirstRing = (det == 1 ? 1 : 0);
     for (UShort_t ir = FirstRing; ir < 2; ir++) {
@@ -204,24 +210,25 @@ void AliFMDBaseDA::Run(AliRawReader* reader)
        std::cout << '.' << std::flush;
       }
       if(fSaveHistograms)
-       diagFile->Flush();
+       diagFile->Flush();
       std::cout << "done" << std::endl;
     }
   }
-
+  
   if(fOutputFile.is_open()) {
     fOutputFile.write("# EOF\n",6);
     fOutputFile.close();
   }
   
+  Terminate(diagFile);
+    
   if(fSaveHistograms ) {
     
-    Terminate(diagFile);
-  
     AliInfo("Closing diagnostics file - please wait ...");
     // diagFile->Write();
     diagFile->Close();
     AliInfo("done");
+    
   }
 }
 //_____________________________________________________________________
@@ -296,41 +303,11 @@ void AliFMDBaseDA::WriteConditionsData(AliFMDRawReader* fmdReader)
   AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate();
   AliFMDCalibStripRange* stripRange = new AliFMDCalibStripRange();
   
-  fmdReader->ReadSODevent(sampleRate,stripRange,fPulseSize,fPulseLength);
-  
-  // Sample Rate
-  /*
-    UShort_t defSampleRate = 4;
-    UShort_t sampleRateFromSOD;
-    
-  AliFMDCalibSampleRate* sampleRate = new AliFMDCalibSampleRate();
+  fmdReader->ReadSODevent(sampleRate,stripRange,fPulseSize,fPulseLength,
+                         fSeenDetectors);
 
-  UShort_t firstStrip = 0;
-  UShort_t lastStrip  = 127;
-  UShort_t firstStripSOD;
-  UShort_t lastStripSOD;
-  AliFMDCalibStripRange* stripRange = new AliFMDCalibStripRange();
-  
-  for(Int_t det=1;det<=3;det++) {
-    UShort_t FirstRing = (det == 1 ? 1 : 0);
-    for (UShort_t ir = FirstRing; ir < 2; ir++) {
-      Char_t   ring = (ir == 0 ? 'O' : 'I');
-      UShort_t nsec = (ir == 0 ? 40  : 20);
-      for(UShort_t sec =0; sec < nsec;  sec++)  {
-       sampleRateFromSOD = defSampleRate;
-       sampleRate->Set(det,ring,sec,0,sampleRateFromSOD);
-       firstStripSOD = firstStrip;
-       lastStripSOD  = lastStrip;
-       stripRange->Set(det,ring,sec,0,firstStripSOD,lastStripSOD);
-       
-      }
-    }
-  }
-  */
-  sampleRate->WriteToFile(fConditionsFile);
-  stripRange->WriteToFile(fConditionsFile);
-  //pars->SetSampleRate(sampleRate);
-  //pars->SetStripRange(stripRange);
+  sampleRate->WriteToFile(fConditionsFile, fSeenDetectors);
+  stripRange->WriteToFile(fConditionsFile, fSeenDetectors);
 
  
   // Zero Suppresion
@@ -340,6 +317,9 @@ void AliFMDBaseDA::WriteConditionsData(AliFMDRawReader* fmdReader)
   fConditionsFile.write("# Gain Events \n",15);
   
   for(UShort_t det=1; det<=3;det++) {
+    if (!fSeenDetectors[det-1]) { 
+      continue;
+    }
     UShort_t firstring = (det == 1 ? 1 : 0);
     for(UShort_t iring = firstring; iring <=1;iring++) {
       Char_t ring = (iring == 1 ? 'I' : 'O');
@@ -359,6 +339,9 @@ void AliFMDBaseDA::WriteConditionsData(AliFMDRawReader* fmdReader)
   fConditionsFile.write("# Gain Pulse \n",14);
   
   for(UShort_t det=1; det<=3;det++) {
+    if (!fSeenDetectors[det-1]) { 
+      continue;
+    }
     UShort_t firstring = (det == 1 ? 1 : 0);
     for(UShort_t iring = firstring; iring <=1;iring++) {
       Char_t ring = (iring == 1 ? 'I' : 'O');
@@ -374,33 +357,6 @@ void AliFMDBaseDA::WriteConditionsData(AliFMDRawReader* fmdReader)
       }
     }
   }
-  
-  
-
-  // Gain Relevant stuff
-  /*
-  UShort_t defPulseSize = 32 ; 
-  UShort_t defPulseLength = 100 ; 
-  UShort_t pulseSizeFromSOD;
-  UShort_t pulseLengthFromSOD;  
-  
-  fPulseSize.Reset(defPulseSize);
-  fPulseLength.Reset(defPulseLength);
-  
-  for(UShort_t det=1;det<=3;det++)
-    for(UShort_t iring=0;iring<=1;iring++)
-      for(UShort_t board=0;board<=1;board++) {
-       pulseSizeFromSOD = defPulseSize;
-       pulseLengthFromSOD = defPulseLength;
-
-       fPulseSize.AddAt(pulseSizeFromSOD,GetHalfringIndex(det,iring,board));
-       fPulseLength.AddAt(pulseLengthFromSOD,GetHalfringIndex(det,iring,board));
-      }
-         
-  
-  //  fConditionsFile     << defSampleRate   << ',' 
-  //                 << timebins     <<"\n";
-  */
   if(fConditionsFile.is_open()) {
     
     fConditionsFile.write("# EOF\n",6);