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

Clust2D.cxx

Go to the documentation of this file.
00001 
00002 // $Id: Clust2D.cxx,v 1.2 2009/08/17 13:11:50 jpaley Exp $
00003 //
00004 // A simple algorithm to form 2D clusters from rb::CalHits
00005 //
00006 // \author $Author: jpaley $
00007 //
00009 
00010 #include "Clusterer/Clust2D.h"
00011 #include "RecoBase/CellHit.h"
00012 #include "RecoBase/Cluster.h"
00013 #include "Geometry/Geometry.h"
00014 #include "JobControl/Exception.h"
00015 
00016 #include <iostream>
00017 #include <map>
00018 
00019 using namespace clust;
00020 using namespace recobase;
00021 using namespace std;
00022 
00023 MODULE_DECL(Clust2D); 
00024 
00025 Clust2D::Clust2D(const char* version) :
00026   jobc::Module("clust::Clust2D") 
00027 {
00028   // Set the configuration version tag
00029   this->SetCfgVersion(version); 
00030 }
00031 
00032 //......................................................................
00033 
00034 void Clust2D::Update(const cfg::Config& c)
00035 {
00036   fInFolder.clear();
00037   fOutFolder.clear();
00038 
00039   try { c("InFolder").Get(fInFolder); }
00040   catch (cfg::Exception e) {
00041     string s;
00042     c("InFolder").Get(s);
00043     fInFolder.push_back(s);
00044   }
00045 
00046   try { c("OutFolder").Get(fOutFolder); }
00047   catch (cfg::Exception e) {
00048     string s;
00049     c("OutFolder").Get(s);
00050     fOutFolder.push_back(s);
00051   }
00052 
00053   assert_jobc(fOutFolder.size() == fInFolder.size(),
00054 "Clust2D::Update error: Num. Input Folders does not equal Num. Output Folders");
00055 
00056 }
00057 
00058 //......................................................................
00059 
00060 Clust2D::~Clust2D()
00061 {
00062 
00063 }
00064 
00065 //......................................................................
00066 
00067 jobc::Result Clust2D::Reco(edm::EventHandle& evt)
00068 {
00069 
00070   for (unsigned int iFld=0; iFld < fInFolder.size(); ++iFld) {
00071 
00072     vector<const CellHit*> cell(0);
00073     try { evt.Cal().Get(fInFolder[iFld].c_str(),cell); }
00074     catch (edm::Exception e) {
00075       continue;
00076     } 
00077 
00078     vector<Cluster*> clust(0);
00079     typedef map<int, vector<const CellHit*> > CellMap;
00080     typedef CellMap::iterator CMItr;
00081 
00082     CellMap mapCell;
00083     for (unsigned int i=0; i<cell.size(); ++i) {
00084       int plane = cell[i]->Plane();
00085       mapCell[plane].push_back(cell[i]);
00086     }
00087 
00088     CMItr itr    = mapCell.begin();
00089     CMItr itrEnd = mapCell.end();
00090 
00091     for (; itr != itrEnd; ++itr) {
00092       vector<const CellHit*>& chvec = itr->second;
00093       Cluster* cl = new Cluster();
00094       for (unsigned int j=0; j<chvec.size(); ++j) {
00095         recobase::CellHit* cell = new recobase::CellHit(*chvec[j]);
00096         cl->Add(cell);
00097       }
00098       clust.push_back(cl);
00099     }
00100     
00101     evt.Reco().MakeFolder(fOutFolder[iFld].c_str());
00102 
00103     evt.Reco().PutVector(clust,fOutFolder[iFld].c_str());
00104 
00105     // now clean up...
00106     for (unsigned int i=0; i<clust.size(); ++i) delete clust[i];
00107   }
00108   
00109   return jobc::kPassed; // kFailed if you want to fail the event
00110 }
00111 

Generated on Mon Nov 23 04:45:25 2009 for NOvA Offline by  doxygen 1.3.9.1