Set dynamics for simulated Pb-Pb collisions
authorcheynis <cheynis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 May 2009 16:34:03 +0000 (16:34 +0000)
committercheynis <cheynis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 27 May 2009 16:34:03 +0000 (16:34 +0000)
VZERO/AliVZERODigitizer.cxx
VZERO/AliVZERODigitizer.h
VZERO/AliVZEROReconstructor.cxx
VZERO/AliVZEROReconstructor.h

index 7ccd763..4dceb51 100644 (file)
@@ -26,6 +26,7 @@
 // --- ROOT system ---
 #include <TMath.h>
 #include <TTree.h>
+#include <TMap.h>
 #include <TGeoManager.h>
 #include <TGeoPhysicalNode.h>
 #include <AliGeomManager.h>
@@ -38,6 +39,7 @@
 #include "AliVZEROhit.h"
 #include "AliRunLoader.h"
 #include "AliLoader.h"
+#include "AliGRPObject.h"
 #include "AliRunDigitizer.h"
 #include "AliCDBManager.h"
 #include "AliCDBStorage.h"
 ClassImp(AliVZERODigitizer)
 
  AliVZERODigitizer::AliVZERODigitizer()
-   :AliDigitizer(),
-    fCalibData(GetCalibData()),
-    fPhotoCathodeEfficiency(0.18),
-    fPMVoltage(768.0),
-    fPMGain(TMath::Power((fPMVoltage / 112.5) ,7.04277)),
-    fNdigits(0),
-    fDigits(0)
+                   :AliDigitizer(),
+                    fCalibData(GetCalibData()),
+                    fPhotoCathodeEfficiency(0.18),
+                    fPMVoltage(768.0),
+                    fPMGain(TMath::Power((fPMVoltage / 112.5) ,7.04277)),
+                    fNdigits(0),
+                    fDigits(0),
+                    fCollisionMode(0),
+                    fBeamEnergy(0.)
    
 {
   // default constructor
@@ -79,7 +83,9 @@ ClassImp(AliVZERODigitizer)
                      fPMVoltage(768.0),
                      fPMGain(TMath::Power((fPMVoltage / 112.5) ,7.04277)),
                     fNdigits(0),
-                     fDigits(0)
+                     fDigits(0),
+                    fCollisionMode(0),
+                     fBeamEnergy(0.)
                                        
 {
   // constructor
@@ -117,7 +123,8 @@ Bool_t AliVZERODigitizer::Init()
   
   //  TGeoHMatrix *im = AliGeomManager::GetMatrix("VZERO/V0C");
   //  im->Print();
-  
+
+  GetCollisionMode();
   return kTRUE;
 }
 
@@ -210,11 +217,11 @@ void AliVZERODigitizer::Exec(Option_t* /*option*/)
        continue; }
        
      for(Int_t i=0; i<80; i++) {map[i] = 0; time[i] = 0.0;}
-             
+     
      TClonesArray* hits = vzero->Hits();
              
 //  Now makes Digits from hits
-         
+     
      Int_t nTracks = (Int_t) treeH->GetEntries();
      for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
          for (Int_t i=0; i<80; i++) {time_ref[i] = 999999.0;}   
@@ -224,7 +231,7 @@ void AliVZERODigitizer::Exec(Option_t* /*option*/)
          for (Int_t iHit = 0; iHit < nHits; iHit++) {
             AliVZEROhit* hit = (AliVZEROhit *)hits->UncheckedAt(iHit);
             Int_t nPhot = hit->Nphot();
-            Int_t cell  = hit->Cell();                                    
+            Int_t cell  = hit->Cell();                          
             map[cell] += nPhot;
             Float_t dt_scintillator = gRandom->Gaus(0,0.7);
             Float_t t = dt_scintillator + 1e9*hit->Tof();
@@ -245,10 +252,13 @@ void AliVZERODigitizer::Exec(Option_t* /*option*/)
         Float_t noise = gRandom->Gaus(10.5,3.22);
         Float_t pmResponse  =  q1/kC*TMath::Power(ktheta/kthau,1/(1-ktheta/kthau)) 
         + noise*1e-3;  
+       if(fCollisionMode >0) adc_gain[i] = adc_gain[i]/70.0; // reduce dynamics in Ion Collision Mode
         map[i] = Int_t( pmResponse * adc_gain[i]);
-//     printf("cell=%d,  pmNumber=%d,  mip=%f \n",i,GetPMNumber(i), (1.0/fCalibData->GetMIPperADC(GetPMNumber(i))));
-        if(map[i] > (int(( 1.0/fCalibData->GetMIPperADC(GetPMNumber(i))/2 ) + 0.5)) )
-                 {map[i] = Int_t(gRandom->Gaus(map[i], (int(( 1.0/fCalibData->GetMIPperADC(GetPMNumber(i))/6 ) + 0.5)) ));}
+        Float_t MIP = 1.0/fCalibData->GetMIPperADC(GetPMNumber(i));
+       if(fCollisionMode >0) MIP=2.0;
+//     printf("cell = %d,  ADC = %d, TDC = %f \n",i,map[i], time[i]*10.0 );
+        if(map[i] > (int(( MIP/2 ) + 0.5)) )
+                 {map[i] = Int_t(gRandom->Gaus(map[i], (int(( MIP/6 ) + 0.5)) ));}
    }
       
 // Now transforms 80 cell responses into 64 photomultiplier responses
@@ -279,7 +289,7 @@ void AliVZERODigitizer::Exec(Option_t* /*option*/)
 //           printf(" Event, cell, adc, tof = %d %d %d %f\n", 
 //                    outRunLoader->GetEventNumber(),i, map[i], time2[i]*10.0);
 //           multiply by 10 to have 100 ps per channel :
-             AddDigit(i, adc[i], Int_t(time2[i]*10.0)) ;}      
+             AddDigit(i, adc[i], Int_t((time2[i]*10.0) +0.5)) ;}      
    }
     
   treeD->Fill();
@@ -300,14 +310,70 @@ void AliVZERODigitizer::AddDigit(Int_t PMnumber, Int_t adc, Int_t time)
 //____________________________________________________________________________
 void AliVZERODigitizer::ResetDigit()
 {
-//
+
 // Clears Digits
-//
+
   fNdigits = 0;
   if (fDigits) fDigits->Delete();
 }
 
 //____________________________________________________________________________
+void AliVZERODigitizer::GetCollisionMode()
+{
+// Retrieves the collision mode from GRP data
+
+// Initialization of the GRP entry 
+
+   Int_t run = AliCDBManager::Instance()->GetRun();
+  
+//   printf("\n ++++++ Run Number retrieved as %d \n",run); 
+  AliCDBEntry*  entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
+  AliGRPObject* grpData = 0x0;
+   
+  if(entry){
+    TMap* m = dynamic_cast<TMap*>(entry->GetObject());  // old GRP entry
+    if(m){
+       m->Print();
+       grpData = new AliGRPObject();
+       grpData->ReadValuesFromMap(m);
+    }
+    else{
+       grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());  // new GRP entry
+       entry->SetOwner(0);
+    }
+    AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
+  }
+
+  if(!grpData) AliError("No GRP entry found in OCDB!");
+
+// Retrieval of collision mode
+
+  TString beamType = grpData->GetBeamType();
+  if(beamType==AliGRPObject::GetInvalidString()){
+     AliError("GRP/GRP/Data entry:  missing value for the beam type !");
+     AliError("\t VZERO cannot retrieve beam type\n");
+     return;
+  }
+
+   if( (beamType.CompareTo("P-P") ==0)  || (beamType.CompareTo("p-p") ==0) ){
+       fCollisionMode=0;
+  }
+   else if( (beamType.CompareTo("Pb-Pb") ==0)  || (beamType.CompareTo("A-A") ==0) ){
+       fCollisionMode=1;
+   }
+    
+  fBeamEnergy = grpData->GetBeamEnergy();
+  if(fBeamEnergy==AliGRPObject::GetInvalidFloat()) {
+     AliError("GRP/GRP/Data entry:  missing value for the beam energy ! Using 0");
+     fBeamEnergy = 0.;
+  }
+  
+//     printf("\n ++++++ Beam type and collision mode retrieved as %s %d @ %1.3f GeV ++++++\n\n",beamType.Data(), fCollisionMode, fBeamEnergy);
+
+}
+
+//____________________________________________________________________________
 AliVZEROCalibData* AliVZERODigitizer::GetCalibData() const
 
 {
index 46c3824..d29523d 100644 (file)
@@ -34,7 +34,10 @@ class AliVZERODigitizer: public AliDigitizer {
 
    void AddDigit(Int_t PMnumber, Int_t adc, Int_t time);
    void ResetDigit();
-  
+   void GetCollisionMode();
+   void GetCollisionMode(Int_t collisionMode, Float_t beamEnergy) 
+                        {fCollisionMode=collisionMode; fBeamEnergy=beamEnergy;}
+                                               
    AliVZEROCalibData *GetCalibData() const;
    Int_t GetPMNumber(Int_t cell) const;
 
@@ -48,14 +51,17 @@ class AliVZERODigitizer: public AliDigitizer {
       
    AliVZERODigitizer& operator = (const AliVZERODigitizer& /*digitizer*/); 
   
-   Float_t fPhotoCathodeEfficiency; // Photocathode efficiency
-   Float_t fPMVoltage ;             // Photomultiplier voltage
-   Float_t fPMGain;                 // Photomultiplier gain
-
-   Int_t   fNdigits;                //! Number of digits
-   TClonesArray *fDigits;           //! List of digits
+   Float_t  fPhotoCathodeEfficiency; // Photocathode efficiency
+   Float_t  fPMVoltage ;             // Photomultiplier voltage
+   Float_t  fPMGain;                 // Photomultiplier gain
 
-   ClassDef(AliVZERODigitizer,2)    // digitizer for VZERO
+   Int_t    fNdigits;                //! Number of digits
+   TClonesArray *fDigits;            //! List of digits
+   
+   Int_t    fCollisionMode;          // =0->p-p, =1->A-A
+   Float_t  fBeamEnergy;            // beam energy
+   
+   ClassDef(AliVZERODigitizer,2)     // digitizer for VZERO
 
 };
 
index 2fca0e2..ce19540 100644 (file)
 
 #include "AliRunLoader.h"
 #include "AliRawReader.h"
+#include "AliGRPObject.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
 #include "AliVZEROReconstructor.h"
 #include "AliVZERORawStream.h"
 #include "AliESDEvent.h"
@@ -34,10 +38,12 @@ ClassImp(AliVZEROReconstructor)
 
 //_____________________________________________________________________________
 AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
-   fESDVZERO(0x0),
-   fESD(0x0),
-   fESDVZEROfriend(0x0),
-   fCalibData(GetCalibData())
+                        fESDVZERO(0x0),
+                        fESD(0x0),
+                        fESDVZEROfriend(0x0),
+                        fCalibData(GetCalibData()),
+                        fCollisionMode(0),
+                        fBeamEnergy(0.)
 {
   // Default constructor  
   // Get calibration data
@@ -73,6 +79,8 @@ void AliVZEROReconstructor::Init()
 
   fESDVZERO  = new AliESDVZERO;
   fESDVZEROfriend = new AliESDVZEROfriend;
+  
+  GetCollisionMode();  // fCollisionMode =1 for Pb-Pb simulated data
 }
 
 //______________________________________________________________________
@@ -158,10 +166,10 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
                                    AliESDEvent* esd) const
 {
 // fills multiplicities to the ESD
-
+    
   if (!digitsTree) {
-    AliError("No digits tree!");
-    return;
+      AliError("No digits tree!");
+      return;
   }
 
   TClonesArray* digitsArray = NULL;
@@ -199,13 +207,19 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
         Int_t  pedestal      = int(fCalibData->GetPedestal(d));
         adc[pmNumber]   = (Short_t) digit->ADC() - pedestal; 
         time[pmNumber]  = (Short_t) digit->Time();
-               width[pmNumber] = (Short_t) digit->Width();
-               BBFlag[pmNumber]= digit->BBFlag();
-               BGFlag[pmNumber]= digit->BGFlag();
+       width[pmNumber] = (Short_t) digit->Width();
+       BBFlag[pmNumber]= digit->BBFlag();
+       BGFlag[pmNumber]= digit->BGFlag();
         // printf("PM = %d,  MIP per ADC channel = %f \n",pmNumber, fCalibData->GetMIPperADC(pmNumber));
         // cut of ADC at 1MIP/2 
-        if (adc[pmNumber] > (int(1.0/fCalibData->GetMIPperADC(pmNumber)) /2) ) 
-           mult[pmNumber] += float(adc[pmNumber])*fCalibData->GetMIPperADC(pmNumber);
+       if(fCollisionMode >0) { 
+          Float_t MIP = 2.0;  
+           if (adc[pmNumber] > (int(MIP) /2) ) mult[pmNumber] += float(adc[pmNumber])*(1.0/MIP) ;
+          }
+           else{    
+           if (adc[pmNumber] > (int(1.0/fCalibData->GetMIPperADC(pmNumber)) /2) ) 
+              mult[pmNumber] += float(adc[pmNumber])*fCalibData->GetMIPperADC(pmNumber);
+        }          
     } // end of loop over digits
   } // end of loop over events in digits tree
   
@@ -221,7 +235,7 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
   // now get the trigger mask
 
   AliVZEROTriggerMask *TriggerMask = new AliVZEROTriggerMask();
-  TriggerMask->SetAdcThreshold(20.0/2.0);
+  TriggerMask->SetAdcThreshold(10.0/2.0);
   TriggerMask->SetTimeWindowWidthBBA(50);
   TriggerMask->SetTimeWindowWidthBGA(20);
   TriggerMask->SetTimeWindowWidthBBC(50);
@@ -239,10 +253,10 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
   }
 
   if (esd) {
-    AliESDfriend *fr = (AliESDfriend*)esd->FindListObject("AliESDfriend");
-    if (fr) {
-      AliDebug(1, Form("Writing VZERO friend data to ESD tree"));
-      fr->SetVZEROfriend(fESDVZEROfriend);
+     AliESDfriend *fr = (AliESDfriend*)esd->FindListObject("AliESDfriend");
+     if (fr) {
+        AliDebug(1, Form("Writing VZERO friend data to ESD tree"));
+        fr->SetVZEROfriend(fESDVZEROfriend);
     }
   }
 }
@@ -273,6 +287,63 @@ AliCDBStorage* AliVZEROReconstructor::SetStorage(const char *uri)
   return storage; 
 }
 
+//____________________________________________________________________________
+void AliVZEROReconstructor::GetCollisionMode()
+{
+// Retrieves the collision mode from GRP data
+
+// Initialization of the GRP entry 
+  
+   Int_t run = AliCDBManager::Instance()->GetRun();
+  
+//   printf("\n ++++++ Run Number retrieved as %d \n",run);
+  
+   AliCDBEntry*  entry = AliCDBManager::Instance()->Get("GRP/GRP/Data",run);
+   AliGRPObject* grpData = 0x0;
+   
+  if(entry){
+    TMap* m = dynamic_cast<TMap*>(entry->GetObject());  // old GRP entry
+    if(m){
+       m->Print();
+       grpData = new AliGRPObject();
+       grpData->ReadValuesFromMap(m);
+    }
+    else{
+       grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());  // new GRP entry
+       entry->SetOwner(0);
+    }
+    AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
+  }
+
+   if(!grpData) { AliError("No GRP entry found in OCDB!");
+                  return; }
+
+// Retrieval of simulated collision mode 
+
+  TString beamType = grpData->GetBeamType();
+  if(beamType==AliGRPObject::GetInvalidString()){
+     AliError("GRP/GRP/Data entry:  missing value for the beam type !");
+     AliError("\t VZERO cannot retrieve beam type\n");
+     return;
+  }
+
+   if( (beamType.CompareTo("P-P") ==0)  || (beamType.CompareTo("p-p") ==0) ){
+       fCollisionMode=0;
+  }
+   else if( (beamType.CompareTo("Pb-Pb") ==0)  || (beamType.CompareTo("A-A") ==0) ){
+       fCollisionMode=1;
+   }
+    
+  fBeamEnergy = grpData->GetBeamEnergy();
+  if(fBeamEnergy==AliGRPObject::GetInvalidFloat()) {
+     AliError("GRP/GRP/Data entry:  missing value for the beam energy ! Using 0");
+     fBeamEnergy = 0.;
+  }
+  
+//    printf("\n ++++++ Beam type and collision mode retrieved as %s %d @ %1.3f GeV ++++++\n\n",beamType.Data(), fCollisionMode, fBeamEnergy);
+
+}
+
 //_____________________________________________________________________________
 AliVZEROCalibData* AliVZEROReconstructor::GetCalibData() const
 {
index 2d244bd..4a186c6 100644 (file)
@@ -45,11 +45,13 @@ public:
                               TTree* digitsTree) const;
                                 
   AliCDBStorage     *SetStorage(const char* uri);
+  void GetCollisionMode();
+  
   AliVZEROCalibData *GetCalibData() const; 
 
 protected:
-  AliESDVZERO*        fESDVZERO;      // ESD output object  
-  AliESDEvent*             fESD;      // ESD object
+  AliESDVZERO*        fESDVZERO;       // ESD output object  
+  AliESDEvent*             fESD;       // ESD object
   AliESDVZEROfriend*  fESDVZEROfriend; // ESD friend object (complete raw data)
   
 private:
@@ -57,6 +59,9 @@ private:
   AliVZEROReconstructor& operator = (const AliVZEROReconstructor& reconstructor);
   
   AliVZEROCalibData* fCalibData;      //! calibration data
+
+  Int_t              fCollisionMode;  // =0->p-p, =1->A-A
+  Float_t            fBeamEnergy;     // beam energy
   
   ClassDef(AliVZEROReconstructor, 0)  // class for the VZERO reconstruction
 };