Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MCNNRunner Class Reference

#include <MCNNRunner.h>

List of all members.

Public Member Functions

 MCNNRunner ()
 ~MCNNRunner ()
void Run (const char *fname, const char *tag, unsigned short qtype)
void Run (const char *fname, const char *tag, Int_t entry_first, Int_t entry_last, Int_t piece_in, unsigned short qtype)
void Run (const char *fname, unsigned short qtype)
void Run (const char *fname, Int_t entry_first, Int_t entry_last, Int_t piece_in, unsigned short qtype)
void SetMCNNPrecutLevel (int level)
int GetMCNNPrecutLevel ()

Private Member Functions

void Initialize (unsigned short qtype)
void ReadEventLibrary ()
bool NextLibraryEvent ()
void CompactInput (const char *fname, unsigned short qtype)
void MakeComparison ()
void WriteResults (const char *fname, const char *tag)
void WriteResults (const char *fname)
void Finish ()
ComparisonResultCompareEventsP (MinosCompactEvent *eventA, MinosCompactEvent *eventB)
comparisonResult_h CompareEvents (MinosCompactEvent *eventA, MinosCompactEvent *eventB)
comparisonResult_h CompareEvents (MinosCompactEvent *eventA, MinosCompactEvent *eventB, int ip, int isU, int isV)
bool CompatibleEvents (compatibilityInfo_h *ciA, compatibilityInfo_h *ciB)
void FillWorkSpaceA (MinosCompactEvent *event)
void FillWorkSpaceB (MinosCompactEvent *event)
void ClearWorkSpaceA (MinosCompactEvent *event)
void ClearWorkSpaceB (MinosCompactEvent *event)
Bool_t PassesMCNNPrecuts (const NtpStRecord *record, const int eventno) const

Private Attributes

unsigned int file_count
Int_t srCtr
Int_t input_first
Int_t input_last
Int_t piece
bool isMRCC
int KEEP_BEST_N
float NO_VALID_COMPARISON
int MCNNPrecutLevel
bool atleastonelibevent
int library_event_count
TChain * lib_chain
std::vector< string > _files
std::vector< ComparisonResultList * > _compResList
std::vector< MinosCompactEvent * > _inputAll
std::vector< compatibilityInfo_h * > _inputAll_compatibilityInfo
std::vector< float > _selflnL
std::vector< float > _compResList_smallestDeltalnL
std::vector< int > _compResList_size
std::vector< ComparisonResultList * > _compResList_untrimmed
std::vector< MinosCompactEvent * > _inputAll_untrimmed
PECalculatorpeCalculator
HitProbTableHPB
MinosEventDisplayeventDisplay
MinosCompactEventpcce
int _workSpaceA [201][201]
int _workSpaceB [201][201]


Constructor & Destructor Documentation

MCNNRunner::MCNNRunner  ) 
 

Definition at line 72 of file MCNNRunner.cxx.

References _workSpaceA, _workSpaceB, atleastonelibevent, input_first, input_last, KEEP_BEST_N, library_event_count, MCNNPrecutLevel, NO_VALID_COMPARISON, and piece.

00072                       {
00073 
00074   KEEP_BEST_N=200;//<--default values
00075   NO_VALID_COMPARISON=-99999999.;//<--default values
00076   input_last=100000000;//<--some humongously large number
00077   input_first=0;
00078   piece=-1;
00079   MCNNPrecutLevel = kLoosePrecuts;
00080   atleastonelibevent=false;
00081   library_event_count = 0;
00082 
00083   for (int i = 0; i < 201; ++i) {
00084     for (int j = 0; j < 201; ++j) {
00085       _workSpaceA[i][j] = 0;
00086       _workSpaceB[i][j] = 0;
00087     }
00088   }
00089 
00090 }

MCNNRunner::~MCNNRunner  ) 
 

Definition at line 92 of file MCNNRunner.cxx.

00092                        {
00093 
00094 }


Member Function Documentation

void MCNNRunner::ClearWorkSpaceA MinosCompactEvent event  )  [private]
 

Definition at line 1596 of file MCNNRunner.cxx.

References _workSpaceA, compactStrip_h::plane, compactStrip_h::strip, MinosCompactEvent::UStrips, and MinosCompactEvent::VStrips.

Referenced by CompareEvents().

01596                                                          {
01597 
01598   std::vector<compactStrip_h>::iterator strips_it;
01599   std::vector<compactStrip_h>::iterator strips_end;
01600 
01601   strips_it  = eventA->UStrips.begin();
01602   strips_end = eventA->UStrips.end();
01603   while (strips_it!=strips_end) {
01604     compactStrip_h strips = *strips_it++;
01605     int plane = strips.plane;
01606     int strip = strips.strip;
01607     _workSpaceA[strip][plane] = 0;
01608   }
01609   strips_it  = eventA->VStrips.begin();
01610   strips_end = eventA->VStrips.end();
01611   while (strips_it!=strips_end) {
01612     compactStrip_h strips = *strips_it++;
01613     int plane = strips.plane;
01614     int strip = strips.strip;
01615     _workSpaceA[strip][plane] = 0;
01616   }
01617 
01618 }

void MCNNRunner::ClearWorkSpaceB MinosCompactEvent event  )  [private]
 

Definition at line 1650 of file MCNNRunner.cxx.

References _workSpaceB, compactStrip_h::plane, compactStrip_h::strip, MinosCompactEvent::UStrips, and MinosCompactEvent::VStrips.

Referenced by CompareEvents().

01650                                                          {
01651 
01652   std::vector<compactStrip_h>::iterator strips_it;
01653   std::vector<compactStrip_h>::iterator strips_end;
01654 
01655   strips_it  = eventB->UStrips.begin();
01656   strips_end = eventB->UStrips.end();
01657   while (strips_it!=strips_end) {
01658     compactStrip_h strips = *strips_it++;
01659     int plane = strips.plane;
01660     int strip = strips.strip;
01661     _workSpaceB[strip][plane] = 0;
01662   }
01663   strips_it  = eventB->VStrips.begin();
01664   strips_end = eventB->VStrips.end();
01665   while (strips_it!=strips_end) {
01666     compactStrip_h strips = *strips_it++;
01667     int plane = strips.plane;
01668     int strip = strips.strip;
01669     _workSpaceB[strip][plane] = 0;
01670   }
01671 
01672   return;
01673 
01674 }

void MCNNRunner::CompactInput const char *  fname,
unsigned short  qtype
[private]
 

Definition at line 355 of file MCNNRunner.cxx.

References _compResList, _compResList_size, _compResList_smallestDeltalnL, _compResList_untrimmed, _inputAll, _inputAll_compatibilityInfo, _inputAll_untrimmed, _selflnL, CompareEvents(), CompatibleEvents(), count, NtpStRecord::evthdr, ComparisonResultList::LastDeltalnL(), comparisonResult_h::lnL, MCNNPrecutLevel, NtpSREventSummary::nevent, NO_VALID_COMPARISON, MinosCompactEvent::nPlanes, compatibilityInfo_h::nplanes, compatibilityInfo_h::nstrips, PassesMCNNPrecuts(), MinosCompactEvent::Qtot, compatibilityInfo_h::qtot, ComparisonResultList::Size(), MinosCompactEvent::UStrips, and MinosCompactEvent::VStrips.

Referenced by Run().

00355                                                                     {
00356 
00357   cout << "*** CompactInput ***" << endl;
00358  //New pattern is truncated after strip 15
00359   static const int PATTERN_SIZE = 7;
00360   int cpattern[PATTERN_SIZE] = {1,1,2,3,4,5,85};
00361   int pattern[201];
00362   pattern[100] = 100;
00363   int ip = 100;
00364   int im = 100;
00365   int ipp = 100; 
00366   int imm = 100;
00367 
00368   //Mark strips >15 from mean as strips to be cut in compression
00369   for(int entry =1;entry<PATTERN_SIZE;entry++){
00370     ipp++;
00371     imm--;
00372     for(int count=0;count<cpattern[entry];count++){
00373       ip++;
00374       im--;
00375       if(ip<=115){ 
00376         pattern[ip] = ipp;
00377       } else if (ip<=200) pattern[ip]=-1;
00378       if(im>=85&&im<=100){
00379         pattern[im] = imm;
00380       } else if (im>=0) pattern[im]=-1;
00381    
00382     }
00383   }
00384 
00385   //-->Opening input file
00386   //NtpFile* input  = new NtpFile(isMC,isMRCC);
00387   TChain *chain = new TChain("NtpSt");
00388   cout << "Adding INPUT file to list: " << fname << endl;
00389   //input->AddFiles(fname);
00390   chain->Add(fname);
00391 
00392   // report
00393   cout << "Applying MCNN precuts at level=" << MCNNPrecutLevel << endl;
00394   Int_t precutDenom = 0;
00395   Int_t precutNumer = 0;
00396 
00397   const NtpStRecord *record = 0;
00398   chain->SetBranchAddress("NtpStRecord",&record);
00399 
00400   Int_t srCtr_local=input_first;
00401   while(chain->GetEntry(srCtr_local) && srCtr_local<=input_last){
00402     ++srCtr_local;
00403 
00404     for(int ievt=0;ievt<record->evthdr.nevent;++ievt){
00405 
00406       MinosCompactEvent* pCompactEvent = new MinosCompactEvent(record, ievt, qtype);
00407       MinosCompactEvent* pCompressedCompactEvent = new MinosCompactEvent(pCompactEvent,pattern);
00408 
00409       delete pCompactEvent;
00410 
00411       //-->create a ComparisonResultList object for this input event
00412       ComparisonResultList *crl = new ComparisonResultList();
00413       
00414       // precuts
00415       Bool_t stripcheck = kTRUE;
00416       if (pCompressedCompactEvent->UStrips.size()==0&&
00417           pCompressedCompactEvent->VStrips.size()==0) stripcheck = kFALSE;
00418 
00419       Bool_t doit = PassesMCNNPrecuts(record,ievt) && stripcheck;
00420       precutDenom++; // counter
00421       
00422       // push (pointers only) to these untrimmed lists so that the writing
00423       // code has something to work with for all input events, regardless
00424       // of precuts.
00425       // These should be a full list of lists used in the output.
00426       _inputAll_untrimmed.push_back(pCompressedCompactEvent);
00427       _compResList_untrimmed.push_back(crl);  
00428 
00429       if (doit) {
00430         // push here those events that should actually be processed.
00431         precutNumer++; // counter
00432 
00433         _inputAll.push_back(pCompressedCompactEvent);
00434         compatibilityInfo_h *ci = new compatibilityInfo_h;
00435         ci->nstrips = pCompressedCompactEvent->UStrips.size()+pCompressedCompactEvent->VStrips.size();
00436         ci->qtot    = pCompressedCompactEvent->Qtot;
00437         ci->nplanes = pCompressedCompactEvent->nPlanes;
00438         _inputAll_compatibilityInfo.push_back(ci);
00439       
00440         //-->compare with self and store
00441         if (CompatibleEvents(ci,ci)) { 
00442           comparisonResult_h selfcomp = CompareEvents(pCompressedCompactEvent,pCompressedCompactEvent);
00443           _selflnL.push_back(selfcomp.lnL);
00444         } else _selflnL.push_back(NO_VALID_COMPARISON-1.0);
00445       
00446         //set the CR list's size (for speed later)
00447         _compResList.push_back(crl);  
00448         _compResList_size.push_back(crl->Size());
00449         _compResList_smallestDeltalnL.push_back(crl->LastDeltalnL());
00450         
00451       }
00452 
00453     }//evt loop
00454 
00455   }//next record loop
00456 
00457   //Check all is OK
00458   if(_inputAll.size()==_selflnL.size() && _selflnL.size()==_compResList.size() && _compResList.size()==_compResList_size.size() ){
00459     cout << "Saved " << _compResList.size() << " input events with self lnL and comp. result lists. " << endl;
00460   } else {
00461     cout << "ERROR !!!; _inputAll, _selflnL, _compResList, and_compResList_size do not have same number of entries; suggest to abort" << endl;
00462   }
00463 
00464   //Delete file
00465   //delete input;
00466   delete chain;//new
00467 
00468   // report on precuts
00469   cout << "Precuts: Running MCNN on " << precutNumer << " of " << precutDenom << " events" << endl;
00470 }//end of CompactInput

comparisonResult_h MCNNRunner::CompareEvents MinosCompactEvent eventA,
MinosCompactEvent eventB,
int  ip,
int  isU,
int  isV
[private]
 

Definition at line 1431 of file MCNNRunner.cxx.

References _workSpaceA, _workSpaceB, MinosCompactEvent::chargeScale, MinosCompactEvent::ChargeType, comparisonResult_h::fractionQMatched, HPB, compactStrip_h::icharge, comparisonResult_h::lnL, HitProbTable::LogL(), comparisonResult_h::nMatched, comparisonResult_h::nUnmatched, peCalculator, compactStrip_h::plane, PECalculator::SimpleLnL(), compactStrip_h::strip, MinosCompactEvent::UStrips, and MinosCompactEvent::VStrips.

01431                                                                                                                           {
01432     
01433   float lnL =0.0;
01434   int nmatched = 0;
01435   int nunmatched = 0;
01436   float qmatched = 0;
01437   float qunmatched = 0;
01438 
01439   //MHO0509 - Check for ChargeType and chargeScale equality
01440   if (eventA->ChargeType != eventB->ChargeType) {
01441     cout << "UTTER FAILURE - Events have different ChargeType" << endl;
01442   }
01443   if (eventA->chargeScale != eventB->chargeScale) {
01444     cout << "UTTER FAILURE - Events have different chargeScale" << endl;
01445   }
01446 
01447   float CS = eventA->chargeScale;
01448   unsigned short int QT = eventA->ChargeType;
01449 
01450   // loop over strips in A
01451 
01452   std::vector<compactStrip_h>::iterator strips_it;
01453   std::vector<compactStrip_h>::iterator strips_end;
01454 
01455   strips_it  = eventA->UStrips.begin();
01456   strips_end = eventA->UStrips.end();
01457   while (strips_it!=strips_end) {
01458     compactStrip_h strips = *strips_it++;
01459     int plane = strips.plane;
01460     int strip = strips.strip;
01461     int ichargeA = strips.icharge;
01462     int ichargeB = _workSpaceB[strip+isU][plane+ip];
01463     int nchargeA = (int)(ichargeA/CS + 0.5);
01464     int nchargeB = (int)(ichargeB/CS + 0.5);
01465     //lnL += peCalculator->LnL(iqpeA,iqpeB);
01466     if (QT==1 || QT==2 || QT==3 || QT==4 || QT==6) {
01467       lnL += HPB->LogL(nchargeA,nchargeB);
01468     }
01469     else if (QT==0 || QT==5) {
01470       lnL += peCalculator->SimpleLnL(nchargeA,nchargeB);
01471     }
01472     //        cout << iqpeA << " <-> " << iqpeB << " : " << peCalculator->LnL(iqpeA,iqpeB) << endl;
01473     //cout << nqpeA << " <-> " << nqpeB << " : " << peCalculator->SimpleLnL(nqpeA,nqpeB) << endl;
01474     if(nchargeA>0&&nchargeB>0){
01475       nmatched+=2;
01476       qmatched = qmatched + ichargeA+ichargeB;
01477     }else{
01478       nunmatched++;
01479       qunmatched = qunmatched + ichargeA;
01480     }
01481   }
01482   strips_it  = eventA->VStrips.begin();
01483   strips_end = eventA->VStrips.end();
01484   while (strips_it!=strips_end) {
01485     compactStrip_h strips = *strips_it++;
01486     int plane = strips.plane;
01487     int strip = strips.strip;
01488     int ichargeA = strips.icharge;
01489     int ichargeB = _workSpaceB[strip+isV][plane+ip];
01490     int nchargeA = (int)(ichargeA/CS + 0.5);
01491     int nchargeB = (int)(ichargeB/CS + 0.5);
01492     //    lnL += peCalculator->LnL(iqpeA,iqpeB);
01493     if(nchargeA>0&&nchargeB>0){
01494       nmatched+=2;
01495       qmatched = qmatched + ichargeA+ichargeB;
01496     }else{
01497       nunmatched++;
01498       qunmatched = qunmatched + ichargeA;
01499     }
01500     if (QT==1 || QT==2 || QT==3 || QT==4 || QT==6) {
01501       lnL += HPB->LogL(nchargeA,nchargeB);
01502     }
01503     else if (QT==0 || QT==5) {
01504       lnL += peCalculator->SimpleLnL(nchargeA,nchargeB);
01505     }
01506     //cout << nqpeA << " <-> " << nqpeB << " : " << peCalculator->SimpleLnL(nqpeA,nqpeB) << endl;
01507   }
01508 
01509   // loop over strips in B - checking for strips not in A
01510 
01511   strips_it  = eventB->UStrips.begin();
01512   strips_end = eventB->UStrips.end();
01513   while (strips_it!=strips_end) {
01514     compactStrip_h strips = *strips_it++;
01515     int plane = strips.plane;
01516     int strip = strips.strip;
01517     if(_workSpaceA[strip-isU][plane-ip]==0){
01518       int ichargeB = strips.icharge;
01519       int nchargeB = (int)(ichargeB/CS + 0.5);
01520       int nchargeA = 0;
01521       nunmatched++;
01522       qunmatched = qunmatched + ichargeB;
01523       //      lnL += peCalculator->LnL(iqpeA,iqpeB);
01524       if (QT==1||QT==2||QT==3||QT==4||QT==6) {
01525         lnL += HPB->LogL(nchargeA,nchargeB);
01526       }
01527       else if (QT==0||QT==5) {
01528         lnL += peCalculator->SimpleLnL(nchargeA,nchargeB);
01529       }
01530       //cout << nqpeA << " <-> " << nqpeB << " : " << peCalculator->SimpleLnL(nqpeA,nqpeB) << endl;
01531     }
01532   }
01533   strips_it  = eventB->VStrips.begin();
01534   strips_end = eventB->VStrips.end();
01535   while (strips_it!=strips_end) {
01536     compactStrip_h strips = *strips_it++;
01537     int plane = strips.plane;
01538     int strip = strips.strip;
01539     if(_workSpaceA[strip-isV][plane-ip]==0){
01540       int ichargeB = strips.icharge;
01541       int nchargeB = (int)(ichargeB/CS + 0.5);
01542       int nchargeA = 0;
01543       nunmatched++;
01544       qunmatched = qunmatched + ichargeB;
01545       //      lnL += peCalculator->LnL(iqpeA,iqpeB);
01546       if (QT==1 || QT==2 || QT==3 || QT==4||QT==6) {
01547         lnL += HPB->LogL(nchargeA,nchargeB);
01548       }
01549       else if (QT==0 || QT==5) {
01550         lnL += peCalculator->SimpleLnL(nchargeA,nchargeB);
01551       }
01552       //cout << nqpeA << " <-> " << nqpeB << " : " << peCalculator->SimpleLnL(nqpeA,nqpeB) << endl;
01553     }
01554   }
01555   
01556   comparisonResult_h result;
01557   result.lnL = lnL;
01558   result.nMatched = nmatched;
01559   result.nUnmatched = nunmatched;  
01560   result.fractionQMatched = (qmatched+qunmatched)?(qmatched/(qmatched+qunmatched)):0;
01561   return result;
01562   
01563 }

comparisonResult_h MCNNRunner::CompareEvents MinosCompactEvent eventA,
MinosCompactEvent eventB
[private]
 

Definition at line 1385 of file MCNNRunner.cxx.

References ClearWorkSpaceA(), ClearWorkSpaceB(), FillWorkSpaceA(), FillWorkSpaceB(), comparisonResult_h::lnL, NO_VALID_COMPARISON, comparisonResult_h::planeOffset, comparisonResult_h::stripOffsetU, and comparisonResult_h::stripOffsetV.

Referenced by CompactInput(), and CompareEventsP().

01385                                                                                                 {
01386   
01387   comparisonResult_h bestResult;
01388   bestResult.lnL = NO_VALID_COMPARISON-1.0; 
01389 
01390   float lnLmax =-99999999.;
01391   FillWorkSpaceA(eventA);
01392   FillWorkSpaceB(eventB);
01393 
01394   for(int iPlaneOffset=-1;iPlaneOffset<=1;++iPlaneOffset){
01395     for(int iStripOffsetU=0;iStripOffsetU<=0;++iStripOffsetU){
01396       for(int iStripOffsetV=0;iStripOffsetV<=0;++iStripOffsetV){
01397         comparisonResult_h result = CompareEvents(eventA, eventB, iPlaneOffset, iStripOffsetU, iStripOffsetV);
01398         if(result.lnL>lnLmax){  
01399           lnLmax = result.lnL;
01400           bestResult = result;
01401           bestResult.stripOffsetU = iStripOffsetU;
01402           bestResult.stripOffsetV = iStripOffsetV;
01403           bestResult.planeOffset = iPlaneOffset;
01404         } 
01405       }
01406     }
01407   }
01408   
01409   ClearWorkSpaceA(eventA);
01410   ClearWorkSpaceB(eventB);
01411 
01412   return bestResult;
01413   
01414 }

ComparisonResult * MCNNRunner::CompareEventsP MinosCompactEvent eventA,
MinosCompactEvent eventB
[private]
 

Definition at line 1417 of file MCNNRunner.cxx.

References CompareEvents(), and comparisonResult_h::lnL.

Referenced by MakeComparison().

01417                                                                                                 {
01418   
01419   ComparisonResult* pResult = NULL;
01420 
01421   comparisonResult_h result = CompareEvents(eventA, eventB);
01422   if(result.lnL>NO_VALID_COMPARISON){
01423     pResult = new ComparisonResult(result);
01424   }
01425 
01426   return pResult;
01427   
01428 }

bool MCNNRunner::CompatibleEvents compatibilityInfo_h ciA,
compatibilityInfo_h ciB
[private]
 

Definition at line 1359 of file MCNNRunner.cxx.

References abs(), compatibilityInfo_h::nplanes, compatibilityInfo_h::nstrips, and compatibilityInfo_h::qtot.

Referenced by CompactInput(), and MakeComparison().

01359                                                                                     {
01360 
01361   // This is the one routine that gets called (library)*(input) times.
01362   // It needs to be as tight as possible.
01363 
01364   int meanN  = (ciA->nplanes+ciB->nplanes+1)/2;
01365   int cut = 2;
01366   if      (meanN>20) cut=4;
01367   else if (meanN>15) cut=3;
01368   if (abs(ciA->nplanes-ciB->nplanes)>cut) return 0;
01369 
01370   if (ciA->nstrips+ciB->nstrips==0) return 0;
01371   float rat1 = 2.0*fabs(static_cast<float>(ciA->nstrips - ciB->nstrips))/(ciA->nstrips + ciB->nstrips);
01372   if (rat1>0.2) return 0;
01373 
01374   if (ciA->qtot+ciB->qtot==0) return 0;
01375   float rat2 = 2.0*fabs(static_cast<float>(ciA->qtot-ciB->qtot))/(ciA->qtot+ciB->qtot);
01376   if (rat2>0.2) return 0;
01377 
01378   return 1;
01379 }

void MCNNRunner::FillWorkSpaceA MinosCompactEvent event  )  [private]
 

Definition at line 1569 of file MCNNRunner.cxx.

References _workSpaceA, compactStrip_h::icharge, compactStrip_h::plane, compactStrip_h::strip, MinosCompactEvent::UStrips, and MinosCompactEvent::VStrips.

Referenced by CompareEvents().

01569                                                         {
01570 
01571   // store hits in workspace for event A
01572 
01573   std::vector<compactStrip_h>::iterator strips_it;
01574   std::vector<compactStrip_h>::iterator strips_end;
01575 
01576   strips_it  = eventA->UStrips.begin();
01577   strips_end = eventA->UStrips.end();
01578   while (strips_it!=strips_end) {
01579     compactStrip_h strips = *strips_it++;
01580     int plane = strips.plane;
01581     int strip = strips.strip;
01582     _workSpaceA[strip][plane] = strips.icharge;
01583   }
01584   strips_it  = eventA->VStrips.begin();
01585   strips_end = eventA->VStrips.end();
01586   while (strips_it!=strips_end) {
01587     compactStrip_h strips = *strips_it++;
01588     int plane = strips.plane;
01589     int strip = strips.strip;
01590     _workSpaceA[strip][plane] = strips.icharge;
01591   }
01592 
01593   return;
01594 }

void MCNNRunner::FillWorkSpaceB MinosCompactEvent event  )  [private]
 

Definition at line 1621 of file MCNNRunner.cxx.

References _workSpaceB, compactStrip_h::icharge, compactStrip_h::plane, compactStrip_h::strip, MinosCompactEvent::UStrips, and MinosCompactEvent::VStrips.

Referenced by CompareEvents().

01621                                                         {
01622 
01623   // store hits in workspace for event B
01624 
01625   std::vector<compactStrip_h>::iterator strips_it;
01626   std::vector<compactStrip_h>::iterator strips_end;
01627 
01628   strips_it  = eventB->UStrips.begin();
01629   strips_end = eventB->UStrips.end();
01630   while (strips_it!=strips_end) {
01631     compactStrip_h strips = *strips_it++;
01632     int plane = strips.plane;
01633     int strip = strips.strip;
01634     _workSpaceB[strip][plane] = strips.icharge;
01635   }
01636   strips_it  = eventB->VStrips.begin();
01637   strips_end = eventB->VStrips.end();
01638   while (strips_it!=strips_end) {
01639     compactStrip_h strips = *strips_it++;
01640     int plane = strips.plane;
01641     int strip = strips.strip;
01642     _workSpaceB[strip][plane] = strips.icharge;
01643   }
01644 
01645   return;
01646 
01647 }

void MCNNRunner::Finish  )  [private]
 

Definition at line 1326 of file MCNNRunner.cxx.

References _compResList, _inputAll, _inputAll_compatibilityInfo, eventDisplay, and peCalculator.

Referenced by Run().

01326                        {
01327 
01328   //-->Tidy up
01329   cout << "Finishing; removing:" << endl;
01330 
01331   //objects
01332   if(peCalculator!=NULL)delete peCalculator;
01333   cout << "peCalculator " << endl;
01334   if(eventDisplay!=NULL)delete eventDisplay;
01335   cout << "eventDisplay" << endl;
01336 
01337   //std::vectors
01338   for(UInt_t ievent = 0; ievent<_inputAll.size();++ievent) {
01339     delete _inputAll[ievent];
01340     delete _inputAll_compatibilityInfo[ievent];
01341   }
01342   cout << "_inputAll (and related)" << endl;  
01343   for(UInt_t ievent = 0; ievent<_compResList.size();++ievent) {
01344     delete _compResList[ievent];
01345   }
01346   cout << "_compResList" << endl;
01347   
01348 
01349 }

int MCNNRunner::GetMCNNPrecutLevel  )  [inline]
 

Definition at line 51 of file MCNNRunner.h.

00051 { return MCNNPrecutLevel; }

void MCNNRunner::Initialize unsigned short  qtype  )  [private]
 

Definition at line 198 of file MCNNRunner.cxx.

References file_count, HPB, isMRCC, pcce, peCalculator, and srCtr.

Referenced by Run().

00199 {
00200   cout << " *** Initialize() ***" << endl;
00201 
00202   //Other variables
00203   isMRCC=false;
00204 
00205   //Start library file & entry count at 0
00206   srCtr=0;
00207   file_count=0;  
00208 
00209   // create the event display if requested
00210   //if(EVENT_DISPLAY)eventDisplay = new MinosEventDisplay(0,true);
00211 
00212   // create the calculator
00213   //MHO0509 - Type of calculator needed depends on qtype
00214   if (qtype == 0 || qtype == 5) {
00215     peCalculator = new PECalculator();
00216   }
00217   if (qtype == 1 || qtype == 2) {
00218     TFile f("/minos/scratch/nue/Releases/Griffin/Data/LEM/hitprobtable/HitProbTableQtypes1and2.root");
00219     gROOT->cd();
00220     HPB = (HitProbTable*)f.Get("HPB");
00221     if (!HPB) {
00222       cout << "Failed to get HitProbTable from file.  SEGV coming!" << endl;
00223     }
00224     HPB = (HitProbTable*)HPB->Clone();
00225   }
00226   if (qtype == 3 || qtype == 4 || qtype == 6) {
00227     TFile f("/minos/scratch/nue/Releases/Griffin/Data/LEM/hitprobtable/HitProbTableQtypes3and4.root");
00228     gROOT->cd();
00229     HPB = (HitProbTable*)f.Get("HPB");
00230     if (!HPB) {
00231       cout << "Failed to get HitProbTable from file.  SEGV coming!" << endl;
00232     }
00233     HPB = (HitProbTable*)HPB->Clone();
00234   }
00235   
00236   // create the CCE
00237   pcce = new MinosCompactEvent(qtype);
00238 
00239   return;
00240 
00241 }

void MCNNRunner::MakeComparison  )  [private]
 

Definition at line 476 of file MCNNRunner.cxx.

References _compResList, _compResList_size, _compResList_smallestDeltalnL, _inputAll, _inputAll_compatibilityInfo, _selflnL, atleastonelibevent, CompareEventsP(), CompatibleEvents(), ComparisonResult::dLnL, KEEP_BEST_N, library_event_count, ComparisonResult::lnL, NextLibraryEvent(), MinosCompactEvent::nPlanes, compatibilityInfo_h::nplanes, compatibilityInfo_h::nstrips, pcce, MinosCompactEvent::Qtot, compatibilityInfo_h::qtot, ComparisonResult::SetNeutrino(), MinosCompactEvent::UStrips, and MinosCompactEvent::VStrips.

Referenced by Run().

00476                                {
00477 
00478   //-->Looping over library events
00479   while(NextLibraryEvent()){
00480 
00481     library_event_count++;
00482     atleastonelibevent=true;
00483 
00484     // for the faster precut routine:
00485     compatibilityInfo_h *ci_lib = new compatibilityInfo_h;
00486     ci_lib->nstrips = pcce->UStrips.size()+pcce->VStrips.size();
00487     ci_lib->qtot    = pcce->Qtot;
00488     ci_lib->nplanes = pcce->nPlanes;
00489 
00490     //-->Looping over input events
00491 
00492     UInt_t total_input = _inputAll.size();
00493     std::vector<compatibilityInfo_h*>::iterator it = _inputAll_compatibilityInfo.begin();
00494 
00495     for(UInt_t ievent = 0; ievent<total_input;++ievent){    
00496       //cout << "===============================" << endl;//tmp
00497       //cout << "Library event: " << pcce->idnu << "," << pcce->idact << "," << pcce->eNu << " -- " << pcce->UStrips.size() << "," << pcce->VStrips.size() << endl;//tmp
00498 
00499       compatibilityInfo_h *ci_inp = *it++;
00500 
00501       if ( CompatibleEvents(ci_inp,ci_lib) ) {
00502         // passes matching precuts (slower)
00503 
00504         MinosCompactEvent *eventi = _inputAll[ievent]; 
00505         ComparisonResult* pResult = CompareEventsP(eventi,pcce);
00506 
00507         if(pResult){
00508           
00509           float deltaLnL = _selflnL[ievent] - pResult->lnL;
00510           int nsize=0;
00511           
00512           if(_compResList[ievent]!=NULL){//<--avoiding seg fault when list is not yet filled
00513             //(seg fault is avoided in next "if" when list empty
00514             //since the first option in the OR passes first)
00515             nsize = _compResList_size[ievent];
00516           }
00517 
00518           //-->saving to the ComparisonResultList of this input event
00519           if(nsize < KEEP_BEST_N || deltaLnL<_compResList_smallestDeltalnL[ievent]){
00520             
00521             pResult->dLnL = deltaLnL;
00522             pResult->SetNeutrino(pcce);
00523             
00524             if(nsize==KEEP_BEST_N){//<--remove last
00525               // RBP - this was breaking.
00526               //list<ComparisonResult>::iterator iter_end = _compResList[ievent]->compResultList.end();
00527               //delete &iter_end;//<--actually deallocate memory for this object           
00528               _compResList[ievent]->PopBack();//<-- remove from list (even if now empty)           
00529               _compResList_size[ievent]--;//<-- Decrement size!
00530               
00531             }
00532             
00533             //-->Insert current guy in the right spot to keep list sorted
00534             _compResList[ievent]->InsertSorted(pResult);
00535             _compResList_size[ievent]++;//<-- Increment size!
00536             _compResList_smallestDeltalnL[ievent] = _compResList[ievent]->LastDeltalnL(); //<-- call and hold this value here instead of calling function on every event
00537           }//saving to ComparisonResultList
00538           
00539           delete pResult;
00540 
00541         }//not NULL comparison            
00542 
00543       }//precuts
00544       
00545     }//input loop 
00546     
00547     delete ci_lib;
00548 
00549   }//lib loop
00550   
00551   cout << "Done!" << endl;
00552 
00553 }//end of MakeComparison

bool MCNNRunner::NextLibraryEvent  )  [private]
 

Definition at line 277 of file MCNNRunner.cxx.

References _files, file_count, lib_chain, pcce, and srCtr.

Referenced by MakeComparison().

00277                                  {
00278 
00279   if(lib_chain==NULL || !lib_chain->GetEntry(srCtr)){
00280     if(file_count<_files.size()){
00281       delete lib_chain;
00282       lib_chain = new TChain("ccetree");
00283       Int_t filenum = lib_chain->Add(_files[file_count].c_str()); 
00284       cout << "Reading " << filenum << " library files: " << _files[file_count] << endl;
00285       lib_chain->SetBranchAddress("cce",&pcce);
00286       srCtr=0;
00287       ++file_count; 
00288     } else {
00289       return false;
00290     }
00291   }
00292   if(lib_chain->GetEntry(srCtr)){
00293     ++srCtr;    
00294     return true;
00295   } else {
00296     return false;
00297   }
00298 
00299 }//Next Library Event

Bool_t MCNNRunner::PassesMCNNPrecuts const NtpStRecord record,
const int  eventno
const [private]
 

Definition at line 306 of file MCNNRunner.cxx.

References NtpSRPlane::beg, det, NtpSRPlane::end, NtpStRecord::evt, SntpHelpers::GetPrimaryTrack(), isMC, kLoosePrecuts, kNoPrecuts, kTightPrecuts, NtpSRStripPulseHeight::mip, NueConvention::NueEnergyCorrection(), NtpSREvent::ph, and NtpSRTrack::plane.

Referenced by CompactInput().

00306                                                                                        {
00307 
00308   const NtpSREvent* event = dynamic_cast<const NtpSREvent*>(record->evt->At(eventno));
00309   const NtpSRTrack* track = dynamic_cast<const NtpSRTrack*>(SntpHelpers::GetPrimaryTrack(eventno, const_cast<NtpStRecord*>(record)));
00310   //const NtpSRTrack* track = dynamic_cast<const NtpSRTrack*>(record->trk->At(eventno));
00311 
00312   Detector::Detector_t det = record->GetHeader().GetVldContext().GetDetector();
00313   SimFlag::SimFlag_t   sim = record->GetHeader().GetVldContext().GetSimFlag();
00314   bool isMC = (sim == SimFlag::kMC);
00315   int release = record->GetRelease();
00316 
00317   Int_t trackplanes = (track)?TMath::Abs(track->plane.end - track->plane.beg):0;
00318   //Int_t trklikeplanes = (track)?track->plane.ntrklike:0;
00319 
00320   //unused//float x = event->vtx.x;
00321   //unused//float y = event->vtx.y;
00322   //unused//float z = event->vtx.z;
00323   float e = NueConvention::NueEnergyCorrection(event->ph.mip,release,isMC,det,false);
00324   Bool_t inFid = kTRUE;
00325   //Comment it out so no fiducial cut in FD
00326   //if (det == Detector::kFar ) inFid = (NueConvention::IsInsideFarFiducial_Nue_Standard (x,y,z,isMC)==1);
00327   //For now, no fid cut in the near detector (until we work out the vertex correction that's present in NueAna...)
00328   //if (det == Detector::kNear) inFid = (NueConvention::IsInsideNearFiducial_Nue_Extended(x,y,z)==1);
00329 
00330   switch (MCNNPrecutLevel) {
00331   case kNoPrecuts:
00332     break;
00333   case kLoosePrecuts:
00334     if (!(inFid&&
00335           e>0.5&&
00336           e<12&&
00337           trackplanes<30))
00338       return kFALSE;
00339     break;
00340   case kTightPrecuts:
00341     if (!(inFid&&
00342           e>1&&
00343           e<8&&
00344           trackplanes<25))
00345       return kFALSE;
00346     break;
00347   default:
00348     break;  
00349   }  
00350 
00351   return kTRUE;
00352 }

void MCNNRunner::ReadEventLibrary  )  [private]
 

Definition at line 246 of file MCNNRunner.cxx.

References _files, gSystem(), and infile.

Referenced by Run().

00246                                  {
00247 
00248   cout << "*** ReadEventLibrary() ***" << endl;
00249 
00250   //--> Read in the list of files from library.filelist
00251   const string fileName= "library.filelist";
00252   ifstream infile(fileName.c_str());
00253   if(!infile){
00254     cerr << "Can't open MC file " << fileName.c_str() << endl;
00255     return;
00256   }
00257   string line;
00258   while( getline(infile,line,'\n')){
00259     if(line[ 0 ] != 'C'){
00260       cout << "Adding file : " << line <<endl;
00261       // handle environment variables here...
00262       char *expanded_line = gSystem->ExpandPathName(line.c_str());
00263       string line_str = expanded_line;
00264       _files.push_back(line_str);
00265       delete expanded_line;
00266     }
00267   }
00268 
00269   cout << "The files array has size " << _files.size() << endl;
00270 
00271 }//ReadEventLibrary

void MCNNRunner::Run const char *  fname,
Int_t  entry_first,
Int_t  entry_last,
Int_t  piece_in,
unsigned short  qtype
 

Definition at line 169 of file MCNNRunner.cxx.

References CompactInput(), Finish(), Initialize(), input_first, input_last, MakeComparison(), piece, ReadEventLibrary(), and WriteResults().

00169                                                                                                                 {
00170 
00171   //-->Init
00172   input_first=entry_first;
00173   input_last=entry_last;
00174   piece=piece_in;
00175   Initialize(qtype);
00176 
00177   //-->Library
00178   ReadEventLibrary();
00179 
00180   //-->Input events 
00181   CompactInput(fname,qtype);
00182 
00183   //-->Compare input and libraries
00184   MakeComparison();
00185 
00186   //--->Write out results
00187   WriteResults(fname);
00188 
00189   //-->Tidy up
00190   Finish();
00191   
00192 }

void MCNNRunner::Run const char *  fname,
unsigned short  qtype
 

Definition at line 122 of file MCNNRunner.cxx.

References CompactInput(), Finish(), Initialize(), MakeComparison(), ReadEventLibrary(), and WriteResults().

00122                                                            {
00123 
00124   //-->Init
00125   Initialize(qtype);
00126 
00127   //-->Library
00128   ReadEventLibrary();
00129 
00130   //-->Input events 
00131   CompactInput(fname,qtype);
00132 
00133   //-->Compare input and libraries
00134   MakeComparison();
00135 
00136   //--->Write out results
00137   WriteResults(fname);
00138 
00139   //-->Tidy up
00140   Finish();
00141   
00142 }

void MCNNRunner::Run const char *  fname,
const char *  tag,
Int_t  entry_first,
Int_t  entry_last,
Int_t  piece_in,
unsigned short  qtype
 

Definition at line 144 of file MCNNRunner.cxx.

References CompactInput(), Finish(), Initialize(), input_first, input_last, MakeComparison(), piece, ReadEventLibrary(), and WriteResults().

00144                                                                                                                                 { //<--obsolete
00145 
00146   //-->Init
00147   input_first=entry_first;
00148   input_last=entry_last;
00149   piece=piece_in;
00150   Initialize(qtype);
00151 
00152   //-->Library
00153   ReadEventLibrary();
00154 
00155   //-->Input events 
00156   CompactInput(fname,qtype);
00157 
00158   //-->Compare input and libraries
00159   MakeComparison();
00160 
00161   //--->Write out results
00162   WriteResults(fname,tag);
00163 
00164   //-->Tidy up
00165   Finish();
00166   
00167 }

void MCNNRunner::Run const char *  fname,
const char *  tag,
unsigned short  qtype
 

Definition at line 100 of file MCNNRunner.cxx.

References CompactInput(), Finish(), Initialize(), MakeComparison(), ReadEventLibrary(), and WriteResults().

00100                                                                             { //<--obsolete
00101 
00102   //-->Init
00103   Initialize(qtype);
00104 
00105   //-->Library
00106   ReadEventLibrary();
00107 
00108   //-->Input events 
00109   CompactInput(fname,qtype);
00110 
00111   //-->Compare input and libraries
00112   MakeComparison();
00113 
00114   //--->Write out results
00115   WriteResults(fname,tag);
00116 
00117   //-->Tidy up
00118   Finish();
00119   
00120 }

void MCNNRunner::SetMCNNPrecutLevel int  level  )  [inline]
 

Definition at line 50 of file MCNNRunner.h.

References MCNNPrecutLevel.

00050 { MCNNPrecutLevel = level; }

void MCNNRunner::WriteResults const char *  fname  )  [private]
 

Definition at line 559 of file MCNNRunner.cxx.

References _compResList_untrimmed, _inputAll_untrimmed, atleastonelibevent, DataPreselected(), NtpMCTruth::emfrac, NtpStRecord::evthdr, NtpTools::FillRecoEInfo(), NtpMCTruth::flux, NtpTools::GetEvent(), RecRecordImp< T >::GetHeader(), RecDataHeader::GetRun(), RecPhysicsHeader::GetSnarl(), RecDataHeader::GetSubRun(), NtpTools::GetTotHadPt(), NtpTools::GetTruth(), gSystem(), NtpMCTruth::iaction, NtpMCTruth::inu, NtpMCTruth::inunoosc, NtpMCTruth::iresonance, library_event_count, MCLibraryPreselected(), NtpSRPlane::n, NtpSREventSummary::nevent, NtpSREvent::nstrip, NtpSRPlane::nu, NtpSRPlane::nv, NtpMCTruth::p4neu, NtpMCTruth::p4neunoosc, piece, NtpSREvent::plane, RecoE::Reset(), MinosAnalysisResult::ResultList, RecoE::totalE, NtpMCFluxInfo::tptype, NtpMCFluxInfo::tpx, NtpMCFluxInfo::tpy, NtpMCFluxInfo::tpz, NtpSRVertex::u, NtpSRVertex::v, NtpSREvent::vtx, NtpMCTruth::vtxx, NtpMCTruth::vtxy, NtpMCTruth::vtxz, NtpMCTruth::w2, NtpSRVertex::x, NtpSRVertex::y, NtpMCTruth::y, and NtpSRVertex::z.

00559                                               {
00560 
00561   cout << "*** WriteResults ***" << endl;
00562   cout << "Going over input file again to write out results" << endl;
00563   cout << "LIBRARY EVENTS USED: " << library_event_count << endl;
00564   cout << "(You should always sanity-check this number!)" << endl;
00565 
00566   if(atleastonelibevent==true){
00567 
00568     Int_t lastrun=0;
00569     Int_t evtcont=-1;//needs to be -1 so when increased after ievt loop get 0
00570     
00571     //-->Output file and tree variables
00572     TFile *OutputFile = NULL;
00573     TTree *OutputTree = NULL;
00574     TTree *OutputTreePOT = NULL;
00575     MinosCompactEvent* pcomptevt = NULL;
00576     MinosAnalysisResult* OutputResult = NULL;
00577     int   OutputRun = 0;
00578     int   OutputSnarl = 0;
00579     int   OutputEvent = 0;
00580     int   OutputNuId = 0 ;
00581     int   OutputNuIdNoOsc = 0;
00582     int   OutputNuAction = 0 ;
00583     float OutputNuE = 0;
00584     float OutputNuENoOsc = 0;
00585     float OutputY   = 0;
00586     float OutputEMFrac   = 0;
00587     int OutputIdRes = 0;
00588     
00589     float OutputQtot    = 0;
00590     float OutputVtxX    = 0;
00591     float OutputVtxY    = 0;
00592     float OutputVtxU    = 0;
00593     float OutputVtxV    = 0;
00594     float OutputVtxZ    = 0;
00595     float OutputTVtxX   = 0;
00596     float OutputTVtxY   = 0;
00597     float OutputTVtxZ   = 0;
00598     float Outputtpx = 0 ;
00599     float Outputtpy = 0;
00600     float Outputtpz = 0;
00601     int Outputtptype = 0;
00602     int   OutputNPln    = 0;
00603     int   OutputNPlnU    = 0;
00604     int   OutputNPlnV    = 0;
00605     int   OutputNStp    = 0;
00606     int OutputMCPresel = 0;
00607     int OutputDataPresel = 0;
00608     int OutputXTalk = 0;
00609     int OutputXTalkTagged = 0;
00610     int OutputXTalkMisTagged = 0;
00611     int OutputPhysics = 0;
00612     float OutputW2 = 0;
00613     float OutputTotPt = 0;
00614     
00615     float OutputRecoE   = 0;
00616     
00617     float snarl_pot = 0;
00618     int good_snarl = 0;//1=good snarl;0=bad snarl (beam wise)
00619     float total_pot = 0;
00620     float good_pot = 0;
00621     
00622     //-->Opening input file
00623     //NtpFile* input  = new NtpFile(isMC,isMRCC);
00624     TChain *chain = new TChain("NtpSt");//new
00625     cout << "Adding INPUT file to list: " << fname << endl;
00626     //input->AddFiles(fname);
00627     chain->Add(fname);
00628     
00629     const NtpStRecord *record = 0;
00630     chain->SetBranchAddress("NtpStRecord",&record);
00631     
00632     //Get first subrun
00633     Int_t firstsubrun=0;
00634     if(chain->GetEntry(0)){
00635       firstsubrun=record->GetHeader().GetSubRun();
00636     }
00637     
00638     //while(input->GetNextRecord()){
00639     Int_t srCtr_local=input_first;//new
00640     while(chain->GetEntry(srCtr_local) && srCtr_local<=input_last){//new
00641       ++srCtr_local;
00642       
00643       //POT counting
00644       //const NtpBDLiteRecord* bdrecord  = input->GetBDRecord();
00645       
00646       good_snarl=0;
00647       static float pot = 0;
00648       /*
00649         if(bdrecord!=NULL){
00650         
00651         pot = 0;
00652         if(NtpTools::PassBeamCuts(NtpTools::kLE10, bdrecord, pot, isMC)){
00653         total_pot+=pot;
00654         good_pot+=pot;
00655         good_snarl=1;
00656         }else{
00657         total_pot+=pot;
00658         //continue;//<--uncomment if only want to save good snarls
00659         }
00660         //printf(" pot: %f sum:%f / %f       \n", pot, good_pot, total_pot);
00661         }else{
00662         cout << "no beam record for this snarl" <<endl;
00663         }//<--pot counting
00664       */
00665       snarl_pot=pot;
00666       
00667       //const NtpStRecord* record = input->GetCCRecord(); 
00668       
00669       //-->file handling
00670       if(record->GetHeader().GetRun()!=lastrun){
00671         // Close last output file
00672         if(lastrun!=0){
00673           OutputTree->AutoSave();
00674           OutputTreePOT->AutoSave();
00675           delete OutputFile;
00676         }
00677         //Create the output file and trees
00678         // This is ugly (small memory leak in recreating _ptr s)
00679         OutputResult = new MinosAnalysisResult();
00680         lastrun = record->GetHeader().GetRun();
00681         
00682         //Run and subrun
00683         ostringstream e;
00684         string filenamestr;
00685         filenamestr=filenamestr+fname;
00686         string filenopath = filenamestr.substr(filenamestr.find_last_of("/")+1,
00687                                                filenamestr.find_last_of(".root")-
00688                                                filenamestr.find_last_of("/"));
00689         
00690         // hardcoding $MCNNTMP as a hack
00691         if(piece==-1){
00692           
00693           e << "$MCNNTMP/mcnn_" << filenopath;
00694           
00695         } else {
00696           
00697           e << "$MCNNTMP/mcnn_" << piece << "_" << filenopath;
00698           
00699         }
00700         
00701         cout << " Opening output file for file : " << filenopath << endl;
00702         
00703         string outputfile = gSystem->ExpandPathName((e.str()).c_str());
00704         cout << " Writing : " << outputfile << endl;
00705         OutputFile = new TFile(outputfile.c_str(),"recreate");
00706         OutputTree = new TTree("nn","Minos NuE Analysis Results");
00707         OutputTreePOT = new TTree("pottree","MCNN pot");
00708         OutputTree->Branch("cce","MinosCompactEvent",&pcomptevt);
00709         OutputTree->Branch("comparisonResults", "MinosAnalysisResult", &OutputResult);
00710         OutputTree->Branch("run", &OutputRun, "run/I");
00711         OutputTree->Branch("snarl", &OutputSnarl, "snarl/I");
00712         OutputTree->Branch("evt", &OutputEvent, "evt/I");
00713         OutputTree->Branch("nuid", &OutputNuId, "nuid/I");
00714         OutputTree->Branch("nuidnoosc",&OutputNuIdNoOsc,"nuidnoosc/I");
00715         OutputTree->Branch("action", &OutputNuAction, "action/I");
00716         OutputTree->Branch("nue", &OutputNuE, "nue/F");
00717         OutputTree->Branch("nuenoosc",&OutputNuENoOsc,"nuenoosc/F");
00718         OutputTree->Branch("reco_nue",&OutputRecoE,"reco_nue/F");
00719         OutputTree->Branch("y", &OutputY, "y/F");
00720         OutputTree->Branch("emfrac", &OutputEMFrac, "emfrac/F");
00721         OutputTree->Branch("ires",&OutputIdRes,"ires/I");
00722         OutputTree->Branch("qtot", &OutputQtot, "qtot/F");
00723         OutputTree->Branch("vtxx", &OutputVtxX, "vtxx/F");
00724         OutputTree->Branch("vtxy", &OutputVtxY, "vtxy/F");
00725         OutputTree->Branch("vtxz", &OutputVtxZ, "vtxz/F");
00726         OutputTree->Branch("vtxu", &OutputVtxU, "vtxu/F");
00727         OutputTree->Branch("vtxv", &OutputVtxV, "vtxv/F");
00728         OutputTree->Branch("tvtxx", &OutputTVtxX, "tvtxx/F");
00729         OutputTree->Branch("tvtxy", &OutputTVtxY, "tvtxy/F");
00730         OutputTree->Branch("tvtxz", &OutputTVtxZ, "tvtxz/F");
00731         OutputTree->Branch("tptype",&Outputtptype,"tptype/I");
00732         OutputTree->Branch("tpx",&Outputtpx,"tpx/F");
00733         OutputTree->Branch("tpy",&Outputtpy,"tpy/F");
00734         OutputTree->Branch("tpz",&Outputtpz,"tpz/F");
00735         OutputTree->Branch("npln", &OutputNPln, "npln/I");
00736         OutputTree->Branch("nstp", &OutputNStp, "nstp/I");
00737         OutputTree->Branch("nplnu", &OutputNPlnU, "nplnu/I");
00738         OutputTree->Branch("nplnv", &OutputNPlnV, "nplnv/I");     
00739         OutputTree->Branch("mcpresel",&OutputMCPresel,"mcpresel/I");
00740         OutputTree->Branch("datapresel",&OutputDataPresel,"datapresel/I");
00741         OutputTree->Branch("nxtalk",&OutputXTalk,"nxtalk/I");
00742         OutputTree->Branch("nxtalk_tagged",&OutputXTalkTagged,"nxtalk_tagged/I");
00743         OutputTree->Branch("nxtalk_mistagged",&OutputXTalkMisTagged,"nxtalk_mistagged/I"); 
00744         OutputTree->Branch("nphysics",&OutputPhysics,"nphysics/I");
00745         OutputTree->Branch("w2",&OutputW2,"w2/F");
00746         OutputTree->Branch("totpt",&OutputTotPt,"totpt/F");
00747         OutputTree->Branch("snarl_pot",&snarl_pot,"snarl_pot/F");
00748         OutputTree->Branch("good_snarl",&good_snarl,"good_snarl/I");
00749         OutputTreePOT->Branch("total_pot",&total_pot,"total_pot/F");
00750         OutputTreePOT->Branch("good_pot",&good_pot,"good_pot/F");
00751         OutputTree->SetDirectory(OutputFile);
00752         OutputTreePOT->SetDirectory(OutputFile);
00753         
00754       }//file handling
00755       
00756       for(int ievt=0;ievt<record->evthdr.nevent;++ievt){
00757         
00758         ++evtcont;
00759         
00760         const NtpSREvent* event = NtpTools::GetEvent(record, ievt);
00761         const NtpMCTruth* truth = NtpTools::GetTruth(record, ievt);
00762         
00763         
00764         //-->Fill MinosAnalysisResult for this input event (kind of ugly code this is)
00765         list<ComparisonResult>::iterator iter;
00766         list<ComparisonResult>::iterator iter_end;
00767         iter     = _compResList_untrimmed[evtcont]->compResultList.begin();
00768         iter_end = _compResList_untrimmed[evtcont]->compResultList.end();
00769         OutputResult = new MinosAnalysisResult();
00770         pcomptevt = new MinosCompactEvent(_inputAll_untrimmed[evtcont]);
00771         TClonesArray& resultList = *(OutputResult->ResultList);
00772         int i=0;
00773         while(iter!=iter_end){
00774           new(resultList[i]) ComparisonResult( &(*iter) );
00775           iter++;
00776           i++;
00777         }
00778         
00779         //-->Other variables from input file
00780         OutputRun = record->GetHeader().GetRun();
00781         OutputSnarl = record->GetHeader().GetSnarl();
00782         OutputEvent = ievt;
00783         if(truth!=0){
00784           OutputNuId = truth->inu;
00785           OutputNuIdNoOsc = truth->inunoosc;
00786           OutputNuAction  = truth->iaction;
00787           OutputNuE = truth->p4neu[3];
00788           OutputNuENoOsc = truth->p4neunoosc[3];
00789           OutputY = truth->y;   
00790           OutputEMFrac = truth->emfrac; 
00791           OutputIdRes = truth->iresonance;
00792           OutputTVtxX = truth->vtxx;
00793           OutputTVtxY = truth->vtxy;
00794           OutputTVtxZ = truth->vtxz;
00795           Outputtptype = truth->flux.tptype;
00796           Outputtpx = truth->flux.tpx;
00797           Outputtpy = truth->flux.tpy;
00798           Outputtpz = truth->flux.tpz;
00799         }
00800         
00801         OutputNPln = event->plane.n;
00802         OutputQtot = _inputAll_untrimmed[evtcont]->Qtot;
00803         OutputVtxX = event->vtx.x;
00804         OutputVtxY = event->vtx.y;
00805         OutputVtxZ = event->vtx.z;
00806         OutputVtxU = event->vtx.u;
00807         OutputVtxV = event->vtx.v;
00808         OutputNPlnU = event->plane.nu;
00809         OutputNPlnV = event->plane.nv;
00810         OutputNStp = event->nstrip;
00811 
00812         OutputXTalk = _inputAll_untrimmed[evtcont]->nxtalk;
00813         OutputXTalkTagged = _inputAll_untrimmed[evtcont]->nxtalk_tagged;
00814         OutputXTalkMisTagged = _inputAll_untrimmed[evtcont]->nxtalk_mistagged;
00815         OutputPhysics = _inputAll_untrimmed[evtcont]->nphysics;
00816 
00817         if(truth!=0){
00818           OutputW2 = truth->w2;
00819           OutputTotPt = NtpTools::GetTotHadPt(record,truth);
00820         } else {
00821           OutputW2 = -1;
00822           OutputTotPt = -1;
00823         }
00824 
00825         static RecoE* recoe = new RecoE();
00826         recoe->Reset(); 
00827         if(!NtpTools::FillRecoEInfo(record, ievt, recoe)){
00828           continue;
00829         }
00830         OutputRecoE=recoe->totalE;
00831 
00832         OutputMCPresel=0;
00833         if(MCLibraryPreselected(record,ievt)){
00834           OutputMCPresel=1;
00835         }
00836         
00837         OutputDataPresel=0;
00838         if(DataPreselected(event)){
00839           OutputDataPresel=1;
00840         }
00841         
00842         //-->fill tree
00843         OutputTree->Fill();
00844 
00845         (OutputResult->ResultList)->Delete();
00846         
00847       }//evt loop
00848       
00849       if(record->evthdr.nevent==0){//<-- an entry must still be recorded for empty snarls (otherwise cannot match with NueAna trees)
00850         
00851         OutputRun = record->GetHeader().GetRun();
00852         OutputSnarl = record->GetHeader().GetSnarl();
00853         OutputEvent = -1;
00854         
00855         OutputNuId = 0 ;
00856         OutputNuIdNoOsc = 0;
00857         OutputNuAction = 0 ;
00858         OutputNuE = 0;
00859         OutputNuENoOsc = 0;
00860         OutputY   = 0;
00861         OutputEMFrac   = 0;
00862         OutputIdRes = 0;
00863         
00864         OutputQtot    = 0;
00865         OutputVtxX    = 0;
00866         OutputVtxY    = 0;
00867         OutputVtxU    = 0;
00868         OutputVtxV    = 0;
00869         OutputVtxZ    = 0;
00870         OutputTVtxX   = 0;
00871         OutputTVtxY   = 0;
00872         OutputTVtxZ   = 0;
00873         Outputtpx = 0 ;
00874         Outputtpy = 0;
00875         Outputtpz = 0;
00876         Outputtptype = 0;
00877         OutputNPln    = 0;
00878         OutputNPlnU    = 0;
00879         OutputNPlnV    = 0;
00880         OutputNStp    = 0;
00881         OutputMCPresel = 0;
00882         OutputDataPresel = 0;
00883         OutputXTalk = 0;
00884         OutputXTalkTagged = 0;
00885         OutputXTalkMisTagged = 0;
00886         OutputPhysics = 0;
00887         OutputW2 = 0;
00888         OutputTotPt = 0;
00889         
00890         OutputRecoE   = 0;
00891         
00892         OutputTree->Fill();
00893       }//in case of empty snarl (0 events)
00894 
00895     }//record loop
00896     
00897     OutputTreePOT->Fill();
00898     
00899     cout << " Closing the output file " << endl;
00900     OutputFile->Write();
00901     OutputFile->Close();  
00902     return;  
00903     cout << "Leaving WriteResults()" << endl;
00904     
00905     delete chain;
00906 
00907   } else {
00908     cout << "CAUTION: Will not write file as libraries were not found/read" << endl;
00909   }
00910 
00911 }//end of WriteResults

void MCNNRunner::WriteResults const char *  fname,
const char *  tag
[private]
 

Definition at line 917 of file MCNNRunner.cxx.

References _compResList_untrimmed, _inputAll_untrimmed, DataPreselected(), NtpMCTruth::emfrac, NtpStRecord::evthdr, NtpTools::FillRecoEInfo(), NtpMCTruth::flux, VldContext::GetDetector(), NtpTools::GetEvent(), RecRecordImp< T >::GetHeader(), RecDataHeader::GetRun(), VldContext::GetSimFlag(), RecPhysicsHeader::GetSnarl(), RecDataHeader::GetSubRun(), NtpTools::GetTotHadPt(), NtpTools::GetTruth(), RecHeader::GetVldContext(), gSystem(), NtpMCTruth::iaction, NtpMCTruth::inu, NtpMCTruth::inunoosc, NtpMCTruth::iresonance, MCLibraryPreselected(), NtpSRPlane::n, NtpSREventSummary::nevent, NtpSREvent::nstrip, NtpSRPlane::nu, NtpSRPlane::nv, NtpMCTruth::p4neu, NtpMCTruth::p4neunoosc, piece, NtpSREvent::plane, RecoE::Reset(), MinosAnalysisResult::ResultList, RecoE::totalE, NtpMCFluxInfo::tptype, NtpMCFluxInfo::tpx, NtpMCFluxInfo::tpy, NtpMCFluxInfo::tpz, NtpSRVertex::u, NtpSRVertex::v, NtpSREvent::vtx, NtpMCTruth::vtxx, NtpMCTruth::vtxy, NtpMCTruth::vtxz, NtpMCTruth::w2, NtpSRVertex::x, NtpSRVertex::y, NtpMCTruth::y, and NtpSRVertex::z.

Referenced by Run().

00917                                                                {
00918   
00919   cout << "*** WriteResults ***" << endl;
00920   cout << "Going over input file again to write out results" << endl;
00921 
00922   Int_t lastrun=0;
00923   Int_t evtcont=-1;//needs to be -1 so when increased after ievt loop get 0
00924 
00925   //-->Output file and tree variables
00926   TFile *OutputFile = NULL;
00927   TTree *OutputTree = NULL;
00928   TTree *OutputTreePOT = NULL;
00929   MinosCompactEvent* pcomptevt = NULL;
00930   MinosAnalysisResult* OutputResult = NULL;
00931   int   OutputRun = 0;
00932   int   OutputSnarl = 0;
00933   int   OutputEvent = 0;
00934   int   OutputNuId = 0 ;
00935   int   OutputNuIdNoOsc = 0;
00936   int   OutputNuAction = 0 ;
00937   float OutputNuE = 0;
00938   float OutputNuENoOsc = 0;
00939   float OutputY   = 0;
00940   float OutputEMFrac   = 0;
00941   int OutputIdRes = 0;
00942 
00943   float OutputQtot    = 0;
00944   float OutputVtxX    = 0;
00945   float OutputVtxY    = 0;
00946   float OutputVtxU    = 0;
00947   float OutputVtxV    = 0;
00948   float OutputVtxZ    = 0;
00949   float OutputTVtxX   = 0;
00950   float OutputTVtxY   = 0;
00951   float OutputTVtxZ   = 0;
00952   float Outputtpx = 0 ;
00953   float Outputtpy = 0;
00954   float Outputtpz = 0;
00955   int Outputtptype = 0;
00956   int   OutputNPln    = 0;
00957   int   OutputNPlnU    = 0;
00958   int   OutputNPlnV    = 0;
00959   int   OutputNStp    = 0;
00960   int OutputMCPresel = 0;
00961   int OutputDataPresel = 0;
00962   int OutputXTalk = 0;
00963   int OutputXTalkTagged = 0;
00964   int OutputXTalkMisTagged = 0;
00965   int OutputPhysics = 0;
00966   float OutputW2 = 0;
00967   float OutputTotPt = 0;
00968     
00969   float OutputRecoE   = 0;
00970   
00971   float snarl_pot = 0;
00972   int good_snarl = 0;//1=good snarl;0=bad snarl (beam wise)
00973   float total_pot = 0;
00974   float good_pot = 0;
00975   
00976   //-->Opening input file
00977   //NtpFile* input  = new NtpFile(isMC,isMRCC);
00978   TChain *chain = new TChain("NtpSt");//new
00979   cout << "Adding INPUT file to list: " << fname << endl;
00980   //input->AddFiles(fname);
00981   chain->Add(fname);
00982 
00983   const NtpStRecord *record = 0;
00984   chain->SetBranchAddress("NtpStRecord",&record);
00985   
00986   //Get first subrun
00987   Int_t firstsubrun=0;
00988   if(chain->GetEntry(0)){
00989     firstsubrun=record->GetHeader().GetSubRun();
00990   }
00991 
00992   //while(input->GetNextRecord()){
00993   Int_t srCtr_local=input_first;//new
00994   while(chain->GetEntry(srCtr_local) && srCtr_local<=input_last){//new
00995     ++srCtr_local;
00996 
00997     //POT counting
00998     //const NtpBDLiteRecord* bdrecord  = input->GetBDRecord();
00999 
01000     good_snarl=0;
01001     static float pot = 0;
01002     /*
01003     if(bdrecord!=NULL){
01004       
01005       pot = 0;
01006       if(NtpTools::PassBeamCuts(NtpTools::kLE10, bdrecord, pot, isMC)){
01007         total_pot+=pot;
01008         good_pot+=pot;
01009         good_snarl=1;
01010       }else{
01011         total_pot+=pot;
01012         //continue;//<--uncomment if only want to save good snarls
01013       }
01014       //printf(" pot: %f sum:%f / %f       \n", pot, good_pot, total_pot);
01015     }else{
01016       cout << "no beam record for this snarl" <<endl;
01017     }//<--pot counting
01018     */
01019     snarl_pot=pot;
01020 
01021     //const NtpStRecord* record = input->GetCCRecord(); 
01022 
01023     //-->file handling
01024     if(record->GetHeader().GetRun()!=lastrun){
01025       // Close last output file
01026       if(lastrun!=0){
01027         OutputTree->AutoSave();
01028         OutputTreePOT->AutoSave();
01029         delete OutputFile;
01030       }
01031       //Create the output file and trees
01032       // This is ugly (small memory leak in recreating _ptr s)
01033       OutputResult = new MinosAnalysisResult();
01034       lastrun = record->GetHeader().GetRun();
01035       cout << " Opening output file for run : " << record->GetHeader().GetRun();
01036 
01037       //Run and subrun
01038       ostringstream e;
01039       Int_t digits=0;
01040       
01041       //-->run
01042       std::stringstream runstr;
01043       Int_t larun=record->GetHeader().GetRun();
01044       if(larun>0){
01045         digits=(int)log10((float)larun) + 1;
01046       }
01047       if(digits==0){
01048         runstr << "00000000" << larun;
01049       } else if(digits==1){
01050         runstr << "0000000" << larun;
01051       } else if(digits==2){
01052         runstr << "000000" << larun;
01053       } else if(digits==3){
01054         runstr << "00000" << larun;
01055       } else if(digits==4){
01056         runstr << "0000" << larun;
01057       } else if(digits==5){
01058         runstr << "000" << larun;
01059       } else if(digits==6){
01060         runstr << "00" << larun;
01061       } else if(digits==7){
01062         runstr << "0" << larun;
01063       } else if(digits==8){
01064         runstr << larun;
01065       }   
01066       
01067       //-->subrun
01068       std::stringstream subrunstr;     
01069       digits=0;
01070       if(firstsubrun>0){
01071         digits=(int)log10((float)firstsubrun) + 1;
01072       }
01073       if(digits==0){
01074         subrunstr << "0000";
01075       } 
01076       else if(digits==1){
01077         subrunstr << "000" << firstsubrun;
01078       }
01079       else if(digits==2){
01080         subrunstr << "00" << firstsubrun;
01081       }
01082       else if(digits==3){
01083         subrunstr << "0" << firstsubrun;
01084       } 
01085       else if(digits==4){
01086         subrunstr << firstsubrun;
01087       }
01088  
01089       //Data or MC?
01090       std::stringstream whatletter;
01091       if(record->GetHeader().GetVldContext().GetSimFlag()==SimFlag::kData){
01092         if(record->GetHeader().GetVldContext().GetDetector()==Detector::kFar){
01093           whatletter << "_F";
01094         } else {
01095           whatletter << "_N";
01096         }
01097       } else {
01098         if(record->GetHeader().GetVldContext().GetDetector()==Detector::kFar){
01099           whatletter << "_f";
01100         } else {
01101           whatletter << "_n";
01102         }
01103       }
01104 
01105       // hardcoding $MCNNTMP as a hack
01106       if(piece==-1){
01107         
01108         e << "$MCNNTMP/mcnn" << whatletter.str() << runstr.str() << "_" << subrunstr.str() << tag;
01109         
01110       } else {
01111         
01112         e << "$MCNNTMP/mcnn_" << piece << whatletter.str() << runstr.str() << "_" << subrunstr.str() << tag;
01113 
01114       }
01115       
01116       string outputfile = e.str();
01117       cout << " Writing : " << outputfile << endl;
01118       OutputFile = new TFile(gSystem->ExpandPathName(outputfile.c_str()),"recreate");
01119       OutputTree = new TTree("nn","Minos NuE Analysis Results");
01120       OutputTreePOT = new TTree("pottree","MCNN pot");
01121       OutputTree->Branch("cce","MinosCompactEvent",&pcomptevt);
01122       OutputTree->Branch("comparisonResults", "MinosAnalysisResult", &OutputResult);
01123       OutputTree->Branch("run", &OutputRun, "run/I");
01124       OutputTree->Branch("snarl", &OutputSnarl, "snarl/I");
01125       OutputTree->Branch("evt", &OutputEvent, "evt/I");
01126       OutputTree->Branch("nuid", &OutputNuId, "nuid/I");
01127       OutputTree->Branch("nuidnoosc",&OutputNuIdNoOsc,"nuidnoosc/I");
01128       OutputTree->Branch("action", &OutputNuAction, "action/I");
01129       OutputTree->Branch("nue", &OutputNuE, "nue/F");
01130       OutputTree->Branch("nuenoosc",&OutputNuENoOsc,"nuenoosc/F");
01131       OutputTree->Branch("reco_nue",&OutputRecoE,"reco_nue/F");
01132       OutputTree->Branch("y", &OutputY, "y/F");
01133       OutputTree->Branch("emfrac", &OutputEMFrac, "emfrac/F");
01134       OutputTree->Branch("ires",&OutputIdRes,"ires/I");
01135       OutputTree->Branch("qtot", &OutputQtot, "qtot/F");
01136       OutputTree->Branch("vtxx", &OutputVtxX, "vtxx/F");
01137       OutputTree->Branch("vtxy", &OutputVtxY, "vtxy/F");
01138       OutputTree->Branch("vtxz", &OutputVtxZ, "vtxz/F");
01139       OutputTree->Branch("vtxu", &OutputVtxU, "vtxu/F");
01140       OutputTree->Branch("vtxv", &OutputVtxV, "vtxv/F");
01141       OutputTree->Branch("tvtxx", &OutputTVtxX, "tvtxx/F");
01142       OutputTree->Branch("tvtxy", &OutputTVtxY, "tvtxy/F");
01143       OutputTree->Branch("tvtxz", &OutputTVtxZ, "tvtxz/F");
01144       OutputTree->Branch("tptype",&Outputtptype,"tptype/I");
01145       OutputTree->Branch("tpx",&Outputtpx,"tpx/F");
01146       OutputTree->Branch("tpy",&Outputtpy,"tpy/F");
01147       OutputTree->Branch("tpz",&Outputtpz,"tpz/F");
01148       OutputTree->Branch("npln", &OutputNPln, "npln/I");
01149       OutputTree->Branch("nstp", &OutputNStp, "nstp/I");
01150       OutputTree->Branch("nplnu", &OutputNPlnU, "nplnu/I");
01151       OutputTree->Branch("nplnv", &OutputNPlnV, "nplnv/I");       
01152       OutputTree->Branch("mcpresel",&OutputMCPresel,"mcpresel/I");
01153       OutputTree->Branch("datapresel",&OutputDataPresel,"datapresel/I");
01154       OutputTree->Branch("nxtalk",&OutputXTalk,"nxtalk/I");
01155       OutputTree->Branch("nxtalk_tagged",&OutputXTalkTagged,"nxtalk_tagged/I");
01156       OutputTree->Branch("nxtalk_mistagged",&OutputXTalkMisTagged,"nxtalk_mistagged/I"); 
01157       OutputTree->Branch("nphysics",&OutputPhysics,"nphysics/I");
01158       OutputTree->Branch("w2",&OutputW2,"w2/F");
01159       OutputTree->Branch("totpt",&OutputTotPt,"totpt/F");
01160       OutputTree->Branch("snarl_pot",&snarl_pot,"snarl_pot/F");
01161       OutputTree->Branch("good_snarl",&good_snarl,"good_snarl/I");
01162       OutputTreePOT->Branch("total_pot",&total_pot,"total_pot/F");
01163       OutputTreePOT->Branch("good_pot",&good_pot,"good_pot/F");
01164       OutputTree->SetDirectory(OutputFile);
01165       OutputTreePOT->SetDirectory(OutputFile);
01166       
01167     }//file handling
01168 
01169     for(int ievt=0;ievt<record->evthdr.nevent;++ievt){
01170 
01171       ++evtcont;
01172   
01173       const NtpSREvent* event = NtpTools::GetEvent(record, ievt);
01174       const NtpMCTruth* truth = NtpTools::GetTruth(record, ievt);
01175        
01176 
01177       //-->Fill MinosAnalysisResult for this input event (kind of ugly code this is)
01178       list<ComparisonResult>::iterator iter;
01179       list<ComparisonResult>::iterator iter_end;
01180       iter     = _compResList_untrimmed[evtcont]->compResultList.begin();
01181       iter_end = _compResList_untrimmed[evtcont]->compResultList.end();
01182       OutputResult = new MinosAnalysisResult();
01183       pcomptevt = new MinosCompactEvent(_inputAll_untrimmed[evtcont]);
01184       TClonesArray& resultList = *(OutputResult->ResultList);
01185       int i=0;
01186       while(iter!=iter_end){
01187         new(resultList[i]) ComparisonResult( &(*iter) );
01188         iter++;
01189         i++;
01190       }
01191 
01192       //-->Other variables from input file
01193       OutputRun = record->GetHeader().GetRun();
01194         OutputSnarl = record->GetHeader().GetSnarl();
01195         OutputEvent = ievt;
01196         if(truth!=0){
01197           OutputNuId = truth->inu;
01198           OutputNuIdNoOsc = truth->inunoosc;
01199           OutputNuAction  = truth->iaction;
01200           OutputNuE = truth->p4neu[3];
01201           OutputNuENoOsc = truth->p4neunoosc[3];
01202           OutputY = truth->y;   
01203           OutputEMFrac = truth->emfrac; 
01204           OutputIdRes = truth->iresonance;
01205           OutputTVtxX = truth->vtxx;
01206           OutputTVtxY = truth->vtxy;
01207           OutputTVtxZ = truth->vtxz;
01208           Outputtptype = truth->flux.tptype;
01209           Outputtpx = truth->flux.tpx;
01210           Outputtpy = truth->flux.tpy;
01211           Outputtpz = truth->flux.tpz;
01212         }
01213 
01214         OutputNPln = event->plane.n;
01215         OutputQtot = _inputAll_untrimmed[evtcont]->Qtot;
01216         OutputVtxX = event->vtx.x;
01217         OutputVtxY = event->vtx.y;
01218         OutputVtxZ = event->vtx.z;
01219         OutputVtxU = event->vtx.u;
01220         OutputVtxV = event->vtx.v;
01221         OutputNPlnU = event->plane.nu;
01222         OutputNPlnV = event->plane.nv;
01223         OutputNStp = event->nstrip;
01224 
01225         OutputXTalk = _inputAll_untrimmed[evtcont]->nxtalk;
01226         OutputXTalkTagged = _inputAll_untrimmed[evtcont]->nxtalk_tagged;
01227         OutputXTalkMisTagged = _inputAll_untrimmed[evtcont]->nxtalk_mistagged;
01228         OutputPhysics = _inputAll_untrimmed[evtcont]->nphysics;
01229 
01230         if(truth!=0){
01231           OutputW2 = truth->w2;
01232           OutputTotPt = NtpTools::GetTotHadPt(record,truth);
01233         } else {
01234           OutputW2 = -1;
01235           OutputTotPt = -1;
01236         }
01237 
01238         static RecoE* recoe = new RecoE();
01239         recoe->Reset(); 
01240         if(!NtpTools::FillRecoEInfo(record, ievt, recoe)){
01241           continue;
01242         }
01243         OutputRecoE=recoe->totalE;
01244 
01245         OutputMCPresel=0;
01246         if(MCLibraryPreselected(record,ievt)){
01247           OutputMCPresel=1;
01248         }
01249 
01250         OutputDataPresel=0;
01251         if(DataPreselected(event)){
01252           OutputDataPresel=1;
01253         }
01254         
01255         //-->fill tree
01256         OutputTree->Fill();
01257 
01258         (OutputResult->ResultList)->Delete();
01259 
01260     }//evt loop
01261 
01262     if(record->evthdr.nevent==0){//<-- an entry must still be recorded for empty snarls (otherwise cannot match with NueAna trees)
01263       
01264       OutputRun = record->GetHeader().GetRun();
01265       OutputSnarl = record->GetHeader().GetSnarl();
01266       OutputEvent = -1;
01267 
01268       OutputNuId = 0 ;
01269       OutputNuIdNoOsc = 0;
01270       OutputNuAction = 0 ;
01271       OutputNuE = 0;
01272       OutputNuENoOsc = 0;
01273       OutputY   = 0;
01274       OutputEMFrac   = 0;
01275       OutputIdRes = 0;
01276       
01277       OutputQtot    = 0;
01278       OutputVtxX    = 0;
01279       OutputVtxY    = 0;
01280       OutputVtxU    = 0;
01281       OutputVtxV    = 0;
01282       OutputVtxZ    = 0;
01283       OutputTVtxX   = 0;
01284       OutputTVtxY   = 0;
01285       OutputTVtxZ   = 0;
01286       Outputtpx = 0 ;
01287       Outputtpy = 0;
01288       Outputtpz = 0;
01289       Outputtptype = 0;
01290       OutputNPln    = 0;
01291       OutputNPlnU    = 0;
01292       OutputNPlnV    = 0;
01293       OutputNStp    = 0;
01294       OutputMCPresel = 0;
01295       OutputDataPresel = 0;
01296       OutputXTalk = 0;
01297       OutputXTalkTagged = 0;
01298       OutputXTalkMisTagged = 0;
01299       OutputPhysics = 0;
01300       OutputW2 = 0;
01301       OutputTotPt = 0;
01302       
01303       OutputRecoE   = 0;
01304 
01305       OutputTree->Fill();
01306     }//in case of empty snarl (0 events)
01307 
01308   }//record loop
01309 
01310   OutputTreePOT->Fill();
01311 
01312   cout << " Closing the output file " << endl;
01313   OutputFile->Write();
01314   OutputFile->Close();  
01315   return;  
01316   cout << "Leaving WriteResults()" << endl;
01317 
01318   delete chain;
01319 
01320 }//end of WriteResults


Member Data Documentation

std::vector<ComparisonResultList*> MCNNRunner::_compResList [private]
 

Definition at line 90 of file MCNNRunner.h.

Referenced by CompactInput(), Finish(), and MakeComparison().

std::vector<int> MCNNRunner::_compResList_size [private]
 

Definition at line 95 of file MCNNRunner.h.

Referenced by CompactInput(), and MakeComparison().

std::vector<float> MCNNRunner::_compResList_smallestDeltalnL [private]
 

Definition at line 94 of file MCNNRunner.h.

Referenced by CompactInput(), and MakeComparison().

std::vector<ComparisonResultList*> MCNNRunner::_compResList_untrimmed [private]
 

Definition at line 98 of file MCNNRunner.h.

Referenced by CompactInput(), and WriteResults().

std::vector<string> MCNNRunner::_files [private]
 

Definition at line 89 of file MCNNRunner.h.

Referenced by NextLibraryEvent(), and ReadEventLibrary().

std::vector<MinosCompactEvent*> MCNNRunner::_inputAll [private]
 

Definition at line 91 of file MCNNRunner.h.

Referenced by CompactInput(), Finish(), and MakeComparison().

std::vector<compatibilityInfo_h*> MCNNRunner::_inputAll_compatibilityInfo [private]
 

Definition at line 92 of file MCNNRunner.h.

Referenced by CompactInput(), Finish(), and MakeComparison().

std::vector<MinosCompactEvent*> MCNNRunner::_inputAll_untrimmed [private]
 

Definition at line 99 of file MCNNRunner.h.

Referenced by CompactInput(), and WriteResults().

std::vector<float> MCNNRunner::_selflnL [private]
 

Definition at line 93 of file MCNNRunner.h.

Referenced by CompactInput(), and MakeComparison().

int MCNNRunner::_workSpaceA[201][201] [private]
 

Definition at line 107 of file MCNNRunner.h.

Referenced by ClearWorkSpaceA(), CompareEvents(), FillWorkSpaceA(), and MCNNRunner().

int MCNNRunner::_workSpaceB[201][201] [private]
 

Definition at line 108 of file MCNNRunner.h.

Referenced by ClearWorkSpaceB(), CompareEvents(), FillWorkSpaceB(), and MCNNRunner().

bool MCNNRunner::atleastonelibevent [private]
 

Definition at line 84 of file MCNNRunner.h.

Referenced by MakeComparison(), MCNNRunner(), and WriteResults().

MinosEventDisplay* MCNNRunner::eventDisplay [private]
 

Definition at line 103 of file MCNNRunner.h.

Referenced by Finish().

unsigned int MCNNRunner::file_count [private]
 

Definition at line 75 of file MCNNRunner.h.

Referenced by Initialize(), and NextLibraryEvent().

HitProbTable* MCNNRunner::HPB [private]
 

Definition at line 102 of file MCNNRunner.h.

Referenced by CompareEvents(), and Initialize().

Int_t MCNNRunner::input_first [private]
 

Definition at line 77 of file MCNNRunner.h.

Referenced by MCNNRunner(), and Run().

Int_t MCNNRunner::input_last [private]
 

Definition at line 78 of file MCNNRunner.h.

Referenced by MCNNRunner(), and Run().

bool MCNNRunner::isMRCC [private]
 

Definition at line 80 of file MCNNRunner.h.

Referenced by Initialize().

int MCNNRunner::KEEP_BEST_N [private]
 

Definition at line 81 of file MCNNRunner.h.

Referenced by MakeComparison(), and MCNNRunner().

TChain* MCNNRunner::lib_chain [private]
 

Definition at line 88 of file MCNNRunner.h.

Referenced by NextLibraryEvent().

int MCNNRunner::library_event_count [private]
 

Definition at line 85 of file MCNNRunner.h.

Referenced by MakeComparison(), MCNNRunner(), and WriteResults().

int MCNNRunner::MCNNPrecutLevel [private]
 

Definition at line 83 of file MCNNRunner.h.

Referenced by CompactInput(), and MCNNRunner().

float MCNNRunner::NO_VALID_COMPARISON [private]
 

Definition at line 82 of file MCNNRunner.h.

Referenced by CompactInput(), CompareEvents(), and MCNNRunner().

MinosCompactEvent* MCNNRunner::pcce [private]
 

Definition at line 104 of file MCNNRunner.h.

Referenced by Initialize(), MakeComparison(), and NextLibraryEvent().

PECalculator* MCNNRunner::peCalculator [private]
 

Definition at line 101 of file MCNNRunner.h.

Referenced by CompareEvents(), Finish(), and Initialize().

Int_t MCNNRunner::piece [private]
 

Definition at line 79 of file MCNNRunner.h.

Referenced by MCNNRunner(), Run(), and WriteResults().

Int_t MCNNRunner::srCtr [private]
 

Definition at line 76 of file MCNNRunner.h.

Referenced by Initialize(), and NextLibraryEvent().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:09:31 2010 for loon by  doxygen 1.3.9.1