--- eventviewer/flight/src/FEVdetector.cpp 2007/02/02 14:35:57 1.8 +++ eventviewer/flight/src/FEVdetector.cpp 2007/02/26 12:51:09 1.10 @@ -86,6 +86,7 @@ var.SHOWDEC = 0; var.TOF = 0; var.AC = 0; + var.RUN = 1; var.TRK = 0; var.CALO = 0; var.S4 = 0; @@ -122,6 +123,10 @@ }; } +void FEVdetector::SetDDEC(TString de){ + ddec=de; +}; + void FEVdetector::GetWindow(){ otr->GetEntry(maxevent); if ( level.file < 2 ){ @@ -161,6 +166,7 @@ void FEVdetector::GetEntry(Int_t i){ thisentry = i; otr->GetEntry(i); + // PrintData(otr,-1LL,44); } void FEVdetector::SetEntry(Int_t i){ @@ -281,6 +287,159 @@ }; } +void FEVdetector::PrintLeaves(TTree *otr, Int_t i, TBranchElement *tb, Int_t lenmax){ + // -- Prints values of leaves. + + // tb->ValidateAddress(); + printf("son qua \n"); + + // if (otr->GetMakeClass()) { + if (!tb->GetAddress()) { + printf("esco \n"); + return; + } + if (tb->GetType() == 3 || tb->GetType() == 4) { + // TClonesArray or STL container top-level branch. + printf("3 o 4 %-15s = %d\n", tb->GetName(), tb->GetNdata()); + return; + } else if (tb->GetType() == 31 || tb->GetType() == 41) { + printf(" 31 o 41 \n"); + // TClonesArray or STL container sub-branch. + Int_t n = TMath::Min(10, tb->GetNdata()); + Int_t atype = tb->GetStreamerType() + 20; + if (tb->GetStreamerType() == 1) { + // TVirtualStreamerInfo::kOffsetL + TVirtualStreamerInfo::kChar is + // printed as a string and could print weird characters. + // So we print an unsigned char instead (not perfect, but better). + atype = 20 + 11 ; + } + if (atype > 54) { + // FIXME: More logic required here (like in ReadLeaves) + printf(">54 %-15s = %d\n", tb->GetName(), tb->GetNdata()); + return; + } + if (tb->GetStreamerType() > 20) { + atype -= 20; + TObjArray *prova= otr->GetListOfLeaves(); + // TObjArray* leaf2 = (TObjArray*) prova->UncheckedAt(i); + //TLeaf* leaf = (TLeaf*)(otr->GetLeaf(tb->GetName())); + // TLeafElement* leaf = (TLeafElement*)((TLeaf*)(otr->GetListOfLeaves()->UncheckedAt(i))->GetBranch()->UncheckedAt(0)); + TLeafElement* leaf = (TLeafElement*)(prova->UncheckedAt(0)); + n = n * leaf->GetLenStatic(); + } + if (tb->GetInfo()) { + // n = 16; + tb->GetInfo()->PrintValue(tb->GetName(), tb->GetAddress(), atype, n, lenmax); + //tb->GetObject()->GetInfo()->PrintValue(tb->GetName(), tb->GetObject(), atype, n, lenmax); + } + return; + } else if (tb->GetType() <= 2) { + printf(" <=2 \n"); + // Branch in split mode. + // FIXME: This should probably be < 60 instead. + if ((tb->GetStreamerType() > 40) && (tb->GetStreamerType() < 55)) { + Int_t atype = tb->GetStreamerType() - 20; + TBranchElement* counterElement = (TBranchElement*) tb->GetBranchCount(); + Int_t n = (Int_t) counterElement->GetValue(0, 0); + if (tb->GetInfo()) { + tb->GetInfo()->PrintValue(tb->GetName(), tb->GetAddress(), atype, n, lenmax); + } + } else { + // if (tb->GetInfo()) { + // tb->GetInfo()->PrintValue(tb->GetName(), tb->GetObject(), tb->GetID(), -1, lenmax); + // } + // } + return; + } + } else if (tb->GetType() == 3) { + printf("3 %-15s = %d\n", tb->GetName(), tb->GetNdata()); + } else if (tb->GetType() == 31) { + printf("31 %-15s = %d\n", tb->GetName(), tb->GetNdata()); + // TClonesArray* clones = (TClonesArray*) tb->GetObject(); + // if (tb->GetInfo()) { + // tb->GetInfo()->PrintValueClones(tb->GetName(), clones, tb->GetID(), tb->GetOffset(), lenmax); + // } + } else if (tb->GetType() == 41) { + printf("41 %-15s = %d\n", tb->GetName(), tb->GetNdata()); + // TVirtualCollectionProxy::TPushPop helper(((TBranchElement*) this)->GetCollectionProxy(), fObject); + // if (GetInfo()) { + // GetInfo()->PrintValueSTL(GetName(), ((TBranchElement*) this)->GetCollectionProxy(), fID, fOffset, lenmax); + // } + } else { + printf("else %-15s = %d\n", tb->GetName(), tb->GetNdata()); + // if (GetInfo()) { + // GetInfo()->PrintValue(GetName(), fObject, fID, -1, lenmax); + // } + } + + // }; + printf("esco qui\n"); +}; + +void FEVdetector::PrintData(TTree *tree, Long64_t entry=-1LL,Int_t lenmax=44){ + // -- Print values of all active leaves for entry. + // + // if entry==-1, print current entry (default) + // if a leaf is an array, a maximum of lenmax elements is printed. + // + if (entry != -1) { + tree->GetEntry(entry); + } + // printf("======> EVENT:%lld\n", thisentry); + printf("======> EVENT:%i\n", thisentry); + TObjArray* leaves = tree->GetListOfLeaves(); // + Int_t nleaves = leaves->GetEntriesFast(); + Int_t ltype; + for (Int_t i = 0; i < nleaves; i++) { + TLeaf* leaf = (TLeaf*) leaves->UncheckedAt(i); + TBranch* branch = leaf->GetBranch(); + // if (branch->TestBit(kDoNotProcess)) { + // continue; + // } + Int_t len = leaf->GetLen(); + if (len <= 0) { + continue; + } + len = TMath::Min(len, lenmax); + if (leaf->IsA() == TLeafElement::Class()) { + // Double_t value = leaf->GetValue(lenmax); + //printf(" ioqui %f \n",value); + // ((TBranchElement*)leaf->GetBranch())->PrintValue(i); + this->PrintLeaves(otr,i,((TBranchElement*)leaf->GetBranch()), lenmax); + //leaf->PrintValue(lenmax); + continue; + } + if (branch->GetListOfBranches()->GetEntriesFast() > 0) { + continue; + } + ltype = 10; + if (leaf->IsA() == TLeafF::Class()) { + ltype = 5; + } + if (leaf->IsA() == TLeafD::Class()) { + ltype = 5; + } + if (leaf->IsA() == TLeafC::Class()) { + len = 1; + ltype = 5; + }; + printf(" %-15s = ", leaf->GetName()); + for (Int_t l = 0; l < len; l++) { + Double_t value = leaf->GetValue(l); + printf(" ioqui %f \n",value); + // leaf->PrintValue(l); + if (l == (len - 1)) { + printf("\n"); + continue; + } + printf(", "); + if ((l % ltype) == 0) { + printf("\n "); + } + } + } +}; + void FEVdetector::GetGeneralInfo(){ // // Get Orbital Time information and header event number @@ -469,14 +628,17 @@ // } -void FEVdetector::Load(TTree &mainotr, TFile &mainfile){ +Int_t FEVdetector::Load(TTree &mainotr, TFile &mainfile){ file = &mainfile; otr = &mainotr; L2 = new PamLevel2(); // if ( level.file == 2 ){ // otr = L2->LoadPamTrees(file); - otr = L2->GetPamTree(file,"+ALL +CAL1 -TRKh -TRK1"); + // printf(" %s \n",ddec.Data()); + otr = L2->GetPamTree(file,ddec.Data()); + // + if ( !otr ) return(0); // ******************** // load magnetic field // ******************** @@ -528,7 +690,6 @@ // }; // - // trigger = new pamela::trigger::TriggerEvent(); eh = new pamela::EventHeader(); @@ -547,7 +708,7 @@ otr->SetBranchAddress("Trigger", &trigger); otr->SetBranchAddress("Header", &eh); }; - if ( level.file == 2 ){ + if ( level.file == 2 && var.RUN){ // otr->AddFriend("OrbitalInfo", file); // otr->SetBranchAddress("OrbitalInfo", &oinfoL2); runinfo->Read(0ULL); @@ -623,6 +784,8 @@ printf("Show the Time of Flight detector, LEVEL2 data \n"); }; }; + // + return(1); // } @@ -2024,7 +2187,8 @@ ms11b[i] = 0.; } else { ms11b[i] = 1.; - }; }; + }; + }; for ( Int_t i = 0; i<6; i++ ) { mt12[0][i] = tof->tdc[ch12a[i]][hb12a[i]]; mt12[1][i] = tof->tdc[ch12b[i]][hb12b[i]]; @@ -2123,7 +2287,7 @@ // var.tofraw = 0; // - repuntil = L2->GetToFLevel2()->ntrk(); + if ( level.file == 2 ) repuntil = L2->GetToFLevel2()->ntrk(); // printf("repuntil = %i \n",repuntil); //repuntil = L2->GetNTracks(); // @@ -4532,7 +4696,8 @@ // if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){ for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){ - TrkTrack *track = L2->GetTrkLevel2()->GetTrack(nt); + PamTrack *ptrack= L2->GetTrack(nt); + TrkTrack *track = ptrack->GetTrkTrack(); if ( nt == 0 ){ var.rig = 0.; if ( track->al[4] != 0. ) var.rig = 1./track->al[4]; @@ -5045,7 +5210,10 @@ // if ( L2->GetTrkLevel2()->GetNTracks() > 0 ){ for (Int_t nt = 0; nt < L2->GetTrkLevel2()->GetNTracks(); nt++){ - TrkTrack *track = L2->GetTrkLevel2()->GetTrack(nt); + + // TrkTrack *track = L2->GetTrkLevel2()->GetTrack(nt); + PamTrack *ptrack = L2->GetTrack(nt); + TrkTrack *track = ptrack->GetTrkTrack(); Int_t npoint = 100; Float_t zin[100]; Double_t xout[100];