CMS 3D CMS Logo

Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes

HIPUserVariablesIORoot Class Reference

#include <HIPUserVariablesIORoot.h>

Inheritance diagram for HIPUserVariablesIORoot:
AlignmentIORootBase AlignmentUserVariablesIO

List of all members.

Public Types

typedef std::vector< Alignable * > Alignables

Public Member Functions

 HIPUserVariablesIORoot ()
std::vector
< AlignmentUserVariables * > 
readHIPUserVariables (const Alignables &alivec, const char *filename, int iter, int &ierr)
void writeHIPUserVariables (const Alignables &alivec, const char *filename, int iter, bool validCheck, int &ierr)

Private Types

typedef std::map< std::pair
< int, int >, int > 
treemaptype

Private Member Functions

int close (void)
void createBranches (void)
 create root branches
int findEntry (unsigned int detId, int comp)
int open (const char *filename, int iteration, bool writemode)
AlignmentUserVariablesreadOne (Alignable *ali, int &ierr)
void setBranchAddresses (void)
 set root branches
int writeOne (Alignable *ali)

Private Attributes

double AlignableChi2
unsigned int AlignableNdof
unsigned int Id
double Jtve [nparmax]
double Jtvj [nparmax *(nparmax+1)/2]
bool newopen
int Nhit
int Npare
int Nparj
int ObjId
treemaptype treemap

Static Private Attributes

static const int nparmax = 6

Detailed Description

concrete class for ROOT based IO of AlignmentUserVariables

Definition at line 9 of file HIPUserVariablesIORoot.h.


Member Typedef Documentation

Definition at line 15 of file HIPUserVariablesIORoot.h.

typedef std::map< std::pair<int,int> , int > HIPUserVariablesIORoot::treemaptype [private]

Definition at line 65 of file HIPUserVariablesIORoot.h.


Constructor & Destructor Documentation

HIPUserVariablesIORoot::HIPUserVariablesIORoot ( )

constructor

Definition at line 16 of file HIPUserVariablesIORoot.cc.

References i, Jtve, Jtvj, nparmax, AlignmentIORootBase::treename, and AlignmentIORootBase::treetxt.

                                               :
  ObjId(0), Id(0),Nhit(0), Nparj(0), Npare(0),
  AlignableChi2(0.), AlignableNdof(0)
{
  treename = "T9";
  treetxt = "HIP User Variables";
  
  for (int i=0;i<nparmax*(nparmax+1)/2;++i) 
    Jtvj[i] = 0.;
  for (int i=0;i<nparmax;++i) 
    Jtve[i] = 0.;
}

Member Function Documentation

int HIPUserVariablesIORoot::close ( void  ) [inline, private, virtual]

close IO

Implements AlignmentUserVariablesIO.

Definition at line 43 of file HIPUserVariablesIORoot.h.

References AlignmentIORootBase::closeRoot().

Referenced by readHIPUserVariables(), and writeHIPUserVariables().

{return closeRoot();};
void HIPUserVariablesIORoot::createBranches ( void  ) [private, virtual]

create root branches

Implements AlignmentIORootBase.

Definition at line 31 of file HIPUserVariablesIORoot.cc.

References AlignableChi2, AlignableNdof, Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, and AlignmentIORootBase::tree.

{
  tree->Branch("Id",        &Id,        "Id/i");
  tree->Branch("ObjId",     &ObjId,     "ObjId/I");

  tree->Branch("Nhit",      &Nhit,      "Nhit/I");
  tree->Branch("Nparj",     &Nparj,     "Nparj/I");
  tree->Branch("Jtvj",      &Jtvj,      "Jtvj[Nparj]/D");
  tree->Branch("Npare",     &Npare,     "Npare/I");
  tree->Branch("Jtve",      &Jtve,      "Jtve[Npare]/D");
  tree->Branch("AlignableChi2",          &AlignableChi2, "AlignableChi2/D");
  tree->Branch("AlignableNdof",          &AlignableNdof, "AlignableNdof/i");
}
int HIPUserVariablesIORoot::findEntry ( unsigned int  detId,
int  comp 
) [private]

Definition at line 65 of file HIPUserVariablesIORoot.cc.

References Id, newopen, ObjId, query::result, AlignmentIORootBase::tree, and treemap.

Referenced by readOne().

{
  if (newopen) { // we're here for the first time
    edm::LogInfo("Alignment") <<"[HIPUserVariablesIORoot::findEntry] fill map ...";
    treemap.erase(treemap.begin(),treemap.end());
    for (int ev = 0;ev<tree->GetEntries();ev++) {
      tree->GetEntry(ev); 
      treemap[std::make_pair(Id,ObjId)]=ev;
    }
    newopen=false;
  }
  
  // now we have filled the map
  treemaptype::iterator imap = treemap.find(std::make_pair(detId,comp));
  int result=-1;
  if (imap != treemap.end()) result=(*imap).second;
  return result;


  //double noAliPar = tree->GetEntries();
  //for (int ev = 0;ev<noAliPar;ev++) {
  //  tree->GetEntry(ev); 
  //  if(Id==detId&&comp==ObjId) return (ev);
  //}
  //return(-1);
}
int HIPUserVariablesIORoot::open ( const char *  filename,
int  iteration,
bool  writemode 
) [inline, private, virtual]

open IO

Implements AlignmentUserVariablesIO.

Definition at line 39 of file HIPUserVariablesIORoot.h.

References newopen, and AlignmentIORootBase::openRoot().

Referenced by readHIPUserVariables(), and writeHIPUserVariables().

    {newopen=true; return openRoot(filename,iteration,writemode);};
std::vector< AlignmentUserVariables * > HIPUserVariablesIORoot::readHIPUserVariables ( const Alignables alivec,
const char *  filename,
int  iter,
int &  ierr 
)

read user variables

Definition at line 190 of file HIPUserVariablesIORoot.cc.

References close(), open(), AlignmentUserVariablesIO::read(), and query::result.

Referenced by HIPAlignmentAlgorithm::collector().

{
  std::vector<AlignmentUserVariables*> result;
  ierr=0;
  int iret;
  iret = open(filename,iter,false);
  if (iret!=0) { ierr=-1; return result;}
  result = read(alivec,iret);
  if (iret!=0) { ierr=-2; return result;}
  iret = close();
  if (iret!=0) { ierr=-3; return result;}

  return result;
}
AlignmentUserVariables * HIPUserVariablesIORoot::readOne ( Alignable ali,
int &  ierr 
) [private, virtual]

read AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 134 of file HIPUserVariablesIORoot.cc.

References HIPUserVariables::alichi2, AlignableChi2, AlignableNdof, Alignable::alignableObjectId(), HIPUserVariables::alindof, cuy::col, prof2calltree::count, findEntry(), Alignable::id(), Jtve, HIPUserVariables::jtve, Jtvj, HIPUserVariables::jtvj, HIPUserVariables::nhit, Nhit, np, Npare, and AlignmentIORootBase::tree.

{
  ierr=0;
  HIPUserVariables* uvar;

  int entry = findEntry(ali->id(), ali->alignableObjectId());
  if(entry!=-1) {
    tree->GetEntry(entry);

    int np=Npare;
    AlgebraicVector jtve(np,0);
    AlgebraicSymMatrix jtvj(np,0);
    int count=0;
    for(int row=0;row<np;row++) {
      jtve[row]=Jtve[row];
      for(int col=0; col < np;col++) {
        if(row-1<col) {jtvj[row][col]=Jtvj[count];count++;}
      }
    } 

    uvar = new HIPUserVariables(np);
    uvar->jtvj=jtvj;
    uvar->jtve=jtve;
    uvar->nhit=Nhit;

    //Chi2n
    uvar->alichi2=AlignableChi2;
    uvar->alindof=AlignableNdof;

    return uvar;
  }

  //  ierr=-1;
  return 0 ;
}
void HIPUserVariablesIORoot::setBranchAddresses ( void  ) [private, virtual]

set root branches

Implements AlignmentIORootBase.

Definition at line 47 of file HIPUserVariablesIORoot.cc.

References AlignableChi2, AlignableNdof, Id, Jtve, Jtvj, Nhit, Npare, Nparj, ObjId, and AlignmentIORootBase::tree.

{
  tree->SetBranchAddress("Id",        &Id);
  tree->SetBranchAddress("ObjId",     &ObjId);

  tree->SetBranchAddress("Nhit",      &Nhit);
  tree->SetBranchAddress("Nparj",     &Nparj);
  tree->SetBranchAddress("Jtvj",      &Jtvj);
  tree->SetBranchAddress("Npare",     &Npare);
  tree->SetBranchAddress("Jtve",      &Jtve);
  tree->SetBranchAddress("AlignableChi2",     &AlignableChi2);
  tree->SetBranchAddress("AlignableNdof",      &AlignableNdof);

}
void HIPUserVariablesIORoot::writeHIPUserVariables ( const Alignables alivec,
const char *  filename,
int  iter,
bool  validCheck,
int &  ierr 
)

write user variables

Definition at line 174 of file HIPUserVariablesIORoot.cc.

References close(), open(), and AlignmentUserVariablesIO::write().

Referenced by HIPAlignmentAlgorithm::terminate().

{
  ierr=0;
  int iret;
  iret = open(filename,iter,true);
  if (iret!=0) { ierr=-1; return;}
  iret = write(alivec,validCheck);
  if (iret!=0) { ierr=-2; return;}
  iret = close();
  if (iret!=0) { ierr=-3; return;}
}
int HIPUserVariablesIORoot::writeOne ( Alignable ali) [private, virtual]

write AlignmentParameters of one Alignable

Implements AlignmentUserVariablesIO.

Definition at line 94 of file HIPUserVariablesIORoot.cc.

References HIPUserVariables::alichi2, AlignableChi2, AlignableNdof, Alignable::alignableObjectId(), Alignable::alignmentParameters(), HIPUserVariables::alindof, cuy::col, prof2calltree::count, Id, Alignable::id(), HIPUserVariables::jtve, Jtve, HIPUserVariables::jtvj, Jtvj, HIPUserVariables::nhit, Nhit, np, Npare, Nparj, ObjId, AlignmentIORootBase::tree, and AlignmentParameters::userVariables().

{
  AlignmentParameters* ap=ali->alignmentParameters();

  if ((ap->userVariables())==0) { 
    edm::LogError("Alignment") <<"UserVariables not found!"; 
    return -1; 
  }

  HIPUserVariables* uvar = 
    dynamic_cast<HIPUserVariables*>(ap->userVariables());

  AlgebraicSymMatrix jtvj = uvar->jtvj;
  AlgebraicVector jtve = uvar->jtve;
  int nhit=uvar->nhit;
  int np=jtve.num_row();

  Nhit=nhit;
  Npare=np;
  Nparj=np*(np+1)/2;
  int count=0;
  for(int row=0;row<np;row++){
    Jtve[row]=jtve[row];
    for(int col=0;col<np;col++){
      if(row-1<col){Jtvj[count]=jtvj[row][col];count++;}
    }
  }
  Id = ali->id();
  ObjId = ali->alignableObjectId();

  //Chi^2 of alignable
  AlignableChi2= uvar->alichi2 ;
  AlignableNdof= uvar->alindof ;

  tree->Fill();
  return 0;
}

Member Data Documentation

Definition at line 61 of file HIPUserVariablesIORoot.h.

Referenced by createBranches(), readOne(), setBranchAddresses(), and writeOne().

unsigned int HIPUserVariablesIORoot::AlignableNdof [private]

Definition at line 62 of file HIPUserVariablesIORoot.h.

Referenced by createBranches(), readOne(), setBranchAddresses(), and writeOne().

unsigned int HIPUserVariablesIORoot::Id [private]

Definition at line 57 of file HIPUserVariablesIORoot.h.

Referenced by createBranches(), findEntry(), setBranchAddresses(), and writeOne().

double HIPUserVariablesIORoot::Jtvj[nparmax *(nparmax+1)/2] [private]

Definition at line 64 of file HIPUserVariablesIORoot.h.

Referenced by findEntry(), and open().

Definition at line 58 of file HIPUserVariablesIORoot.h.

Referenced by createBranches(), readOne(), setBranchAddresses(), and writeOne().

Definition at line 58 of file HIPUserVariablesIORoot.h.

Referenced by createBranches(), readOne(), setBranchAddresses(), and writeOne().

Definition at line 58 of file HIPUserVariablesIORoot.h.

Referenced by createBranches(), setBranchAddresses(), and writeOne().

const int HIPUserVariablesIORoot::nparmax = 6 [static, private]

Definition at line 53 of file HIPUserVariablesIORoot.h.

Referenced by HIPUserVariablesIORoot().

alignment parameter tree

Definition at line 56 of file HIPUserVariablesIORoot.h.

Referenced by createBranches(), findEntry(), setBranchAddresses(), and writeOne().

Definition at line 66 of file HIPUserVariablesIORoot.h.

Referenced by findEntry().