CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes | Static Private Attributes
AlignmentStats Class Reference

#include <AlignmentStats.h>

Inheritance diagram for AlignmentStats:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 AlignmentStats (const edm::ParameterSet &iConfig)
 
void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
void beginJob () override
 
void endJob () override
 
 ~AlignmentStats () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::map< uint32_t, uint32_t > DetHitMap
 

Private Attributes

float Chi2n [MAXTRKS_]
 
float Eta [MAXTRKS_]
 
int event_
 
bool firstEvent_
 
DetHitMap hitmap_
 
std::string hitsTreeName_
 
bool keepHitPopulation_
 
bool keepTrackStats_
 
const edm::EventSetuplastSetup_
 
int Nhits [MAXTRKS_][7]
 
unsigned int ntracks
 
TTree * outtree_
 
edm::InputTag overlapAM_
 
DetHitMap overlapmap_
 
float P [MAXTRKS_]
 
float Phi [MAXTRKS_]
 
uint32_t prescale_
 
float Pt [MAXTRKS_]
 
int run_
 
edm::InputTag src_
 
std::string statsTreeName_
 
uint32_t tmpPresc_
 
const TrackerGeometrytrackerGeometry_
 
TFile * treefile_
 

Static Private Attributes

static const int MAXTRKS_ =200
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 28 of file AlignmentStats.h.

Member Typedef Documentation

typedef std::map<uint32_t,uint32_t> AlignmentStats::DetHitMap
private

Definition at line 61 of file AlignmentStats.h.

Constructor & Destructor Documentation

AlignmentStats::AlignmentStats ( const edm::ParameterSet iConfig)

Definition at line 28 of file AlignmentStats.cc.

References outtree_.

28  :
29  src_(iConfig.getParameter<edm::InputTag>("src")),
30  overlapAM_(iConfig.getParameter<edm::InputTag>("OverlapAssoMap")),
31  keepTrackStats_(iConfig.getParameter<bool>("keepTrackStats")),
32  keepHitPopulation_(iConfig.getParameter<bool>("keepHitStats")),
33  statsTreeName_(iConfig.getParameter<string>("TrkStatsFileName")),
34  hitsTreeName_(iConfig.getParameter<string>("HitStatsFileName")),
35  prescale_(iConfig.getParameter<uint32_t>("TrkStatsPrescale")),
36  lastSetup_(nullptr)
37 {
38 
39  //sanity checks
40 
41  //init
42  outtree_=nullptr;
43 
44 }//end constructor
T getParameter(std::string const &) const
uint32_t prescale_
const edm::EventSetup * lastSetup_
edm::InputTag src_
std::string statsTreeName_
std::string hitsTreeName_
edm::InputTag overlapAM_
AlignmentStats::~AlignmentStats ( )
override

Definition at line 46 of file AlignmentStats.cc.

46  {
47  //
48 }

Member Function Documentation

void AlignmentStats::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 86 of file AlignmentStats.cc.

References Chi2n, className(), SiStripRecHit1D::cluster(), SiStripRecHit2D::cluster(), SiPixelRecHit::cluster(), Eta, edm::EventID::event(), event_, Exception, firstEvent_, TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByLabel(), hitmap_, edm::EventBase::id(), AlignmentClusterFlag::isOverlap(), TrackingRecHit::isValid(), gen::k, lastSetup_, MAXTRKS_, Nhits, ntracks, outtree_, overlapAM_, overlapmap_, Phi, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, prescale_, Pt, DetId::rawId(), edm::EventID::run(), run_, src_, DetId::subdetId(), SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, tmpPresc_, SiStripDetId::TOB, trackerGeometry_, and gather_cfg::Tracks.

86  {
87 
88  lastSetup_ = &iSetup;
89 
90  //load list of detunits needed then in endJob
91 
92  if(firstEvent_){
93  edm::ESHandle<TrackerGeometry> tmpTkGeometry;
94  iSetup.get<TrackerDigiGeometryRecord>().get(tmpTkGeometry);
95  trackerGeometry_=&(*tmpTkGeometry);
96  firstEvent_=false;
97  }
98 
99 
100  //take trajectories and tracks to loop on
101  // edm::Handle<TrajTrackAssociationCollection> TrackAssoMap;
103  iEvent.getByLabel(src_, Tracks);
104 
105  //take overlap HitAssomap
107  iEvent.getByLabel(overlapAM_, hMap);
108  const AliClusterValueMap &OverlapMap=*hMap;
109 
110  // Initialise
111  run_=1;
112  event_=1;
113  ntracks=0;
114  run_=iEvent.id().run();
115  event_=iEvent.id().event();
116  ntracks=Tracks->size();
117  // if(ntracks>1) std::cout<<"~~~~~~~~~~~~\n For this event processing "<<ntracks<<" tracks"<<std::endl;
118 
119  unsigned int trk_cnt=0;
120 
121  for(int j=0;j<MAXTRKS_;j++){
122  Eta[j]=-9999.0;
123  Phi[j]=-8888.0;
124  P[j] =-7777.0;
125  Pt[j] =-6666.0;
126  Chi2n[j]=-2222.0;
127  for(int k=0;k<7;k++){
128  Nhits[j][k]=0;
129  }
130  }
131 
132  // int npxbhits=0;
133 
134  //loop on tracks
135  for(std::vector<reco::Track>::const_iterator ittrk = Tracks->begin(), edtrk = Tracks->end(); ittrk != edtrk; ++ittrk){
136  Eta[trk_cnt]=ittrk->eta();
137  Phi[trk_cnt]=ittrk->phi();
138  Chi2n[trk_cnt]=ittrk->normalizedChi2();
139  P[trk_cnt]=ittrk->p();
140  Pt[trk_cnt]=ittrk->pt();
141  Nhits[trk_cnt][0]=ittrk->numberOfValidHits();
142 
143  // if(ntracks>1)std::cout<<"Track #"<<trk_cnt+1<<" params: Eta="<< Eta[trk_cnt]<<" Phi="<< Phi[trk_cnt]<<" P="<<P[trk_cnt]<<" Nhits="<<Nhits[trk_cnt][0]<<std::endl;
144 
145  int nhit=0;
146  //loop on tracking rechits
147  //std::cout << " loop on hits of track #" << (itt - tracks->begin()) << std::endl;
148  for (trackingRecHit_iterator ith = ittrk->recHitsBegin(), edh = ittrk->recHitsEnd(); ith != edh; ++ith) {
149 
150  const TrackingRecHit *hit = *ith; // ith is an iterator on edm::Ref to rechit
151  if(! hit->isValid())continue;
152  DetId detid = hit->geographicalId();
153  int subDet = detid.subdetId();
154  uint32_t rawId = hit->geographicalId().rawId();
155 
156  // if(subDet==1)npxbhits++;
157 
158  //look if you find this detid in the map
159  DetHitMap::iterator mapiter;
160  mapiter= hitmap_.find(rawId);
161  if(mapiter!=hitmap_.end() ){//present, increase its value by one
162  // hitmap_[rawId]=hitmap_[rawId]+1;
163  ++(hitmap_[rawId]);
164  }
165  else{//not present, let's add this key to the map with value=1
166  hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
167  }
168 
169  AlignmentClusterFlag inval;
170 
171  bool hitInPixel= (subDet==PixelSubdetector::PixelBarrel)||(subDet==PixelSubdetector::PixelEndcap);
172  bool hitInStrip=(subDet==SiStripDetId::TIB) || (subDet==SiStripDetId::TID) ||(subDet==SiStripDetId::TOB) ||(subDet==SiStripDetId::TEC);
173 
174  if(!(hitInPixel||hitInStrip)){
175  //skip only this hit, don't stop everything throwing an exception
176  edm::LogError("AlignmentStats")<<"Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= "<<subDet;
177  continue;
178  }
179 
180  //check also if the hit is an overlap. If yes fill a dedicated hitmap
181  if (hitInStrip){
182  const std::type_info &type = typeid(*hit);
183 
184  if (type == typeid(SiStripRecHit1D)) {
185  //Notice the difference respect to when one loops on Trajectories: the recHit is a TrackingRecHit and not a TransientTrackingRecHit
186  const SiStripRecHit1D* striphit=dynamic_cast<const SiStripRecHit1D*>(hit);
187  if(striphit!=nullptr){
188  SiStripRecHit1D::ClusterRef stripclust(striphit->cluster());
189  inval = OverlapMap[stripclust];
190  }
191  else{
192  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "<<className(*hit);
193  throw cms::Exception("NullPointerError")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "<<className(*hit);
194  }
195  }//end if sistriprechit1D
196  if (type == typeid(SiStripRecHit2D)) {
197  const SiStripRecHit2D* striphit=dynamic_cast<const SiStripRecHit2D*>(hit);
198  if(striphit!=nullptr){
199  SiStripRecHit2D::ClusterRef stripclust(striphit->cluster());
200  inval = OverlapMap[stripclust];
201  //cout<<"Taken the Strip Cluster with ProdId "<<stripclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")"<<endl;
202  }
203  else{
204  throw cms::Exception("NullPointerError")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "<<className(*hit);
205  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "<<className(*hit);
206  }
207  }//end if sistriprechit2D
208 
209  }//end if hit in Strips
210  else{
211  const SiPixelRecHit* pixelhit= dynamic_cast<const SiPixelRecHit*>(hit);
212  if(pixelhit!=nullptr){
213  SiPixelClusterRefNew pixclust(pixelhit->cluster());
214  inval = OverlapMap[pixclust];
215  //cout<<"Taken the Pixel Cluster with ProdId "<<pixclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")"<<endl;
216  }
217  else{
218  edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: "<<className(*hit);
219  }
220  }//end else hit is in Pixel
221 
222 
223  bool isOverlapHit(inval.isOverlap());
224 
225  if( isOverlapHit ){
226  //cout<<"This hit is an overlap !"<<endl;
227  DetHitMap::iterator overlapiter;
228  overlapiter=overlapmap_.find(rawId);
229 
230  if(overlapiter!=overlapmap_.end() ){//the det already collected at least an overlap, increase its value by one
231  overlapmap_[rawId]=overlapmap_[rawId]+1;
232  }
233  else{//first overlap on det unit, let's add it to the map
234  overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
235  }
236  }//end if the hit is an overlap
237 
238 
239 
240 
241  int subdethit= static_cast<int>(hit->geographicalId().subdetId());
242  // if(ntracks>1)std::cout<<"Hit in SubDet="<<subdethit<<std::endl;
243  Nhits[trk_cnt][subdethit]=Nhits[trk_cnt][subdethit]+1;
244  nhit++;
245  }//end loop on trackingrechits
246  trk_cnt++;
247 
248  }//end loop on tracks
249 
250  // cout<<"Total number of pixel hits is "<<npxbhits<<endl;
251 
252  tmpPresc_--;
253  if(tmpPresc_<1){
254  outtree_->Fill();
256  }
257  if(trk_cnt!=ntracks)edm::LogError("AlignmentStats")<<"\nERROR! trk_cnt="<<trk_cnt<<" ntracks="<<ntracks;
258 
259  return;
260 }
RunNumber_t run() const
Definition: EventID.h:39
ClusterRef cluster() const
float Eta[MAXTRKS_]
type
Definition: HCALResponse.h:21
EventNumber_t event() const
Definition: EventID.h:41
uint32_t prescale_
DetHitMap hitmap_
const edm::EventSetup * lastSetup_
edm::InputTag src_
DetHitMap overlapmap_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
float Chi2n[MAXTRKS_]
uint32_t tmpPresc_
float Phi[MAXTRKS_]
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
ClusterRef cluster() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
int k[5][pyjets_maxn]
Definition: DetId.h:18
const TrackerGeometry * trackerGeometry_
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
bool isValid() const
static const int MAXTRKS_
std::pair< OmniClusterRef, TrackingParticleRef > P
unsigned int ntracks
edm::EventID id() const
Definition: EventBase.h:60
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
T get() const
Definition: EventSetup.h:62
DetId geographicalId() const
edm::InputTag overlapAM_
std::string className(const T &t)
Definition: ClassName.h:30
Our base class.
Definition: SiPixelRecHit.h:23
void AlignmentStats::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file AlignmentStats.cc.

References Chi2n, Eta, event_, firstEvent_, Nhits, ntracks, outtree_, Phi, prescale_, Pt, run_, statsTreeName_, tmpPresc_, and treefile_.

50  {// const edm::EventSetup &iSetup
51 
52  //book track stats tree
53  treefile_=new TFile(statsTreeName_.c_str(),"RECREATE");
54  treefile_->cd();
55  outtree_=new TTree("AlignmentTrackStats","Statistics of Tracks used for Alignment");
56  // int nHitsinPXB[MAXTRKS_], nHitsinPXE[MAXTRKS_], nHitsinTEC[MAXTRKS_], nHitsinTIB[MAXTRKS_],nHitsinTOB[MAXTRKS_],nHitsinTID[MAXTRKS_];
57 
58 
59  outtree_->Branch("Ntracks" ,&ntracks ,"Ntracks/i");
60  outtree_->Branch("Run_" ,&run_ ,"Run_Nr/I");
61  outtree_->Branch("Event" ,&event_ ,"EventNr/I");
62  outtree_->Branch("Eta" ,&Eta ,"Eta[Ntracks]/F");
63  outtree_->Branch("Phi" ,&Phi ,"Phi[Ntracks]/F");
64  outtree_->Branch("P" ,&P ,"P[Ntracks]/F");
65  outtree_->Branch("Pt" ,&Pt ,"Pt[Ntracks]/F");
66  outtree_->Branch("Chi2n" ,&Chi2n ,"Chi2n[Ntracks]/F");
67  outtree_->Branch("Nhits" ,&Nhits ,"Nhits[Ntracks][7]/I");
68  /*
69  outtree_->Branch("NhitsPXB" , ,);
70  outtree_->Branch("NhitsPXE" , ,);
71  outtree_->Branch("NhitsTIB" , ,);
72  outtree_->Branch("NhitsTID" , ,);
73  outtree_->Branch("NhitsTOB" , ,);
74  outtree_->Branch("NhitsTOB" , ,);
75  */
76 
78  firstEvent_=true;
79 
80  //load the tracker geometry from the EventSetup
81  // iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry_);
82 
83 }//end beginJob
float Eta[MAXTRKS_]
uint32_t prescale_
float Chi2n[MAXTRKS_]
uint32_t tmpPresc_
float Phi[MAXTRKS_]
std::string statsTreeName_
std::pair< OmniClusterRef, TrackingParticleRef > P
unsigned int ntracks
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
void AlignmentStats::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 262 of file AlignmentStats.cc.

References Alignable::deepComponents(), DEFINE_FWK_MODULE, PV3DBase< T, PVType, FrameType >::eta(), edm::EventSetup::get(), hitmap_, hitsTreeName_, triggerObjects_cff::id, fastTrackerRecHitType::is2D(), lastSetup_, nhits, outtree_, overlapmap_, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, edm::ESHandle< T >::product(), TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), DetId::subdetId(), SiStripDetId::TEC, TrackerTopology::tecIsDoubleSide(), TrackerTopology::tecIsStereo(), TrackerTopology::tecWheel(), SiStripDetId::TIB, TrackerTopology::tibIsDoubleSide(), TrackerTopology::tibIsStereo(), TrackerTopology::tibLayer(), SiStripDetId::TID, TrackerTopology::tidIsDoubleSide(), TrackerTopology::tidIsStereo(), TrackerTopology::tidWheel(), SiStripDetId::TOB, TrackerTopology::tobIsDoubleSide(), TrackerTopology::tobIsStereo(), TrackerTopology::tobLayer(), trackerGeometry_, and treefile_.

Referenced by o2olib.O2ORunMgr::executeJob().

262  {
263 
264  treefile_->cd();
265  edm::LogInfo("AlignmentStats")<<"Writing out the TrackStatistics in "<<gDirectory->GetPath()<<std::endl;
266  outtree_->Write();
267  delete outtree_;
268 
269  //create tree with hit maps (hitstree)
270  //book track stats tree
271  TFile *hitsfile=new TFile(hitsTreeName_.c_str(),"RECREATE");
272  hitsfile->cd();
273  TTree *hitstree=new TTree("AlignmentHitMap","Maps of Hits used for Alignment");
274 
275  unsigned int id=0,nhits=0,noverlaps=0;
276  float posX(-99999.0),posY(-77777.0),posZ(-88888.0);
277  float posEta(-6666.0),posPhi(-5555.0),posR(-4444.0);
278  int subdet=0;
279  unsigned int layer=0;
280  bool is2D=false,isStereo=false;
281  hitstree->Branch("DetId", &id , "DetId/i");
282  hitstree->Branch("Nhits", &nhits , "Nhits/i");
283  hitstree->Branch("Noverlaps",&noverlaps,"Noverlaps/i");
284  hitstree->Branch("SubDet", &subdet, "SubDet/I");
285  hitstree->Branch("Layer", &layer, "Layer/i");
286  hitstree->Branch("is2D" , &is2D, "is2D/B");
287  hitstree->Branch("isStereo", &isStereo, "isStereo/B");
288  hitstree->Branch("posX", &posX, "posX/F");
289  hitstree->Branch("posY", &posY, "posY/F");
290  hitstree->Branch("posZ", &posZ, "posZ/F");
291  hitstree->Branch("posR", &posR, "posR/F");
292  hitstree->Branch("posEta", &posEta, "posEta/F");
293  hitstree->Branch("posPhi", &posPhi, "posPhi/F");
294 
295  /*
296  TTree *overlapstree=new TTree("OverlapHitMap","Maps of Overlaps used for Alignment");
297  hitstree->Branch("DetId", &id , "DetId/i");
298  hitstree->Branch("NOverlaps", &nhits , "Nhits/i");
299  hitstree->Branch("SubDet", &subdet, "SubDet/I");
300  hitstree->Branch("Layer", &layer, "Layer/i");
301  hitstree->Branch("is2D" , &is2D, "is2D/B");
302  hitstree->Branch("isStereo",&isStereo,"isStereo/B");
303  hitstree->Branch("posX", &posX, "posX/F");
304  hitstree->Branch("posY", &posY, "posY/F");
305  hitstree->Branch("posZ", &posZ, "posZ/F");
306  hitstree->Branch("posR", &posR, "posR/F");
307  hitstree->Branch("posEta", &posEta, "posEta/F");
308  hitstree->Branch("posPhi", &posPhi, "posPhi/F");
309  */
310 
311  //Retrieve tracker topology from geometry
312  edm::ESHandle<TrackerTopology> tTopoHandle;
313  lastSetup_->get<TrackerTopologyRcd>().get(tTopoHandle);
314  const TrackerTopology* const tTopo = tTopoHandle.product();
315 
316  AlignableTracker* theAliTracker=new AlignableTracker(&(*trackerGeometry_), tTopo);
317  const auto& Detunitslist = theAliTracker->deepComponents();
318  int ndetunits=Detunitslist.size();
319  edm::LogInfo("AlignmentStats")<<"Number of DetUnits in the AlignableTracker: "<< ndetunits<<std::endl;
320 
321  for(int det_cnt=0;det_cnt< ndetunits;++det_cnt){
322 
323  //re-initialize for safety
324  id=0;
325  nhits=0;
326  noverlaps=0;
327  posX=-99999.0;
328  posY=-77777.0;
329  posZ=-88888.0;
330  posEta=-6666.0;
331  posPhi=-5555.0;
332  posR=-4444.0;
333  subdet=0;
334  layer=0;
335  is2D=false;
336  isStereo=false;
337 
338  //if detunit in vector is found also in the map, look for how many hits were collected
339  //and save in the tree this number
340  id=static_cast <uint32_t>( Detunitslist[det_cnt]->id() );
341  if( hitmap_.find(id) != hitmap_.end() ){
342  nhits=hitmap_[id];
343  }
344  //if not, save nhits=0
345  else{
346  nhits=0;
347  hitmap_.insert(pair<uint32_t, uint32_t>(id, 0));
348  }
349 
350  if( overlapmap_.find(id) != overlapmap_.end() ){
351  noverlaps=overlapmap_[id];
352  }
353  //if not, save nhits=0
354  else{
355  noverlaps=0;
356  overlapmap_.insert(pair<uint32_t, uint32_t>(id, 0));
357  }
358 
359  //take other geometrical infos from the det
360  posX= Detunitslist[det_cnt]->globalPosition().x();
361  posY= Detunitslist[det_cnt]->globalPosition().y();
362  posZ= Detunitslist[det_cnt]->globalPosition().z();
363 
364  align::GlobalVector vec(posX,posY,posZ);
365  posR = vec.perp();
366  posPhi = vec.phi();
367  posEta = vec.eta();
368  // posPhi = atan2(posY,posX);
369 
370  DetId detid(id);
371  subdet=detid.subdetId();
372 
373  //get layers, petals, etc...
374  if(subdet==PixelSubdetector::PixelBarrel){//PXB
375 
376  layer=tTopo->pxbLayer(id);
377  is2D=true;
378  isStereo=false;
379  }
380  else if(subdet==PixelSubdetector::PixelEndcap){
381 
382  layer=tTopo->pxfDisk(id);
383  is2D=true;
384  isStereo=false;
385  }
386  else if(subdet==SiStripDetId::TIB){
387 
388  layer=tTopo->tibLayer(id);
389  is2D=tTopo->tibIsDoubleSide(id);
390  isStereo=tTopo->tibIsStereo(id);
391  }
392  else if(subdet==SiStripDetId::TID){
393 
394  layer=tTopo->tidWheel(id);
395  is2D=tTopo->tidIsDoubleSide(id);
396  isStereo=tTopo->tidIsStereo(id);
397  }
398  else if(subdet==SiStripDetId::TOB){
399 
400  layer=tTopo->tobLayer(id);
401  is2D=tTopo->tobIsDoubleSide(id);
402  isStereo=tTopo->tobIsStereo(id);
403  }
404  else if(subdet==SiStripDetId::TEC){
405 
406  layer=tTopo->tecWheel(id);
407  is2D=tTopo->tecIsDoubleSide(id);
408  isStereo=tTopo->tecIsStereo(id);
409  }
410  else{
411  edm::LogError("AlignmentStats")<<"Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= "<<subdet;
412  }
413 
414  //write in the hitstree
415  hitstree->Fill();
416  }//end loop over detunits
417 
418 
419  //save hitstree
420  hitstree->Write();
421  delete hitstree;
422  //delete Detunitslist;
423  hitmap_.clear();
424  overlapmap_.clear();
425  delete hitsfile;
426 }
DetHitMap hitmap_
bool tecIsDoubleSide(const DetId &id) const
bool tobIsDoubleSide(const DetId &id) const
bool tibIsDoubleSide(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
const edm::EventSetup * lastSetup_
bool tobIsStereo(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
DetHitMap overlapmap_
unsigned int tidWheel(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool is2D(HitType hitType)
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
const TrackerGeometry * trackerGeometry_
const Alignables & deepComponents() const
Definition: Alignable.h:75
bool tibIsStereo(const DetId &id) const
bool tidIsDoubleSide(const DetId &id) const
std::string hitsTreeName_
T get() const
Definition: EventSetup.h:62
unsigned int tecWheel(const DetId &id) const
T const * product() const
Definition: ESHandle.h:86
unsigned int tobLayer(const DetId &id) const

Member Data Documentation

float AlignmentStats::Chi2n[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

float AlignmentStats::Eta[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

int AlignmentStats::event_
private

Definition at line 55 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

bool AlignmentStats::firstEvent_
private

Definition at line 49 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

DetHitMap AlignmentStats::hitmap_
private

Definition at line 62 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

std::string AlignmentStats::hitsTreeName_
private

Definition at line 45 of file AlignmentStats.h.

Referenced by endJob().

bool AlignmentStats::keepHitPopulation_
private

Definition at line 43 of file AlignmentStats.h.

bool AlignmentStats::keepTrackStats_
private

Definition at line 42 of file AlignmentStats.h.

const edm::EventSetup* AlignmentStats::lastSetup_
private

Definition at line 68 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

const int AlignmentStats::MAXTRKS_ =200
staticprivate

Definition at line 54 of file AlignmentStats.h.

Referenced by analyze().

int AlignmentStats::Nhits[MAXTRKS_][7]
private

Definition at line 58 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

unsigned int AlignmentStats::ntracks
private

Definition at line 56 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

TTree* AlignmentStats::outtree_
private

Definition at line 53 of file AlignmentStats.h.

Referenced by AlignmentStats(), analyze(), beginJob(), and endJob().

edm::InputTag AlignmentStats::overlapAM_
private

Definition at line 41 of file AlignmentStats.h.

Referenced by analyze().

DetHitMap AlignmentStats::overlapmap_
private

Definition at line 63 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

float AlignmentStats::P[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

float AlignmentStats::Phi[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

uint32_t AlignmentStats::prescale_
private

Definition at line 46 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

float AlignmentStats::Pt[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

int AlignmentStats::run_
private

Definition at line 55 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

edm::InputTag AlignmentStats::src_
private

Definition at line 40 of file AlignmentStats.h.

Referenced by analyze().

std::string AlignmentStats::statsTreeName_
private

Definition at line 44 of file AlignmentStats.h.

Referenced by beginJob().

uint32_t AlignmentStats::tmpPresc_
private

Definition at line 48 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

const TrackerGeometry* AlignmentStats::trackerGeometry_
private

Definition at line 66 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

TFile* AlignmentStats::treefile_
private

Definition at line 52 of file AlignmentStats.h.

Referenced by beginJob(), and endJob().