ROOT logo
//////////////////////////////////////////////////////////////////////////////
//
// $Id: $
//
//*-- Author  : RICH team member
//*-- Revised : Martin Jurkovic <martin.jurkovic@ph.tum.de> 2010
//
//_HADES_CLASS_DESCRIPTION
//////////////////////////////////////////////////////////////////////////////
//
//  HRichDetector
//
//
//
//////////////////////////////////////////////////////////////////////////////


#include "TClass.h"

#include "hades.h"
#include "hcategory.h"
#include "hdetpario.h"
#include "hlinearcategory.h"
#include "hmatrixcategory.h"
#include "hparasciifileio.h"
#include "hpario.h"
#include "hparrootfileio.h"
#include "hrichanalysis.h"
#include "hrichdetector.h"
#include "hrichparasciifileio.h"
#include "hrichparrootfileio.h"
#include "htaskset.h"
#include "richdef.h"

#include <string.h>

using namespace std;

ClassImp(HRichDetector)

HRichDetector::HRichDetector(void) : HDetector("Rich", "The RICH detector")
{

   maxModules = 1;
   modules    = new TArrayI(RICH_MAX_SECTORS);
   maxComponents = RICH700_MAX_PMT; // JAM2018 must set this if you want to work with geometry parameter!

}

HTask* HRichDetector::buildTask(const Text_t*   name,
                         const Option_t* opt)
{
   if (NULL != name && 0 == strcmp(name, "default")) {
      name = NULL;
   }

   HTaskSet* pDetTasks = new HTaskSet("Rich", "List of Rich tasks");

   if (NULL == name) {
      //default list of tasks
      pDetTasks->add(new HRichAnalysis("rich.ana", "Ring finder", kFALSE));
      return pDetTasks;
   }

   return HDetector::buildTask(name, opt);
}

HCategory* HRichDetector::buildLinearCat(const Text_t* classname,
                              const Int_t size)
{
   HLinearCategory* category = NULL;

   category = new HLinearCategory(classname, size);
   return category;
}

HCategory* HRichDetector::buildMatrixCat(const Text_t* classname,
                              const Float_t fillRate)
{
   Int_t            sizes[3];
   HMatrixCategory* category = NULL;

   sizes[0] = RICH_MAX_SECTORS;
   sizes[1] = RICH700_MAX_ROWS;
   sizes[2] = RICH700_MAX_COLS;

   category = new HMatrixCategory(classname, 3, sizes, fillRate);
   return category;
}

HCategory* HRichDetector::buildSimMatrixCat(const Text_t* classname,
                                 const Float_t fillRate,
                                 const Int_t   size)
{

   HMatrixCategory *category = NULL;
   Int_t ini[2];

   ini[0] = RICH_MAX_SECTORS;
   ini[1] = size;

   category = new HMatrixCategory(classname, 2, ini, fillRate);
   return category;
}

// new JAM2017
HCategory* HRichDetector::build700MatrixCat(const Text_t* classname,
                                 const Float_t fillRate)
{

   HMatrixCategory *category = NULL;
   Int_t ini[2];

   ini[0] = RICH700_MAX_PMT+1; // indices in database are from 1 to RICH700_MAX_PMT, ignore 0 slot here!
   ini[1] = RICH700_MAX_PMTPIXELS+1; // indices in database are from 1 to RICH700_MAX_PMTPIXELS, ignore 0 slot here!

   category = new HMatrixCategory(classname, 2, ini, fillRate);
   return category;
}



HCategory* HRichDetector::buildCategory(Cat_t cat)
{
   switch (cat) {
      case catRichCal             :
         return buildMatrixCat("HRichCal", 1);
      case catRichHit             :
         return buildLinearCat("HRichHit");
      case catRichTrack           :
         return buildLinearCat("HRichTrack");
      case catRichDirClus         :
         return buildMatrixCat("HRichDirClus", 0.5);
      case catRichHitHdr          :
         return buildLinearCat("HRichHitHeader");
      case catRich700Raw          :
    	  return build700MatrixCat("HRich700Raw",1);

      default:
         return NULL;
   }
}

void HRichDetector::activateParIo(HParIo* io)
{
// Initialization according to Ilse's scheme
// activates the input/output class for the parameters
// needed by the Rich


   if (0 == strncmp(io->IsA()->GetName(), "HOraIo", strlen("HOraIo"))) {
      io->setDetParIo("HRichParIo");
      return;
   }

   if (0 == strncmp(io->IsA()->GetName(), "HParRootFileIo", strlen("HParRootFileIo"))) {
      HRichParRootFileIo* p = NULL;
      p = new HRichParRootFileIo(static_cast<HParRootFileIo*>(io)->getParRootFile());
      io->setDetParIo(p);
   }

   if (0 == strncmp(io->IsA()->GetName(), "HParAsciiFileIo", strlen("HParAsciiFileIo"))) {
      HRichParAsciiFileIo* p = NULL;
      p = new HRichParAsciiFileIo(static_cast<HParAsciiFileIo*>(io)->getFile());
      io->setDetParIo(p);
   }

}

Bool_t HRichDetector::write(HParIo* output)
{
// Writes the Rich setup to output

   HDetParIo* out = NULL;
   out  = output->getDetParIo("HRichParIo");
   if (NULL != out)
      return out->write(this);
   return kFALSE;
}
 hrichdetector.cc:1
 hrichdetector.cc:2
 hrichdetector.cc:3
 hrichdetector.cc:4
 hrichdetector.cc:5
 hrichdetector.cc:6
 hrichdetector.cc:7
 hrichdetector.cc:8
 hrichdetector.cc:9
 hrichdetector.cc:10
 hrichdetector.cc:11
 hrichdetector.cc:12
 hrichdetector.cc:13
 hrichdetector.cc:14
 hrichdetector.cc:15
 hrichdetector.cc:16
 hrichdetector.cc:17
 hrichdetector.cc:18
 hrichdetector.cc:19
 hrichdetector.cc:20
 hrichdetector.cc:21
 hrichdetector.cc:22
 hrichdetector.cc:23
 hrichdetector.cc:24
 hrichdetector.cc:25
 hrichdetector.cc:26
 hrichdetector.cc:27
 hrichdetector.cc:28
 hrichdetector.cc:29
 hrichdetector.cc:30
 hrichdetector.cc:31
 hrichdetector.cc:32
 hrichdetector.cc:33
 hrichdetector.cc:34
 hrichdetector.cc:35
 hrichdetector.cc:36
 hrichdetector.cc:37
 hrichdetector.cc:38
 hrichdetector.cc:39
 hrichdetector.cc:40
 hrichdetector.cc:41
 hrichdetector.cc:42
 hrichdetector.cc:43
 hrichdetector.cc:44
 hrichdetector.cc:45
 hrichdetector.cc:46
 hrichdetector.cc:47
 hrichdetector.cc:48
 hrichdetector.cc:49
 hrichdetector.cc:50
 hrichdetector.cc:51
 hrichdetector.cc:52
 hrichdetector.cc:53
 hrichdetector.cc:54
 hrichdetector.cc:55
 hrichdetector.cc:56
 hrichdetector.cc:57
 hrichdetector.cc:58
 hrichdetector.cc:59
 hrichdetector.cc:60
 hrichdetector.cc:61
 hrichdetector.cc:62
 hrichdetector.cc:63
 hrichdetector.cc:64
 hrichdetector.cc:65
 hrichdetector.cc:66
 hrichdetector.cc:67
 hrichdetector.cc:68
 hrichdetector.cc:69
 hrichdetector.cc:70
 hrichdetector.cc:71
 hrichdetector.cc:72
 hrichdetector.cc:73
 hrichdetector.cc:74
 hrichdetector.cc:75
 hrichdetector.cc:76
 hrichdetector.cc:77
 hrichdetector.cc:78
 hrichdetector.cc:79
 hrichdetector.cc:80
 hrichdetector.cc:81
 hrichdetector.cc:82
 hrichdetector.cc:83
 hrichdetector.cc:84
 hrichdetector.cc:85
 hrichdetector.cc:86
 hrichdetector.cc:87
 hrichdetector.cc:88
 hrichdetector.cc:89
 hrichdetector.cc:90
 hrichdetector.cc:91
 hrichdetector.cc:92
 hrichdetector.cc:93
 hrichdetector.cc:94
 hrichdetector.cc:95
 hrichdetector.cc:96
 hrichdetector.cc:97
 hrichdetector.cc:98
 hrichdetector.cc:99
 hrichdetector.cc:100
 hrichdetector.cc:101
 hrichdetector.cc:102
 hrichdetector.cc:103
 hrichdetector.cc:104
 hrichdetector.cc:105
 hrichdetector.cc:106
 hrichdetector.cc:107
 hrichdetector.cc:108
 hrichdetector.cc:109
 hrichdetector.cc:110
 hrichdetector.cc:111
 hrichdetector.cc:112
 hrichdetector.cc:113
 hrichdetector.cc:114
 hrichdetector.cc:115
 hrichdetector.cc:116
 hrichdetector.cc:117
 hrichdetector.cc:118
 hrichdetector.cc:119
 hrichdetector.cc:120
 hrichdetector.cc:121
 hrichdetector.cc:122
 hrichdetector.cc:123
 hrichdetector.cc:124
 hrichdetector.cc:125
 hrichdetector.cc:126
 hrichdetector.cc:127
 hrichdetector.cc:128
 hrichdetector.cc:129
 hrichdetector.cc:130
 hrichdetector.cc:131
 hrichdetector.cc:132
 hrichdetector.cc:133
 hrichdetector.cc:134
 hrichdetector.cc:135
 hrichdetector.cc:136
 hrichdetector.cc:137
 hrichdetector.cc:138
 hrichdetector.cc:139
 hrichdetector.cc:140
 hrichdetector.cc:141
 hrichdetector.cc:142
 hrichdetector.cc:143
 hrichdetector.cc:144
 hrichdetector.cc:145
 hrichdetector.cc:146
 hrichdetector.cc:147
 hrichdetector.cc:148
 hrichdetector.cc:149
 hrichdetector.cc:150
 hrichdetector.cc:151
 hrichdetector.cc:152
 hrichdetector.cc:153
 hrichdetector.cc:154
 hrichdetector.cc:155
 hrichdetector.cc:156
 hrichdetector.cc:157
 hrichdetector.cc:158
 hrichdetector.cc:159
 hrichdetector.cc:160
 hrichdetector.cc:161
 hrichdetector.cc:162
 hrichdetector.cc:163
 hrichdetector.cc:164
 hrichdetector.cc:165
 hrichdetector.cc:166
 hrichdetector.cc:167
 hrichdetector.cc:168
 hrichdetector.cc:169
 hrichdetector.cc:170
 hrichdetector.cc:171
 hrichdetector.cc:172
 hrichdetector.cc:173
 hrichdetector.cc:174
 hrichdetector.cc:175
 hrichdetector.cc:176
 hrichdetector.cc:177
 hrichdetector.cc:178
 hrichdetector.cc:179