Adding AliITSDigitizer class to do merging and digitization . Based on the
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Nov 2001 16:27:28 +0000 (16:27 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 27 Nov 2001 16:27:28 +0000 (16:27 +0000)
TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h
file. The following files required minor changes. AliITS, added functions
SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD.
AliITSsimulationSDD.cxx needed a Tree indepenent way of returning back to
the original Root Directory in function Compress1D. Now it uses gDirectory.

ITS/AliITS.cxx
ITS/AliITS.h
ITS/AliITSDigitizer.cxx [new file with mode: 0644]
ITS/AliITSDigitizer.h [new file with mode: 0644]
ITS/AliITSsimulationSDD.cxx
ITS/ITSLinkDef.h
ITS/Makefile

index 13f6f325a311576ba0df12375bed008b05d921c5..f5a2a279a315b9a3ef4b402d5d415061c0a3b932 100644 (file)
 
 /*
 $Log$
+Revision 1.64  2001/11/19 16:17:02  nilsen
+Applyed fixes to bugs found by Rene Brun. With many thanks. Some additonal
+bugs found by Rene require more work to fix. Will be fixed soon.
+
 Revision 1.63  2001/10/24 21:16:34  nilsen
 Removed some dead code and improved comments/documntation.
 
@@ -255,7 +259,6 @@ the AliITS class.
 #include <TString.h>
 
 #include "AliMC.h"
-#include "AliRun.h"
 #include "AliHeader.h"
 
 #include "AliITS.h"
@@ -989,7 +992,7 @@ void AliITS::SetTreeAddressS(TTree *treeS){
     if (branch) branch->SetAddress(&fSDigits);
 }
 //______________________________________________________________________
-void AliITS::MakeBranchD(const char *file){
+void AliITS::MakeBranchInTreeD(TTree *treeD,const char *file){
     // Creates Tree branches for the ITS.
     // Inputs:
     //      cont char *file  File name where Digits branch is to be written
@@ -1017,8 +1020,8 @@ void AliITS::MakeBranchD(const char *file){
     for (i=0; i<kNTYPES ;i++) {
        if (kNTYPES==3) sprintf(branchname,"%sDigits%s",GetName(),det[i]);
        else  sprintf(branchname,"%sDigits%d",GetName(),i+1);      
-       if (fDtype && gAlice->TreeD()) {
-           MakeBranchInTree(gAlice->TreeD()
+       if (fDtype && treeD) {
+           MakeBranchInTree(treeD
                             branchname, &((*fDtype)[i]),buffersize,file);
        } // end if
     } // end for i
index 0b5b0eba6006a1bf66d5eea7c5b03317c9654797..e52ebc6a7043fa6597bbd7e87d40e40ee76ea332 100644 (file)
@@ -12,6 +12,7 @@
 #include <TObjArray.h> // used in inline function GetModule.
 #include <TBranch.h>   // used in inline function SetHitsAddressBranch
 
+#include "AliRun.h"
 #include "AliDetector.h"
 
 class TString;
@@ -69,7 +70,7 @@ class AliITS : public AliDetector {
     virtual void MakeBranch(Option_t *opt=" ", const char *file=0);
     virtual void SetTreeAddress();
     // For a give branch from the treeH sets the TClonesArray address.
-    virtual void SetHitsAddressBranch(TBranch *b){b->SetAddress(fHits);}
+    virtual void SetHitsAddressBranch(TBranch *b){b->SetAddress(&fHits);}
     // Return pointer to DetType #id
     AliITSDetType *DetType(Int_t id);
     //Int_t           NDetTypes() {return fNDetTypes;}
@@ -102,7 +103,9 @@ class AliITS : public AliDetector {
     //===================== Digitisation ===============================
     void MakeBranchS(const char *file);
     void SetTreeAddressS(TTree *treeS);
-    void MakeBranchD(const char *file);
+    void MakeBranchInTreeD(TTree *treeD,const char *file=0);
+    void MakeBranchD(const char *file){
+       MakeBranchInTreeD(gAlice->TreeD(),file);}
     void SetTreeAddressD(TTree *treeD);
     void Hits2SDigits(); // Turn hits into SDigits
     void Hits2PreDigits(); // Turn hits into SDigits
diff --git a/ITS/AliITSDigitizer.cxx b/ITS/AliITSDigitizer.cxx
new file mode 100644 (file)
index 0000000..c7ec163
--- /dev/null
@@ -0,0 +1,179 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/*
+$Log$
+*/
+
+#include <stdlib.h>
+#include <iostream.h>
+#include <TObjArray.h>
+#include <TTree.h>
+#include <TBranch.h>
+
+#include <AliRun.h>
+#include <AliRunDigitizer.h>
+
+#include "AliITSDigitizer.h"
+#include "AliITShit.h"
+#include "AliITSmodule.h"
+#include "AliITSsimulation.h"
+#include "AliITSDetType.h"
+#include "AliITSgeom.h"
+
+ClassImp(AliITSDigitizer)
+
+//______________________________________________________________________
+AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){
+    // Default constructor. Assign fITS since it is never written out from
+    // here. 
+    // Inputs:
+    //      Option_t * opt   Not used
+    // Outputs:
+    //      none.
+    // Return:
+    //      A blank AliITSDigitizer class.
+
+    fITS = 0;
+}
+//______________________________________________________________________
+AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){
+    // Standard constructor. Assign fITS since it is never written out from
+    // here. 
+    // Inputs:
+    //      Option_t * opt   Not used
+    // Outputs:
+    //      none.
+    // Return:
+    //      An AliItSDigitizer class.
+
+    fITS = 0;
+}
+//______________________________________________________________________
+AliITSDigitizer::~AliITSDigitizer(){
+    // Default destructor. 
+    // Inputs:
+    //      Option_t * opt   Not used
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+
+    fITS = 0; // don't delete fITS. Done else where.
+}
+
+//______________________________________________________________________
+Bool_t AliITSDigitizer::Init(){
+    // Iniliztion 
+    // Inputs:
+    //      none.
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+
+//    if(GetHits()) fITS->fHits = new TClonesArray("AliITSHit",1000);
+    return kTRUE;
+}
+//______________________________________________________________________
+void AliITSDigitizer::Exec(Option_t* opt){
+    // Main digitizing function. 
+    // Inputs:
+    //      Option_t * opt   list of subdetector to digitize. =0 all.
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+    Int_t size=0,ifls=0,trk=0,ntracks=0,h=0,nhit=0;
+    TTree *treeH=0;
+    TBranch *brchHits=0;
+    AliITShit *itsHit=0;
+    char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+    char *all;
+    const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
+                          strstr(opt,"SSD")};
+    if(!det[0] && !det[1] && !det[2]) all = "All";
+    else all = 0;
+    AliITSsimulation *sim      = 0;
+    AliITSDetType    *iDetType = 0;
+    AliITSmodule     *mod      = 0;
+    Int_t id=0,module=0,nfls=0,mask=0;
+    static Bool_t setDef=kTRUE;
+
+    if(!fITS) fITS = (AliITS*)(gAlice->GetDetector("ITS"));
+    if(!(fITS->GetITSgeom())){
+       Warning("Exec","Need ITS geometry to be properly defined first.");
+       return; // need transformations to do digitization.
+    } // end if !GetITSgeom()
+    if (setDef) fITS->SetDefaultSimulation();
+    setDef=kFALSE;
+    sprintf(name,"%s",fITS->GetName());
+    if(!GetModules()) {
+       fITS->InitModules(0,size);
+    } // end if
+
+    nfls = GetManager()->GetNinputs();
+    for(ifls=0;ifls<nfls;ifls++){
+       treeH = GetManager()->GetInputTreeH(ifls);
+       if(!(treeH && GetHits())) continue;
+       brchHits = treeH->GetBranch(name);
+       if(brchHits){
+           GetHits()->Clear();
+           fITS->SetHitsAddressBranch(brchHits);
+       } else{
+           Error("Exec","branch ITS not found");
+       } // end if brchHits
+
+       ntracks = (Int_t) treeH->GetEntries();
+       for(trk=0;trk<ntracks;trk++){
+           GetHits()->Clear();
+           brchHits->GetEntry(trk);
+           nhit = GetHits()->GetEntries();
+           mask = GetManager()->GetMask(ifls);
+           for(h=0;h<nhit;h++){
+               itsHit = GetHit(h);
+               mod = GetModule(itsHit->GetModule());
+               id       = fITS->GetITSgeom()->GetModuleType(module);
+               if (!all && !det[id]) continue;
+               mod->AddHit(itsHit,trk+mask,h);
+           } // end for h
+       } // end for trk
+    } // end for ifls
+
+    // Digitize 
+    fITS->MakeBranchInTreeD(GetManager()->GetTreeD());
+    for(module=0;module<size;module++){
+        id       = fITS->GetITSgeom()->GetModuleType(module);
+        if (!all && !det[id]) continue;
+        iDetType = fITS->DetType(id);
+        sim      = (AliITSsimulation*)iDetType->GetSimulationModel();
+        if (!sim) {
+            Error("Exec","The simulation class was not instanciated!");
+            exit(1);
+        } // end if !sim
+        mod      = GetModule(module);
+        sim->DigitiseModule(mod,module,0);
+        // fills all branches - wasted disk space
+        GetManager()->GetTreeD()->Fill();
+        fITS->ResetDigits();
+    } // end for module
+    fITS->ClearModules();
+    GetManager()->GetTreeD()->GetEntries();
+    GetManager()->GetTreeD()->Write(0,TObject::kOverwrite);
+    // reset tree
+    GetManager()->GetTreeD()->Reset();
+}
diff --git a/ITS/AliITSDigitizer.h b/ITS/AliITSDigitizer.h
new file mode 100644 (file)
index 0000000..c270ae3
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef ALIITSDIGITZER_H
+#define ALIITSDIGITZER_H
+/* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
+ * See cxx source for full Copyright notice                               */
+
+/*
+  $Id$
+ */
+
+class TObjArray;
+
+#include <TClonesArray.h> // function of this class used in inline functions.
+
+class AliRunDigitizer;
+
+#include "AliDigitizer.h" // Base class from which this one is derived
+#include "AliITS.h"   // ITS class functions used in inline functions.
+class AliITShit;
+class AliITSmodule;
+
+
+
+class AliITSDigitizer : public AliDigitizer{
+ public:
+    AliITSDigitizer();
+    AliITSDigitizer(AliRunDigitizer *manager);
+    virtual ~AliITSDigitizer();
+    // Standard routines.
+    virtual Bool_t Init();
+    virtual void Exec(Option_t* opt=0);
+ private:
+    // Routines used internaly
+    TClonesArray* GetHits(){return fITS->Hits();}
+    AliITShit* GetHit(Int_t h){return (AliITShit*)(GetHits()->UncheckedAt(h));}
+    TObjArray* GetModules(){return fITS->GetModules();}
+    AliITSmodule* GetModule(Int_t i){return fITS->GetModule(i);}
+    AliRunDigitizer* GetManager(){return fManager;}
+ private:
+    AliITS *fITS;  //! local pointer to ITS
+
+    ClassDef(AliITSDigitizer,1) // Task to Digitize ITS from summable hits.
+};
+#endif
index 2e8f8424f35022a093a237880552bd2e560d0cb6..f25cb07a505e7d035d037e2098a685ec79a65f13 100644 (file)
@@ -1372,6 +1372,7 @@ void AliITSsimulationSDD::Compress1D(){
     static Bool_t open=kTRUE;
     static TFile *outFile;
     Bool_t write = fResponse->OutputOption();
+    TDirectory *savedir = gDirectory;
  
     if (write ) {
        if(open) {
@@ -1388,12 +1389,7 @@ void AliITSsimulationSDD::Compress1D(){
     fStream->ClearStream();
 
     // back to galice.root file
-
-    TTree *fAli=gAlice->TreeK();
-    TFile *file = 0;
-
-    if (fAli) file =fAli->GetCurrentFile();
-    file->cd();
+    if(savedir) savedir->cd();
 }
 //______________________________________________________________________
 void AliITSsimulationSDD::StoreAllDigits(){
index 151fa16bb500592927fb4fab8172c4d9a3b5c249..a15e74fd4d62bf3e3f3dd7d4ec1b12b0ac5afd8a 100644 (file)
 #pragma link C++ class  AliV0vertexer+;
 
 #pragma link C++ class  AliITSVertex+;
+
+#pragma link C++ class  AliITSDigitizer+;
+
 #endif
index 55bc2f0a67e187edb6ddea2923cc8adb9d898ef1..028ffebedc7e11492c648715735965437fd08622 100644 (file)
@@ -43,7 +43,8 @@ SRCS          = AliITS.cxx AliITSv1.cxx AliITSv3.cxx AliITSv5.cxx \
                AliITSvtest.cxx \
                 AliITSclusterV2.cxx AliITStrackV2.cxx AliITStrackerV2.cxx \
                AliITSVertex.cxx \
-               AliV0vertex.cxx AliV0vertexer.cxx
+               AliV0vertex.cxx AliV0vertexer.cxx \
+               AliITSDigitizer.cxx
 #              AliITSAlignmentTrack.cxx AliITSAlignmentModule.cxx \
 
 # Fortran sources