]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSGeoPlot.C
Reverting the previous mods as they cause a segmentation violation
[u/mrichter/AliRoot.git] / ITS / AliITSGeoPlot.C
index 0bd6faa15053da97a9163ae89141606886cd7f0d..ecf9def8052559a85f751c4b270705e1b675ef96 100644 (file)
@@ -7,37 +7,39 @@
 #include<TClassTable.h>
 #include<TClonesArray.h>
 #include<TFile.h>
+#include<TGeoManager.h>
 #include<TH1.h>
 #include<TH2.h>
 #include <TInterpreter.h>
 #include<TObject.h>
 #include<TObjArray.h>
 #include<TTree.h>
-#include "AliGenEventHeader.h"
-#include <AliRun.h>
-#include <AliITS.h>
-#include <AliITSgeom.h>
-#include <AliITSDetType.h>
-#include <AliITSRecPoint.h>
-#include <AliITSclusterV2.h>
-#include <AliITSdigit.h>
-#include <AliITSdigitSSD.h>
-#include <AliITShit.h>
-#include <AliITSmodule.h> 
-#include <AliITSsegmentation.h>
-#include <AliITSsegmentationSPD.h> 
-#include <AliITSsegmentationSDD.h>
-#include <AliITSsegmentationSSD.h>
-#include <AliRunLoader.h>
-#include <AliITSLoader.h>
-#include <AliHeader.h>
+#include "AliRun.h"
+#include "AliITS.h"
+#include "AliITSgeom.h"
+#include "AliITSDetTypeRec.h"
+#include "AliITSRecPoint.h"
+#include "AliITSRecPoint.h"
+#include "AliITSdigit.h"
+#include "AliITSdigitSSD.h"
+#include "AliITShit.h"
+#include "AliITSmodule.h" 
+#include "AliITSsegmentation.h"
+#include "AliITSsegmentationSPD.h" 
+#include "AliITSsegmentationSDD.h"
+#include "AliITSsegmentationSSD.h"
+#include "AliRunLoader.h"
+#include "AliITSLoader.h"
+#include "AliHeader.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
 #endif
 void GetHitsCoor(TObject *its, Int_t mod, TObjArray & histos, Int_t subd,Bool_t verb);
 Int_t GetRecCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb);
 Int_t GetClusCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb);
 void GetDigits(TObject *tmps,TObject *ge,TClonesArray *ITSdigits, Int_t subd, Int_t mod, Bool_t verbose, TObjArray & histos);
 
-Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+Rec", char *filename="galice.root", Int_t isfastpoints = 0) {
+Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+ClustersV2", TString filename="galice.root", Int_t isfastpoints = 0) {
   /*******************************************************************
    *  This macro displays geometrical information related to the
    *  hits, digits and rec points (or V2 clusters) in ITS.
@@ -94,19 +96,36 @@ Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+Rec", char *filename="galice
   Bool_t userec=choice.Contains("Rec");
   Bool_t useclustersv2=choice.Contains("ClustersV2");
   Int_t retcode=1; //return code
   if (gClassTable->GetID("AliRun") < 0) {
     gInterpreter->ExecuteMacro("loadlibs.C");
   }
   else { 
     if(gAlice){
-      delete gAlice->GetRunLoader();
+      delete AliRunLoader::Instance();
       delete gAlice;
       gAlice=0;
     }
   }
+  // Set OCDB if needed
+  AliCDBManager* man = AliCDBManager::Instance();
+  if (!man->IsDefaultStorageSet()) {
+    printf("Setting a local default storage and run number 0\n");
+    man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+    man->SetRun(0);
+  }
+  else {
+    printf("Using deafult storage \n");
+  }
+  // retrives geometry 
+  TString geof(gSystem->DirName(filename));
+  geof += "/geometry.root";
+  TGeoManager::Import(geof.Data());
+  if (!gGeoManager) {
+    cout<<"geometry not found\n";
+    return -1;
+  }
  
-  AliRunLoader* rl = AliRunLoader::Open(filename);
+  AliRunLoader* rl = AliRunLoader::Open(filename.Data());
   if (rl == 0x0){
     cerr<<"AliITSGeoPlot.C : Can not open session RL=NULL"<< endl;
     return -1;
@@ -159,13 +178,17 @@ Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+Rec", char *filename="galice
   cout<<"Filling modules... It takes a while, now. Please be patient"<<endl;
   ITS->FillModules(0,0,nmodules," "," ");
   cout<<"ITS modules .... DONE!"<<endl;
+  
+  AliITSDetTypeRec* detTypeRec = new AliITSDetTypeRec();
+  detTypeRec->SetITSgeom(ITSloader->GetITSgeom());
+  detTypeRec->SetDefaults();
 
   // DIGITS
   TTree *TD = ITSloader->TreeD();
 
   //RECPOINTS (V2 clusters)
   TTree *TR = ITSloader->TreeR();
-  TClonesArray *ITSrec  = ITS->RecPoints();
+  TClonesArray *ITSrec  = detTypeRec->RecPoints();
   TBranch *branch = 0;
   if(userec && TR && ITSrec){
     if(isfastpoints==1){
@@ -185,8 +208,7 @@ Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+Rec", char *filename="galice
     cout<<"======================================================= \n \n";
   }
   if(useclustersv2 && TR && ITSrec){
-  
-    branch = ITSloader->TreeR()->GetBranch("Clusters");
+    branch = ITSloader->TreeR()->GetBranch("ITSRecPoints");
     if(branch)branch->SetAddress(&ITSrec);
   }
 
@@ -301,6 +323,7 @@ Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+Rec", char *filename="galice
   //
   // Loop on subdetectors
   // 
+  cout<<"CALL GETITSGEOM \n \n \n";
   AliITSgeom *geom = ITS->GetITSgeom();
   TString detna; // subdetector name
   for(Int_t subd=0;subd<3;subd++){
@@ -315,11 +338,10 @@ Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+Rec", char *filename="galice
         cout<<"======================================================= \n \n";
       }
       // Get segmentation model
-      AliITSDetType *iDetType=ITS->DetType(subd);
       if(subd==0)detna="SPD";
       if(subd==1)detna="SDD";
       if(subd==2)detna="SSD";
-      AliITSsegmentation *seg=(AliITSsegmentation*)iDetType->GetSegmentationModel();
+      AliITSsegmentation *seg=(AliITSsegmentation*)detTypeRec->GetSegmentationModel(subd);
       // Loop on modules
       first = geom->GetStartDet(subd);
       last = geom->GetLastDet(subd);
@@ -350,23 +372,24 @@ Int_t AliITSGeoPlot (Int_t evesel=0, char *opt="All+Rec", char *filename="galice
 
         //RecPoints     
         if(userec){
-          ITS->ResetRecPoints();
+          detTypeRec->ResetRecPoints();
           branch->GetEvent(mod);
           TH2F *bidi=(TH2F*)histos.At(6+subd*9);
           TH1F *uni=(TH1F*)histos.At(7+subd*9);
           nrecp=GetRecCoor(geom,ITSrec,mod,bidi,uni,verbose);
         }
         if(useclustersv2){
-          ITS->ResetRecPoints();
+          detTypeRec->ResetRecPoints();
           branch->GetEvent(mod);
           TH2F *bidi=(TH2F*)histos.At(6+subd*9);
           TH1F *uni=(TH1F*)histos.At(7+subd*9);
           nrecp=GetClusCoor(geom,ITSrec,mod,bidi,uni,verbose);
+         
         }
      
         // Digits
         if(usedigits){
-          ITS->ResetDigits();
+          detTypeRec->ResetDigits();
           nbytes += TD->GetEvent(mod);
           GetDigits(seg,geom,ITSdigits,subd,mod,verbose,histos);
         }
@@ -480,6 +503,7 @@ void GetHitsCoor(TObject *its, Int_t mod, TObjArray & histos, Int_t subd,Bool_t
 
 
 Int_t GetClusCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb){
+
   AliITSgeom *geom = (AliITSgeom*)ge;
   Int_t nrecp = ITSrec->GetEntries();
   if(nrecp>0){
@@ -490,7 +514,7 @@ Int_t GetClusCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *
       cout<<"Number of CLUSTERS for module "<<mod<<": "<<nrecp<<endl;
     }
     for(Int_t irec=0;irec<nrecp;irec++) {
-      AliITSclusterV2 *recp = (AliITSclusterV2*)ITSrec->At(irec);
+      AliITSRecPoint *recp = (AliITSRecPoint*)ITSrec->At(irec);
       Double_t rot[9];     
       geom->GetRotMatrix(mod,rot);
       Int_t lay,lad,det;   
@@ -516,6 +540,7 @@ Int_t GetClusCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *
       }
       h2->Fill(gc[0],gc[1]);
       h1->Fill(gc[2]);
+
     }
   }
   return nrecp;
@@ -532,8 +557,8 @@ Int_t GetRecCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h
     }
     for(Int_t irec=0;irec<nrecp;irec++) {
       AliITSRecPoint *recp = (AliITSRecPoint*)ITSrec->At(irec);
-      lc[0]=recp->GetX();
-      lc[2]=recp->GetZ();
+      lc[0]=recp->GetDetLocalX();
+      lc[2]=recp->GetDetLocalZ();
       geom->LtoG(mod,lc,gc);
       if(verb){
         cout<<"recp # "<<irec<<" local coordinates. lx= "<<lc[0]<<" lz= ";
@@ -661,3 +686,4 @@ void GetDigits(TObject *tmps,TObject *ge,TClonesArray *ITSdigits, Int_t subd, In
     } // loop on digits for this module
   } // if(ndigits>0....
 }
+