#include <TTree.h>

typedef struct CaLevel1 {
    Double_t al_p[5][2];    
    Float_t estrip[96][22][2];
    Float_t paw;
    Int_t good2;
    Int_t trkchi2;
    Float_t xalig;
    Float_t yalig;
    Float_t zalig;
} clevel1;    

typedef struct CaLevel2 {
    Int_t OBT;
    Int_t pkt_num;
    Int_t pro_num;    
    Float_t trigty;
    Int_t good;
    Int_t perr[4];
    Int_t swerr[4];
    Int_t crc[4];
    Float_t nstrip;
    Float_t qtot;
    Float_t ncore;
    Float_t qcore;
    Float_t impx;
    Float_t impy;
    Float_t tanx;
    Float_t tany;
    Float_t nint;
    Float_t ncyl;
    Float_t qcyl;
    Float_t qtrack;
    Float_t qmax;
    Float_t nx22;
    Float_t qx22;
    Float_t qq[4];
    Float_t qtrackx;
    Float_t qtracky;
    Float_t dxtrack;
    Float_t dytrack;
    Float_t qlast;
    Float_t nlast;
    Float_t qpre;
    Float_t npre;
    Float_t qpresh;
    Float_t npresh;
    Float_t qlow;
    Float_t nlow;
    Float_t qtr;
    Float_t ntr;
    Float_t planetot;
    Float_t qmean;
    Float_t varcfit[2];
    Int_t npcfit[2];
    Float_t thex;
    Float_t they;
    Int_t cibar[22][2];
    Int_t tibar[22][2];
    Float_t cbar[22][2];
    Float_t tbar[22][2];
} clevel2;    

void setcalolevel2(TTree *tree, CaLevel2 & clevel2){
	tree->SetBranchAddress("OBT",&clevel2.OBT);
	tree->SetBranchAddress("pkt_num",&clevel2.pkt_num);
	tree->SetBranchAddress("pro_num",&clevel2.pro_num);
	tree->SetBranchAddress("trigty",&clevel2.trigty);
	tree->SetBranchAddress("good",&clevel2.good);
	tree->SetBranchAddress("perr",clevel2.perr);
	tree->SetBranchAddress("swerr",clevel2.swerr);
	tree->SetBranchAddress("crc",clevel2.crc);
	tree->SetBranchAddress("nstrip",&clevel2.nstrip);
	tree->SetBranchAddress("qtot",&clevel2.qtot);
	tree->SetBranchAddress("ncore",&clevel2.ncore);
	tree->SetBranchAddress("qcore",&clevel2.qcore);
	tree->SetBranchAddress("impx",&clevel2.impx);
	tree->SetBranchAddress("impy",&clevel2.impy);
	tree->SetBranchAddress("tanx",&clevel2.tanx);
	tree->SetBranchAddress("tany",&clevel2.tany);
	tree->SetBranchAddress("nint",&clevel2.nint);
	tree->SetBranchAddress("ncyl",&clevel2.ncyl);
	tree->SetBranchAddress("qcyl",&clevel2.qcyl);
	tree->SetBranchAddress("qtrack",&clevel2.qtrack);
	tree->SetBranchAddress("qmax",&clevel2.qmax);
	tree->SetBranchAddress("nx22",&clevel2.nx22);
	tree->SetBranchAddress("qx22",&clevel2.nx22);
	tree->SetBranchAddress("qq",clevel2.qq);
	tree->SetBranchAddress("qtrackx",&clevel2.qtrackx);
	tree->SetBranchAddress("qtracky",&clevel2.qtracky);
	tree->SetBranchAddress("dxtrack",&clevel2.dxtrack);
	tree->SetBranchAddress("dytrack",&clevel2.dytrack);
	tree->SetBranchAddress("qlast",&clevel2.qlast);
	tree->SetBranchAddress("nlast",&clevel2.nlast);
	tree->SetBranchAddress("qpre",&clevel2.qpre);
	tree->SetBranchAddress("npre",&clevel2.npre);
	tree->SetBranchAddress("qpresh",&clevel2.qpresh);
	tree->SetBranchAddress("npresh",&clevel2.npresh);
	tree->SetBranchAddress("qlow",&clevel2.qlow);
	tree->SetBranchAddress("nlow",&clevel2.nlow);
	tree->SetBranchAddress("qtr",&clevel2.qtr);
	tree->SetBranchAddress("ntr",&clevel2.ntr);
	tree->SetBranchAddress("planetot",&clevel2.planetot);
	tree->SetBranchAddress("qmean",&clevel2.qmean);
	tree->SetBranchAddress("varcfit",clevel2.varcfit);
	tree->SetBranchAddress("npcfit",clevel2.npcfit);
	tree->SetBranchAddress("thex",&clevel2.thex);
	tree->SetBranchAddress("they",&clevel2.they);
	tree->SetBranchAddress("cibar",clevel2.cibar);
	tree->SetBranchAddress("tibar",clevel2.tibar);
	tree->SetBranchAddress("cbar",clevel2.cbar);
	tree->SetBranchAddress("tbar",clevel2.tbar);
}

//void setcalolevel2(TTree *tree, CaLevel2 *clevel2){
//	tree->SetBranchAddress("OBT",&clevel2->OBT);
//	tree->SetBranchAddress("pkt_num",&clevel2->pkt_num);
//	tree->SetBranchAddress("pro_num",&clevel2->pro_num);
//	tree->SetBranchAddress("trigty",&clevel2->trigty);
//	tree->SetBranchAddress("good",&clevel2->good);
//	tree->SetBranchAddress("perr",clevel2->perr);
//	tree->SetBranchAddress("swerr",clevel2->swerr);
//	tree->SetBranchAddress("crc",clevel2->crc);
//	tree->SetBranchAddress("nstrip",&clevel2->nstrip);
//	tree->SetBranchAddress("qtot",&clevel2->qtot);
//tree->SetBranchAddress("ncore",&clevel2->ncore);
//	tree->SetBranchAddress("qcore",&clevel2->qcore);
//	tree->SetBranchAddress("impx",&clevel2->impx);
//	tree->SetBranchAddress("impy",&clevel2->impy);
//	tree->SetBranchAddress("tanx",&clevel2->tanx);
//	tree->SetBranchAddress("tany",&clevel2->tany);
//	tree->SetBranchAddress("nint",&clevel2->nint);
//	tree->SetBranchAddress("ncyl",&clevel2->ncyl);
//	tree->SetBranchAddress("qcyl",&clevel2->qcyl);
//	tree->SetBranchAddress("qtrack",&clevel2->qtrack);
//	tree->SetBranchAddress("qmax",&clevel2->qmax);
//	tree->SetBranchAddress("nx22",&clevel2->nx22);
//	tree->SetBranchAddress("qx22",&clevel2->nx22);
//	tree->SetBranchAddress("qq",clevel2->qq);
//	tree->SetBranchAddress("qtrackx",&clevel2->qtrackx);
//	tree->SetBranchAddress("qtracky",&clevel2->qtracky);
//	tree->SetBranchAddress("dxtrack",&clevel2->dxtrack);
//	tree->SetBranchAddress("dytrack",&clevel2->dytrack);
//	tree->SetBranchAddress("qlast",&clevel2->qlast);
//	tree->SetBranchAddress("nlast",&clevel2->nlast);
//tree->SetBranchAddress("qpre",&clevel2->qpre);
//	tree->SetBranchAddress("npre",&clevel2->npre);
//	tree->SetBranchAddress("qpresh",&clevel2->qpresh);
//	tree->SetBranchAddress("npresh",&clevel2->npresh);
//	tree->SetBranchAddress("qlow",&clevel2->qlow);
//	tree->SetBranchAddress("nlow",&clevel2->nlow);
//	tree->SetBranchAddress("qtr",&clevel2->qtr);
//	tree->SetBranchAddress("ntr",&clevel2->ntr);
//	tree->SetBranchAddress("planetot",&clevel2->planetot);
//tree->SetBranchAddress("qmean",&clevel2->qmean);
//	tree->SetBranchAddress("varcfit",clevel2->varcfit);
//	tree->SetBranchAddress("npcfit",clevel2->npcfit);
//tree->SetBranchAddress("cibar",clevel2->cibar);
//	tree->SetBranchAddress("tibar",clevel2->tibar);
//	tree->SetBranchAddress("cbar",clevel2->cbar);
//	tree->SetBranchAddress("tbar",clevel2->tbar);
//}
