updates for running beamtest analysis within AliRoot - minor bug fixes still need...
authorjklay <jklay@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 5 Dec 2007 06:51:06 +0000 (06:51 +0000)
committerjklay <jklay@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 5 Dec 2007 06:51:06 +0000 (06:51 +0000)
EMCAL/beamtest07/EMCAL/Calib/Data/Run0_999999999_v0_s0.root [new file with mode: 0644]
EMCAL/beamtest07/Rec.C [new file with mode: 0644]
EMCAL/beamtest07/SetCalibDB.C [new file with mode: 0644]
EMCAL/beamtest07/TestESDCaloCluster.C [new file with mode: 0644]

diff --git a/EMCAL/beamtest07/EMCAL/Calib/Data/Run0_999999999_v0_s0.root b/EMCAL/beamtest07/EMCAL/Calib/Data/Run0_999999999_v0_s0.root
new file mode 100644 (file)
index 0000000..209aba3
Binary files /dev/null and b/EMCAL/beamtest07/EMCAL/Calib/Data/Run0_999999999_v0_s0.root differ
diff --git a/EMCAL/beamtest07/Rec.C b/EMCAL/beamtest07/Rec.C
new file mode 100644 (file)
index 0000000..2b882c8
--- /dev/null
@@ -0,0 +1,26 @@
+void Rec(TString file="/Users/jklay/Projects/LHC/alice/work/beamtest07/Period_LHC07a_EMCAL.Run_000000518.Host_001.Seq_10.root")
+{
+  // Reconstruction of RAW data from the input file raw.root
+  // Boris Polichtchouk, 31 Aug 2007
+
+  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+  AliCDBManager::Instance()->SetSpecificStorage("EMCAL/Calib/Data","local://");
+
+  //AliLog::SetGlobalDebugLevel(2);
+
+  AliReconstruction rec ;
+  rec.SetOption("EMCAL","OldRCUFormat");
+  rec.SetRunTracking("") ;
+  rec.SetRunVertexFinder(kFALSE) ; 
+  rec.SetRunLocalReconstruction("EMCAL") ;
+  rec.SetFillESD("EMCAL") ;
+
+  rec.SetInput(file.Data());  // read RAW data
+
+  rec.SetEventRange(0,10);
+  rec.SetNumberOfEventsPerFile(-1);
+
+  rec.Run();
+
+
+}
diff --git a/EMCAL/beamtest07/SetCalibDB.C b/EMCAL/beamtest07/SetCalibDB.C
new file mode 100644 (file)
index 0000000..1a35d5a
--- /dev/null
@@ -0,0 +1,119 @@
+// Script to create calibration parameters and store them into CDB 
+// from gain values determined for 2007 beam test
+//
+// JLK 2007-12-04
+//
+//
+#if !defined(__CINT__)
+#include "AliRun.h"
+#include "AliEMCALCalibData.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBId.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#endif
+
+void SetCalibDB() {
+
+  Int_t firstRun   =  0; // What is this                                                
+  Int_t lastRun    = 9999999;
+  Int_t beamPeriod =  1;
+  char* objFormat  = "";
+
+  TString DBFolder  ="local://$ALICE_ROOT/EMCAL/beamtest07";
+  firstRun  =  0;
+  lastRun   =  999999999;
+  objFormat = "EMCAL beam test 2007 gain factors and pedestals";
+
+  AliEMCALCalibData *calibda=new AliEMCALCalibData("EMCAL");
+
+  Float_t fADCpedestal = 0.009;
+  Float_t fADCchannel  = 0.0153;  // 250 GeV / (16*1024)                               
+  Float_t ped = 0.;
+  Float_t cc = fADCchannel;
+
+  Int_t nSMod  = 12;
+  Int_t nCol   = 48;
+  Int_t nRow   = 24;
+  Int_t nRow2  = 12; //Modules 11 and 12 are half modules                          
+
+  Int_t colOffset = 40;
+  Int_t rowOffset = 16;
+
+  Double_t gain_ratios[8][8] =
+    {
+      15.9289, 16.2141, 16.1204, 15.9118,
+      15.9363, 15.9402, 16.2257, 16.0097,
+      16.058, 16.1116, 16.039, 16.4167,
+      16.2148, 16.1399, 16.1515, 16.2194,
+      15.9082, 16.0776, 16.0496, 16.2353,
+      15.8054, 16.2158, 16.2344, 16.1023,
+      15.8903, 16.2387, 16.13, 16.157,
+      16.0685, 16.172, 16.3495, 16.3887,
+      16.2842, 16.049, 16.4328, 16.3954,
+      16.4226, 15.7254, 16.1634, 16.3182,
+      16.4216, 16.1201, 16.0000, 16.2305,
+      16.0266, 16.3573, 16.1382, 16.237,
+      16.2981, 16.1796, 15.854, 16.4189,
+      15.6425, 16.287, 16.3293, 16.6308,
+      16.2469, 16.0412, 16.252, 16.3367,
+      16.1412, 16.0646, 16.3996, 16.3479
+    };
+
+  
+  Float_t gains[8][8] =
+    {
+      4.43274, 6.7283, 8.23733, 3.59882,
+      4.2717, 2.85658, 4.86389, 2.71961,
+      3.05523, 3.02552, 3.50615, 3.26494,
+      6.69024, 2.51058, 8.42275, 2.83824,
+      8.05074, 5.36051, 4.36794, 4.73468,
+      9.9684, 5.5, 6.42999, 5.6,
+      7.37306, 5.28314, 5.27662, 5.26982,
+      3.29468, 5.23107, 6.40948, 4.06855,
+      4.09685, 5.37323, 5.32816, 5.89487,
+      9.2395, 5.3, 4.77239, 5.0,
+      4.85923, 3.44063, 4.74517, 5.28772,
+      3.80171, 4.84878, 5.12039, 4.59205,
+      2.34745, 3.16971, 3.61231, 3.65195,
+      3.43496, 3.4, 3.65678, 2.9,
+      2.71648, 3.39577, 3.40896, 3.31741,
+      3.24286, 3.51346, 2.61503, 3.44246
+    };
+
+  for(Int_t supermodule=0; supermodule < nSMod; supermodule++) {
+    for(Int_t column=0; column< nCol; column++) {
+      if(supermodule >= 10)
+        nRow = nRow2;
+      for(Int_t row=0; row< nRow; row++) {
+       if(supermodule < 2 && column > 39 && row > 15) {
+         cc = 1./gain_ratios[column-colOffset][row-rowOffset]/gains[column-colOffset][row-rowOffset];
+         cout << "column = " << column << " column - colOffset = " << column-colOffset << " row = " << " row Offset = " << row-rowOffset << endl;
+       }
+        calibda->SetADCchannel(supermodule,column,row,cc);
+        calibda->SetADCpedestal(supermodule,column,row,ped);
+      }
+    }
+  }
+
+  //Store calibration data into database
+  AliCDBMetaData md;
+  md.SetComment(objFormat);
+  md.SetBeamPeriod(beamPeriod);
+  md.SetResponsible("David Silvermyr");
+  AliCDBId id("EMCAL/Calib/Data",firstRun,lastRun); // create in
+                                                   // EMCAL/Calib/Data DBFolder                     
+
+  AliCDBManager* man = AliCDBManager::Instance();
+  AliCDBStorage* loc = man->GetStorage(DBFolder.Data());
+  loc->Put(calibda, id, &md);
+
+}
+
+
+
+
+
+
+
diff --git a/EMCAL/beamtest07/TestESDCaloCluster.C b/EMCAL/beamtest07/TestESDCaloCluster.C
new file mode 100644 (file)
index 0000000..6df90dd
--- /dev/null
@@ -0,0 +1,180 @@
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+//Root include files
+#include <Riostream.h>
+#include <TFile.h>
+#include <TChain.h>
+#include <TParticle.h>
+#include <TNtuple.h>
+#include <TCanvas.h>
+#include <TObjArray.h>
+#include <TSystem.h>
+#include <TString.h> 
+#include <TH1F.h> 
+#include <TVector.h> 
+#include <TParticle.h> 
+
+//AliRoot include files
+#include "AliESD.h"
+#include "AliESDEvent.h"
+#include "AliEMCALLoader.h"
+#include "AliESDCaloCluster.h"
+#include "AliEMCALRecPoint.h"
+#include "AliPID.h"
+#include "AliLog.h" 
+
+//macros
+
+#endif
+
+TChain * AliReadESDfromdisk(const UInt_t eventsToRead, 
+                                  const TString dirName, 
+                                  const TString esdTreeName, 
+                                  const char *  pattern) 
+{
+  // Reads ESDs from Disk
+ TChain *  rv = 0; 
+  
+  // create a TChain of all the files 
+  TChain * cESDTree = new TChain(esdTreeName) ; 
+
+  // read from the directory file until the require number of events are collected
+  void * from = gSystem->OpenDirectory(dirName) ;
+   if (!from) 
+     rv = 0 ;   
+  else{ // reading file names from directory
+    const char * subdir ; 
+    // search all subdirectories witch matching pattern
+    while( (subdir = gSystem->GetDirEntry(from))  && 
+          (cESDTree->GetEntries() < eventsToRead)) {
+      if ( strstr(subdir, pattern) != 0 ) { 
+       char file[200] ; 
+        sprintf(file, "%s%s/AliESDs.root", dirName.Data(), subdir);    
+       cESDTree->Add(file) ;
+      }
+    } // while file
+  
+    rv = cESDTree ; 
+    
+  } // reading file names from directory
+  return rv ; 
+}
+
+//======================================================================
+TChain * AliReadESD(const UInt_t eventsToRead,
+                 const TString dirName, 
+                 const TString esdTreeName, 
+                 const char *  pattern)  
+{
+  // Read AliESDs files and return a Chain of events
+  if ( dirName == "" ) 
+    return 0 ; 
+  if ( esdTreeName == "" ) 
+    return AliReadESDfromdisk(eventsToRead, dirName,"","") ;//Last 2 arguments are not necessary but pdsf compiler complains "","'
+  else if ( strcmp(pattern, "") == 0 )
+    return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName,"") ;//Last argument is not necessary but pdsf compiler complains "","'
+  else 
+    return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName, pattern) ;       
+}
+
+//=====================================================================
+//  Do:
+//  .L TestESDCaloCluster.C++
+//  TestESDCaloCluster(number of events to process)
+//=====================================================================
+void TestESDCaloCluster(const UInt_t eventsToProcess = 5, 
+                       TString dirName = "./", 
+                       const TString esdTreeName = "esdTree", 
+                       const char *  pattern = ".") 
+{ 
+  
+  //Create chain of esd trees
+  //AliReadESD(eventsToProcess, directoryName,esdTreeName,patternOfDirectory) ;
+  //By default the root files are in the same directory 
+  TChain * t = AliReadESD(eventsToProcess, dirName,esdTreeName,pattern) ; 
+  
+  // ESD
+  AliESDEvent * esd = new AliESDEvent();
+  esd->ReadFromTree(t);
+  
+  //Define few variables to be used in macro
+  TString alirunName = "" ; 
+
+  //Define example histograms
+  TH1F * hEnergy = new TH1F("hEnergy","Energy Distribution",100,0.,100.);   
+  TH1F * hEta    = new TH1F("hEta","Eta Distribution",100,-0.7,0.7);
+  TH1F * hPhi    = new TH1F("hPhi","Phi Distribution",100,0,2*TMath::Pi());
+
+  Int_t beg, end ;
+  UInt_t event ;
+  Float_t pos[3] ; 
+
+  for (event = 0; event < eventsToProcess; event++) {//event loop
+    //AliInfo( Form("Event %d \n",event) );  
+    Int_t nbytes = t->GetEntry(event); // store event in esd
+    //cout<<"nbytes "<<nbytes<<endl;
+    if ( nbytes == 0 ) //If nothing in ESD 
+      break ; 
+    
+    // Check that name of file is correct
+    if (alirunName != t->GetFile()->GetName()) {        
+      alirunName = t->GetFile()->GetName() ; 
+      alirunName.ReplaceAll("galice.root", "AliESDs.root") ;
+    }
+    
+    //get reconstructed vertex position 
+    
+    //Double_t vertex_position[3] ; 
+    //    esd->GetVertex()->GetXYZ(vertex_position) ; 
+    
+    cout<<"Event >>>>>>>>>>> "<<event<<endl;
+    
+
+    //select EMCAL tracks only 
+    end = esd->GetNumberOfCaloClusters() ;  
+    beg = 0;
+    Int_t nphP ;
+    //cout<<"begin "<<beg<<" end "<<end<<endl;
+    Int_t iclus = 0;
+    for (nphP =  beg; nphP <  end; nphP++) {//////////////EMCAL cluster loop
+      AliESDCaloCluster * clus = esd->GetCaloCluster(nphP) ; // retrieve cluster from esd
+      
+      //Get the cluster parameters
+      Float_t energy   = clus->E() ;
+      cout << "Cluster " << nphP << " energy = " << energy << endl;
+
+       //      Int_t mult       = clus->GetNumberOfDigits() ;
+       //      Float_t disp     = clus->GetClusterDisp() ;
+       //      UShort_t * amp   = clus->GetDigitAmplitude() ;
+       //      UShort_t * time  = clus->GetDigitTime() ;
+       //      UShort_t * index = clus->GetDigitIndex() ;
+       //      Int_t iprim = clus->GetPrimaryIndex();
+
+      /*
+      clus->GetPosition(pos) ;
+      TVector3 vpos(pos[0],pos[1],pos[2]) ;
+      //Print values on screen
+      cout<<"ESD cluster "<<iclus <<"; Energy "<<energy
+         <<"; Phi "<<vpos.Phi()*180/TMath::Pi()<<"; Eta "<<vpos.Eta()<<endl;
+      //cout<<"Dispersion "<<disp<<"; multiplicity "<<mult<<endl;
+      //Get the parent main values
+      */
+      //Fill histograms
+      hEnergy->Fill(energy) ;
+      //      hEta->Fill(vpos.Eta()) ;
+      //hPhi->Fill(vpos.Phi()) ;
+
+    }// track loop 
+  }//////////////////////////////////////////event loop
+  hEnergy->Draw();//Draw histogram on screen
+  //Write histograms in Root file 
+  TFile outf("histo.root","recreate") ;
+  hEnergy->Write() ;
+  hPhi->Write() ;
+  hEta->Write() ;
+  outf.Close() ;
+}
+
+