]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOS.cxx
Major changes in AliAltroBuffer. Now it can be used only for writing of raw data...
[u/mrichter/AliRoot.git] / PHOS / AliPHOS.cxx
index 01bbdca7176cee51ffa6fc5545cc2161e5b2f095..c73bf3d6e357cd744654b225a9e7514b5938b7fb 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.97  2006/04/22 10:30:17  hristov
+ * Add fEnergy to AliPHOSDigit and operate with EMC amplitude in energy units (Yu.Kharlov)
+ *
+ * Revision 1.96  2006/04/07 08:41:59  hristov
+ * Follow AliAlignObj framework and remove AliPHOSAlignData (Yu.Kharlov)
+ *
+ * Revision 1.95  2006/03/14 19:40:41  kharlov
+ * Remove De-digitizing of raw data and digitizing the raw data fit
+ *
  * Revision 1.94  2006/03/07 18:56:25  kharlov
  * CDB is passed via environment variable
  *
@@ -94,25 +103,10 @@ AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title)
 {
   //   ctor : title is used to identify the layout
 
-  // Check if CDB_PATH is defined and take alignment data from CDB
-  AliPHOSAlignData* alignda = 0;
-  if (gSystem->Getenv("CDB_PATH")) {
-    TString cdbPath = gSystem->Getenv("CDB_PATH");
-    AliCDBStorage *cdbStorage = AliCDBManager::Instance()->GetStorage(cdbPath);
-    if (cdbStorage != NULL) {
-      alignda  =
-       (AliPHOSAlignData*)(cdbStorage->Get("PHOS/Alignment/Geometry",0)->GetObject());
-      if(AliLog::GetGlobalDebugLevel()>0) alignda->Print();
-    }
-    else {
-      Fatal("AliPHOS", "No CDB storage at the path %s", cdbPath.Data()) ;
-    }
-  }
-  
   fHighCharge        = 8.2 ;          // adjusted for a high gain range of 5.12 GeV (10 bits)
   fHighGain          = 6.64 ; 
   fHighLowGainFactor = 16. ;          // adjusted for a low gain range of 82 GeV (10 bits) 
-  fLowGainOffset     = GetGeometry(alignda)->GetNModules() + 1 ;   
+  fLowGainOffset     = GetGeometry()->GetNModules() + 1 ;   
     // offset added to the module id to distinguish high and low gain data
 }
 
@@ -436,10 +430,6 @@ void AliPHOS::Digits2Raw()
     return;
   }
 
-  // get the digitizer 
-  loader->LoadDigitizer();
-//   AliPHOSDigitizer * digitizer = dynamic_cast<AliPHOSDigitizer *>(loader->Digitizer())  ; 
-  
   // get the geometry
   AliPHOSGeometry* geom = GetGeometry();
   if (!geom) {
@@ -449,26 +439,19 @@ void AliPHOS::Digits2Raw()
 
   // some digitization constants
   const Int_t    kDDLOffset = 0x600; // assigned to PHOS
-  const Int_t    kThreshold = 1; // skip digits below this threshold
+//   const Int_t    kThreshold = 1; // skip digits below this threshold // YVK
+  const Float_t    kThreshold = 0.001; // skip digits below 1 MeV
+  const Int_t      kAdcThreshold = 1;  // Lower ADC threshold to write to raw data
 
   AliAltroBuffer* buffer = NULL;
   Int_t prevDDL = -1;
   Int_t adcValuesLow[fkTimeBins];
   Int_t adcValuesHigh[fkTimeBins];
 
-//   AliPHOSCalibData* calib=0;
-
-//   //retrieve calibration database
-//   if(AliCDBManager::Instance()->IsDefaultStorageSet()){
-//     AliCDBEntry *entry = (AliCDBEntry*) AliCDBManager::Instance()->GetDefaultStorage()
-//       ->Get("PHOS/GainFactors_and_Pedestals/Calibration",gAlice->GetRunNumber());
-//     calib = (AliPHOSCalibData*) entry->GetObject();
-//   }
-
   // loop over digits (assume ordered digits)
   for (Int_t iDigit = 0; iDigit < digits->GetEntries(); iDigit++) {
     AliPHOSDigit* digit = dynamic_cast<AliPHOSDigit *>(digits->At(iDigit)) ;
-    if (digit->GetAmp() < kThreshold) 
+    if (digit->GetEnergy() < kThreshold) 
       continue;
     Int_t relId[4];
     geom->AbsToRelNumbering(digit->GetId(), relId);
@@ -495,7 +478,7 @@ void AliPHOS::Digits2Raw()
       TString fileName("PHOS_") ;
       fileName += (iDDL + kDDLOffset) ; 
       fileName += ".ddl" ; 
-      buffer = new AliAltroBuffer(fileName.Data(), 1);
+      buffer = new AliAltroBuffer(fileName.Data());
       buffer->WriteDataHeader(kTRUE, kFALSE);  //Dummy;
 
       prevDDL = iDDL;
@@ -503,7 +486,7 @@ void AliPHOS::Digits2Raw()
 
     // out of time range signal (?)
     if (digit->GetTimeR() > GetRawFormatTimeMax() ) {
-      buffer->FillBuffer(digit->GetAmp());
+      buffer->FillBuffer((Int_t)digit->GetEnergy());
       buffer->FillBuffer(GetRawFormatTimeBins() );  // time bin
       buffer->FillBuffer(3);          // bunch length      
       buffer->WriteTrailer(3, relId[3], relId[2], module);  // trailer
@@ -512,16 +495,8 @@ void AliPHOS::Digits2Raw()
     } else {
       Double_t energy = 0 ;
       Int_t   module = relId[0];
-//       Int_t   column = relId[3];
-//       Int_t   row    = relId[2];
       if ( digit->GetId() <= geom->GetNModules() *  geom->GetNCristalsInModule()) {
-//     if(calib)
-//       energy = digit->GetAmp()*calib->GetADCchannelEmc(module,column,row) + 
-//         calib->GetADCpedestalEmc(module,column,row);
-//     else
-//       energy=digit->GetAmp()*digitizer->GetEMCchannel()+digitizer->GetEMCpedestal();
-//       } 
-       energy=digit->GetAmp();
+       energy=digit->GetEnergy();
       }
       else {
 //     energy = digit->GetAmp()*digitizer->GetCPVchannel()+digitizer->GetCPVpedestal();
@@ -529,12 +504,12 @@ void AliPHOS::Digits2Raw()
       }        
       Bool_t lowgain = RawSampledResponse(digit->GetTimeR(), energy, adcValuesHigh, adcValuesLow) ; 
       
-     if (lowgain) 
+      if (lowgain) 
        buffer->WriteChannel(relId[3], relId[2], module + fLowGainOffset, 
-                          GetRawFormatTimeBins(), adcValuesLow, kThreshold);
+                            GetRawFormatTimeBins(), adcValuesLow , kAdcThreshold);
       else 
        buffer->WriteChannel(relId[3], relId[2], module, 
-                            GetRawFormatTimeBins(), adcValuesHigh, kThreshold);
+                            GetRawFormatTimeBins(), adcValuesHigh, kAdcThreshold);
       
     }
   }
@@ -605,6 +580,10 @@ Bool_t AliPHOS::RawSampledResponse(Double_t dtime, Double_t damp, Int_t * adcH,
 {
   // for a start time dtime and an amplitude damp given by digit, 
   // calculates the raw sampled response AliPHOS::RawResponseFunction
+  // Input: dtime - signal start time
+  //        damp  - signal amplitude (energy)
+  // Output: adcH - array[fkTimeBins] of 10-bit samples for high-gain channel
+  //         adcL - array[fkTimeBins] of 10-bit samples for low-gain channel
 
   const Int_t kRawSignalOverflow = 0x3FF ; 
   Bool_t lowGain = kFALSE ;