ROOT logo
#pragma implementation
using namespace std;
#include "hshowerdetector.h"
#include "hades.h"
#include "hpario.h"
#include "hparrootfileio.h"
#include "hdetpario.h"
#include "hparasciifileio.h"
#include "hcategory.h"
#include "hmatrixcategory.h"
#include "hlinearcategory.h"
#include "showerdef.h"
#include "hshowercalibrater.h"
#include "hshowerhit.h"
#include "hshowerhitfinder.h"
#include "hshowerparasciifileio.h"
#include "hshowerparrootfileio.h"
#include "htaskset.h"
#include "TClass.h"
#include <iostream> 
#include <iomanip>
HShowerDetector::HShowerDetector(void) : HDetector("Shower","The SHOWER detector") {
  maxModules=3;
  maxRows=32;
  maxColumns=32;
  maxComponents =1;
  modules=new TArrayI(getMaxSectors()*maxModules);

  //  createTaskSet("ShowerTaskSet", "Shower list of tasks");
}

HShowerDetector::~HShowerDetector(void) {
}

Bool_t HShowerDetector::init(const Text_t*) {
  return kTRUE;
}

//_HADES_CLASS_DESCRIPTION 
////////////////////////////////////////////////////
// initialization according to Ilse's scheme

void HShowerDetector::activateParIo(HParIo* io) {
  // activates the input/output class for the parameters
  // needed by the Shower
  if (strcmp(io->IsA()->GetName(),"HOra2Io")==0) {
    io->setDetParIo("HShowerParIo");
    return;
  }

  if (strcmp(io->IsA()->GetName(),"HParRootFileIo")==0) {
    HShowerParRootFileIo* p=new HShowerParRootFileIo(((HParRootFileIo*)io)
                                                        ->getParRootFile());
    io->setDetParIo(p);
  }

  if (strcmp(io->IsA()->GetName(),"HParAsciiFileIo")==0) {
    HShowerParAsciiFileIo* p=new HShowerParAsciiFileIo(((HParAsciiFileIo*)io)->getFile());
    io->setDetParIo(p);
  }

}

Bool_t HShowerDetector::write(HParIo* output) {
  // writes the Shower setup to output
  HDetParIo* out=output->getDetParIo("HShowerParIo");
  if (out) return out->write(this);
  return kFALSE;
}
//////////////////////////////////////////////////////////

/*
HTask *HShowerDetector::buildTask(Text_t *name,Option_t *opt="") {
  HTask *r=NULL;
  if (strcmp(name,"calibrate")==0) {
    r=new HShowerCalibrater("shower.calibrater","calibrater");
  } else if (strcmp(name,"hitF")==0) {
    r=new HShowerHitFinder("shower.hitF","Hit finder");
    if (strcmp(opt,"raw")==0) {
      HTaskSet *ts=new HTaskSet("shower.hitF","Hit finder");
      ts->connect(new HShowerCalibrater("shower.calibrater","shower.calibrater"));
      if (!ts->connect(r,"shower.calibrater")) 
	Error("buildTask","connection failed");
      ts->connect(NULL,r);
      r=ts;
    }
  }
  return r;
} 
*/

HTask *HShowerDetector::buildTask(const Text_t *name,const Option_t *opt) {
 //name bedzie pozniej nazwa klasy tworzacej liste zadan dla operacji
 //opisanych przez ta nazwe


 if (name && strcmp(name, "default")==0)  name = NULL;
  
 HTaskSet *pDetTasks = new HTaskSet();

  if (!name) //default list of tasks
  { 
      HShowerCalibrater *cal = new HShowerCalibrater("ShowerCal","shower.cal");
      HShowerHitFinder *hit=new HShowerHitFinder("ShowerHitFinder","Shower hit finder");

      pDetTasks->connect(cal);
      pDetTasks->connect(hit, "ShowerCal");
      pDetTasks->connect((HTask*)NULL, "ShowerHitFinder");

      return pDetTasks;
  }

return NULL;
}

HCategory *HShowerDetector::buildLinearCat(const Text_t *classname) {
  HLinearCategory *category=NULL;

		// allocate 10% of maximum
  Int_t size = (Int_t)0.1*32*32*3*getShowerSectors();     
  category=new HLinearCategory(classname, size);
  return category;
}


HCategory *HShowerDetector::buildMatrixCat(const Text_t *classname,Float_t fillRate, Int_t nLevels, Int_t* sizes) {
  return new HMatrixCategory(classname,nLevels,sizes,fillRate);
}
 
HCategory *HShowerDetector::buildMatrixCat(const Text_t *classname,Float_t fillRate, Int_t nLevels) {
  Int_t maxSector=0,maxModule=0,mod=0;
  Int_t sec=0;
  Int_t i,sizes[4];
  HMatrixCategory *category=NULL;

  for (i=0;i<modules->fN;i++) {
    mod=modules->At(i)-1;
    if (mod>-1) {
      mod = i;
      sec=mod/maxModules;
      mod=mod%maxModules;
      maxSector=((sec)>maxSector)?(sec):maxSector;
      maxModule=((mod)>maxModule)?(mod):maxModule;
    }
  }
  maxSector++; maxModule++;
  sizes[0]=maxSector; sizes[1]=maxModule;
  sizes[2] = sizes[3] = 32;

  category=(HMatrixCategory*)buildMatrixCat(classname,fillRate, nLevels, sizes);
  return category;
}

Int_t HShowerDetector::getShowerSectors() {
  Int_t sect, mod;
  getMaxValues(&sect, &mod);

  return sect;
}

Int_t HShowerDetector::getShowerModules() {
  Int_t sect, mod;
  getMaxValues(&sect, &mod);

  return mod;
}

void HShowerDetector::getMaxValues(Int_t* pMaxSector, Int_t *pMaxModule) {
  Int_t mod,sec=0;
  Int_t i;
  Int_t maxSector=0;
  Int_t maxModule=0;

  for (i=0;i<modules->fN;i++) {
    mod=modules->At(i)-1;
    if (mod>-1) {
      mod = i;
      sec=mod/maxModules;
      mod=mod%maxModules;
      maxSector=((sec)>maxSector)?(sec):maxSector;
      maxModule=((mod)>maxModule)?(mod):maxModule;
    }
  }
  *pMaxSector = ++maxSector; 
  *pMaxModule = ++maxModule;
}

HCategory *HShowerDetector::buildCategory(Cat_t cat) {
  Int_t wireSizes[] = {6,600};
  
  switch (cat) {
//  case catShowerRaw : return buildMatrixCat("HShowerRaw",1, 4);
//  case catShowerCal : return buildMatrixCat("HShowerCal",1, 4);
  case catShowerRaw : return buildLinearCat("HShowerRaw");
  case catShowerCal : return buildLinearCat("HShowerCal");
  case catShowerRawMatr : return buildMatrixCat("HShowerRawMatr",1, 4);

  case catShowerHit : return buildLinearCat("HShowerHit");
  case catShowerPID : return buildLinearCat("HShowerPID");
  case catShowerTrack : return buildLinearCat("HShowerTrack");
  case catShowerGeantRaw : return buildMatrixCat("HShowerGeantHit", 0.2, 2, wireSizes);
 
  case catShowerGeantWire : return buildLinearCat("HShowerGeantWire");
  case catShowerHitHdr : return buildMatrixCat("HShowerHitHeader", 1, 2);
  case catShowerPIDTrack : return buildLinearCat("HShowerPIDTrack");

  default : return NULL;
  }
}

ClassImp(HShowerDetector)
 hshowerdetector.cc:1
 hshowerdetector.cc:2
 hshowerdetector.cc:3
 hshowerdetector.cc:4
 hshowerdetector.cc:5
 hshowerdetector.cc:6
 hshowerdetector.cc:7
 hshowerdetector.cc:8
 hshowerdetector.cc:9
 hshowerdetector.cc:10
 hshowerdetector.cc:11
 hshowerdetector.cc:12
 hshowerdetector.cc:13
 hshowerdetector.cc:14
 hshowerdetector.cc:15
 hshowerdetector.cc:16
 hshowerdetector.cc:17
 hshowerdetector.cc:18
 hshowerdetector.cc:19
 hshowerdetector.cc:20
 hshowerdetector.cc:21
 hshowerdetector.cc:22
 hshowerdetector.cc:23
 hshowerdetector.cc:24
 hshowerdetector.cc:25
 hshowerdetector.cc:26
 hshowerdetector.cc:27
 hshowerdetector.cc:28
 hshowerdetector.cc:29
 hshowerdetector.cc:30
 hshowerdetector.cc:31
 hshowerdetector.cc:32
 hshowerdetector.cc:33
 hshowerdetector.cc:34
 hshowerdetector.cc:35
 hshowerdetector.cc:36
 hshowerdetector.cc:37
 hshowerdetector.cc:38
 hshowerdetector.cc:39
 hshowerdetector.cc:40
 hshowerdetector.cc:41
 hshowerdetector.cc:42
 hshowerdetector.cc:43
 hshowerdetector.cc:44
 hshowerdetector.cc:45
 hshowerdetector.cc:46
 hshowerdetector.cc:47
 hshowerdetector.cc:48
 hshowerdetector.cc:49
 hshowerdetector.cc:50
 hshowerdetector.cc:51
 hshowerdetector.cc:52
 hshowerdetector.cc:53
 hshowerdetector.cc:54
 hshowerdetector.cc:55
 hshowerdetector.cc:56
 hshowerdetector.cc:57
 hshowerdetector.cc:58
 hshowerdetector.cc:59
 hshowerdetector.cc:60
 hshowerdetector.cc:61
 hshowerdetector.cc:62
 hshowerdetector.cc:63
 hshowerdetector.cc:64
 hshowerdetector.cc:65
 hshowerdetector.cc:66
 hshowerdetector.cc:67
 hshowerdetector.cc:68
 hshowerdetector.cc:69
 hshowerdetector.cc:70
 hshowerdetector.cc:71
 hshowerdetector.cc:72
 hshowerdetector.cc:73
 hshowerdetector.cc:74
 hshowerdetector.cc:75
 hshowerdetector.cc:76
 hshowerdetector.cc:77
 hshowerdetector.cc:78
 hshowerdetector.cc:79
 hshowerdetector.cc:80
 hshowerdetector.cc:81
 hshowerdetector.cc:82
 hshowerdetector.cc:83
 hshowerdetector.cc:84
 hshowerdetector.cc:85
 hshowerdetector.cc:86
 hshowerdetector.cc:87
 hshowerdetector.cc:88
 hshowerdetector.cc:89
 hshowerdetector.cc:90
 hshowerdetector.cc:91
 hshowerdetector.cc:92
 hshowerdetector.cc:93
 hshowerdetector.cc:94
 hshowerdetector.cc:95
 hshowerdetector.cc:96
 hshowerdetector.cc:97
 hshowerdetector.cc:98
 hshowerdetector.cc:99
 hshowerdetector.cc:100
 hshowerdetector.cc:101
 hshowerdetector.cc:102
 hshowerdetector.cc:103
 hshowerdetector.cc:104
 hshowerdetector.cc:105
 hshowerdetector.cc:106
 hshowerdetector.cc:107
 hshowerdetector.cc:108
 hshowerdetector.cc:109
 hshowerdetector.cc:110
 hshowerdetector.cc:111
 hshowerdetector.cc:112
 hshowerdetector.cc:113
 hshowerdetector.cc:114
 hshowerdetector.cc:115
 hshowerdetector.cc:116
 hshowerdetector.cc:117
 hshowerdetector.cc:118
 hshowerdetector.cc:119
 hshowerdetector.cc:120
 hshowerdetector.cc:121
 hshowerdetector.cc:122
 hshowerdetector.cc:123
 hshowerdetector.cc:124
 hshowerdetector.cc:125
 hshowerdetector.cc:126
 hshowerdetector.cc:127
 hshowerdetector.cc:128
 hshowerdetector.cc:129
 hshowerdetector.cc:130
 hshowerdetector.cc:131
 hshowerdetector.cc:132
 hshowerdetector.cc:133
 hshowerdetector.cc:134
 hshowerdetector.cc:135
 hshowerdetector.cc:136
 hshowerdetector.cc:137
 hshowerdetector.cc:138
 hshowerdetector.cc:139
 hshowerdetector.cc:140
 hshowerdetector.cc:141
 hshowerdetector.cc:142
 hshowerdetector.cc:143
 hshowerdetector.cc:144
 hshowerdetector.cc:145
 hshowerdetector.cc:146
 hshowerdetector.cc:147
 hshowerdetector.cc:148
 hshowerdetector.cc:149
 hshowerdetector.cc:150
 hshowerdetector.cc:151
 hshowerdetector.cc:152
 hshowerdetector.cc:153
 hshowerdetector.cc:154
 hshowerdetector.cc:155
 hshowerdetector.cc:156
 hshowerdetector.cc:157
 hshowerdetector.cc:158
 hshowerdetector.cc:159
 hshowerdetector.cc:160
 hshowerdetector.cc:161
 hshowerdetector.cc:162
 hshowerdetector.cc:163
 hshowerdetector.cc:164
 hshowerdetector.cc:165
 hshowerdetector.cc:166
 hshowerdetector.cc:167
 hshowerdetector.cc:168
 hshowerdetector.cc:169
 hshowerdetector.cc:170
 hshowerdetector.cc:171
 hshowerdetector.cc:172
 hshowerdetector.cc:173
 hshowerdetector.cc:174
 hshowerdetector.cc:175
 hshowerdetector.cc:176
 hshowerdetector.cc:177
 hshowerdetector.cc:178
 hshowerdetector.cc:179
 hshowerdetector.cc:180
 hshowerdetector.cc:181
 hshowerdetector.cc:182
 hshowerdetector.cc:183
 hshowerdetector.cc:184
 hshowerdetector.cc:185
 hshowerdetector.cc:186
 hshowerdetector.cc:187
 hshowerdetector.cc:188
 hshowerdetector.cc:189
 hshowerdetector.cc:190
 hshowerdetector.cc:191
 hshowerdetector.cc:192
 hshowerdetector.cc:193
 hshowerdetector.cc:194
 hshowerdetector.cc:195
 hshowerdetector.cc:196
 hshowerdetector.cc:197
 hshowerdetector.cc:198
 hshowerdetector.cc:199
 hshowerdetector.cc:200
 hshowerdetector.cc:201
 hshowerdetector.cc:202
 hshowerdetector.cc:203
 hshowerdetector.cc:204
 hshowerdetector.cc:205
 hshowerdetector.cc:206
 hshowerdetector.cc:207
 hshowerdetector.cc:208
 hshowerdetector.cc:209
 hshowerdetector.cc:210
 hshowerdetector.cc:211