ROOT logo
/**************************************************************************
 * 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.                  *
 **************************************************************************/
 
/* $Id$ */
/////////////////////////////////////////////////////////////////////////
//                                                                     //
// Class for ITS RecPoint reconstruction                               //
//                                                                     //
////////////////////////////////////////////////////////////////////////

#include <TString.h>
#include "AliRun.h"
#include "AliRunLoader.h"
#include "AliITSDetTypeRec.h"
#include "AliITSLoader.h"
#include "AliITSreconstruction.h"
#include "AliITSgeom.h"

using std::endl;
using std::cout;
ClassImp(AliITSreconstruction)

//______________________________________________________________________
AliITSreconstruction::AliITSreconstruction():
 fInit(kFALSE),
 fEnt(0),
 fEnt0(0),
 fDetTypeRec(0x0),
 fDfArp(kFALSE),
 fITSgeom(0x0),
 fLoader(0x0),
 fRunLoader(0x0)
{
    // Default constructor.
    // Inputs:
    //  none.
    // Outputs:
    //   none.
    // Return:
    //    A zero-ed constructed AliITSreconstruction class.
    fDet[0] = fDet[1] = fDet[2] = kTRUE;
}
//______________________________________________________________________

AliITSreconstruction::AliITSreconstruction(AliRunLoader *rl):
 fInit(kFALSE),
 fEnt(0),
 fEnt0(0),
 fDetTypeRec(0x0),
 fDfArp(kFALSE),
 fITSgeom(0x0),
 fLoader(0x0),
 fRunLoader(rl)
{
  fDet[0] = fDet[1] = fDet[2] = kTRUE;
}
//______________________________________________________________________
AliITSreconstruction::AliITSreconstruction(const char* filename):
 fInit(kFALSE),
 fEnt(0),
 fEnt0(0),
 fDetTypeRec(0x0),
 fDfArp(kFALSE),
 fITSgeom(0x0),
 fLoader(0x0),
 fRunLoader(0x0)
{
    // Standard constructor.
    // Inputs:
    //  const char* filename    filename containing the digits to be
    //                          reconstructed. If filename = 0 (nil)
    //                          then no file is opened but a file is
    //                          assumed to already be opened. This 
    //                          already opened file will be used.
    // Outputs:
    //   none.
    // Return:
    //    A standardly constructed AliITSreconstruction class.

    fDet[0] = fDet[1] = fDet[2] = kTRUE;

    fRunLoader = AliRunLoader::Open(filename);
    if (fRunLoader == 0x0)
     {
       Error("AliITSreconstruction","Can not load the session %s \n",filename);
       return;
     }

}


//______________________________________________________________________
AliITSreconstruction::~AliITSreconstruction(){
    //    A destroyed AliITSreconstruction class.
    
    //fITS      = 0;
    delete fRunLoader;
    
}
//______________________________________________________________________
Bool_t AliITSreconstruction::Init(){
    // Class Initilizer.
    // Inputs:
    //  none.
    // Outputs:
    //   none.
    // Return:
    //    kTRUE if no errors initilizing this class occurse else kFALSE
    Info("Init"," Init ITS reconstruction");
    if (fRunLoader == 0x0)
     {
       Error("Init","Run Loader is NULL");
       return kFALSE;
     }
    //  fRunLoader->LoadgAlice();
    //   fRunLoader->LoadHeader();  

    fLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
    if(!fLoader) {
      Error("Init","ITS loader not found");
      fInit = kFALSE;
    }

    // Now ready to init.
 
    //fRunLoader->CdGAFile();
    fITSgeom = fLoader->GetITSgeom();

    fDetTypeRec = new AliITSDetTypeRec();
    fDetTypeRec->SetITSgeom(fITSgeom);
    fDetTypeRec->SetDefaults();
    fDet[0] = fDet[1] = fDet[2] = kTRUE;
    fEnt0 = 0;

    fEnt = Int_t(fRunLoader->GetNumberOfEvents());

    fLoader->LoadDigits("read");
    fLoader->LoadRecPoints("recreate");
    if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
 
    fDetTypeRec->SetTreeAddressD(fLoader->TreeD());
    fDetTypeRec->MakeBranchR(fLoader->TreeR());
    fDetTypeRec->SetTreeAddressR(fLoader->TreeR());

    fInit = InitRec();

    Info("Init","  Done\n\n\n");

    return fInit;
}
//______________________________________________________________________
Bool_t AliITSreconstruction::InitRec(){
    // Sets up Reconstruction part of AliITSDetType..
    // Inputs:
    //      none.
    // Outputs:
    //      none.
    // Return:
    //      none.


  fDetTypeRec->SetDefaultClusterFindersV2();
  Info("InitRec","    Done\n");
  return kTRUE;
}
//______________________________________________________________________ 
void AliITSreconstruction::Exec(const Option_t *opt){
    // Main reconstruction function.
    // Inputs:
    //      Option_t * opt   list of subdetector to digitize. =0 all.
    // Outputs:
    //      none.
    // Return:
    //      none.
    Option_t *lopt;
    Int_t evnt;
    Bool_t condition =kFALSE;
    if(opt){
      if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS"))condition =kTRUE;
    }
    else{
      condition = kTRUE;
    }
    if(condition){
      fDet[0] = fDet[1] = fDet[2] = kTRUE;
      lopt = "All";
    }else{
      fDet[0] = fDet[1] = fDet[2] = kFALSE;
      if(strstr(opt,"SPD")) fDet[kSPD] = kTRUE;
      if(strstr(opt,"SDD")) fDet[kSDD] = kTRUE;
      if(strstr(opt,"SSD")) fDet[kSSD] = kTRUE;
      if(fDet[kSPD] && fDet[kSDD] && fDet[kSSD]) lopt = "All";
      else lopt = opt;
    } // end if strstr(opt,...)

    if(!fInit){
      cout << "Initilization Failed, Can't run Exec." << endl;
      return;
    } // end if !fInit
    for(evnt=0;evnt<fEnt;evnt++)
     {
       //      Info("Exec","");
      Info("Exec","Processing Event %d",evnt);
      //      Info("Exec","");

      fRunLoader->GetEvent(evnt);
      if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
      fDetTypeRec->MakeBranchR(0);
      fDetTypeRec->SetTreeAddressR(fLoader->TreeR());
      fDetTypeRec->SetTreeAddressD(fLoader->TreeD());
      fDetTypeRec->DigitsToRecPoints(fLoader->TreeD(),fLoader->TreeR(),0,lopt);
    } // end for evnt
}
//______________________________________________________________________ 
void AliITSreconstruction::SetOutputFile(TString filename){
  // Set a new file name for recpoints. 
  // It must be called before Init()
  if(!fLoader)fLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
  if(fLoader){
    Info("SetOutputFile","name for rec points is %s",filename.Data());
    fLoader->SetRecPointsFileName(filename);
  }
  else {
    Error("SetOutputFile",
    "ITS loader not available. Not possible to set name: %s",filename.Data());
  }
}
 AliITSreconstruction.cxx:1
 AliITSreconstruction.cxx:2
 AliITSreconstruction.cxx:3
 AliITSreconstruction.cxx:4
 AliITSreconstruction.cxx:5
 AliITSreconstruction.cxx:6
 AliITSreconstruction.cxx:7
 AliITSreconstruction.cxx:8
 AliITSreconstruction.cxx:9
 AliITSreconstruction.cxx:10
 AliITSreconstruction.cxx:11
 AliITSreconstruction.cxx:12
 AliITSreconstruction.cxx:13
 AliITSreconstruction.cxx:14
 AliITSreconstruction.cxx:15
 AliITSreconstruction.cxx:16
 AliITSreconstruction.cxx:17
 AliITSreconstruction.cxx:18
 AliITSreconstruction.cxx:19
 AliITSreconstruction.cxx:20
 AliITSreconstruction.cxx:21
 AliITSreconstruction.cxx:22
 AliITSreconstruction.cxx:23
 AliITSreconstruction.cxx:24
 AliITSreconstruction.cxx:25
 AliITSreconstruction.cxx:26
 AliITSreconstruction.cxx:27
 AliITSreconstruction.cxx:28
 AliITSreconstruction.cxx:29
 AliITSreconstruction.cxx:30
 AliITSreconstruction.cxx:31
 AliITSreconstruction.cxx:32
 AliITSreconstruction.cxx:33
 AliITSreconstruction.cxx:34
 AliITSreconstruction.cxx:35
 AliITSreconstruction.cxx:36
 AliITSreconstruction.cxx:37
 AliITSreconstruction.cxx:38
 AliITSreconstruction.cxx:39
 AliITSreconstruction.cxx:40
 AliITSreconstruction.cxx:41
 AliITSreconstruction.cxx:42
 AliITSreconstruction.cxx:43
 AliITSreconstruction.cxx:44
 AliITSreconstruction.cxx:45
 AliITSreconstruction.cxx:46
 AliITSreconstruction.cxx:47
 AliITSreconstruction.cxx:48
 AliITSreconstruction.cxx:49
 AliITSreconstruction.cxx:50
 AliITSreconstruction.cxx:51
 AliITSreconstruction.cxx:52
 AliITSreconstruction.cxx:53
 AliITSreconstruction.cxx:54
 AliITSreconstruction.cxx:55
 AliITSreconstruction.cxx:56
 AliITSreconstruction.cxx:57
 AliITSreconstruction.cxx:58
 AliITSreconstruction.cxx:59
 AliITSreconstruction.cxx:60
 AliITSreconstruction.cxx:61
 AliITSreconstruction.cxx:62
 AliITSreconstruction.cxx:63
 AliITSreconstruction.cxx:64
 AliITSreconstruction.cxx:65
 AliITSreconstruction.cxx:66
 AliITSreconstruction.cxx:67
 AliITSreconstruction.cxx:68
 AliITSreconstruction.cxx:69
 AliITSreconstruction.cxx:70
 AliITSreconstruction.cxx:71
 AliITSreconstruction.cxx:72
 AliITSreconstruction.cxx:73
 AliITSreconstruction.cxx:74
 AliITSreconstruction.cxx:75
 AliITSreconstruction.cxx:76
 AliITSreconstruction.cxx:77
 AliITSreconstruction.cxx:78
 AliITSreconstruction.cxx:79
 AliITSreconstruction.cxx:80
 AliITSreconstruction.cxx:81
 AliITSreconstruction.cxx:82
 AliITSreconstruction.cxx:83
 AliITSreconstruction.cxx:84
 AliITSreconstruction.cxx:85
 AliITSreconstruction.cxx:86
 AliITSreconstruction.cxx:87
 AliITSreconstruction.cxx:88
 AliITSreconstruction.cxx:89
 AliITSreconstruction.cxx:90
 AliITSreconstruction.cxx:91
 AliITSreconstruction.cxx:92
 AliITSreconstruction.cxx:93
 AliITSreconstruction.cxx:94
 AliITSreconstruction.cxx:95
 AliITSreconstruction.cxx:96
 AliITSreconstruction.cxx:97
 AliITSreconstruction.cxx:98
 AliITSreconstruction.cxx:99
 AliITSreconstruction.cxx:100
 AliITSreconstruction.cxx:101
 AliITSreconstruction.cxx:102
 AliITSreconstruction.cxx:103
 AliITSreconstruction.cxx:104
 AliITSreconstruction.cxx:105
 AliITSreconstruction.cxx:106
 AliITSreconstruction.cxx:107
 AliITSreconstruction.cxx:108
 AliITSreconstruction.cxx:109
 AliITSreconstruction.cxx:110
 AliITSreconstruction.cxx:111
 AliITSreconstruction.cxx:112
 AliITSreconstruction.cxx:113
 AliITSreconstruction.cxx:114
 AliITSreconstruction.cxx:115
 AliITSreconstruction.cxx:116
 AliITSreconstruction.cxx:117
 AliITSreconstruction.cxx:118
 AliITSreconstruction.cxx:119
 AliITSreconstruction.cxx:120
 AliITSreconstruction.cxx:121
 AliITSreconstruction.cxx:122
 AliITSreconstruction.cxx:123
 AliITSreconstruction.cxx:124
 AliITSreconstruction.cxx:125
 AliITSreconstruction.cxx:126
 AliITSreconstruction.cxx:127
 AliITSreconstruction.cxx:128
 AliITSreconstruction.cxx:129
 AliITSreconstruction.cxx:130
 AliITSreconstruction.cxx:131
 AliITSreconstruction.cxx:132
 AliITSreconstruction.cxx:133
 AliITSreconstruction.cxx:134
 AliITSreconstruction.cxx:135
 AliITSreconstruction.cxx:136
 AliITSreconstruction.cxx:137
 AliITSreconstruction.cxx:138
 AliITSreconstruction.cxx:139
 AliITSreconstruction.cxx:140
 AliITSreconstruction.cxx:141
 AliITSreconstruction.cxx:142
 AliITSreconstruction.cxx:143
 AliITSreconstruction.cxx:144
 AliITSreconstruction.cxx:145
 AliITSreconstruction.cxx:146
 AliITSreconstruction.cxx:147
 AliITSreconstruction.cxx:148
 AliITSreconstruction.cxx:149
 AliITSreconstruction.cxx:150
 AliITSreconstruction.cxx:151
 AliITSreconstruction.cxx:152
 AliITSreconstruction.cxx:153
 AliITSreconstruction.cxx:154
 AliITSreconstruction.cxx:155
 AliITSreconstruction.cxx:156
 AliITSreconstruction.cxx:157
 AliITSreconstruction.cxx:158
 AliITSreconstruction.cxx:159
 AliITSreconstruction.cxx:160
 AliITSreconstruction.cxx:161
 AliITSreconstruction.cxx:162
 AliITSreconstruction.cxx:163
 AliITSreconstruction.cxx:164
 AliITSreconstruction.cxx:165
 AliITSreconstruction.cxx:166
 AliITSreconstruction.cxx:167
 AliITSreconstruction.cxx:168
 AliITSreconstruction.cxx:169
 AliITSreconstruction.cxx:170
 AliITSreconstruction.cxx:171
 AliITSreconstruction.cxx:172
 AliITSreconstruction.cxx:173
 AliITSreconstruction.cxx:174
 AliITSreconstruction.cxx:175
 AliITSreconstruction.cxx:176
 AliITSreconstruction.cxx:177
 AliITSreconstruction.cxx:178
 AliITSreconstruction.cxx:179
 AliITSreconstruction.cxx:180
 AliITSreconstruction.cxx:181
 AliITSreconstruction.cxx:182
 AliITSreconstruction.cxx:183
 AliITSreconstruction.cxx:184
 AliITSreconstruction.cxx:185
 AliITSreconstruction.cxx:186
 AliITSreconstruction.cxx:187
 AliITSreconstruction.cxx:188
 AliITSreconstruction.cxx:189
 AliITSreconstruction.cxx:190
 AliITSreconstruction.cxx:191
 AliITSreconstruction.cxx:192
 AliITSreconstruction.cxx:193
 AliITSreconstruction.cxx:194
 AliITSreconstruction.cxx:195
 AliITSreconstruction.cxx:196
 AliITSreconstruction.cxx:197
 AliITSreconstruction.cxx:198
 AliITSreconstruction.cxx:199
 AliITSreconstruction.cxx:200
 AliITSreconstruction.cxx:201
 AliITSreconstruction.cxx:202
 AliITSreconstruction.cxx:203
 AliITSreconstruction.cxx:204
 AliITSreconstruction.cxx:205
 AliITSreconstruction.cxx:206
 AliITSreconstruction.cxx:207
 AliITSreconstruction.cxx:208
 AliITSreconstruction.cxx:209
 AliITSreconstruction.cxx:210
 AliITSreconstruction.cxx:211
 AliITSreconstruction.cxx:212
 AliITSreconstruction.cxx:213
 AliITSreconstruction.cxx:214
 AliITSreconstruction.cxx:215
 AliITSreconstruction.cxx:216
 AliITSreconstruction.cxx:217
 AliITSreconstruction.cxx:218
 AliITSreconstruction.cxx:219
 AliITSreconstruction.cxx:220
 AliITSreconstruction.cxx:221
 AliITSreconstruction.cxx:222
 AliITSreconstruction.cxx:223
 AliITSreconstruction.cxx:224
 AliITSreconstruction.cxx:225
 AliITSreconstruction.cxx:226
 AliITSreconstruction.cxx:227
 AliITSreconstruction.cxx:228
 AliITSreconstruction.cxx:229
 AliITSreconstruction.cxx:230
 AliITSreconstruction.cxx:231
 AliITSreconstruction.cxx:232
 AliITSreconstruction.cxx:233
 AliITSreconstruction.cxx:234
 AliITSreconstruction.cxx:235
 AliITSreconstruction.cxx:236
 AliITSreconstruction.cxx:237
 AliITSreconstruction.cxx:238
 AliITSreconstruction.cxx:239