ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/grimes/L1Menu/src/TriggerRatePlot.cpp
(Generate patch)

Comparing UserCode/grimes/L1Menu/src/TriggerRatePlot.cpp (file contents):
Revision 1.6 by grimes, Sat Jun 29 16:14:45 2013 UTC vs.
Revision 1.7 by grimes, Tue Jul 2 23:30:37 2013 UTC

# Line 103 | Line 103 | l1menu::TriggerRatePlot::~TriggerRatePlo
103          }
104   }
105  
106 < void l1menu::TriggerRatePlot::addEvent( const l1menu::L1TriggerDPGEvent& event )
106 > void l1menu::TriggerRatePlot::addEvent( const l1menu::IEvent& event )
107   {
108 <        // loop over all of the bins in the histogram, and see if the trigger passes
109 <        // for the value at the center of the bin.
108 >        const l1menu::ISample& sample=event.sample();
109 >        float weightPerEvent=sample.eventRate()/sample.sumOfWeights();
110 >
111 >        // For some implementations of ISample, it is significantly faster to
112 >        // create ICachedTriggers and then loop over those.
113 >        std::unique_ptr<l1menu::ICachedTrigger> pCachedTrigger=sample.createCachedTrigger( *pTrigger_ );
114 >
115          for( int binNumber=1; binNumber<pHistogram_->GetNbinsX(); ++binNumber )
116          {
117                  (*pParameter_)=pHistogram_->GetBinCenter(binNumber);
# Line 114 | Line 119 | void l1menu::TriggerRatePlot::addEvent(
119                  // Scale accordingly any other parameters that should be scaled.
120                  for( const auto& parameterScalingPair : otherParameterScalings_ ) *(parameterScalingPair.first)=parameterScalingPair.second*(*pParameter_);
121  
122 <                if( pTrigger_->apply( event ) )
122 >                if( pCachedTrigger->apply(event) )
123                  {
124 <                        pHistogram_->Fill( (*pParameter_), event.weight() );
124 >                        pHistogram_->Fill( (*pParameter_), event.weight()*weightPerEvent );
125                  }
126 <                // could put an "else break" in here, but I don't know if triggers
126 >                else break;
127 >                // Not sure if this "else break" is a good idea. I don't know if triggers
128                  // will run their thresholds the other way. E.g. a trigger could require
129                  // a minimum amount of energy in the event, in which case the higher
130                  // bins will pass.
# Line 148 | Line 154 | void l1menu::TriggerRatePlot::addSample(
154                          {
155                                  pHistogram_->Fill( (*pParameter_), event.weight()*weightPerEvent );
156                          }
157 <                        // could put an "else break" in here, but I don't know if triggers will
158 <                        // run their thresholds the other way. E.g. a trigger could require
157 >                        else break;
158 >                        // Not sure if this "else break" is a good idea. I don't know if triggers
159 >                        // will run their thresholds the other way. E.g. a trigger could require
160                          // a minimum amount of energy in the event, in which case the higher
161                          // bins will pass.
162                  } // end of loop over histogram bins
# Line 162 | Line 169 | const l1menu::ITrigger& l1menu::TriggerR
169          return *pTrigger_;
170   }
171  
165 void l1menu::TriggerRatePlot::initiateForReducedSample( const l1menu::ReducedMenuSample& sample )
166 {
167        pTrigger_->initiateForReducedSample( sample );
168 }
169
170 void l1menu::TriggerRatePlot::addEvent( const l1menu::ReducedEvent& event )
171 {
172        // Basically exactly the same as for the l1menu::L1TriggerDPGEvent version. I
173        // should probably template this.
174        for( int binNumber=1; binNumber<pHistogram_->GetNbinsX(); ++binNumber )
175        {
176                (*pParameter_)=pHistogram_->GetBinCenter(binNumber);
177
178                // Scale accordingly any other parameters that should be scaled.
179                for( const auto& parameterScalingPair : otherParameterScalings_ ) *(parameterScalingPair.first)=parameterScalingPair.second*(*pParameter_);
180
181                if( pTrigger_->apply( event ) )
182                {
183                        pHistogram_->Fill( (*pParameter_), event.weight() );
184                }
185        }
186
187 }
188
172   TH1* l1menu::TriggerRatePlot::getPlot()
173   {
174          return pHistogram_.get();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines