ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/AnaFwkMod.cc
(Generate patch)

Comparing UserCode/MitAna/TreeMod/src/AnaFwkMod.cc (file contents):
Revision 1.7 by loizides, Thu Mar 12 18:25:35 2009 UTC vs.
Revision 1.12 by loizides, Fri Jun 19 07:39:01 2009 UTC

# Line 17 | Line 17 | AnaFwkMod::AnaFwkMod(const char *name, c
17    BaseMod(name,title),
18    fAllHeadTreeName(Names::gkAllEvtTreeName),
19    fAllHeadBrName(Names::gkAllEvtHeaderBrn),
20 +  fSkipNEvents(0),
21 +  fPrintScale(100),
22    fSWtotal(0),
23    fSWevent(0),
24    fAllHeaders(0,Names::gkSkimmedHeaders),
# Line 24 | Line 26 | AnaFwkMod::AnaFwkMod(const char *name, c
26    fAllEventHeader(0),
27    fReload(kFALSE),
28    fCurEnt(-2),
29 <  fNEventsSkimmed(0)
29 >  fNEventsSkimmed(0),
30 >  fNEventsSkipped(0)
31   {
32    // Constructor.
33   }
# Line 47 | Line 50 | void AnaFwkMod::BeginRun()
50      if (!file)
51        return;
52  
53 <    // get HLT tree
53 >    // get all event header tree
54      fAllHeadTree = dynamic_cast<TTree*>(file->Get(fAllHeadTreeName));
55      if (!fAllHeadTree) {
56        SendError(kWarning, "BeginRun",
57 <                "Can not find tree '%s' in file '%s'",
57 >                "Cannot find tree '%s' in file '%s'",
58                  fAllHeadTreeName.Data(),file->GetName());
59        return;
60      }
58  }
61  
62 <  // get HLT trigger name branch
63 <  if (fAllHeadTree->GetBranch(fAllHeadBrName)) {
64 <    fAllHeadTree->SetBranchAddress(fAllHeadBrName, &fAllEventHeader);
65 <  } else {
66 <    SendError(kWarning, "BeginRun",
67 <              "Can not find branch '%s' in tree '%s'",
68 <              fAllHeadBrName.Data(), fAllHeadTreeName.Data());
69 <    return;
62 >    // get all event header branch
63 >    if (fAllHeadTree->GetBranch(fAllHeadBrName)) {
64 >      fAllHeadTree->SetBranchAddress(fAllHeadBrName, &fAllEventHeader);
65 >    } else {
66 >      SendError(kWarning, "BeginRun",
67 >                "Cannot find branch '%s' in tree '%s'",
68 >                fAllHeadBrName.Data(), fAllHeadTreeName.Data());
69 >      return;
70 >    }
71    }
72   }
73  
# Line 77 | Line 80 | void AnaFwkMod::CopyAllEventHeaders()
80  
81    const EventHeader *curev = GetEventHeader();
82    if (!curev) {
83 <    SendError(kWarning, "CopyAllEventHeaders", "Can not obtain current event");
83 >    SendError(kWarning, "CopyAllEventHeaders", "Cannot obtain current event");
84      return;
85    }
86  
# Line 152 | Line 155 | Bool_t AnaFwkMod::Notify()
155   //--------------------------------------------------------------------------------------------------
156   void AnaFwkMod::Process()
157   {
158 <  // Do event counting and print out timing information.
158 >  // Do event skipping and counting and print out timing information.
159  
160 +  // counting processed events
161 +  IncNEventsProcessed();
162    
163    // get skimmed event headers
164    CopyAllEventHeaders();
165    fNEventsSkimmed += fAllHeaders.GetEntries();
166  
167 <  // counting events
168 <  IncNEventsProcessed();
167 >  // check if events should be skipped
168 >  if (fNEventsSkipped<fSkipNEvents) {
169 >    ++fNEventsSkipped;
170 >    MDB(kAnalysis, 3) {
171 >      Info("Process", "Skipping (aborting) %d out of %d first events.",
172 >           fNEventsSkipped, fSkipNEvents);
173 >    }
174 >    AbortEvent();
175 >    return;
176 >  }
177  
178    // check if printout should be done
179    Bool_t doPrint = 0;
180  
181    MDB(kAnalysis, 4) {
182 <    if (GetNEventsProcessed() % 1000  == 0)
182 >    if (GetNEventsProcessed() % (fPrintScale)  == 0)
183        doPrint = 1;
184    } else {
185      MDB(kAnalysis, 3) {
186 <      if (GetNEventsProcessed() % 10000  == 0)
186 >      if (GetNEventsProcessed() % (fPrintScale*10)  == 0)
187          doPrint = 1;
188      } else {
189        MDB(kAnalysis, 2) {
190 <        if (GetNEventsProcessed() % 50000  == 0)
190 >        if (GetNEventsProcessed() % (fPrintScale*100)  == 0)
191            doPrint = 1;
192        } else {
193          MDB(kAnalysis, 1) {
194 <          if (GetNEventsProcessed() % 250000 == 0)
194 >          if (GetNEventsProcessed() % (fPrintScale*1000) == 0)
195              doPrint = 1;
196          }
197        }
# Line 187 | Line 200 | void AnaFwkMod::Process()
200  
201    if (doPrint) {
202      fSWevent->Stop();
203 <    Info("Process", "Events %d -> %.2gs real, %.2gs cpu (%.2g real, %.2g cpu per event)",
203 >    Info("Process",
204 >         "Events %d -> %.2gs real, %.2gs cpu (%.2g real, %.2g cpu per event)",
205           GetNEventsProcessed(), fSWevent->RealTime(), fSWevent->CpuTime(),
206 <         fSWevent->RealTime()/GetNEventsProcessed(), fSWevent->CpuTime()/GetNEventsProcessed());
206 >         fSWevent->RealTime()/GetNEventsProcessed(),
207 >         fSWevent->CpuTime()/GetNEventsProcessed());
208      fSWevent->Start();
209    }  
210   }
# Line 201 | Line 216 | void AnaFwkMod::SlaveBegin()
216  
217    fSWtotal = new TStopwatch;
218    fSWevent = new TStopwatch;
219 +  cout << fSkipNEvents << endl;
220  
221    if (!PublishObj(&fAllHeaders)) {
222      SendError(kAbortAnalysis, "SlaveBegin",
# Line 222 | Line 238 | void AnaFwkMod::SlaveTerminate()
238    hDAllEvents->SetEntries(fNEventsSkimmed+GetNEventsProcessed());
239    AddOutput(hDAllEvents);
240  
241 +  TH1D *hDSkippedEvents = new TH1D("hDSkippedEvents","Number of skipped events",1,-0.5,0.5);
242 +  hDSkippedEvents->Fill(0.0,fNEventsSkipped);
243 +  hDSkippedEvents->SetEntries(fNEventsSkipped);
244 +  AddOutput(hDSkippedEvents);
245 +
246    fSWtotal->Stop();
247    fSWevent->Stop();
248  
249    MDB(kAnalysis, 1)
250 <    Info("SlaveTerminate", "Events %d -> %.2gs real, %.2gs cpu (%.2gs real, %.2gs cpu per event)",
250 >    Info("SlaveTerminate",
251 >         "Events %d -> %.2gs real, %.2gs cpu (%.2gs real, %.2gs cpu per event)",
252           GetNEventsProcessed(), fSWtotal->RealTime(), fSWtotal->CpuTime(),
253 <         fSWtotal->RealTime()/GetNEventsProcessed(), fSWtotal->CpuTime()/GetNEventsProcessed());
253 >         fSWtotal->RealTime()/GetNEventsProcessed(),
254 >         fSWtotal->CpuTime()/GetNEventsProcessed());
255  
256    delete fSWtotal;
257    delete fSWevent;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines