#include "hmatrixcategorysplit.h" #include "hclonestable.h" #include "hades.h" #include #include #include "htree.h" #include #include #include #include "hdebug.h" #include "hiterator.h" #include "hlineparser.h" #include "hdataobject.h" //*-- Author : Manuel Sanchez //*-- Modified : 9/11/1998 by Manuel Sanchez /////////////////////////////////////// //HMatrixCategorySplit // // This class extends HCategorySplit by allowing to have empty locations //(holes). /////////////////////////////////////// HMatrixCategorySplit::HMatrixCategorySplit(void) { //Constructor fHeader=NULL; strcpy(fClassName,""); strcpy(fBranchPattern,""); fTableArray=NULL; } HMatrixCategorySplit::HMatrixCategorySplit(Text_t *className,Int_t n, Int_t *siz,Text_t *branchPattern, TObject *header) { // Sets the category up for objects of the class className. The category //will hold a matrix of n-dimensional matrix for the modules; the maximun //range for each index in the matrix is set in siz. In the output tree the //branches are created with names according to the pattern branchPattern: //For example if n=2 siz={2,2} and branchPattern="S%0%.M%1%" the branches //will be: // S1.M1 // S1.M2 // S2.M1 // S2.M2 // // fHeader is a pointer to a category header. Int_t prod=1,i; fSizesArray.Set(n,siz); for (i=0;i array with the size (max number of cells) for each "module" // a value of -1 means an empty module for which no output // branch is created. // fillRate-> expected multiplicity. Int_t prod=1,i; for (i=0;iDelete(); for (i=0;i-1) { fTableArray->AddAt(new HClonesTable(fClassName, moduleSizes[i], (Int_t)(moduleSizes[i]*fillRate)),i); } } return kTRUE; } Bool_t HMatrixCategorySplit::setup(Int_t nActive,Int_t *activeModules, Int_t size,Float_t fillRate) { //Sets the category up, i.e. creates the internal structures to hold the data //objects. // //Parameters: // nActive-> number of active "modules" // activeModules-> array of nActive integers corresponding to the numbers of // the active modules. // size-> size (max number of cells) for each module. // fillRate-> expected multiplicity. Int_t i; fTableArray->Delete(); for (i=0;iAddAt(new HClonesTable(fClassName,size, (Int_t)(size*fillRate)), activeModules[i]); } return kTRUE; } TObject *&HMatrixCategorySplit::getNewSlot(HLocation &aLoc) { //see HCategory Int_t la,i; HClonesTable *table; la=aLoc[0]; for (i=1;iAt(la))!=NULL) { for (i=0;igetCapacity();i++) { if (table->At(i)==NULL) return table->operator[](i); } } return gNullObject; } TObject *&HMatrixCategorySplit::getSlot(HLocation &aLoc) { //see HCategory #if DEBUG_LEVEL>2 gDebuger->enterFunc("HMatrixCategorySplit::getSlot"); #endif Int_t la,i; HClonesTable *table; la=aLoc[0]; for (i=1;iAt(la))!=NULL) return table->operator[](aLoc.getOffset()); #if DEBUG_LEVEL>2 gDebuger->leaveFunc("HMatrixCategorySplit::getSlot"); #endif return gNullObject; } HDataObject *HMatrixCategorySplit::getObject(HLocation &aLoc) { //See HCategory Int_t la,i; HClonesTable *table; HDataObject *r=NULL; //aLoc.Dump(); la=aLoc[0]; for (i=1;iUncheckedAt(la))!=NULL) { //printf("module %i exists ",la); r=(HDataObject *)table->At(aLoc.getOffset()); } //else printf("module %i doesn't exist ",la); //if (r) printf("and data exists"); //else printf("and data doesn't exist"); return r; } ClassImp(HMatrixCategorySplit)