#include <MadChain.h>
Public Member Functions | |
| MadChain (TChain *chainSR=0, TChain *chainMC=0, TChain *chainTH=0, TChain *chainEM=0, bool build_index=false) | |
| ~MadChain () | |
| Int_t | GetEntryNumber (Int_t run, Int_t snarl) |
| Int_t | Get (Int_t entry) |
| void | Init (TChain *chainSR, TChain *chainMC, TChain *chainTH, TChain *chainEM) |
| void | Show (Int_t entry=-1) |
Public Attributes | |
| Bool_t | isMC |
| Bool_t | isTH |
| Bool_t | isEM |
| Bool_t | isST |
| Int_t | Nentries |
| NtpSRRecord * | Record |
| NtpStRecord * | stRecord |
| NtpMCRecord * | mcRecord |
| NtpTHRecord * | thRecord |
| NtpEMRecord * | emRecord |
Protected Member Functions | |
| void | Zero () |
Protected Attributes | |
| TChain * | fChainSR |
| Int_t | fCurrentSR |
| TChain * | fChainMC |
| Int_t | fCurrentMC |
| TChain * | fChainTH |
| Int_t | fCurrentTH |
| TChain * | fChainEM |
| Int_t | fCurrentEM |
Private Member Functions | |
| void | BuildLookup () |
Private Attributes | |
| bool | fLookupBuilt |
| std::map< std::pair< Int_t, Int_t >, Long64_t, first_then_second > | fLookUp |
|
||||||||||||||||||||||||
|
Definition at line 9 of file MadChain.cxx. References BuildLookup(), and Init(). 00011 : fLookupBuilt(false) 00012 { 00013 00014 Init(chainSR,chainMC,chainTH,chainEM); 00015 if(build_lookup) BuildLookup(); 00016 }
|
|
|
Definition at line 18 of file MadChain.cxx. References fChainEM, fChainMC, fChainSR, and fChainTH. 00019 {
00020 if(!fChainSR) return;
00021 delete fChainSR->GetCurrentFile();
00022 if(fChainEM) delete fChainEM->GetCurrentFile();
00023 if(!fChainMC) return;
00024 delete fChainMC->GetCurrentFile();
00025 if(!fChainTH) return;
00026 delete fChainTH->GetCurrentFile();
00027 }
|
|
|
Definition at line 182 of file MadChain.cxx. References fChainSR, fLookUp, fLookupBuilt, RecRecordImp< T >::GetHeader(), RecDataHeader::GetRun(), RecPhysicsHeader::GetSnarl(), Record, and stRecord. Referenced by MadChain(). 00182 {
00183 // fill fLookUp with run,snarl of each entry in the chain
00184 // do it as efficiently as possible by only reading the header
00185
00186 if(!fChainSR) return;
00187
00188 /*
00189 RecRecordImp<RecCandHeader>* recrecord = 0;
00190 // fChainSR->SetBranchAddress(fChainSR->GetListOfBranches()->At(0)->GetName(),
00191 // &recrecord);
00192 fChainSR->SetBranchAddress("NtpStRecord",
00193 &recrecord);
00194 fChainSR->SetBranchStatus("*",0);
00195 fChainSR->SetBranchStatus("fHeader.*",1);
00196 fChainSR->SetBranchAddress("NtpStRecord",
00197 &recrecord);
00198 */
00199 /*
00200 fChainSR->SetBranchStatus("fHeader.fRun",1);
00201 fChainSR->SetBranchStatus("fHeader.fSnarl",1);
00202 Int_t run, snarl;
00203 if(isST) {
00204 fChainSR->SetBranchAddress("NtpStRecord",&stRecord);
00205 fChainSR->SetBranchAddress("fHeader.fRun",&run);
00206 fChainSR->SetBranchAddress("fHeader.fSnarl",&snarl);
00207 }
00208 else{
00209 fChainSR->SetBranchAddress("NtpSRRecord",&Record);
00210 fChainSR->SetBranchAddress("fHeader.fRun",&run);
00211 fChainSR->SetBranchAddress("fHeader.fSnarl",&snarl);
00212 }
00213 */
00214
00215
00216 Long64_t N = fChainSR->GetEntries();
00217 Int_t nbytes=0;
00218 std::cout<<"MadChain building lookup table"<<std::endl;
00219 // Int_t current_tree=-1; //fChainSR->GetTreeNumber();
00220 for(Long64_t i = 0; i<N; i++){
00221 std::pair<Int_t,Int_t> p;
00222 /* // this trash doesn't work
00223 // mock up what MakeClass generated code does
00224 Long64_t centry = fChainSR->LoadTree(i);
00225 if(fChainSR->GetTreeNumber() != current_tree){
00226 current_tree=fChainSR->GetTreeNumber();
00227 fChainSR->SetBranchStatus("*",0);
00228 // fChainSR->SetBranchStatus("fHeader.*",1);
00229 // fChainSR->SetBranchAddress("NtpStRecord", &recrecord);
00230 }
00231 nbytes+=fChainSR->GetEntry(centry);
00232 */
00233
00234 nbytes+=fChainSR->GetEntry(i);
00235
00236 if(isST) {
00237 p.first = stRecord->GetHeader().GetRun();
00238 p.second = stRecord->GetHeader().GetSnarl();
00239 }
00240 else{
00241 p.first = Record->GetHeader().GetRun();
00242 p.second = Record->GetHeader().GetSnarl();
00243 }
00244
00245 // p.first=run; p.second=snarl;
00246 // if(i%1000==0) recrecord->GetHeader().Print();
00247 // p.first = recrecord->GetHeader().GetRun();
00248 // p.second = recrecord->GetHeader().GetSnarl();
00249
00250 fLookUp.insert( std::pair< std::pair<Int_t,Int_t>, Long64_t>(p, i) );
00251 if(i%10000==0){
00252 std::cout<<"progress: "<<i<<" events and ";
00253 std::cout.precision(3);
00254 std::cout<<(nbytes/1024.0)<<" kb read \r";
00255 std::cout.flush();
00256 }
00257 // recrecord->Clear();
00258 }
00259 std::cout<<"Done "<<std::endl;
00260 std::cout<<"lookup table has "<<fLookUp.size()<<" entries"<<std::endl;
00261
00262 /*
00263 std::map< std::pair<Int_t,Int_t> , Long64_t>::const_iterator it
00264 =fLookUp.begin();
00265 int cntr=0;
00266 for(; it!=fLookUp.end(); it++){
00267 if(cntr%1000==0){
00268 std::cout<<cntr<<" "<<it->first.first<<" "
00269 <<it->first.second<<" "<<it->second<<std::endl;
00270 }
00271 cntr++;
00272 }
00273 */
00274 fChainSR->SetBranchStatus("*",1);
00275 if(isST) {
00276 fChainSR->SetBranchAddress("NtpStRecord",&stRecord);
00277 }
00278 else{
00279 fChainSR->SetBranchAddress("NtpSRRecord",&Record);
00280 }
00281
00282
00283 fLookupBuilt=true;
00284 }
|
|
|
Definition at line 41 of file MadChain.cxx. References emRecord, fChainEM, fChainMC, fChainSR, fChainTH, fCurrentEM, fCurrentMC, fCurrentSR, fCurrentTH, RecRecordImp< T >::GetHeader(), RecPhysicsHeader::GetSnarl(), mcRecord, Record, and thRecord. Referenced by MadBase::GetEntry(). 00042 {
00043
00044 //estimate MC,TH entry numbers
00045 if(entry<fCurrentSR||fCurrentSR==-1) {
00046 fCurrentMC=entry;
00047 fCurrentTH=entry;
00048 fCurrentEM=entry;
00049 }
00050 else if(entry>fCurrentSR) {
00051 fCurrentMC+=(entry-fCurrentSR);
00052 fCurrentTH+=(entry-fCurrentSR);
00053 fCurrentEM+=(entry-fCurrentSR);
00054 }
00055
00056 // Read contents of entry.
00057 if (!fChainSR) return 0;
00058 Int_t status = fChainSR->GetEntry(entry);
00059 fCurrentSR = entry;
00060
00061 if(isEM) {
00062 fChainEM->GetEntry(fCurrentEM);
00063 int xtra = 0; //just in case tree entries are not correlated
00064 while(Record->GetHeader().GetSnarl()!=emRecord->GetHeader().GetSnarl()){
00065 xtra+=1;
00066 fChainEM->GetEntry(fCurrentEM+xtra);
00067 }
00068 fCurrentEM+=xtra;
00069 }
00070
00071 if(isMC) {
00072 fChainMC->GetEntry(fCurrentMC);
00073 int xtra = 0; //just in case tree entries are not correlated
00074 while(Record->GetHeader().GetSnarl()!=mcRecord->GetHeader().GetSnarl()){
00075 xtra+=1;
00076 fChainMC->GetEntry(fCurrentMC+xtra);
00077 }
00078 fCurrentMC+=xtra;
00079 }
00080
00081 if(isTH) {
00082 fChainTH->GetEntry(fCurrentTH);
00083 int xtra = 0; //just in case tree entries are not correlated
00084 while(Record->GetHeader().GetSnarl()!=thRecord->GetHeader().GetSnarl()){
00085 xtra+=1;
00086 fChainTH->GetEntry(fCurrentTH+xtra);
00087 }
00088 fCurrentTH+=xtra;
00089 }
00090 return status;
00091 }
|
|
||||||||||||
|
Definition at line 29 of file MadChain.cxx. References fChainSR, fLookUp, and run(). Referenced by MadBase::GetEntry(), MadScanDisplay::JumpTo(), MadEvDisplay::JumpTo(), MadScanDisplay::NextInterestingEvent(), and MadEvDisplay::NextInterestingEvent(). 00030 {
00031 if(!fLookupBuilt) return fChainSR->GetEntryNumberWithIndex(run,snarl);
00032 else{
00033 std::pair<Int_t,Int_t> p(run,snarl);
00034 std::map< std::pair<Int_t,Int_t> , Long64_t>::const_iterator it
00035 = fLookUp.find(p);
00036 if(it==fLookUp.end()) return -1;
00037 else return it->second;
00038 }
00039 }
|
|
||||||||||||||||||||
|
Definition at line 93 of file MadChain.cxx. References emRecord, fChainEM, fChainMC, fChainSR, fChainTH, fCurrentEM, fCurrentMC, fCurrentSR, fCurrentTH, isEM, isMC, isST, isTH, mcRecord, Nentries, Record, stRecord, thRecord, and Zero(). Referenced by MadChain(). 00095 {
00096
00097 Zero();
00098
00099 if(chainSR==0) {
00100 std::cerr << "No file added" << std::endl;
00101 return;
00102 }
00103 fChainSR = chainSR;
00104 if(strcmp(fChainSR->GetName(),"NtpSR")==0){
00105 fChainSR->SetBranchAddress("NtpSRRecord",&Record);
00106 }
00107 else if(strcmp(fChainSR->GetName(),"NtpSt")==0){
00108 isST = true;
00109 fChainSR->SetBranchAddress("NtpStRecord",&stRecord);
00110 }
00111 fCurrentSR = -1;
00112 Nentries = Int_t(fChainSR->GetEntries());
00113 //chainSR->BuildIndex("fHeader.fRun","fHeader.fSnarl");
00114
00115 if(chainEM==0) {
00116 isEM = false;
00117 }
00118 else {
00119 fChainEM = chainEM;
00120 fChainEM->SetBranchAddress("NtpEMRecord",&emRecord);
00121 fCurrentEM = -1;
00122 }
00123
00124 if(chainMC==0) {
00125 isMC = false;
00126 isTH = false;
00127 return;
00128 }
00129 fChainMC = chainMC;
00130 fChainMC->SetBranchAddress("NtpMCRecord",&mcRecord);
00131 fCurrentMC = -1;
00132
00133 if(chainTH==0) {
00134 isTH = false;
00135 return;
00136 }
00137 fChainTH = chainTH;
00138 fChainTH->SetBranchAddress("NtpTHRecord",&thRecord);
00139 fCurrentTH = -1;
00140
00141 }
|
|
|
Definition at line 143 of file MadChain.cxx. References fChainEM, fChainMC, fChainSR, and fChainTH. 00144 {
00145 // Print contents of entry.
00146 // If entry is not specified, print current entry
00147 if (!fChainSR) return;
00148 fChainSR->Show(entry);
00149 if (fChainEM) fChainEM->Show(entry);
00150 if (!fChainMC) return;
00151 fChainMC->Show(entry);
00152 if (!fChainTH) return;
00153 fChainTH->Show(entry);
00154 }
|
|
|
Definition at line 156 of file MadChain.cxx. References emRecord, fChainEM, fChainMC, fChainSR, fChainTH, fCurrentEM, fCurrentMC, fCurrentSR, fCurrentTH, isEM, isMC, isST, isTH, mcRecord, Nentries, Record, stRecord, and thRecord. Referenced by Init(). 00156 {
00157
00158 Record = 0;
00159 stRecord = 0;
00160 emRecord = 0;
00161 mcRecord = 0;
00162 thRecord = 0;
00163
00164 isMC = true;
00165 isTH = true;
00166 isEM = true;
00167 isST = false;
00168 Nentries = -1;
00169
00170 fChainSR = 0;
00171 fChainMC = 0;
00172 fChainTH = 0;
00173 fChainEM = 0;
00174
00175 fCurrentSR = 0;
00176 fCurrentMC = 0;
00177 fCurrentTH = 0;
00178 fCurrentEM = 0;
00179
00180 }
|
|
|
Definition at line 54 of file MadChain.h. Referenced by Get(), MadBase::GetEntry(), Init(), and Zero(). |
|
|
Definition at line 29 of file MadChain.h. Referenced by Get(), Init(), Show(), Zero(), and ~MadChain(). |
|
|
Definition at line 23 of file MadChain.h. Referenced by Get(), Init(), Show(), Zero(), and ~MadChain(). |
|
|
Definition at line 20 of file MadChain.h. Referenced by BuildLookup(), Get(), GetEntryNumber(), Init(), Show(), Zero(), and ~MadChain(). |
|
|
Definition at line 26 of file MadChain.h. Referenced by Get(), Init(), Show(), Zero(), and ~MadChain(). |
|
|
Definition at line 30 of file MadChain.h. |
|
|
Definition at line 24 of file MadChain.h. |
|
|
Definition at line 21 of file MadChain.h. |
|
|
Definition at line 27 of file MadChain.h. |
|
|
Definition at line 79 of file MadChain.h. Referenced by BuildLookup(), and GetEntryNumber(). |
|
|
Definition at line 59 of file MadChain.h. Referenced by BuildLookup(). |
|
|
Definition at line 46 of file MadChain.h. Referenced by Init(), MadBase::InitChain(), and Zero(). |
|
|
Definition at line 44 of file MadChain.h. Referenced by Init(), MadBase::InitChain(), and Zero(). |
|
|
Definition at line 47 of file MadChain.h. Referenced by Init(), MadBase::InitChain(), and Zero(). |
|
|
Definition at line 45 of file MadChain.h. Referenced by Init(), MadBase::InitChain(), and Zero(). |
|
|
Definition at line 52 of file MadChain.h. Referenced by Get(), MadBase::GetEntry(), Init(), and Zero(). |
|
|
Definition at line 48 of file MadChain.h. Referenced by Init(), MadBase::InitChain(), and Zero(). |
|
|
Definition at line 50 of file MadChain.h. Referenced by BuildLookup(), Get(), MadBase::GetEntry(), Init(), and Zero(). |
|
|
Definition at line 51 of file MadChain.h. Referenced by BuildLookup(), MadBase::GetEntry(), Init(), and Zero(). |
|
|
Definition at line 53 of file MadChain.h. Referenced by Get(), MadBase::GetEntry(), Init(), and Zero(). |
1.3.9.1