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

fillntup::FillNtup Class Reference

#include <FillNtup.h>

Inheritance diagram for fillntup::FillNtup:

jobc::Module cfg::Observer List of all members.

Public Member Functions

 FillNtup (const char *version)
void Update (const cfg::Config &c)
virtual ~FillNtup ()
jobc::Result Ana (const edm::EventHandle &evt)
void FillEventInfo (const edm::EventHandle &evt)
void FillMCTruth (const simb::MCTruth *particles)
void FillTrackReco (vector< const recobase::TrackBase * > tracks)
void FillShowerReco (vector< const recobase::ShowerBase * > showers)
void FillShower3DReco (vector< const recobase::ShowerBase3D * > showers3D)

Private Attributes

string fTreeName
short fDetGeom
geo::GeometryfGeo
string fEventName
string fTrackRecoName
string fShowerRecoName
string fShower3DRecoName
string fClassName

Constructor & Destructor Documentation

FillNtup::FillNtup const char *  version  ) 
 

Definition at line 30 of file FillNtup.cxx.

References jobc::Module::SetCfgVersion().

00030                                       : 
00031   jobc::Module("FillNtup"),
00032   fDetGeom(1), 
00033   fGeo(0)
00034 {
00035   this->SetCfgVersion(version);
00036 }

FillNtup::~FillNtup  )  [virtual]
 

Definition at line 40 of file FillNtup.cxx.

References fTreeName, SAnaNtup::Save(), and sn.

00041 {
00042   sn.Save(fTreeName);
00043 }


Member Function Documentation

jobc::Result FillNtup::Ana const edm::EventHandle evt  )  [virtual]
 

Reimplemented from jobc::Module.

Definition at line 64 of file FillNtup.cxx.

References StdNtup::Clear(), fGeo, SAnaNtup::Fill(), FillEventInfo(), FillMCTruth(), FillShower3DReco(), fShower3DRecoName, fShowerRecoName, fTrackRecoName, fTreeName, util::EDMUtils::GetGeometry(), gMyNt, edm::EventHandle::MC(), edm::EventHandle::Reco(), StdNtup::SetEvent(), StdNtup::SetNShw(), and sn.

00065 {
00066 
00067   if (!fGeo)  fGeo = &util::EDMUtils::GetGeometry(evt);
00068 
00069   bool mctruth_flag      = true;
00070   bool trackreco_flag    = true;
00071   bool showerreco_flag   = true;
00072   bool shower3dreco_flag = true;
00073   bool event_flag        = true;
00074  
00075   vector<const simb::MCTruth*> particles(0);
00076   try{
00077     evt.MC().Get("./",particles);
00078   }
00079   catch(edm::Exception e) {
00080     mctruth_flag = false;
00081   }  
00082 
00083   // Get Track Sengemnts
00084   vector<const recobase::TrackBase*> tracks(0);
00085   try{
00086     evt.Reco().Get(fTrackRecoName.c_str(),tracks);
00087   }
00088   catch(edm::Exception e) {
00089     trackreco_flag = false;
00090   }
00091   
00092   // Get 2D Showers
00093   vector<const recobase::ShowerBase*> showers(0);
00094   try{
00095     evt.Reco().Get(fShowerRecoName.c_str(),showers);
00096   }
00097   catch(edm::Exception e) {
00098     showerreco_flag = false;
00099   }
00100 // Get 3D Showers
00101   vector<const recobase::ShowerBase3D*> showers3d(0);
00102   try{
00103     evt.Reco().Get(fShower3DRecoName.c_str(),showers3d);
00104   }
00105   catch(edm::Exception e) {
00106     shower3dreco_flag = false;
00107   }
00108   
00109   // loop for neutrino interactions in one spill
00110   for(unsigned int event=0; event<particles.size(); event++) {
00111 
00112     gMyNt->Clear();
00113 
00114     // fill event #
00115     gMyNt->SetEvent(event);
00116      
00117     // fill MC truth information
00118     if(mctruth_flag) FillMCTruth(particles[event]);
00119 
00120     // fill track reconstruction quantity
00121     // if(trackreco_flag) FillTrackReco(tracks);
00122     // Comment by M. Ishitsuka, September 7, 2008.
00123     // "tracks" from RecoPrimo currently stores single event, so
00124     // I use the same tracks repeatedly for all interactions
00125     
00126     //if(showerreco_flag)   FillShowerReco(showers);
00127            
00128     gMyNt->SetNShw(showers.size());
00129     
00130     if(shower3dreco_flag)  FillShower3DReco(showers3d);
00131     
00132     if(event_flag)         FillEventInfo(evt);
00133           
00134     sn.Fill(fTreeName);
00135 
00136   }
00137  
00138   return jobc::kPassed;
00139 }

void FillNtup::FillEventInfo const edm::EventHandle evt  ) 
 

Definition at line 141 of file FillNtup.cxx.

References StdNtup::AddEvtCells(), StdNtup::AddEvtLength(), StdNtup::AddEvtPH(), StdNtup::AddEvtWidth(), recobase::CellHit::Cell(), fGeo, util::EDMUtils::GetGeometry(), gMyNt, recobase::CellHit::Plane(), edm::EventHandle::Reco(), and recobase::CellHit::View().

Referenced by Ana().

00141                                                      {
00142   
00143   std::vector<const recobase::CellHit*> pStpstemp;
00144          
00145   evt.Reco().Get("Hits",pStpstemp);        
00146   fGeo = &util::EDMUtils::GetGeometry(evt);
00147   
00148   Double_t totph    = 0;
00149   Int_t    totlen   = 0;
00150   Int_t    totcell  = 0;
00151   
00152   Int_t    firstplane  =  99999;
00153   Int_t    lastplane   = -1;
00154   Double_t min_stripx  =  99999;
00155   Double_t max_stripx  = -99999;
00156   Double_t min_stripy  =  99999;
00157   Double_t max_stripy  = -99999;
00158    
00159   for (std::vector<const  recobase::CellHit*>::iterator itert = pStpstemp.begin();
00160                 itert!=pStpstemp.end(); itert++) 
00161     {   
00162      const recobase::CellHit* stp = *itert;
00163      if(stp->Plane() < 0 || stp->Plane()>2000) pStpstemp.erase(itert);  // TRA LA FIX PROPERLY
00164      if(stp->Cell()  < 0 || stp->Cell() >2000) pStpstemp.erase(itert);
00165     }
00166  
00167    //  NOW MERGE! THIS SHOULD BE PART OF A "STRIPMAKING CLASS" TRA LA FIX
00168   
00169     for (std::vector<const  recobase::CellHit*>::iterator iter = pStpstemp.begin();iter!= pStpstemp.end(); iter++) 
00170     {
00171     
00172      const recobase::CellHit* stp = *iter;  
00173      recobase::CellHit *ct = new recobase::CellHit(*stp);
00174      
00175      float adc1;
00176      ct->MIP(adc1);        
00177      
00178      float totadc = adc1;
00179        
00180        std::vector<const recobase::CellHit*>::iterator iter2=iter;
00181        iter2++;
00182        
00183        for(;iter2<pStpstemp.end();iter2++)
00184        {
00185         
00186         const recobase::CellHit* stp2 = *iter2;
00187         recobase::CellHit *ct2 = new recobase::CellHit(*stp2);
00188         
00189         float adc2; 
00190         ct2->MIP(adc2);
00191         
00192         if(stp->Plane()==stp2->Plane() && stp->Cell()==stp2->Cell()){
00193          cout  << " found same Plane " << stp2->Plane() << " strip " << stp2->Cell() << endl;
00194          totadc = totadc + adc2;
00195          pStpstemp.erase(iter2);
00196         }
00197        
00198         delete ct2;
00199         ct2 =0;
00200         
00201        }     
00202       // set the overall ADC  
00203       ct->SetMIP(totadc); // this is actually MIP , ADC->PE DIVIDE BY 4 , PE - >MIP DIVIDE BY 30 , MIP->GEV DIVIDE BY 18.5 
00204       
00205       if(stp->Plane()<= firstplane) firstplane = stp->Plane();
00206       if(stp->Plane()>= lastplane)  lastplane  = stp->Plane();
00207       if(stp->View()==geo::kX){
00208         if(stp->TCPos()<=min_stripx) min_stripx=stp->TCPos();
00209         if(stp->TCPos()>=max_stripx) max_stripx=stp->TCPos();
00210       }
00211       if(stp->View()==geo::kY){
00212         if(stp->TCPos()<=min_stripy) min_stripy=stp->TCPos();
00213         if(stp->TCPos()>=max_stripy) max_stripy=stp->TCPos();
00214       }       
00215       
00216       totph   = totph + totadc;
00217       totcell = totcell +1;
00218          
00219     }
00220    
00221     totlen = lastplane  - firstplane;
00222 
00223     Double_t widx=max_stripx-min_stripx;
00224     Double_t widy=max_stripy-min_stripy;
00225     
00226     gMyNt->AddEvtLength(totlen);
00227     gMyNt->AddEvtCells(totcell);
00228     gMyNt->AddEvtPH(totph);
00229     gMyNt->AddEvtWidth((widx+widy)/2.);      
00230           
00231 }

void FillNtup::FillMCTruth const simb::MCTruth *  particles  ) 
 

find outgoing charged lepton from CC and fill it.

Definition at line 234 of file FillNtup.cxx.

References gMyNt, StdNtup::SetMCCCNC(), StdNtup::SetMCElep(), StdNtup::SetMCEnu(), StdNtup::SetMCMode(), StdNtup::SetMCNuType(), and StdNtup::SetMCVertex().

Referenced by Ana().

00234                                                       {
00235 
00236 
00237   if(particles->NParticles()>0) {
00238     TParticle particle = particles->GetParticle(0);
00239     double xyz[3] = {particle.Vx(), particle.Vy(), particle.Vz()};
00240     gMyNt->SetMCVertex(xyz);
00241   }
00242 
00243   if(particles->Origin() == simb::kBeamNeutrino 
00244      || particles->Origin() == simb::kSuperNovaNeutrino){
00245 
00246     gMyNt->SetMCNuType ( particles->GetNeutrino()->Nu().GetPdgCode() );
00247     gMyNt->SetMCCCNC   ( particles->GetNeutrino()->CCNC()            );
00248     gMyNt->SetMCMode   ( particles->GetNeutrino()->Mode()            );
00249     gMyNt->SetMCEnu    ( particles->GetNeutrino()->Nu().Energy()     );
00250     
00252     if(particles->GetNeutrino()->CCNC()==simb::kCC) {    
00253       
00254       int leptonpdg = (particles->GetNeutrino()->Nu().GetPdgCode()>0)?
00255         particles->GetNeutrino()->Nu().GetPdgCode() - 1:
00256         particles->GetNeutrino()->Nu().GetPdgCode() + 1;
00257 
00258       for(int iprt=0;iprt<particles->NParticles();iprt++) {
00259         
00260         TParticle particle = particles->GetParticle(iprt);
00261         
00262         if ( particle.GetPdgCode() == leptonpdg ) {
00263           gMyNt->SetMCElep ( particle.Energy() );
00264           break;
00265         }    
00266 
00267       }//end loop over particles
00268     }//end if CC
00269   }//end if a neutrino
00270   
00271 }

void FillNtup::FillShower3DReco vector< const recobase::ShowerBase3D * >  showers3D  ) 
 

Definition at line 332 of file FillNtup.cxx.

References StdNtup::AddShwBetaConst3Dp(), StdNtup::AddShwChiFit3Dp(), StdNtup::AddShwCosZ3Dp(), StdNtup::AddShwCsubE3Dp(), StdNtup::AddShwECritical3Dp(), StdNtup::AddShwEndX3Dp(), StdNtup::AddShwEndY3Dp(), StdNtup::AddShwEndZ3Dp(), StdNtup::AddShwEnergy3Dp(), StdNtup::AddShwFracMR3Dp(), StdNtup::AddShwFracPH3Dp(), StdNtup::AddShwLength3Dp(), StdNtup::AddShwNCell3Dp(), StdNtup::AddShwNPeaks3Dp(), StdNtup::AddShwPH13Dp(), StdNtup::AddShwPH23Dp(), StdNtup::AddShwPH33Dp(), StdNtup::AddShwPulseHeight3Dp(), StdNtup::AddShwRMSX3Dp(), StdNtup::AddShwRMSY3Dp(), StdNtup::AddShwSinglePlanes3Dp(), StdNtup::AddShwVtxPlane3Dp(), StdNtup::AddShwVtxX3Dp(), StdNtup::AddShwVtxY3Dp(), StdNtup::AddShwVtxZ3Dp(), StdNtup::AddShwWPlXmax3Dp(), StdNtup::AddShwWPlXmin3Dp(), StdNtup::AddShwWPlYmax3Dp(), StdNtup::AddShwWPlYmin3Dp(), StdNtup::AddShwWX3Dp(), StdNtup::AddShwWY3Dp(), StdNtup::AddShwXMax3Dp(), StdNtup::AddShwYMax3Dp(), StdNtup::AddShwZMaxX3Dp(), StdNtup::AddShwZMaxY3Dp(), recobase::ShowerBase::GetEndPlane(), recobase::ShowerBase::GetEndT(), recobase::ShowerBase::GetEndZ(), recobase::ShowerBase::GetEnergy(), recobase::ShowerBase::GetNCell(), recobase::ShowerBase::GetPlaneWMax(), recobase::ShowerBase::GetPlaneWMin(), recobase::ShowerBase::GetPulseHeight(), recobase::ShowerBase::GetSinglePlanes(), recobase::ShowerBase::GetTMax(), recobase::ShowerBase::GetTransW(), recobase::ShowerBase::GetVtxPlane(), recobase::ShowerBase::GetVtxT(), recobase::ShowerBase::GetVtxZ(), recobase::ShowerBase::GetZMax(), gMyNt, and StdNtup::SetNShw3D().

Referenced by Ana().

00332                                                                             {
00333 
00334  gMyNt->SetNShw3D(showers3d.size());
00335  
00336  Double_t Tot3DShwPH =0;
00337  
00338  // Find Toatl PH Associated with 3D Showers
00339  
00340  for(unsigned int i=0; i<showers3d.size(); i++) {
00341  
00342    const recobase::ShowerBase *showerx = showers3d[i]->GetMatchX();
00343    const recobase::ShowerBase *showery = showers3d[i]->GetMatchY();
00344    
00345    Tot3DShwPH=Tot3DShwPH+showerx->GetPulseHeight()+showery->GetPulseHeight();
00346    
00347   }
00348   
00349  for(unsigned int i=0; i<showers3d.size(); i++) {
00350  
00351     int isprimary = 0;
00352     if(showers3d[i]->IsPrimary()) isprimary = 1;
00353     
00354     const recobase::ShowerBase *showerx = showers3d[i]->GetMatchX();
00355     const recobase::ShowerBase *showery = showers3d[i]->GetMatchY();
00356       // EARLIEST
00357     double zvtx  = -1;
00358     if(showerx->GetVtxZ()< showery->GetVtxZ()) zvtx = showerx->GetVtxZ();
00359     if(showerx->GetVtxZ()>=showery->GetVtxZ()) zvtx = showery->GetVtxZ();
00360       // EARLIEST
00361     double    zvtxp = -1;
00362     if(showerx->GetVtxPlane()< showery->GetVtxPlane()) zvtxp = showerx->GetVtxPlane();
00363     if(showerx->GetVtxPlane()>=showery->GetVtxPlane()) zvtxp = showery->GetVtxPlane();
00364       // LATEST
00365     int     endp = -1;
00366     if(showerx->GetEndPlane()> showery->GetEndPlane()) endp = showerx->GetEndPlane();
00367     if(showerx->GetEndPlane()<=showery->GetEndPlane()) endp = showery->GetEndPlane();
00368 
00369      // LATEST
00370     double endz  = -1;
00371     if(showerx->GetEndZ()> showery->GetEndZ()) endz = showerx->GetEndZ();
00372     if(showerx->GetEndZ()<=showery->GetEndZ()) endz = showery->GetEndZ();
00373   
00374    /* 
00375     gMyNt->AddShwPulseHeight3D    (showerx->GetPulseHeight()+showery->GetPulseHeight()); 
00376     gMyNt->AddShwLength3D         (endp-zvtxp); 
00377     gMyNt->AddShwNCell3D          (showerx->GetNCell()+showery->GetNCell());        
00378     gMyNt->AddShwVtxX3D           (showerx->GetVtxT());            
00379     gMyNt->AddShwVtxY3D           (showery->GetVtxT());       
00380     gMyNt->AddShwVtxZ3D           (zvtx);     
00381     gMyNt->AddShwVtxPlane3D       (zvtxp); 
00382     gMyNt->AddShwEndX3D           (showerx->GetEndT());     
00383     gMyNt->AddShwEndY3D           (showery->GetEndT());     
00384     gMyNt->AddShwEndZ3D           (endz);         
00385     gMyNt->AddShwSinglePlanes3D   (showerx->GetSinglePlanes()+showery->GetSinglePlanes()); 
00386     gMyNt->AddShwEnergy3D         (showerx->GetEnergy()+showery->GetEnergy()); 
00387     gMyNt->AddShwXMax3D           (TMath::Abs(showerx->GetTMax()-showerx->GetVtxT()));     
00388     gMyNt->AddShwYMax3D           (TMath::Abs(showery->GetTMax()-showery->GetVtxT()));     
00389     gMyNt->AddShwZMaxX3D          (TMath::Abs(showerx->GetZMax()-showerx->GetVtxZ())); 
00390     gMyNt->AddShwZMaxY3D          (TMath::Abs(showery->GetZMax()-showery->GetVtxZ())); 
00391    */
00392 
00393     if(isprimary==1){
00394       
00395       gMyNt->AddShwPH13Dp          (showers3d[i]->GetPH1());
00396       gMyNt->AddShwPH23Dp          (showers3d[i]->GetPH2());
00397       gMyNt->AddShwPH33Dp          (showers3d[i]->GetPH3());      
00398       gMyNt->AddShwPulseHeight3Dp  (showerx->GetPulseHeight()+showery->GetPulseHeight());       
00399       gMyNt->AddShwFracPH3Dp       ((showerx->GetPulseHeight()+showery->GetPulseHeight())/Tot3DShwPH);   
00400       gMyNt->AddShwLength3Dp       (endp-zvtxp); 
00401       gMyNt->AddShwNCell3Dp        (showerx->GetNCell()+showery->GetNCell());      
00402       gMyNt->AddShwVtxX3Dp         (showerx->GetVtxT());            
00403       gMyNt->AddShwVtxY3Dp         (showery->GetVtxT());          
00404       gMyNt->AddShwVtxZ3Dp         (zvtx);     
00405       gMyNt->AddShwVtxPlane3Dp     ((int)zvtxp); 
00406       gMyNt->AddShwEndX3Dp         (showerx->GetEndT());        
00407       gMyNt->AddShwEndY3Dp         (showery->GetEndT());        
00408       gMyNt->AddShwEndZ3Dp         (endz);         
00409       gMyNt->AddShwSinglePlanes3Dp (showerx->GetSinglePlanes()+showery->GetSinglePlanes()); 
00410       gMyNt->AddShwEnergy3Dp       (showerx->GetEnergy()+showery->GetEnergy()); 
00411       gMyNt->AddShwXMax3Dp         (TMath::Abs(showerx->GetTMax()-showerx->GetVtxT()));   
00412       gMyNt->AddShwYMax3Dp         (TMath::Abs(showery->GetTMax()-showery->GetVtxT()));   
00413       gMyNt->AddShwZMaxX3Dp        (TMath::Abs(showerx->GetZMax()-showerx->GetVtxZ())); 
00414       gMyNt->AddShwZMaxY3Dp        (TMath::Abs(showery->GetZMax()-showery->GetVtxZ())); 
00415     
00416       gMyNt->AddShwWX3Dp           (showerx->GetTransW());             
00417       gMyNt->AddShwWY3Dp           (showery->GetTransW());           
00418       gMyNt->AddShwWPlXmin3Dp      (showerx->GetPlaneWMin());                
00419       gMyNt->AddShwWPlYmin3Dp      (showery->GetPlaneWMin());                
00420       gMyNt->AddShwWPlXmax3Dp      (showerx->GetPlaneWMax());               
00421       gMyNt->AddShwWPlYmax3Dp      (showery->GetPlaneWMax()); 
00422   
00423       gMyNt->AddShwBetaConst3Dp    (showers3d[i]->GetBetaConst());
00424       gMyNt->AddShwChiFit3Dp       (showers3d[i]->GetChiFit());
00425       gMyNt->AddShwFracMR3Dp       (showers3d[i]->GetFracMR());
00426       gMyNt->AddShwECritical3Dp    (showers3d[i]->GetECritical());
00427       gMyNt->AddShwCsubE3Dp        (showers3d[i]->GetCsubE());
00428       gMyNt->AddShwCosZ3Dp         (showers3d[i]->GetCosZ()); 
00429       gMyNt->AddShwRMSY3Dp         (showers3d[i]->GetRMSY());
00430       gMyNt->AddShwRMSX3Dp         (showers3d[i]->GetRMSX());
00431       gMyNt->AddShwNPeaks3Dp       (showers3d[i]->GetNPeaks());
00432 
00433     }
00434 
00435   }
00436 
00437 }

void fillntup::FillNtup::FillShowerReco vector< const recobase::ShowerBase * >  showers  ) 
 

void fillntup::FillNtup::FillTrackReco vector< const recobase::TrackBase * >  tracks  ) 
 

void FillNtup::Update const cfg::Config c  )  [virtual]
 

Implements cfg::Observer.

Definition at line 47 of file FillNtup.cxx.

References SAnaNtup::Add(), fClassName, fDetGeom, fEventName, fShower3DRecoName, fShowerRecoName, fTrackRecoName, fTreeName, gMyNt, and sn.

00048 {
00049   
00050   c("DetGeom").            Get(fDetGeom);
00051   c("TrackRecoName").      Get(fTrackRecoName);
00052   c("ShowerRecoName").     Get(fShowerRecoName); 
00053   c("Shower3DRecoName").   Get(fShower3DRecoName); 
00054   c("TreeName").           Get(fTreeName);
00055   c("ClassName").          Get(fClassName);
00056   c("EventName").          Get(fEventName);
00057    
00058   sn.Add(&gMyNt,fClassName,fTreeName);
00059  
00060 }


Member Data Documentation

string fillntup::FillNtup::fClassName [private]
 

Definition at line 52 of file FillNtup.h.

Referenced by Update().

short fillntup::FillNtup::fDetGeom [private]
 

Definition at line 46 of file FillNtup.h.

Referenced by Update().

string fillntup::FillNtup::fEventName [private]
 

Definition at line 48 of file FillNtup.h.

Referenced by Update().

geo::Geometry* fillntup::FillNtup::fGeo [private]
 

Definition at line 47 of file FillNtup.h.

Referenced by Ana(), and FillEventInfo().

string fillntup::FillNtup::fShower3DRecoName [private]
 

Definition at line 51 of file FillNtup.h.

Referenced by Ana(), and Update().

string fillntup::FillNtup::fShowerRecoName [private]
 

Definition at line 50 of file FillNtup.h.

Referenced by Ana(), and Update().

string fillntup::FillNtup::fTrackRecoName [private]
 

Definition at line 49 of file FillNtup.h.

Referenced by Ana(), and Update().

string fillntup::FillNtup::fTreeName [private]
 

Definition at line 45 of file FillNtup.h.

Referenced by Ana(), Update(), and ~FillNtup().


The documentation for this class was generated from the following files:
Generated on Mon Nov 23 04:45:32 2009 for NOvA Offline by  doxygen 1.3.9.1