Hi Jacek, This is trivial to implement with a ROOT Tree. Make a small class MyClass with data members Int_t BoardID; Int_t ModuleID; Int_t ChannelID; Int_t WireNumber; Int_t WireType; TTree *tree; //!not persistent and functions Int_t GetWireID(BoardID,ModuleID,ChannelID) Int_t GetBoardID(WireNumber,WireType) void SetTree(TTree *t) {tree=t;} Make a Tree T and Fill it with instances of this class. When you connect the Tree in your analysis job, do TFile f("mytree.root"); MyClass *cl = new MyClass(); TTree *T = (TTree*)f.Get("T"); T->SetBranchAddress("branch",&cl); cl->SetTree(T); now you can call cl->GetWireID(...); An implementation of this function could be: Int_t MyClass::GetWireID(Int_t board, Int_t module, Int_t channel) { for (Int_t i=0;i<tree->GetEntries();i++) { tree->GetEntry(i); if (BoardID != board) continue; if (ModuleID != module) continue; if (ChannelID != channel) continue; return WireID; } } Same procedure for the function GetBoardID. You can speed up the implementation above by reading the branch corresponding to BoardID. When you find an entry with BoardID==board, you read the branch ModuileID, etc. You may also want to consider the case where more than one entry matches the query and return an array instead. Rene Brun Jacek M. Holeczek wrote: > > Hi, > Assume one has a set of numbers (describing the wire mapping) in form : > BoardID ModuleID ChannelID WireNumber WireType > ... > 34 12 0 121 4 > 34 12 1 126 1 > ... > 55 15 7 121 4 > 55 37 288 5878 2 > ... > Now I would like to have functions like : > GetWireID(BoardID,ModuleID,ChannelID) > GetBoardID(WireNumber,WireType) > The canonical approach would be to create a "database", feed it with this > table, and then make queries. But ... I would like to do this without any > database connection. Just "pure" root. > I can't seem to have any good idea how to do this (mapping in both > directions between "electronic" channels and detector wires). > Any help appreciated. > Thanks in advance, > Jacek.
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:50 MET