#define PomoneStruct_cxx #include "PomoneStruct.h" #include #include #include void PomoneStruct::Loop() { // In a ROOT session, you can do: // Root > .L PomoneStruct.C // Root > PomoneStruct t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; // if ( jentry % 1000 == 0 ) { std::cout <<"jentry = " << jentry << "\n"; std::cout <<"EventSize = " << EventSize << "\n"; // } if ( EventSize > maxEvts ) continue; nClusters = 0; clustPH[nClusters] = -1.; clustPlaneId[nClusters] = -1; clustMul[nClusters] = -1; std::map strips[maxChips]; for ( UInt_t iEvent = 0; iEvent < EventSize; iEvent++ ) { if ( Row[iEvent] < 0 || Row[iEvent] > nRows ) continue; if ( Col[iEvent] < 0 || Col[iEvent] > nCols ) continue; Double_t strp = Row[iEvent]+Col[iEvent]*nRows; if ( strp < minStrip || strp > maxStrip ) { std::cerr << "\t\tWrong strip number = " << strp << "\n"; continue; } else { strip[iEvent] = strp; std::cout << "\t\tStrip = " << strp << "\n"; strips[planeIds[Planeid[iEvent]]][strp] = iEvent; } std::cout << "\t\tAdc = " << Adc[iEvent] << "\n"; std::cout << "\t\tChipid = " << Chipid[iEvent] << "\n"; std::cout << "\t\tCol = " << Col[iEvent] << "\n"; std::cout << "\t\tRow = " << Row[iEvent] << "\n"; std::cout << "\t\tPlaneid = " << Planeid[iEvent] << "\n"; std::cout << "\t\tTimestamp = " << Timestamp[iEvent] << "\n"; std::cout << "\t\tFinecnt = " << Finecnt[iEvent] << "\n"; std::cout << "\t\tChipbco = " << Chipbco[iEvent] << "\n"; } for ( int ichip = 0; ichip < maxChips; ichip++ ) { std::map strip_perchip; strip_perchip = strips[ichip]; // 0 strips in chip if ( strip_perchip.size() == 0 ) continue; // 1 strip in chip if ( strip_perchip.size() == 1 ) { clustPH[nClusters] = Thrs[Adc[strip_perchip.begin()->second]]; clustPlaneId[nClusters] = Planeid[strip_perchip.begin()->second]; clustMul[nClusters] = 1; // more than one strip } else if ( strip_perchip.size() > 1 ) { std::map::iterator astrip; std::map::iterator fwdstrip; std::map::iterator final_iter = strip_perchip.end(); --final_iter; for ( astrip = strip_perchip.begin(); astrip != strip_perchip.end(); astrip++ ) { clustPH[nClusters] = Thrs[Adc[astrip->second]]; clustPlaneId[nClusters] = Planeid[astrip->second]; clustMul[nClusters] = 1; if( astrip == final_iter ) continue; fwdstrip = astrip; fwdstrip++; while( fabs( fwdstrip->first - astrip->first ) < 2 ) { clustPH[nClusters] += Thrs[Adc[fwdstrip->second]]; clustMul[nClusters] += 1; astrip = fwdstrip; fwdstrip++; if( fwdstrip == final_iter ) break; } nClusters++; } } nClusters++; } std::cout << "\tnClusters = " << nClusters << "\n"; for ( int iCluster = 0; iCluster < nClusters; iCluster++ ) { std::cout << "\tclustMul[" << iCluster << "] = " << clustMul[iCluster] << "\n"; std::cout << "\tclustPH[" << iCluster << "] = " << clustPH[iCluster] << "\n"; std::cout << "\tclustPlaneId[" << iCluster << "] = " << clustPlaneId[iCluster] << "\n"; } std::cout << "\tready to test new branches\n"; std::cout << "\tb_strip = " << b_strip << "\n"; std::cout << "\tb_clustMul = " << b_clustMul << "\n"; std::cout << "\tb_clustPlaneId = " << b_clustPlaneId << "\n"; std::cout << "\tb_clustPH = " << b_clustPH << "\n"; std::cout << "\tb_nClusters = " << b_nClusters << "\n"; if ( !b_strip ) std::cout << "FATAL: b_strip is NULL\n"; if ( b_strip->IsZombie() ) std::cout << "FATAL: b_strip is NULL\n"; std::cout << "\tready to write\n"; b_strip->Fill(); std::cout << "\tstrip info written\n"; if ( !b_nClusters ) std::cout << "FATAL: b_nClusters is NULL\n"; if ( b_nClusters->IsZombie() ) std::cout << "FATAL: b_nClusters is NULL\n"; b_nClusters->Fill(); std::cout << "\tnClusters info written\n"; if ( !b_clustPH ) std::cout << "FATAL: b_clustPH is NULL\n"; if ( b_clustPH->IsZombie() ) std::cout << "FATAL: b_clustPH is NULL\n"; b_clustPH->Fill(); std::cout << "\tclustPH info written\n"; if ( !b_clustPlaneId ) std::cout << "FATAL: b_clustPlaneId is NULL\n"; if ( b_clustPlaneId->IsZombie() ) std::cout << "FATAL: b_clustPlaneId is NULL\n"; b_clustPlaneId->Fill(); std::cout << "\tclustPlaneId info written\n"; if ( !b_clustMul ) std::cout << "FATAL: b_clustMul is NULL\n"; if ( b_clustMul->IsZombie() ) std::cout << "FATAL: b_clustMul is NULL\n"; b_clustMul->Fill(); std::cout << "\tclustMul info written\n"; } fChain->Write("", TObject::kOverwrite); }