CMS 3D CMS Logo

Classes | Public Member Functions | Private Types | Private Attributes

SiStripLAProfileBooker Class Reference

#include <SiStripLAProfileBooker.h>

Inheritance diagram for SiStripLAProfileBooker:
edm::EDAnalyzer

List of all members.

Classes

struct  detparameters

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
void beginRun (const edm::EventSetup &c)
void endJob ()
void getlayer (const DetId &detid, std::string &name, unsigned int &layerid)
 SiStripLAProfileBooker (const edm::ParameterSet &conf)
 ~SiStripLAProfileBooker ()

Private Types

typedef std::map< unsigned int,
detparameters * > 
detparmap
typedef std::map< unsigned int,
MonitorElement * > 
histomap

Private Attributes

uint8_t Amplitudes [100]
float barycenter
int better_double_hit
int bw_fw
float chi2norm
int ClSize
edm::ParameterSet conf_
DQMStoredbe_
detparmap detmap
float EtaTrack
TDirectory * Event_Tree
int EventCounter
int eventcounter
int EventNumber
TTree * EventTree
int Ext_Int
TFile * hFile
histomap histos
float hit_std_dev
TDirectory * Hit_Tree
int HitCharge
int hitcounter
int hitcounter_2ndloop
int HitNr
int HitPerTrack
TTree * HitsTree
int id_detector
int Layer
float MagField
float Momentum
int MonoStereo
int nstrip
int ParticleCharge
float PhiTrack
float pitch_detector
float pt
int RunNumber
float SignCorrection
int size
detparmap summarydetmap
histomap summaryhisto
float sumx
float TanTrackAngle
float TanTrackAngleParallel
float thick_detector
TDirectory * Track_Tree
int trackcollsize
int TrackCounter
const TrackerGeometrytracker
TTree * TrackTree
int trajsize
std::string treename_
int Type
int Wheel
int worse_double_hit
float XGlobal
float YGlobal
float ZGlobal

Detailed Description

Definition at line 28 of file SiStripLAProfileBooker.h.


Member Typedef Documentation

typedef std::map<unsigned int, detparameters*> SiStripLAProfileBooker::detparmap [private]

Definition at line 47 of file SiStripLAProfileBooker.h.

typedef std::map<unsigned int, MonitorElement*> SiStripLAProfileBooker::histomap [private]

Definition at line 48 of file SiStripLAProfileBooker.h.


Constructor & Destructor Documentation

SiStripLAProfileBooker::SiStripLAProfileBooker ( const edm::ParameterSet conf) [explicit]

Definition at line 61 of file SiStripLAProfileBooker.cc.

                                                                          : 
  conf_(conf)
{
}
SiStripLAProfileBooker::~SiStripLAProfileBooker ( )

Definition at line 254 of file SiStripLAProfileBooker.cc.

References detmap, hFile, and summarydetmap.

                                                {  
  detparmap::iterator detpariter;
  for( detpariter=detmap.begin(); detpariter!=detmap.end();++detpariter)delete detpariter->second;
  for( detpariter=summarydetmap.begin(); detpariter!=summarydetmap.end();++detpariter)delete detpariter->second;
  delete hFile;
}  

Member Function Documentation

void SiStripLAProfileBooker::analyze ( const edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 263 of file SiStripLAProfileBooker.cc.

References Amplitudes, barycenter, begin, better_double_hit, BoundSurface::bounds(), bw_fw, chi2norm, ClSize, SiStripRecHit2D::cluster(), conf_, cond::rpcobgas::detid, detmap, EtaTrack, edm::EventID::event(), eventcounter, EventNumber, EventTree, Ext_Int, TrackingRecHit::geographicalId(), edm::Event::getByLabel(), getlayer(), edm::ParameterSet::getParameter(), histos, hit_std_dev, HitCharge, hitcounter, hitcounter_2ndloop, HitNr, HitPerTrack, HitsTree, i, edm::EventBase::id(), id_detector, TrackerGeometry::idToDet(), Layer, TIBDetId::layer(), TOBDetId::layer(), TrajectoryStateOnSurface::localDirection(), StripTopology::localPitch(), BaseSiTrackerRecHit2DLocalPos::localPosition(), LogDebug, PV3DBase< T, PVType, FrameType >::mag(), MagField, TIDDetId::module(), Momentum, GluedGeomDet::monoDet(), SiStripMatchedRecHit2D::monoHit(), MonoStereo, mergeVDriftHistosByStation::name, nstrip, ProjectedSiStripRecHit2D::originalHit(), ParticleCharge, TECDetId::petal(), PhiTrack, pitch_detector, position, funct::pow(), pt, DetId::rawId(), TOBDetId::rod(), edm::EventID::run(), RunNumber, SignCorrection, size, GeomDet::specificSurface(), mathSSE::sqrt(), StripSubdetector::stereo(), GluedGeomDet::stereoDet(), SiStripMatchedRecHit2D::stereoHit(), TIBDetId::string(), DetId::subdetId(), summaryhisto, sumx, GeomDet::surface(), TanTrackAngle, TanTrackAngleParallel, StripSubdetector::TEC, thick_detector, Bounds::thickness(), StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, GeomDet::toGlobal(), GeomDet::toLocal(), GeomDetUnit::topology(), trackcollsize, tracker, testEve_cfg::tracks, TrackTree, trajsize, Type, TIDDetId::wheel(), Wheel, TECDetId::wheel(), worse_double_hit, PV3DBase< T, PVType, FrameType >::x(), XGlobal, PV3DBase< T, PVType, FrameType >::y(), YGlobal, PV3DBase< T, PVType, FrameType >::z(), and ZGlobal.

{
  
  RunNumber = e.id().run();
  EventNumber = e.id().event();
  
  eventcounter++;
  
  EventTree->Fill();
  
  //Analysis of Trajectory-RecHits
        
  edm::InputTag TkTag = conf_.getParameter<edm::InputTag>("Tracks");
  
  edm::Handle<reco::TrackCollection> trackCollection;
  e.getByLabel(TkTag,trackCollection);
    
  edm::Handle<std::vector<Trajectory> > TrajectoryCollection;
  e.getByLabel(TkTag,TrajectoryCollection);
  
  edm::Handle<TrajTrackAssociationCollection> TrajTrackMap;
  e.getByLabel(TkTag, TrajTrackMap);
  
  const reco::TrackCollection *tracks=trackCollection.product();
   
  std::map<const SiStripRecHit2D*,std::pair<float,float>,DetIdLess> hitangleassociation;
    
  trackcollsize=tracks->size();
  trajsize=TrajectoryCollection->size();
  
  edm::LogInfo("SiStripLAProfileBooker::analyze") <<" Number of tracks in event = "<<trackcollsize<<"\n";
  edm::LogInfo("SiStripLAProfileBooker::analyze") <<" Number of trajectories in event = "<<trajsize<<"\n";
  
  TrajTrackAssociationCollection::const_iterator TrajTrackIter;
  
  for(TrajTrackIter = TrajTrackMap->begin(); TrajTrackIter!= TrajTrackMap->end(); TrajTrackIter++){ //loop on trajectories
    
    if(TrajTrackIter->key->foundHits()>=5){
      
      TrackTree->Fill();
    
      ParticleCharge = -99;
      Momentum = -99;
      pt = -99;
      chi2norm = -99;
      HitPerTrack = -99;
      EtaTrack = -99;
      PhiTrack = -99;
      
      ParticleCharge = TrajTrackIter->val->charge();
      pt = TrajTrackIter->val->pt();
      Momentum = TrajTrackIter->val->p();
      chi2norm = TrajTrackIter->val->normalizedChi2();
      EtaTrack = TrajTrackIter->val->eta();
      PhiTrack = TrajTrackIter->val->phi();
      HitPerTrack = TrajTrackIter->key->foundHits();
          
      std::vector<TrajectoryMeasurement> TMeas=TrajTrackIter->key->measurements();
      std::vector<TrajectoryMeasurement>::iterator itm;
      
      for (itm=TMeas.begin();itm!=TMeas.end();itm++){ //loop on hits
           
      int i;
      for(i=0;i<100;i++){
      Amplitudes[i]=0;}
      
      TanTrackAngle = -99;
      TanTrackAngleParallel=-99;
      ClSize = -99;
      HitCharge = 0;
      Type = -99;
      Layer = -99;
      Wheel = -99;
      bw_fw = -99;
      Ext_Int = -99;
      MonoStereo = -99;
      MagField = -99;
      SignCorrection = -99;
      XGlobal = -99;
      YGlobal = -99;
      ZGlobal = -99;
      barycenter = -99;
      hit_std_dev = -99;
      sumx = 0;
      id_detector=-1;
      thick_detector=-1;
      pitch_detector=-1;       
      HitNr = 1;    
      
        TrajectoryStateOnSurface tsos=itm->updatedState();
        const TransientTrackingRecHit::ConstRecHitPointer thit=itm->recHit();
        if((thit->geographicalId().subdetId() == int(StripSubdetector::TIB)) ||  thit->geographicalId().subdetId()== int(StripSubdetector::TOB)){ //include only barrel
          const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>((*thit).hit());
          const ProjectedSiStripRecHit2D* phit=dynamic_cast<const ProjectedSiStripRecHit2D*>((*thit).hit());
          const SiStripRecHit2D* hit=dynamic_cast<const SiStripRecHit2D*>((*thit).hit());
          if(phit) hit=&(phit->originalHit());
          
          LocalVector trackdirection=tsos.localDirection();
          
          if(matchedhit){//if matched hit...
            
            GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(matchedhit->geographicalId());
            
            GlobalVector gtrkdir=gdet->toGlobal(trackdirection);        
            
            // THIS THE POINTER TO THE MONO HIT OF A MATCHED HIT 
            
            const SiStripRecHit2D *monohit=matchedhit->monoHit();    
            const SiStripRecHit2D::ClusterRef & monocluster=monohit->cluster();
            const GeomDetUnit * monodet=gdet->monoDet();    
            const LocalPoint monoposition = monohit->localPosition();    
            StripSubdetector detid=(StripSubdetector)monohit->geographicalId();
            id_detector = detid.rawId();
            thick_detector=monodet->specificSurface().bounds().thickness();
            const StripTopology& mtopol=(StripTopology&)monodet->topology();
            pitch_detector = mtopol.localPitch(monoposition);
            const GlobalPoint monogposition = (monodet->surface()).toGlobal(monoposition);
            ClSize = (monocluster->amplitudes()).size();
            
            const std::vector<uint8_t> amplitudes = monocluster->amplitudes();
            
            barycenter = monocluster->barycenter()- 0.5; 
            uint16_t FirstStrip = monocluster->firstStrip();
            std::vector<uint8_t>::const_iterator idigi;
            std::vector<uint8_t>::const_iterator begin=amplitudes.begin();
            nstrip=0;
            for(idigi=begin; idigi!=amplitudes.end(); idigi++){
            Amplitudes[nstrip]=*idigi;
            sumx+=pow(((FirstStrip+idigi-begin)-barycenter),2)*(*idigi);
            HitCharge+=*idigi;
            }
            hit_std_dev = sqrt(sumx/HitCharge);
          
                    
            XGlobal = monogposition.x();
            YGlobal = monogposition.y();
            ZGlobal = monogposition.z();
            
            Type = detid.subdetId();
            MonoStereo=detid.stereo();
            
            if(detid.subdetId() == int (StripSubdetector::TIB)){
            TIBDetId TIBid=TIBDetId(detid);
            Layer = TIBid.layer();
            bw_fw = TIBid.string()[0];
            Ext_Int = TIBid.string()[1];
            }
            if(detid.subdetId() == int (StripSubdetector::TOB)){
            TOBDetId TOBid=TOBDetId(detid);
            Layer = TOBid.layer();
            bw_fw = TOBid.rod()[0];
            }
            if(detid.subdetId() == int (StripSubdetector::TID)){
            TIDDetId TIDid=TIDDetId(detid);
            Wheel = TIDid.wheel();
            bw_fw = TIDid.module()[0];
            }
            if(detid.subdetId() == int (StripSubdetector::TEC)){
            TECDetId TECid=TECDetId(detid);
            Wheel = TECid.wheel();
            bw_fw = TECid.petal()[0];
            }
            
            
            LocalVector monotkdir=monodet->toLocal(gtrkdir);
           
            if(monotkdir.z()!=0){
              
              // THE LOCAL ANGLE (MONO)
              float tanangle = monotkdir.x()/monotkdir.z();
              TanTrackAngleParallel = monotkdir.y()/monotkdir.z();            
              TanTrackAngle = tanangle;
              detparmap::iterator TheDet=detmap.find(detid.rawId());
              LocalVector localmagdir;
              if(TheDet!=detmap.end())localmagdir=TheDet->second->magfield;
              MagField = localmagdir.mag();
              if(MagField != 0.){
              LocalVector monoylocal(0,1,0);
              float signcorrection = (localmagdir * monoylocal)/(MagField);
              if(signcorrection!=0)SignCorrection=1/signcorrection;}
              
              std::map<const SiStripRecHit2D *,std::pair<float,float>,DetIdLess>::iterator alreadystored=hitangleassociation.find(monohit);
              
              
              if(alreadystored != hitangleassociation.end()){//decide which hit take
              if(itm->estimate() >  alreadystored->second.first){
                worse_double_hit++;}
                if(itm->estimate() <  alreadystored->second.first){
                better_double_hit++;
                hitangleassociation.insert(std::make_pair(monohit, std::make_pair(itm->estimate(),tanangle)));
                
                }}
              else{
              hitangleassociation.insert(make_pair(monohit, std::make_pair(itm->estimate(),tanangle)));
              HitsTree->Fill();
              hitcounter++;}
                  
              // THIS THE POINTER TO THE STEREO HIT OF A MATCHED HIT 
              
            const SiStripRecHit2D *stereohit=matchedhit->stereoHit();
            const SiStripRecHit2D::ClusterRef & stereocluster=stereohit->cluster();
            const GeomDetUnit * stereodet=gdet->stereoDet();
            const LocalPoint stereoposition = stereohit->localPosition();    
            StripSubdetector detid=(StripSubdetector)stereohit->geographicalId();
            id_detector = detid.rawId();
            thick_detector=stereodet->specificSurface().bounds().thickness();
            const StripTopology& stopol=(StripTopology&)stereodet->topology();
            pitch_detector = stopol.localPitch(stereoposition);
            const GlobalPoint stereogposition = (stereodet->surface()).toGlobal(stereoposition);
            
            ClSize = (stereocluster->amplitudes()).size();
            
            const std::vector<uint8_t> amplitudes = stereocluster->amplitudes();
            
            barycenter = stereocluster->barycenter()- 0.5; 
            uint16_t FirstStrip = stereocluster->firstStrip();
            std::vector<uint8_t>::const_iterator idigi;
            std::vector<uint8_t>::const_iterator begin=amplitudes.begin();
            nstrip=0;
            for(idigi=begin; idigi!=amplitudes.end(); idigi++){
            Amplitudes[nstrip]=*idigi;
            sumx+=pow(((FirstStrip+idigi-begin)-barycenter),2)*(*idigi);
            HitCharge+=*idigi;
            }
            hit_std_dev = sqrt(sumx/HitCharge);
        
            XGlobal = stereogposition.x();
            YGlobal = stereogposition.y();
            ZGlobal = stereogposition.z();
            
            Type = detid.subdetId();
            MonoStereo=detid.stereo();
            
            if(detid.subdetId() == int (StripSubdetector::TIB)){
            TIBDetId TIBid=TIBDetId(detid);
            Layer = TIBid.layer();
            bw_fw = TIBid.string()[0];
            Ext_Int = TIBid.string()[1];
            }
            if(detid.subdetId() == int (StripSubdetector::TOB)){
            TOBDetId TOBid=TOBDetId(detid);
            Layer = TOBid.layer();
            bw_fw = TOBid.rod()[0];
            }
            if(detid.subdetId() == int (StripSubdetector::TID)){
            TIDDetId TIDid=TIDDetId(detid);
            Wheel = TIDid.wheel();
            bw_fw = TIDid.module()[0];
            }
            if(detid.subdetId() == int (StripSubdetector::TEC)){
            TECDetId TECid=TECDetId(detid);
            Wheel = TECid.wheel();
            bw_fw = TECid.petal()[0];
            }
              
              
              LocalVector stereotkdir=stereodet->toLocal(gtrkdir);
              
              if(stereotkdir.z()!=0){
                
                // THE LOCAL ANGLE (STEREO)
                float tanangle = stereotkdir.x()/stereotkdir.z();
                TanTrackAngleParallel = stereotkdir.y()/stereotkdir.z();
                TanTrackAngle = tanangle;
                detparmap::iterator TheDet=detmap.find(detid.rawId());
                LocalVector localmagdir;
                if(TheDet!=detmap.end())localmagdir=TheDet->second->magfield;
                MagField = localmagdir.mag();
                LocalVector stereoylocal(0,1,0);
                if(MagField != 0.){
                float signcorrection = (localmagdir * stereoylocal)/(MagField);
                if(signcorrection!=0)SignCorrection=1/signcorrection;}
                
                std::map<const SiStripRecHit2D *,std::pair<float,float>,DetIdLess>::iterator alreadystored=hitangleassociation.find(stereohit);
                                
                if(alreadystored != hitangleassociation.end()){//decide which hit take
                if(itm->estimate() >  alreadystored->second.first){
                worse_double_hit++;}
                  if(itm->estimate() <  alreadystored->second.first){
                  better_double_hit++;
                  hitangleassociation.insert(std::make_pair(stereohit, std::make_pair(itm->estimate(),tanangle)));
                  
                  }}
                else{
                hitangleassociation.insert(std::make_pair(stereohit, std::make_pair(itm->estimate(),tanangle)));
                HitsTree->Fill();
                hitcounter++;}
                                  
              }
            }
          }
          else if(hit){
          
          
            //  hit= POINTER TO THE RECHIT
            
            const SiStripRecHit2D::ClusterRef & cluster=hit->cluster();
           
            GeomDetUnit * gdet=(GeomDetUnit *)tracker->idToDet(hit->geographicalId());
            const LocalPoint position = hit->localPosition();    
            StripSubdetector detid=(StripSubdetector)hit->geographicalId();
            id_detector = detid.rawId();
            thick_detector=gdet->specificSurface().bounds().thickness();
            const StripTopology& topol=(StripTopology&)gdet->topology();
            pitch_detector = topol.localPitch(position);
            const GlobalPoint gposition = (gdet->surface()).toGlobal(position);
            
            ClSize = (cluster->amplitudes()).size();
            
            const std::vector<uint8_t> amplitudes = cluster->amplitudes();
            
            barycenter = cluster->barycenter()- 0.5; 
            uint16_t FirstStrip = cluster->firstStrip();
            std::vector<uint8_t>::const_iterator idigi;
            std::vector<uint8_t>::const_iterator begin=amplitudes.begin();
            nstrip=0;
            for(idigi=begin; idigi!=amplitudes.end(); idigi++){
            Amplitudes[nstrip]=*idigi;
            sumx+=pow(((FirstStrip+idigi-begin)-barycenter),2)*(*idigi);
            HitCharge+=*idigi;
            }
            hit_std_dev = sqrt(sumx/HitCharge);
            
            XGlobal = gposition.x();
            YGlobal = gposition.y();
            ZGlobal = gposition.z();
            
            Type = detid.subdetId();
            MonoStereo=detid.stereo();
            
            if(detid.subdetId() == int (StripSubdetector::TIB)){
            TIBDetId TIBid=TIBDetId(detid);
            Layer = TIBid.layer();
            bw_fw = TIBid.string()[0];
            Ext_Int = TIBid.string()[1];
            }
            if(detid.subdetId() == int (StripSubdetector::TOB)){
            TOBDetId TOBid=TOBDetId(detid);
            Layer = TOBid.layer();
            bw_fw = TOBid.rod()[0];
            }
            if(detid.subdetId() == int (StripSubdetector::TID)){
            TIDDetId TIDid=TIDDetId(detid);
            Wheel = TIDid.wheel();
            bw_fw = TIDid.module()[0];
            }
            if(detid.subdetId() == int (StripSubdetector::TEC)){
            TECDetId TECid=TECDetId(detid);
            Wheel = TECid.wheel();
            bw_fw = TECid.petal()[0];
            }
                    
            if(trackdirection.z()!=0){
            
              // THE LOCAL ANGLE 
              float tanangle = trackdirection.x()/trackdirection.z();
              TanTrackAngleParallel = trackdirection.y()/trackdirection.z();
              TanTrackAngle = tanangle;
              detparmap::iterator TheDet=detmap.find(detid.rawId());
              LocalVector localmagdir;
              if(TheDet!=detmap.end())localmagdir=TheDet->second->magfield;
              MagField = localmagdir.mag();
              if(MagField != 0.){
              LocalVector ylocal(0,1,0);
              float signcorrection = (localmagdir * ylocal)/(MagField);
              if(signcorrection!=0)SignCorrection=1/signcorrection;}
                
              std::map<const SiStripRecHit2D *,std::pair<float,float>, DetIdLess>::iterator alreadystored=hitangleassociation.find(hit);
                      
              if(alreadystored != hitangleassociation.end()){//decide which hit take
              if(itm->estimate() >  alreadystored->second.first){
              worse_double_hit++;}
                if(itm->estimate() <  alreadystored->second.first){
                better_double_hit++;
                hitangleassociation.insert(std::make_pair(hit, std::make_pair(itm->estimate(),tanangle)));
                
                }}
              else{
              hitangleassociation.insert(std::make_pair(hit,std::make_pair(itm->estimate(), tanangle) ) );
              HitsTree->Fill();
              hitcounter++;}
              
              
            }
          }
        }
      }
    }
  }
    std::map<const SiStripRecHit2D *,std::pair<float,float>,DetIdLess>::iterator hitsiter;
    
        
    for(hitsiter=hitangleassociation.begin();hitsiter!=hitangleassociation.end();hitsiter++){
    
    hitcounter_2ndloop++;
    
    const SiStripRecHit2D* hit=hitsiter->first;
    const SiStripRecHit2D::ClusterRef & cluster=hit->cluster();

    size=(cluster->amplitudes()).size();
    
    const LocalPoint position = hit->localPosition();    
    StripSubdetector detid=(StripSubdetector)hit->geographicalId();  
    
    const GeomDetUnit * StripDet=dynamic_cast<const GeomDetUnit*>(tracker->idToDet(detid));
    const GlobalPoint gposition = (StripDet->surface()).toGlobal(position);
      
    float tangent = hitsiter->second.second;
          
    //Sign and XZ plane projection correction applied in TrackLocalAngle (TIB|TOB layers)
      
    detparmap::iterator thedet=detmap.find(detid.rawId());
    LocalVector localmagdir;
    if(thedet!=detmap.end())localmagdir=thedet->second->magfield;
    float localmagfield = localmagdir.mag();
        
    if(localmagfield != 0.){
      
      LocalVector ylocal(0,1,0);
      
      float normprojection = (localmagdir * ylocal)/(localmagfield);
      
      if(normprojection == 0.)LogDebug("SiStripLAProfileBooker::analyze")<<"Error: YBprojection = 0";
      
      else{
        float signprojcorrection = 1/normprojection;
        tangent*=signprojcorrection;
      }
    }
          
    //Filling histograms
    
    histomap::iterator thehisto=histos.find(detid.rawId());
   
    if(thehisto==histos.end())edm::LogError("SiStripLAProfileBooker::analyze")<<"Error: the profile associated to"<<detid.rawId()<<"does not exist! ";    
    else thehisto->second->Fill(tangent,size);
    
    //Summary histograms
    std::string name;
    unsigned int layerid;
    getlayer(detid,name,layerid);
    histomap::iterator thesummaryhisto=summaryhisto.find(layerid);
    if(thesummaryhisto==summaryhisto.end())edm::LogError("SiStripLAProfileBooker::analyze")<<"Error: the profile associated to subdet "<<name<<"does not exist! ";   
    else thesummaryhisto->second->Fill(tangent,size);
    
  }
    
        
}
void SiStripLAProfileBooker::beginRun ( const edm::EventSetup c)

Definition at line 68 of file SiStripLAProfileBooker.cc.

References Amplitudes, better_double_hit, DQMStore::bookProfile(), BoundSurface::bounds(), bw_fw, chi2norm, ClSize, conf_, SiStripHistoId::createHistoId(), dbe_, detmap, EtaTrack, Event_Tree, EventCounter, eventcounter, EventNumber, EventTree, Ext_Int, edm::EventSetup::get(), getlayer(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hFile, histos, hit_std_dev, Hit_Tree, HitCharge, hitcounter, hitcounter_2ndloop, HitNr, HitPerTrack, HitsTree, id_detector, TrackerGeometry::idToDet(), MagneticField::inTesla(), edm::InputTag::label(), Layer, StripTopology::localPitch(), SiStripLAProfileBooker::detparameters::magfield, MagField, autoMagneticFieldProducer_cfi::magfield, Momentum, MonoStereo, mergeVDriftHistosByStation::name, cmsCodeRules::cppFunctionSkipper::operator, L1TEmulatorMonitor_cff::p, ParticleCharge, PhiTrack, SiStripLAProfileBooker::detparameters::pitch, pitch_detector, profilereader::profile, pt, DetId::rawId(), RunNumber, MonitorElement::setAxisTitle(), SiStripFolderOrganizer::setDetectorFolder(), SiStripFolderOrganizer::setSiStripFolder(), SignCorrection, GeomDet::specificSurface(), DetId::subdetId(), summarydetmap, summaryhisto, GeomDet::surface(), TanTrackAngle, TanTrackAngleParallel, StripSubdetector::TEC, thick_detector, SiStripLAProfileBooker::detparameters::thickness, Bounds::thickness(), StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, toLocal(), GeomDetUnit::topology(), Track_Tree, trackcollsize, TrackCounter, tracker, TrackTree, trajsize, Type, Wheel, worse_double_hit, XGlobal, YGlobal, and ZGlobal.

                                                           {

 
  //get magnetic field and geometry from ES
  edm::ESHandle<MagneticField> esmagfield;
  c.get<IdealMagneticFieldRecord>().get(esmagfield);
  const MagneticField *  magfield=&(*esmagfield);
  
  edm::ESHandle<TrackerGeometry> estracker;
  c.get<TrackerDigiGeometryRecord>().get(estracker);
  tracker=&(*estracker); 

  std::vector<uint32_t> activeDets;
  edm::ESHandle<SiStripDetCabling> tkmechstruct=0;
  if (conf_.getParameter<bool>("UseStripCablingDB")){ 
    c.get<SiStripDetCablingRcd>().get(tkmechstruct);
    activeDets.clear();
    tkmechstruct->addActiveDetectorsRawIds(activeDets);
  }
  else {
    const TrackerGeometry::DetIdContainer& Id = estracker->detIds();
    TrackerGeometry::DetIdContainer::const_iterator Iditer;    
    activeDets.clear();
    for(Iditer=Id.begin();Iditer!=Id.end();Iditer++){
      activeDets.push_back(Iditer->rawId());
    }
  }
   
  edm::InputTag TkTag = conf_.getParameter<edm::InputTag>("Tracks");
  //Get Ids;
  double ModuleRangeMin=conf_.getParameter<double>("ModuleXMin");
  double ModuleRangeMax=conf_.getParameter<double>("ModuleXMax");
  double TIBRangeMin=conf_.getParameter<double>("TIBXMin");
  double TIBRangeMax=conf_.getParameter<double>("TIBXMax");
  double TOBRangeMin=conf_.getParameter<double>("TOBXMin");
  double TOBRangeMax=conf_.getParameter<double>("TOBXMax");
  int TIB_bin=conf_.getParameter<int>("TIB_bin");
  int TOB_bin=conf_.getParameter<int>("TOB_bin");
  int SUM_bin=conf_.getParameter<int>("SUM_bin");
    
  hFile = new TFile (conf_.getUntrackedParameter<std::string>("treeName").c_str(), "RECREATE" );
  
  Hit_Tree = hFile->mkdir("Hit_Tree");
  Track_Tree = hFile->mkdir("Track_Tree");
  Event_Tree = hFile->mkdir("Event_Tree");
  
  HitsTree = new TTree("HitsTree", "HitsTree");
  
  HitsTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
  HitsTree->Branch("EventNumber", &EventNumber, "EventNumber/I");
  HitsTree->Branch("TanTrackAngle", &TanTrackAngle, "TanTrackAngle/F");
  HitsTree->Branch("TanTrackAngleParallel", &TanTrackAngleParallel, "TanTrackAngleParallel/F");
  HitsTree->Branch("ClSize", &ClSize, "ClSize/I");
  HitsTree->Branch("HitCharge", &HitCharge, "HitCharge/I");
  HitsTree->Branch("Hit_Std_Dev", &hit_std_dev, "hit_std_dev/F");
  HitsTree->Branch("Type", &Type, "Type/I");
  HitsTree->Branch("Layer", &Layer, "Layer/I");
  HitsTree->Branch("Wheel", &Wheel, "Wheel/I");
  HitsTree->Branch("bw_fw", &bw_fw, "bw_fw/I");
  HitsTree->Branch("Ext_Int", &Ext_Int, "Ext_Int/I");
  HitsTree->Branch("MonoStereo", &MonoStereo, "MonoStereo/I");
  HitsTree->Branch("MagField", &MagField, "MagField/F");
  HitsTree->Branch("SignCorrection", &SignCorrection, "SignCorrection/F");
  HitsTree->Branch("XGlobal", &XGlobal, "XGlobal/F");
  HitsTree->Branch("YGlobal", &YGlobal, "YGlobal/F");
  HitsTree->Branch("ZGlobal", &ZGlobal, "ZGlobal/F");
  HitsTree->Branch("ParticleCharge", &ParticleCharge, "ParticleCharge/I");
  HitsTree->Branch("Momentum", &Momentum, "Momentum/F");
  HitsTree->Branch("pt", &pt, "pt/F");
  HitsTree->Branch("chi2norm", &chi2norm, "chi2norm/F");
  HitsTree->Branch("EtaTrack", &EtaTrack, "EtaTrack/F");
  HitsTree->Branch("PhiTrack", &PhiTrack, "PhiTrack/F");
  HitsTree->Branch("TrajSize", &trajsize, "trajsize/I");
  HitsTree->Branch("HitNr", &HitNr, "HitNr/I");
  HitsTree->Branch("HitPerTrack", &HitPerTrack, "HitPerTrack/I");
  HitsTree->Branch("id_detector", &id_detector, "id_detector/I");
  HitsTree->Branch("thick_detector", &thick_detector, "thick_detector/F");
  HitsTree->Branch("pitch_detector", &pitch_detector, "pitch_detector/F");  
  HitsTree->Branch("Amplitudes", Amplitudes, "Amplitudes[ClSize]/I");
  
  HitsTree->SetDirectory(Hit_Tree);
  
  TrackTree = new TTree("TrackTree", "TrackTree");
  
  TrackTree->Branch("TrackCounter", &TrackCounter, "TrackCounter/I");
  
  TrackTree->SetDirectory(Track_Tree);
  
  EventTree = new TTree("EventTree", "EventTree");
  
  EventTree->Branch("EventCounter", &EventCounter, "EventCounter/I");
  
  EventTree->SetDirectory(Event_Tree);
  
      
  // use SistripHistoId for producing histogram id (and title)
  SiStripHistoId hidmanager;

  // create SiStripFolderOrganizer
  SiStripFolderOrganizer folder_organizer;

  dbe_ = edm::Service<DQMStore>().operator->();
  
  //get all detids
  
  for(std::vector<uint32_t>::const_iterator Id = activeDets.begin(); Id!=activeDets.end(); Id++){

    //  for(Iditer=Id.begin();Iditer!=Id.end();Iditer++){ //loop on detids
    DetId Iditero=DetId(*Id);
    DetId *Iditer=&Iditero;
    if((Iditer->subdetId() == int(StripSubdetector::TIB)) || (Iditer->subdetId() == int(StripSubdetector::TOB))){ //include only barrel

      int module_bin = 0;
      if(Iditer->subdetId() == int(StripSubdetector::TIB)){
      module_bin = TIB_bin;
      }else{
      module_bin = TOB_bin;
      }
      
      // create a TProfile for each module
      StripSubdetector subid(*Iditer);
      std::string hid;
      //Mono single sided detectors
      LocalPoint p;
      const GeomDetUnit * stripdet=dynamic_cast<const GeomDetUnit*>(tracker->idToDet(subid));
      if(stripdet==0)continue;
      const StripTopology& topol=(StripTopology&)stripdet->topology();
      float thickness=stripdet->specificSurface().bounds().thickness();
      
      folder_organizer.setDetectorFolder(Iditer->rawId());
      hid = hidmanager.createHistoId(TkTag.label().c_str(),"det",Iditer->rawId());
      MonitorElement * profile=dbe_->bookProfile(hid,hid,module_bin,ModuleRangeMin,ModuleRangeMax,20,0,5,"");
      detparameters *param=new detparameters;
      histos[Iditer->rawId()] = profile;
      detmap[Iditer->rawId()] = param;
      param->thickness = thickness*10000;
      param->pitch = topol.localPitch(p)*10000;

      const GlobalPoint globalp = (stripdet->surface()).toGlobal(p);
      GlobalVector globalmagdir = magfield->inTesla(globalp);
      param->magfield=(stripdet->surface()).toLocal(globalmagdir);

      profile->setAxisTitle("tan(#theta_{t})",1);
      profile->setAxisTitle("Cluster size",2);

      // create a summary histo if it does not exist already
      std::string name;
      unsigned int layerid;
      getlayer(subid,name,layerid);
      name+=TkTag.label().c_str();
      if(summaryhisto.find(layerid)==(summaryhisto.end())){
        folder_organizer.setSiStripFolder();
        MonitorElement * summaryprofile=0;
        if (subid.subdetId()==int (StripSubdetector::TIB)||subid.subdetId()==int (StripSubdetector::TID))
          summaryprofile=dbe_->bookProfile(name,name,SUM_bin,TIBRangeMin,TIBRangeMax,20,0,5,"");
        else if (subid.subdetId()==int (StripSubdetector::TOB)||subid.subdetId()==int (StripSubdetector::TEC))
          summaryprofile=dbe_->bookProfile(name,name,SUM_bin,TOBRangeMin,TOBRangeMax,20,0,5,"");
        if(summaryprofile){
          detparameters *summaryparam=new detparameters;
          summaryhisto[layerid] = summaryprofile;
          summarydetmap[layerid] = summaryparam;
          summaryparam->thickness = thickness*10000;
          summaryparam->pitch = topol.localPitch(p)*10000;
          summaryprofile->setAxisTitle("tan(#theta_{t})",1);
          summaryprofile->setAxisTitle("Cluster size",2);
        }
      }
      
    } 
  } 
  
  trackcollsize = 0;
  trajsize = 0;
  RunNumber = 0;
  EventNumber = 0;
  hitcounter = 0;
  hitcounter_2ndloop = 0;
  worse_double_hit = 0;
  better_double_hit = 0;
  eventcounter = 0;
  
  EventCounter = 1;
  TrackCounter = 1;
  
}
void SiStripLAProfileBooker::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 750 of file SiStripLAProfileBooker.cc.

References conf_, dbe_, edm::ParameterSet::getUntrackedParameter(), hFile, and DQMStore::save().

                                   {

  std::string outputFile_ =conf_.getUntrackedParameter<std::string>("fileName", "LorentzAngle.root");
  dbe_->save(outputFile_);
  
  hFile->Write();
  hFile->Close();
}
void SiStripLAProfileBooker::getlayer ( const DetId detid,
std::string &  name,
unsigned int &  layerid 
)

Definition at line 716 of file SiStripLAProfileBooker.cc.

References TIBDetId::layer(), TOBDetId::layer(), TIDDetId::ring(), TECDetId::ring(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

Referenced by analyze(), and beginRun().

                                                                                               {
    int layer=0;
    std::stringstream layernum;

    if(detid.subdetId() == int (StripSubdetector::TIB)){
      TIBDetId TIBid=TIBDetId(detid);
      name+="TIB_Layer_";
      layer = TIBid.layer();
    }

    else if(detid.subdetId() == int (StripSubdetector::TID)){
      TIDDetId TIDid=TIDDetId(detid);
      name+="TID_Ring_";
      layer = TIDid.ring();
    }

    else if(detid.subdetId() == int (StripSubdetector::TOB)){
      TOBDetId TOBid=TOBDetId(detid);
      name+="TOB_Layer_";
      layer = TOBid.layer();

    }

    else if(detid.subdetId() == int (StripSubdetector::TEC)){
      TECDetId TECid=TECDetId(detid);
      name+="TEC_Ring_";
      layer = TECid.ring();
    }
    layernum<<layer;
    name+=layernum.str();
    layerid=detid.subdetId()*10+layer;
  
}

Member Data Documentation

uint8_t SiStripLAProfileBooker::Amplitudes[100] [private]

Definition at line 55 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 69 of file SiStripLAProfileBooker.h.

Referenced by analyze(), beginRun(), and endJob().

Definition at line 65 of file SiStripLAProfileBooker.h.

Referenced by beginRun(), and endJob().

Definition at line 67 of file SiStripLAProfileBooker.h.

Referenced by analyze(), beginRun(), and ~SiStripLAProfileBooker().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

TDirectory * SiStripLAProfileBooker::Event_Tree [private]

Definition at line 60 of file SiStripLAProfileBooker.h.

Referenced by beginRun().

Definition at line 53 of file SiStripLAProfileBooker.h.

Referenced by beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 57 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 58 of file SiStripLAProfileBooker.h.

Referenced by beginRun(), endJob(), and ~SiStripLAProfileBooker().

Definition at line 62 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

TDirectory* SiStripLAProfileBooker::Hit_Tree [private]

Definition at line 60 of file SiStripLAProfileBooker.h.

Referenced by beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 57 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 53 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 54 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

float SiStripLAProfileBooker::pt [private]

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze().

Definition at line 68 of file SiStripLAProfileBooker.h.

Referenced by beginRun(), and ~SiStripLAProfileBooker().

Definition at line 63 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 54 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

TDirectory * SiStripLAProfileBooker::Track_Tree [private]

Definition at line 60 of file SiStripLAProfileBooker.h.

Referenced by beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 53 of file SiStripLAProfileBooker.h.

Referenced by beginRun().

Definition at line 72 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 57 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

std::string SiStripLAProfileBooker::treename_ [private]

Definition at line 70 of file SiStripLAProfileBooker.h.

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 50 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 52 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().

Definition at line 51 of file SiStripLAProfileBooker.h.

Referenced by analyze(), and beginRun().