]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliCaloCalibPedestal.cxx
select only primaries
[u/mrichter/AliRoot.git] / EMCAL / AliCaloCalibPedestal.cxx
index b45b833995e2021369d01950bb1efd4933e11cf7..b17639957217f321eb537fde138332e166fc7328 100644 (file)
@@ -54,6 +54,8 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
   TObject(),
   fPedestalLowGain(),
   fPedestalHighGain(),
+  fSampleLowGain(),
+  fSampleHighGain(),
   fPeakMinusPedLowGain(),
   fPeakMinusPedHighGain(),
   fPedestalLowGainDiff(),
@@ -65,6 +67,8 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
   fPeakMinusPedLowGainRatio(),
   fPeakMinusPedHighGainRatio(),
   fDeadMap(),
+  fNEvents(0),
+  fNChanFills(0),
   fDeadTowers(0),
   fNewDeadTowers(0),
   fResurrectedTowers(0),
@@ -73,6 +77,11 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
   fColumns(0),
   fRows(0),
   fModules(0),
+  fRowMin(0),
+  fRowMax(0),
+  fRowMultiplier(0),
+  fCaloString(),
+  fMapping(NULL),
   fRunNumber(-1)
 {
   //Default constructor. First we set the detector-type related constants.
@@ -80,6 +89,10 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
     fColumns = fgkPhosCols;
     fRows = fgkPhosRows;
     fModules = fgkPhosModules;
+    fCaloString = "PHOS";
+    fRowMin = -1*fRows;
+    fRowMax = 0;
+    fRowMultiplier = -1;
   } 
   else {
     //We'll just trust the enum to keep everything in line, so that if detectorType
@@ -88,6 +101,10 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
     fColumns = fgkEmCalCols;
     fRows = fgkEmCalRows;
     fModules = fgkEmCalModules;
+    fCaloString = "EMCAL";
+    fRowMin = 0;
+    fRowMax = fRows;
+    fRowMultiplier = 1;
   } 
   fDetType = detectorType;
  
@@ -101,7 +118,7 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
     title += i; 
     fPedestalLowGain.Add(new TProfile2D(name, title,
                                        fColumns, 0.0, fColumns, 
-                                       fRows, -fRows, 0.0));
+                                       fRows, fRowMin, fRowMax,"s"));
   
     //Pedestals, high gain
     name = "hPedhighgain";
@@ -110,7 +127,24 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
     title += i; 
     fPedestalHighGain.Add(new TProfile2D(name, title,
                                         fColumns, 0.0, fColumns, 
-                                        fRows, -fRows, 0.0));
+                                        fRows, fRowMin, fRowMax,"s"));
+    //All Samples, low gain
+    name = "hSamplelowgain";
+    name += i;
+    title = "All Samples, low gain, module ";
+    title += i; 
+    fSampleLowGain.Add(new TProfile2D(name, title,
+                                       fColumns, 0.0, fColumns, 
+                                       fRows, fRowMin, fRowMax,"s"));
+  
+    //All Samples, high gain
+    name = "hSamplehighgain";
+    name += i;
+    title = "All Samples, high gain, module ";
+    title += i; 
+    fSampleHighGain.Add(new TProfile2D(name, title,
+                                        fColumns, 0.0, fColumns, 
+                                        fRows, fRowMin, fRowMax,"s"));
   
     //Peak-Pedestals, low gain
     name = "hPeakMinusPedlowgain";
@@ -119,7 +153,7 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
     title += i; 
     fPeakMinusPedLowGain.Add(new TProfile2D(name, title,
                                            fColumns, 0.0, fColumns, 
-                                           fRows, -fRows, 0.0));
+                                           fRows, fRowMin, fRowMax,"s"));
   
     //Peak-Pedestals, high gain
     name = "hPeakMinusPedhighgain";
@@ -128,20 +162,22 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(kDetType detectorType) :
     title += i; 
     fPeakMinusPedHighGain.Add(new TProfile2D(name, title,
                                             fColumns, 0.0, fColumns, 
-                                            fRows, -fRows, 0.0));
+                                            fRows, fRowMin, fRowMax,"s"));
   
     name = "hDeadMap";
     name += i;
     title = "Dead map, module ";
     title += i;
     fDeadMap.Add(new TH2D(name, title, fColumns, 0.0, fColumns, 
-                         fRows, -fRows, 0.0));
+                         fRows, fRowMin, fRowMax));
   
   }//end for nModules create the histograms
  
   //Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default)
   fPedestalLowGain.Compress();
   fPedestalHighGain.Compress();
+  fSampleLowGain.Compress();
+  fSampleHighGain.Compress();
   fPeakMinusPedLowGain.Compress();
   fPeakMinusPedHighGain.Compress();
   fDeadMap.Compress();
@@ -167,6 +203,8 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) :
   TObject(ped),
   fPedestalLowGain(),
   fPedestalHighGain(),
+  fSampleLowGain(),
+  fSampleHighGain(),
   fPeakMinusPedLowGain(),
   fPeakMinusPedHighGain(),
   fPedestalLowGainDiff(),
@@ -178,6 +216,8 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) :
   fPeakMinusPedLowGainRatio(),
   fPeakMinusPedHighGainRatio(),
   fDeadMap(),
+  fNEvents(ped.GetNEvents()),
+  fNChanFills(ped.GetNChanFills()),
   fDeadTowers(ped.GetDeadTowerCount()),
   fNewDeadTowers(ped.GetDeadTowerNew()),
   fResurrectedTowers(ped.GetDeadTowerResurrected()),
@@ -186,6 +226,11 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) :
   fColumns(ped.GetColumns()),
   fRows(ped.GetRows()),
   fModules(ped.GetModules()),
+  fRowMin(ped.GetRowMin()),
+  fRowMax(ped.GetRowMax()),
+  fRowMultiplier(ped.GetRowMultiplier()),
+  fCaloString(ped.GetCaloString()),
+  fMapping(NULL), //! note that we are not copying the map info
   fRunNumber(ped.GetRunNumber())
 {
   // Then the ObjArray ones; we add the histograms rather than trying TObjArray = assignment
@@ -193,6 +238,8 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) :
   for (int i = 0; i < fModules; i++) {
     fPedestalLowGain.Add( ped.GetPedProfileLowGain(i) );
     fPedestalHighGain.Add( ped.GetPedProfileHighGain(i) );
+    fSampleLowGain.Add( ped.GetSampleProfileLowGain(i) );
+    fSampleHighGain.Add( ped.GetSampleProfileHighGain(i) );
     fPeakMinusPedLowGain.Add( ped.GetPeakProfileLowGain(i) );
     fPeakMinusPedHighGain.Add( ped.GetPeakProfileHighGain(i) );
 
@@ -202,6 +249,8 @@ AliCaloCalibPedestal::AliCaloCalibPedestal(const AliCaloCalibPedestal &ped) :
   //Compress the arrays, in order to remove the empty objects (a 16 slot array is created by default)
   fPedestalLowGain.Compress();
   fPedestalHighGain.Compress();
+  fSampleLowGain.Compress();
+  fSampleHighGain.Compress();
   fPeakMinusPedLowGain.Compress();
   fPeakMinusPedHighGain.Compress();
   fDeadMap.Compress();
@@ -243,6 +292,8 @@ void AliCaloCalibPedestal::Reset()
       GetPeakProfileHighGainRatio(i)->Reset();
     }
   }
+  fNEvents = 0;
+  fNChanFills = 0;
   fDeadTowers = 0;
   fNewDeadTowers = 0;
   fResurrectedTowers = 0;
@@ -250,12 +301,38 @@ void AliCaloCalibPedestal::Reset()
   //To think about: should fReference be deleted too?... let's not do it this time, at least...
 }
 
+//_____________________________________________________________________
+Bool_t AliCaloCalibPedestal::AddInfo(const AliCaloCalibPedestal *ped)
+{
+  // just do this for the basic histograms/profiles that get filled in ProcessEvent
+  // may not have data for all modules, but let's just Add everything..
+  for (int i = 0; i < fModules; i++) {
+    GetPedProfileLowGain(i)->Add( ped->GetPedProfileLowGain(i) );
+    GetPedProfileHighGain(i)->Add( ped->GetPedProfileHighGain(i) );
+    GetPeakProfileLowGain(i)->Add( ped->GetPeakProfileLowGain(i) );
+    GetPeakProfileHighGain(i)->Add( ped->GetPeakProfileHighGain(i) );
+  }//end for nModules 
+
+  // DeadMap; Diff profiles etc would need to be redone after this operation
+
+  return kTRUE;//We succesfully added info from the supplied object
+}
+
+//_____________________________________________________________________
+Bool_t AliCaloCalibPedestal::ProcessEvent(AliRawReader *rawReader)
+{ 
+  // if fMapping is NULL the rawstream will crate its own mapping
+  AliCaloRawStream rawStream(rawReader, fCaloString, (AliAltroMapping**)fMapping);
+  return ProcessEvent(&rawStream);
+}
+
 //_____________________________________________________________________
 Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStream *in)
 { 
   // Method to process=analyze one event in the data stream
   if (!in) return kFALSE; //Return right away if there's a null pointer
   
+  fNEvents++; // one more event
   int sample, i = 0; //The sample temp, and the sample number in current event.
   int max = fgkSampleMin, min = fgkSampleMax;//Use these for picking the pedestal
   int gain = 0;
@@ -267,8 +344,14 @@ Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStream *in)
     i++;
     if ( i >= in->GetTimeLength()) {
       //If we're here then we're done with this tower
-      gain = 1 - in->IsLowGain();
-      
+      gain = -1; // init to not valid value
+      if ( in->IsLowGain() ) {
+       gain = 0;
+      }
+      else if ( in->IsHighGain() ) {
+       gain = 1;
+      }
+
       int arrayPos = in->GetModule(); //The modules are numbered starting from 0
       if (arrayPos >= fModules) {
        //TODO: return an error message, if appopriate (perhaps if debug>0?)
@@ -280,17 +363,20 @@ Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStream *in)
        printf("Oh no: arrayPos = %i.\n", arrayPos); 
       }
 
+      fNChanFills++; // one more channel found, and profile to be filled
       //NOTE: coordinates are (column, row) for the profiles
       if (gain == 0) {
        //fill the low gain histograms
-       ((TProfile2D*)fPedestalLowGain[arrayPos])->Fill(in->GetColumn(), -in->GetRow() - 1, min);
-       ((TProfile2D*)fPeakMinusPedLowGain[arrayPos])->Fill(in->GetColumn(), -in->GetRow() - 1, max - min);
+       ((TProfile2D*)fPedestalLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), min);
+       ((TProfile2D*)fPeakMinusPedLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), max - min);
+       ((TProfile2D*)fSampleLowGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), sample);
       } 
-      else {//fill the high gain ones
-       ((TProfile2D*)fPedestalHighGain[arrayPos])->Fill(in->GetColumn(), -in->GetRow() - 1, min);
-       ((TProfile2D*)fPeakMinusPedHighGain[arrayPos])->Fill(in->GetColumn(), -in->GetRow() - 1, max - min);
+      else if (gain == 1) {//fill the high gain ones
+       ((TProfile2D*)fPedestalHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), min);
+       ((TProfile2D*)fPeakMinusPedHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), max - min);
+       ((TProfile2D*)fSampleHighGain[arrayPos])->Fill(in->GetColumn(), fRowMultiplier*in->GetRow(), sample);
       }//end if gain
-      
+
       max = fgkSampleMin; min = fgkSampleMax;
       i = 0;
     
@@ -327,6 +413,12 @@ Bool_t AliCaloCalibPedestal::SaveHistograms(TString fileName, Bool_t saveEmptyHi
     if( ((TProfile2D *)fPedestalHighGain[i])->GetEntries() || saveEmptyHistos) {
       fPedestalHighGain[i]->Write();
     }
+    if( ((TProfile2D *)fSampleLowGain[i])->GetEntries() || saveEmptyHistos) {
+      fSampleLowGain[i]->Write();
+    }
+    if( ((TProfile2D *)fSampleHighGain[i])->GetEntries() || saveEmptyHistos) {
+      fSampleHighGain[i]->Write();
+    }
   } 
   
   destFile.Close();
@@ -384,7 +476,7 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles()
     title += i; 
     fPedestalLowGainDiff.Add(new TProfile2D(name, title,
                                            fColumns, 0.0, fColumns, 
-                                           fRows, -fRows, 0.0));
+                                           fRows, fRowMin, fRowMax,"s"));
   
     //Pedestals, high gain
     name = "hPedhighgainDiff";
@@ -393,17 +485,8 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles()
     title += i; 
     fPedestalHighGainDiff.Add(new TProfile2D(name, title,
                                             fColumns, 0.0, fColumns, 
-                                            fRows, -fRows, 0.0));
-  
-    //Peak-Pedestals, low gain
-    name = "hPeakMinusPedlowgainDiff";
-    name += i;
-    title = "Peak-Pedestal difference, low gain, module ";
-    title += i; 
-    fPeakMinusPedLowGainDiff.Add(new TProfile2D(name, title,
-                                               fColumns, 0.0, fColumns, 
-                                               fRows, -fRows, 0.0));
-  
+                                            fRows, fRowMin, fRowMax,"s"));
+
     //Peak-Pedestals, high gain
     name = "hPeakMinusPedhighgainDiff";
     name += i;
@@ -411,7 +494,7 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles()
     title += i; 
     fPeakMinusPedHighGainDiff.Add(new TProfile2D(name, title,
                                                 fColumns, 0.0, fColumns, 
-                                                fRows, -fRows, 0.0));
+                                                fRows, fRowMin, fRowMax,"s"));
   
     //Pedestals, low gain
     name = "hPedlowgainRatio";
@@ -420,7 +503,7 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles()
     title += i; 
     fPedestalLowGainRatio.Add(new TProfile2D(name, title,
                                             fColumns, 0.0, fColumns, 
-                                            fRows, -fRows, 0.0));
+                                            fRows, fRowMin, fRowMax,"s"));
   
     //Pedestals, high gain
     name = "hPedhighgainRatio";
@@ -429,7 +512,7 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles()
     title += i; 
     fPedestalHighGainRatio.Add(new TProfile2D(name, title,
                                              fColumns, 0.0, fColumns, 
-                                             fRows, -fRows, 0.0));
+                                             fRows, fRowMin, fRowMax,"s"));
   
     //Peak-Pedestals, low gain
     name = "hPeakMinusPedlowgainRatio";
@@ -438,7 +521,7 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles()
     title += i; 
     fPeakMinusPedLowGainRatio.Add(new TProfile2D(name, title,
                                                 fColumns, 0.0, fColumns, 
-                                                fRows, -fRows, 0.0));
+                                                fRows, fRowMin, fRowMax,"s"));
   
     //Peak-Pedestals, high gain
     name = "hPeakMinusPedhighgainRatio";
@@ -447,7 +530,7 @@ void AliCaloCalibPedestal::ValidateComparisonProfiles()
     title += i; 
     fPeakMinusPedHighGainRatio.Add(new TProfile2D(name, title,
                                                  fColumns, 0.0, fColumns, 
-                                                 fRows, -fRows, 0.0));
+                                                 fRows, fRowMin, fRowMax,"s"));
     
   }//end for nModules create the histograms
 }