#include <AlgDeMuxGolden.h>
Inheritance diagram for AlgDeMuxGolden:

Public Member Functions | |
| AlgDeMuxGolden () | |
| virtual | ~AlgDeMuxGolden () |
| virtual void | Trace (const char *c) const |
| virtual void | RunAlg (AlgConfig &acd, CandHandle &ch, CandContext &cx) |
Private Member Functions | |
| void | SetPlanesToDeterminedFit (DmxPlaneItr &planeItr, Double_t a, Double_t b, Int_t firstPlane, Int_t lastPlane) |
| void | UseGoldenFit (DmxPlaneItr &leadPlaneItr, DmxPlaneItr &goldenPlaneItr, Int_t vertexPlane, Int_t endPlane) |
Private Attributes | |
| Int_t | fStrayPlanes |
| UInt_t | fPlanesInSet |
| Int_t | fStrayCut |
|
|
Definition at line 78 of file AlgDeMuxGolden.cxx. 00078 : 00079 fStrayPlanes(0), 00080 fPlanesInSet(6), 00081 fStrayCut(6) 00082 { 00083 //default constructor 00084 }
|
|
|
Definition at line 88 of file AlgDeMuxGolden.cxx. 00089 {
00090
00091 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 95 of file AlgDeMuxGolden.cxx. References DmxUtilities::CheckFit(), DmxUtilities::FillPlaneArray(), DmxUtilities::FindEndPlane(), DmxUtilities::FindVertexPlane(), fPlanesInSet, fStrayPlanes, Registry::GetDouble(), DmxStatus::GetEndPlaneNumber(), DmxStatus::GetEventDeMuxed(), DmxStatus::GetEventNumber(), DmxStatus::GetFigureOfMeritFailure(), Registry::GetInt(), DmxStatus::GetPlaneArray(), DmxStatus::GetVertexPlaneNumber(), DmxStatus::GetVertexZPosition(), DmxUtilities::IsOverlappingMultiple(), KeyOnGoldenU(), KeyOnGoldenV(), KeyOnLeadU(), KeyOnLeadV(), KeyPlane(), MSG, DmxStatus::ResetStatus(), DmxStatus::SetEndPlaneNumber(), DmxStatus::SetFigureOfMerit(), DmxStatus::SetMultipleMuon(), DmxStatus::SetNumberOfPlanes(), DmxStatus::SetUOverlappingMultiple(), DmxStatus::SetUStrayPlanes(), DmxStatus::SetUValidPlanes(), DmxStatus::SetValidPlanesFailure(), DmxStatus::SetVertexPlaneNumber(), DmxStatus::SetVertexPlaneZPosition(), DmxStatus::SetVOverlappingMultiple(), DmxStatus::SetVStrayPlanes(), DmxStatus::SetVValidPlanes(), and UseGoldenFit(). 00096 {
00097
00098 assert( ch.InheritsFrom("CandDeMuxDigitListHandle") );
00099 CandDeMuxDigitListHandle &cdlh = dynamic_cast<CandDeMuxDigitListHandle&>(ch);
00100 //get the AlgConfigDeMux object
00101 fPlanesInSet = acd.GetInt("PlanesInSet");
00102 //MSG("DMX", Msg::kInfo) << "window size = " << fPlanesInSet << "\tcut = " << fStrayCut << endl;
00103
00104 //get the DmxStatus object
00105 // Find the DmxStatus object or create one for needed scratch space
00106 DmxStatus *status = dynamic_cast<DmxStatus *>(gROOT->GetRootFolder()->FindObject("Loon/DeMux/DmxStatus"));
00107 bool tempStatus = false;
00108 if (status == 0) {
00109 MSG("DMXX", Msg::kDebug) << "//root/Loon/DeMux/DmxStatus not found."
00110 << " Create a temporary DmxStatus." << endl;
00111 status = new DmxStatus; // Make a temporary DmxStatus if needed
00112 tempStatus = true;
00113 }
00114 else status->ResetStatus();
00115
00116 //instantiate the DmxUtilities object and then fill DmxStatus with the event information
00117 DmxUtilities util;
00118
00119 util.FillPlaneArray(status, cdlh, acd);
00120 const TObjArray *planeArray = status->GetPlaneArray();
00121 //DmxPlane *plane = dynamic_cast<DmxPlane *>(planeArray->First());
00122 //MSG("DMX", Msg::kInfo) <<"Event = " << status->GetEventNumber() << endl;
00123
00124 //create the DmxPlaneItr over planes and program it to sort the planes
00125 DmxPlaneItr planeItr(planeArray);
00126 DmxPlaneKeyFunc *pnKF = planeItr.CreateKeyFunc();
00127 pnKF->SetFun(KeyPlane);
00128 planeItr.GetSet()->AdoptSortKeyFunc(pnKF);
00129 pnKF = 0;
00130
00131 planeItr.ResetFirst();
00132 status->SetNumberOfPlanes(planeItr.SizeSelect());
00133 status->SetVertexPlaneNumber(util.FindVertexPlane(planeItr));
00134
00135 //demux the event if there is an identified vertex
00136 if( status->GetVertexPlaneNumber() != -1){
00137
00138 planeItr.ResetFirst();
00139 planeItr.GetSet()->Slice(status->GetVertexPlaneNumber(), 500);
00140 //set the end plane number since there was a vertex plane
00141 status->SetEndPlaneNumber(util.FindEndPlane(planeItr));
00142 planeItr.GetSet()->Slice();
00143 planeItr.ResetFirst();
00144
00145 //set the z position of the vertex plane
00146 planeItr.GetSet()->Slice(status->GetVertexPlaneNumber());
00147 planeItr.ResetFirst();
00148 status->SetVertexPlaneZPosition(dynamic_cast<DmxPlane *>(planeItr.Ptr())->GetZPosition());
00149
00150 planeItr.GetSet()->Slice();
00151 planeItr.ResetFirst();
00152
00153 //DmxPlane *plane = dynamic_cast<DmxPlane *>(planeArray->First());
00154 //MSG("DMX", Msg::kInfo) <<"Event = " << status->GetEventNumber() << endl;
00155
00156 //create two DmxPlaneItrs
00157 DmxPlaneItr leadPlaneItr(planeArray);
00158 DmxPlaneItr vertexPlaneItr(planeArray);
00159 DmxPlaneItr goldenPlaneItr(planeArray);
00160
00161 //create a KeyFunc to sort planes by number
00162 DmxPlaneKeyFunc *pnKF = leadPlaneItr.CreateKeyFunc();
00163 DmxPlaneKeyFunc *vertexPlaneKF = vertexPlaneItr.CreateKeyFunc();
00164 DmxPlaneKeyFunc *goldenPlaneKF = goldenPlaneItr.CreateKeyFunc();
00165
00166 //program the KeyFunc with the sort function
00167 pnKF->SetFun(KeyPlane);
00168 vertexPlaneKF->SetFun(KeyPlane);
00169 goldenPlaneKF->SetFun(KeyPlane);
00170
00171 //get the NavSet from the iterator and pass the KeyFunc to it
00172 leadPlaneItr.GetSet()->AdoptSortKeyFunc(pnKF);
00173 vertexPlaneItr.GetSet()->AdoptSortKeyFunc(vertexPlaneKF);
00174 goldenPlaneItr.GetSet()->AdoptSortKeyFunc(goldenPlaneKF);
00175
00176 //clear the KF pointer because we no longer own the KeyFunc
00177
00178 pnKF = 0;
00179 vertexPlaneKF = 0;
00180 goldenPlaneKF = 0;
00181 leadPlaneItr.ResetFirst();
00182 goldenPlaneItr.ResetFirst();
00183 vertexPlaneItr.ResetFirst();
00184
00185 //now program a key function to select on plane orientation - U first
00186 DmxPlaneKeyFunc *orientGoldenUKF = goldenPlaneItr.CreateKeyFunc();
00187 DmxPlaneKeyFunc *orientLeadUKF = leadPlaneItr.CreateKeyFunc();
00188 DmxPlaneKeyFunc *orientGoldenVKF = goldenPlaneItr.CreateKeyFunc();
00189 DmxPlaneKeyFunc *orientLeadVKF = leadPlaneItr.CreateKeyFunc();
00190
00191 Int_t viewCtr = 0;
00192 while( viewCtr < 2 ){
00193
00194 if( viewCtr == 0){
00195 //program this function with the select function
00196 orientLeadUKF->SetFun(KeyOnLeadU);
00197 orientGoldenUKF->SetFun(KeyOnGoldenU);
00198
00199 //adopt it as a selection function
00200 leadPlaneItr.GetSet()->AdoptSelectKeyFunc(orientLeadUKF);
00201 orientLeadUKF = 0;
00202 leadPlaneItr.Reset();
00203 goldenPlaneItr.GetSet()->AdoptSelectKeyFunc(orientGoldenUKF);
00204 orientGoldenUKF = 0;
00205 goldenPlaneItr.Reset();
00206 }
00207 else if(viewCtr == 1){
00208 //program this function with the select function
00209 orientLeadVKF->SetFun(KeyOnLeadV);
00210 orientGoldenVKF->SetFun(KeyOnGoldenV);
00211
00212 //adopt it as a selection function
00213 leadPlaneItr.GetSet()->AdoptSelectKeyFunc(orientLeadVKF);
00214 orientLeadVKF = 0;
00215 leadPlaneItr.Reset();
00216 goldenPlaneItr.GetSet()->AdoptSelectKeyFunc(orientGoldenVKF);
00217 orientGoldenVKF = 0;
00218 goldenPlaneItr.Reset();
00219 }
00220
00221 //slice to those planes from the vertex on
00222 goldenPlaneItr.GetSet()->Slice(status->GetVertexPlaneNumber(), status->GetEndPlaneNumber());
00223
00224 if(goldenPlaneItr.SizeSelect() >=2 ){
00225
00226 //MSG("DMX", Msg::kInfo) << "event " << status->GetEventNumber() << endl;
00227 //loop over the golden planes and set them
00228 while(goldenPlaneItr.IsValid() ){
00229
00230 //MSG("DMX", Msg::kInfo) << dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetPlaneNumber() << endl;
00231 if(dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetPlaneType() == DmxPlaneTypes::kShower){
00232 dynamic_cast<DmxShowerPlane *>(goldenPlaneItr.Ptr())->SetStrips("best");
00233 }
00234 goldenPlaneItr.Next();
00235 }//end setting golden planes
00236
00237 goldenPlaneItr.Reset();
00238
00239 UseGoldenFit(leadPlaneItr, goldenPlaneItr, status->GetVertexPlaneNumber(),
00240 status->GetEndPlaneNumber());
00241
00242 //check the fit
00243 fStrayPlanes -= util.CheckFit(leadPlaneItr);
00244
00245 //what about multiple muons? look for another vertex after the end plane
00246 leadPlaneItr.GetSet()->Slice();
00247 goldenPlaneItr.GetSet()->Slice();
00248 vertexPlaneItr.GetSet()->Slice(status->GetEndPlaneNumber()+1, 500);
00249 //MSG("DMX1", Msg::kInfo)<< "event = " << status->GetEventNumber()
00250 // << "\tend plane = " << status->GetEndPlaneNumber() << endl;
00251
00252 Int_t nextVertex = -1;
00253 if(vertexPlaneItr.SizeSelect() > 3) nextVertex = util.FindVertexPlane(vertexPlaneItr);
00254
00255 while( nextVertex != -1){
00256
00257 status->SetMultipleMuon(true);
00258 vertexPlaneItr.GetSet()->Slice();
00259 vertexPlaneItr.GetSet()->Slice(nextVertex, 500);
00260
00261 //get the next end plane
00262 Int_t endPlane = util.FindEndPlane(vertexPlaneItr);
00263
00264 //MSG("DMX1", Msg::kInfo)<< "\tin double muon loop, vertex at plane " << nextVertex
00265 // << "\tend plane = " << endPlane << "\tplanes in slice = "
00266 // << vertexPlaneItr.SizeSelect() << endl;
00267
00268 goldenPlaneItr.GetSet()->Slice(nextVertex, endPlane);
00269
00270 if(goldenPlaneItr.SizeSelect() >= 2 ){
00271 //loop over the golden planes and set them
00272 while(goldenPlaneItr.IsValid() ){
00273
00274 if(dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetPlaneType() == DmxPlaneTypes::kShower){
00275 dynamic_cast<DmxShowerPlane *>(goldenPlaneItr.Ptr())->SetStrips("best");
00276 }
00277 goldenPlaneItr.Next();
00278 }
00279
00280 goldenPlaneItr.Reset();
00281
00282 UseGoldenFit(leadPlaneItr, goldenPlaneItr, status->GetVertexPlaneNumber(),
00283 status->GetEndPlaneNumber());
00284
00285 //check the fit
00286 fStrayPlanes -= util.CheckFit(leadPlaneItr);
00287
00288 //CheckFitWithTiming(ch, planeItr);
00289
00290 }//end if enough golden planes to try
00291
00292 //look for another vertex after the end plane
00293 leadPlaneItr.GetSet()->Slice();
00294 goldenPlaneItr.GetSet()->Slice();
00295 vertexPlaneItr.GetSet()->Slice();
00296 vertexPlaneItr.GetSet()->Slice(endPlane+1, 500);
00297 //MSG("DMX1", Msg::kInfo)<< "\tlook for new vertex, slice from " << endPlane+1
00298 // << "\tto plane 500, planes in slice = "
00299 // << vertexPlaneItr.SizeSelect() << endl;
00300
00301 vertexPlaneItr.Reset();
00302
00303 if(vertexPlaneItr.SizeSelect() > 0){
00304 nextVertex = util.FindVertexPlane(vertexPlaneItr);
00305 }
00306 else{ nextVertex = -1; }
00307 }//end loop over new verticies
00308 }//end if at least 2 golden planes
00309 else{
00310 MSG("DMX", Msg::kWarning)<< "Event " << status->GetEventNumber()
00311 << " not demuxed; not enough golden planes in view" << endl;
00312 status->SetValidPlanesFailure(true);
00313 } //not enough planes to demux
00314
00315 status->SetFigureOfMerit(goldenPlaneItr.SizeSelect(), fStrayPlanes);
00316 if(viewCtr == 0 && status->GetEventDeMuxed()){
00317 status->SetUStrayPlanes(fStrayPlanes);
00318 status->SetUValidPlanes(goldenPlaneItr.SizeSelect());
00319 if( status->GetFigureOfMeritFailure() )
00320 //see if the event failed the figure of Merit test, if so, see if it is an
00321 //overlapping muon
00322 status->SetUOverlappingMultiple(util.IsOverlappingMultiple(goldenPlaneItr, status->GetVertexZPosition(),
00323 acd.GetDouble("HoughInterceptRMSLimit"),
00324 acd.GetDouble("HoughSlopeRMSLimit"),
00325 acd.GetDouble("HoughPeakLimit")));
00326 }
00327 if(viewCtr == 1 && status->GetEventDeMuxed()){
00328 status->SetVStrayPlanes(fStrayPlanes);
00329 status->SetVValidPlanes(goldenPlaneItr.SizeSelect());
00330 //see if the event failed the figure of Merit test, if so, see if it is an
00331 //overlapping muon
00332 if( status->GetFigureOfMeritFailure() )
00333 status->SetVOverlappingMultiple(util.IsOverlappingMultiple(goldenPlaneItr, status->GetVertexZPosition(),
00334 acd.GetDouble("HoughInterceptRMSLimit"),
00335 acd.GetDouble("HoughSlopeRMSLimit"),
00336 acd.GetDouble("HoughPeakLimit")));
00337 }
00338
00339 //done using the first view, so clear the selection function
00340 //MSG("Dmx", Msg::kInfo) <<"Done with View " << viewCtr << endl;
00341 vertexPlaneItr.GetSet()->Slice();
00342 leadPlaneItr.GetSet()->Slice();
00343 leadPlaneItr.GetSet()->AdoptSelectKeyFunc(0);
00344 leadPlaneItr.Reset();
00345 goldenPlaneItr.GetSet()->Slice();
00346 goldenPlaneItr.GetSet()->AdoptSelectKeyFunc(0);
00347 goldenPlaneItr.Reset();
00348
00349 ++viewCtr;
00350 } //end loop over views
00351
00352 }//end if event has a vertex
00353 return;
00354 }
|
|
||||||||||||||||||||||||
|
Definition at line 438 of file AlgDeMuxGolden.cxx. References DmxPlane::GetPlaneNumber(), DmxPlane::GetZPosition(), and DmxPlane::SetStrips(). Referenced by UseGoldenFit(). 00441 {
00442 planeItr.ResetFirst();
00443
00444 while( planeItr.IsValid() ){
00445
00446 DmxPlane *plane = dynamic_cast<DmxPlane *>(planeItr.Ptr());
00447 //MSG("DMX", Msg::kInfo)<<"\tin SetPlanesToDeterminedFit " << plane->GetPlaneNumber() << endl;
00448
00449 if(plane->GetPlaneNumber()>=firstPlane && plane->GetPlaneNumber()<=lastPlane){
00450 Double_t fitCoG = a + (plane->GetZPosition() * b);
00451
00452 plane->SetStrips(fitCoG);
00453 }//end if plane is in the window bounds
00454
00455 planeItr.Next();
00456 }
00457
00458 planeItr.Reset();
00459
00460 return;
00461 }
|
|
|
Reimplemented from AlgBase. Definition at line 357 of file AlgDeMuxGolden.cxx. 00358 {
00359 }
|
|
||||||||||||||||||||
|
Definition at line 363 of file AlgDeMuxGolden.cxx. References DmxUtilities::FindPlanesOffFit(), fStrayCut, fStrayPlanes, and SetPlanesToDeterminedFit(). Referenced by RunAlg(). 00365 {
00366
00367 //get the number of loops you have to iterate over. you have (# golden planes - 1)
00368 //loops to go through them each
00369 Int_t numLoops = goldenPlaneItr.SizeSelect() - 1;
00370 Int_t loopCtr = 0;
00371 DmxUtilities util = DmxUtilities();
00372
00373 goldenPlaneItr.Reset();
00374
00375 while(loopCtr < numLoops){
00376
00377
00378 Int_t goldCtr = 0;
00379 Float_t goldCoG1 = -1.;
00380 Float_t goldCoG2 = -1.;
00381 Float_t goldZ1 = -1.;
00382 Float_t goldZ2 = -1.;
00383 Int_t firstPlane = -1;
00384 Int_t lastPlane = -1;
00385 //get the cog's for the next two golden planes
00386 while(goldCtr < 2 && goldenPlaneItr.IsValid()){
00387
00388 //advance the iterator only if on the first plane of the set - that way the first plane
00389 //in the next set is the last in this one
00390 if(goldCtr == 0){
00391 firstPlane = dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetPlaneNumber();
00392 goldCoG1 = dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetCoG();
00393 goldZ1 = dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetZPosition();
00394 goldenPlaneItr.Next();
00395 }
00396 else if(goldCtr == 1){
00397 lastPlane = dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetPlaneNumber();
00398 goldCoG2 = dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetCoG();
00399 goldZ2 = dynamic_cast<DmxPlane*>(goldenPlaneItr.Ptr())->GetZPosition();
00400 }
00401 ++goldCtr;
00402 }//end loop over golden planes
00403
00404 //find the slope and intercept between the two golden plane centers of gravity
00405 Float_t slope = (goldCoG2 - goldCoG1)/(goldZ2 - goldZ1);
00406 Float_t intercept = goldCoG2 - goldZ2*slope;
00407
00408 //MSG("DMX", Msg::kInfo) << "first gold plane " << goldCoG1 << " " << goldZ1
00409 // << " second " << goldCoG2 << " " << goldZ2 << " " << slope << " " << intercept << endl;
00410
00411 //slice the lead plane iterator to be between the golden planes.
00412 //if first loop, slice from vertex to second golden plane
00413 //if last loop, slice from first golden plane to end plane
00414
00415 if(loopCtr == 0) firstPlane = vertexPlane;
00416 else if(loopCtr == numLoops-1) lastPlane = endPlane;
00417
00418 leadPlaneItr.GetSet()->Slice(firstPlane, lastPlane);
00419
00420 SetPlanesToDeterminedFit(leadPlaneItr, intercept, slope, firstPlane, lastPlane);
00421
00422 fStrayPlanes += util.FindPlanesOffFit(leadPlaneItr, fStrayCut);
00423
00424 //clear the lead plane slice
00425 leadPlaneItr.GetSet()->Slice();
00426
00427 ++loopCtr;
00428 }//end loop over sets of goldenPlanes
00429
00430 leadPlaneItr.Reset();
00431 goldenPlaneItr.Reset();
00432 return;
00433
00434 }
|
|
|
Definition at line 39 of file AlgDeMuxGolden.h. Referenced by RunAlg(). |
|
|
Definition at line 40 of file AlgDeMuxGolden.h. Referenced by UseGoldenFit(). |
|
|
Definition at line 38 of file AlgDeMuxGolden.h. Referenced by RunAlg(), and UseGoldenFit(). |
1.3.9.1