new TTask to replace non-working AliITSFindClusterV2.C macro.
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Sep 2002 17:36:05 +0000 (17:36 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Sep 2002 17:36:05 +0000 (17:36 +0000)
ITS/AliITSFindClustersV2.cxx [new file with mode: 0644]
ITS/AliITSFindClustersV2.h [new file with mode: 0644]
ITS/ITSLinkDef.h
ITS/Makefile
ITS/libITS.pkg

diff --git a/ITS/AliITSFindClustersV2.cxx b/ITS/AliITSFindClustersV2.cxx
new file mode 100644 (file)
index 0000000..96e50d5
--- /dev/null
@@ -0,0 +1,367 @@
+/**************************************************************************
+ * 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 <TROOT.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TBranch.h>
+#include <TClonesArray.h>
+#include <TParticle.h>
+
+#include "AliRun.h"
+#include "AliHeader.h"
+
+#include "AliITS.h"
+#include "AliITSRecPoint.h"
+#include "AliITSFindClustersV2.h"
+#include "AliITSclusterV2.h"
+#include "AliITSgeom.h"
+
+ClassImp(AliITSFindClustersV2)
+
+//______________________________________________________________________
+AliITSFindClustersV2::AliITSFindClustersV2(){
+    // Default constructor.
+    // Inputs:
+    //  none.
+    // Outputs:
+    //   none.
+    // Return:
+    //    A zero-ed constructed AliITSFindClustersV2 class.
+
+    fAr          = 0;
+    fDeletfAr     = kFALSE; // fAr=0 dont't delete it.
+    fGeom        = 0;
+    fInFileName  = 0;
+    fOutFileName = 0;
+    fIn          = 0;
+    fOut         = 0;
+    fSlowFast    = kFALSE;  // slow simulation
+    fInit        = kFALSE;  // Init failed
+}
+//______________________________________________________________________
+AliITSFindClustersV2::AliITSFindClustersV2(const TString infile,
+                                          const TString outfile){
+    // Standard constructor.
+    // Inputs:
+    //  const TString infile   Input file name where the RecPoints are
+    //                         to be read from.
+    //  const TString outfile  Output file where V2 tracking clulsters
+    //                         are to be written. if =="" writen to the
+    //                         same file as input.
+    // Outputs:
+    //   none.
+    // Return:
+    //    A standardly constructed AliITSFindClustersV2 class.
+
+    fAr          = 0;
+    fDeletfAr    = kFALSE; // fAr=0 dont't delete it.
+    fGeom        = 0;
+    fInFileName  = 0;
+    fOutFileName = 0;
+    fIn          = 0;
+    fOut         = 0;
+    fSlowFast    = kFALSE;  // slow simulation
+    fInit        = kFALSE;  // Init failed
+
+    fInFileName = new TString(infile);
+    if(outfile.CompareTo("")!=0){
+       fOutFileName = new TString(outfile);
+    } // end if outfile.CompareeTo("")!=0
+    
+    if(fOutFileName!=0){
+       fIn = new TFile(fInFileName->Data(),"READ");
+       fOut = new TFile(fOutFileName->Data(),"UPDATE");
+    }else{ // open fIn file for update
+       fIn = new TFile(fInFileName->Data(),"UPDATE");
+    } // end if
+
+    fAr  = (AliRun*) fIn->Get("gAlice");
+    if(!fAr){
+       Warning("AliITSFindClusterV2",
+               "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
+       return;
+    } // end if !fAr
+    fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
+
+    AliITS *its = (AliITS*) fAr->GetModule("ITS");
+    if(!its){
+       Warning("AliITSFindClusterV2",
+               "Can't fine the ITS in gAlice. Aborting.");
+       return;
+    } // end if !its
+    fGeom = its->GetITSgeom();
+    if(!fGeom){
+       Warning("AliITSFindClusterV2",
+               "Can't fine the ITS geometry in gAlice. Aborting.");
+       return;
+    } // end if !fGeom
+
+    if(fOut) fOut->cd();
+    fInit = kTRUE;
+}
+//______________________________________________________________________
+AliITSFindClustersV2::AliITSFindClustersV2(TFile *in,
+                                          TFile *out){
+    // Standard constructor.
+    // Inputs:
+    //  const TFile *in   Input file where the RecPoints are
+    //                         to be read from.
+    //  const Tfile *out  Output file where V2 tracking clulsters
+    //                         are to be written. if ==0 writen to the
+    //                         same file as input.
+    // Outputs:
+    //   none.
+    // Return:
+    //    A standardly constructed AliITSFindClustersV2 class.
+
+    fAr          = 0;
+    fDeletfAr    = kFALSE; // fAr=0 dont't delete it.
+    fGeom        = 0;
+    fInFileName  = 0;
+    fOutFileName = 0;
+    fIn          = 0;
+    fOut         = 0;
+    fSlowFast    = kFALSE;  // slow simulation
+    fInit        = kFALSE;  // Init failed
+
+    fIn  = in;
+    fOut = out;
+    fAr  = (AliRun*) fIn->Get("gAlice");
+    if(!fAr){
+       Warning("AliITSFindClusterV2",
+               "Can't fine gAlice in file %s. Aborting.",fIn->GetName());
+       return;
+    } // end if !fAr
+    fDeletfAr = kTRUE; // Since gAlice was read in, delete it.
+    AliITS *its = (AliITS*) fAr->GetModule("ITS");
+    if(!its){
+       Warning("AliITSFindClusterV2",
+               "Can't fine the ITS in gAlice. Aborting.");
+       return;
+    } // end if !its
+    fGeom = its->GetITSgeom();
+    if(!fGeom){
+       Warning("AliITSFindClusterV2",
+               "Can't fine the ITS geometry in gAlice. Aborting.");
+       return;
+    } // end if !fGeom
+
+    if(fOut) fOut->cd();
+    fInit = kTRUE;
+}
+//______________________________________________________________________
+AliITSFindClustersV2::AliITSFindClustersV2(AliRun *ar,
+                                          const TString outfile){
+    // Standard constructor.
+    // Inputs:
+    //  const TString infile   Input file name where the RecPoints are
+    //                         to be read from.
+    //  const TString outfile  Output file where V2 tracking clulsters
+    //                         are to be written. if =="" writen to the
+    //                         same file as input.
+    // Outputs:
+    //   none.
+    // Return:
+    //    A standardly constructed AliITSFindClustersV2 class.
+
+    fAr          = 0;
+    fDeletfAr    = kFALSE; // fAr=0 dont't delete it.
+    fGeom        = 0;
+    fInFileName  = 0;
+    fOutFileName = 0;
+    fIn          = 0;
+    fOut         = 0;
+    fSlowFast    = kFALSE;  // slow simulation
+    fInit        = kFALSE;  // Init failed
+
+    if(outfile.CompareTo("")!=0){
+       fOutFileName = new TString(outfile);
+    } // end if outfile.CompareeTo("")!=0
+    
+    if(fOutFileName!=0){
+       fOut = new TFile(fOutFileName->Data(),"UPDATE");
+    } // end if
+
+    fAr  = ar;
+    if(!fAr){
+       Warning("AliITSFindClusterV2",
+               "ar==0. Aborting.");
+       return;
+    } // end if !fAr
+    AliITS *its = (AliITS*) fAr->GetModule("ITS");
+    if(!its){
+       Warning("AliITSFindClusterV2",
+               "Can't fine the ITS in gAlice. Aborting.");
+       return;
+    } // end if !its
+    fGeom = its->GetITSgeom();
+    if(!fGeom){
+       Warning("AliITSFindClusterV2",
+               "Can't fine the ITS geometry in gAlice. Aborting.");
+       return;
+    } // end if !fGeom
+
+    if(fOut) fOut->cd();
+    fInit = kTRUE;
+}
+//______________________________________________________________________
+AliITSFindClustersV2::~AliITSFindClustersV2(){
+    // Default constructor.
+    // Inputs:
+    //  none.
+    // Outputs:
+    //   none.
+    // Return:
+    //    A destroyed AliITSFindclustersV2 class.
+
+    fGeom = 0; // Deleted when AliRun/ITS is deleted.
+    if(fInFileName!=0){ // input file opened by AliITSFindClustersV2
+       if(fIn!=0){
+           if(fIn->IsOpen()) fIn->Close();
+           delete fIn;
+           fIn = 0;
+       } // end if
+       delete fInFileName;
+       fInFileName = 0;
+    } // end if
+
+    if(fOutFileName!=0){ // input file opened by AliITSFindClustersV2
+       if(fOut!=0){
+           if(fOut->IsOpen()) fOut->Close();
+           delete fOut;
+           fOut = 0;
+       } // end if
+       delete fOutFileName;
+       fOutFileName = 0;
+    } // end if
+    if(fDeletfAr && !fAr){
+       cout << "deleting fAr."<< endl;
+       delete fAr;
+       fAr = 0;
+       cout << "fAr deleted OK."<< endl;
+    } // end if fDeletfAr
+}
+//______________________________________________________________________ 
+void AliITSFindClustersV2::Exec(const Option_t *opt){
+    // Main FindclustersV2 function.
+    // Inputs:
+    //      Option_t * opt   list of subdetector to digitize. =0 all.
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+    Char_t name[50];
+
+    if(!fInit){
+       Warning("Exec","Initilization not succesfull. Aborting.");
+       return;
+    } // end if !fInit
+
+    fGeom->Write();
+
+    fAr->GetEvent(0);
+    TTree *pTree = fAr->TreeR();
+    if(!pTree){
+       Warning("Exec","Error getting TreeR. TreeR=%p",pTree);
+       return;
+    } // end if !pTree
+    TBranch *branch = 0;
+    if(fSlowFast) sprintf(name,"ITSRecPointsF");
+    else sprintf(name,"ITSRecPoints");
+    branch = pTree->GetBranch(name);
+    if(!branch){
+       Warning("Exec","Can't find branch \%s in TreeR fSlowFast=%d",
+               name,fSlowFast);
+       return;
+    } // end if !branch
+    TClonesArray *points = new TClonesArray("AliITSRecPoint",10000);
+    branch->SetAddress(&points);
+    Int_t nentr = (Int_t) branch->GetEntries();
+
+    if(fOut) fOut->cd();
+    TClonesArray *cluster = new TClonesArray("AliITSclusterV2",10000);
+    sprintf(name,"TreeC_ITS_%d",fAr->GetHeader()->GetEvent());
+    TTree *cTree = new TTree(name,"ITS clusters");
+    cTree->Branch("Clusters",&cluster);
+    TClonesArray &cl = *cluster;
+
+    Float_t lp[5];
+    Int_t lab[6];
+    Int_t i,j,lay,lad,det,nclusters=0,ncl;
+    Float_t kmip,x,y,zshift,yshift;
+    Double_t rot[9];
+    AliITSRecPoint *p;
+    TParticle *part;
+
+    for(i=0;i<nentr;i++){
+       points->Clear();
+       branch->GetEvent(i);
+       ncl = points->GetEntriesFast();
+       if(ncl<=0) {
+           cTree->Fill();
+           continue;
+       } // end if ncl<=0
+       nclusters += ncl;
+       fGeom->GetModuleId(i,lay,lad,det);
+       fGeom->GetTrans(i,x,y,zshift);
+       fGeom->GetRotMatrix(i,rot);
+       yshift = x*rot[0] + y*rot[1];
+       kmip = 1.0; // fGeom->GetModuletype(i)==kSPD
+       if(fGeom->GetModuleType(i)==kSDD) kmip = 280.0;
+       if(fGeom->GetModuleType(i)==kSSD) kmip = 38.0;
+       for(j=0;j<ncl;j++){
+           p = (AliITSRecPoint*)(points->UncheckedAt(j));
+           lp[0] = - (p->GetX() + yshift);
+           if(lay==1) lp[0] = -lp[0];
+           lp[1] = p->GetZ() + zshift;
+           lp[2] = p->GetSigmaX2();
+           lp[3] = p->GetSigmaZ2();
+           lp[4] = p->GetQ()/kmip;
+           lab[0] = p->GetLabel(0);
+           lab[1] = p->GetLabel(1);
+           lab[2] = p->GetLabel(2);
+           lab[3] = i;
+           lad = lab[0];
+           if(lad>=0){
+               part = (TParticle*) fAr->Particle(lad);
+               lad = -3;
+               while(part->P() < 0.005){
+                   if(part->GetFirstMother()<0){
+                       Warning("Exec","Primary momentum: %e",part->P());
+                       break;
+                   } // end if part->GetFirstMother()<0
+                   lad = part->GetFirstMother();
+                   part = (TParticle*) fAr->Particle(lad);
+               } // end while part->P() < 0.005
+               if(lab[1]<0) lab[1] = lad;
+               else if(lab[2]<0) lab[2] = lad;
+               else Warning("Exec","No empty lables!");
+           } // end if lab>=0
+           new(cl[j]) AliITSclusterV2(lab,lp);
+       } // end for j
+       cTree->Fill();
+       cluster->Delete();
+       points->Delete();
+    } // end for i
+    cTree->Write();
+    
+    delete cTree;
+    delete cluster;
+    delete points;
+}
diff --git a/ITS/AliITSFindClustersV2.h b/ITS/AliITSFindClustersV2.h
new file mode 100644 (file)
index 0000000..617ffee
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef ALIITSFINDCLUSTERSV2_H
+#define ALIITSFINDCLUSTERSV2_H
+/* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
+ * See cxx source for full Copyright notice                               */
+/*
+  $Id$
+ */
+
+#include <TTask.h>
+
+class TString;
+class TFile;
+class AliRun;
+class AliITSgeom;
+
+class AliITSFindClustersV2 : public TTask{
+ public:
+    AliITSFindClustersV2(); // default constructor
+    // standard constructor files not opened, by file name
+    AliITSFindClustersV2(const TString infile,const TString outfile = "");
+    // standard constructor for files already opened.
+    AliITSFindClustersV2(TFile *in,TFile *out=0);
+    // Standard constructor for AliRun already read in.
+    AliITSFindClustersV2(AliRun *ar,TString outfile = "");
+    virtual ~AliITSFindClustersV2();//Destructor
+    virtual Bool_t FastSimulation() const {return fSlowFast;}
+    virtual void SetSlowSimulation(){fSlowFast = kFALSE;}
+    virtual void SetFastSimulation(){fSlowFast = kTRUE;}
+    virtual void Exec(const Option_t *opt="");
+ private:
+    AliRun *fAr;           //! Pointer of type AliRun
+    Bool_t fDeletfAr;      //! Logical to indecate if fAr should be deleted.
+    AliITSgeom *fGeom;     //! Pointer to ITS geometry
+    TString *fInFileName;  //! Pointer to input file name string.
+    TString *fOutFileName; //! Pointer to output file name string.
+    TFile   *fIn;          //! pointer to input file
+    TFile   *fOut;         //! pointer to output file
+    Bool_t fInit;          //! true if Init was successfull
+    Bool_t fSlowFast;      //! if true then using fast ITS simulation.
+
+    ClassDef(AliITSFindClustersV2,1) // Task to Reconstruct ITS from Digits.
+
+};
+#endif
index 5ab5778..7fad241 100644 (file)
 #pragma link C++ class AliITSsDigitize+;
 #pragma link C++ class AliITSDigitizer+;
 #pragma link C++ class AliITSFDigitizer+;
+#pragma link C++ class AliITSFindClustersV2+;
 #endif
index c55312d..16ae62b 100644 (file)
@@ -47,6 +47,7 @@ SRCS          = AliITS.cxx AliITSv1.cxx AliITSv5.cxx \
                AliCascadeVertex.cxx AliCascadeVertexer.cxx \
                AliITSglobalRecPoint.cxx AliITSneuralTrack.cxx \
                AliITSneuralTracker.cxx AliITSRiemannFit.cxx \
+               AliITSFindClustersV2.cxx \
                AliITSFDigitizer.cxx
 #              AliITSAlignmentTrack.cxx AliITSAlignmentModule.cxx \
 
index 01cd55e..b8e3cc4 100644 (file)
@@ -35,7 +35,9 @@ SRCS          = AliITS.cxx AliITSv1.cxx AliITSv5.cxx \
                 AliITSPid.cxx AliITStrackV2Pid.cxx AliCascadeVertex.cxx \
                 AliCascadeVertexer.cxx  AliITSneuralTrack.cxx \
                 AliITSneuralTracker.cxx AliITSglobalRecPoint.cxx \
-                AliITSsDigitize.cxx AliITSDigitizer.cxx AliITSreconstruction.cxx \
+                AliITSsDigitize.cxx AliITSDigitizer.cxx \
+               AliITSreconstruction.cxx \
+               AliITSFindClustersV2.cxx \
                AliITSRiemannFit.cxx \
                AliITSFDigitizer.cxx
 #              AliITSAlignmentTrack.cxx AliITSAlignmentModule.cxx \